WPSEO_Option_Permalinks

The Yoast SEO WPSEO Option Permalinks class.

Defined (1)

The class is defined in the following location(s).

/inc/options/class-wpseo-option-permalinks.php  
  1. class WPSEO_Option_Permalinks extends WPSEO_Option { 
  2.  
  3. /** 
  4. * @var string option name 
  5. */ 
  6. public $option_name = 'wpseo_permalinks'; 
  7.  
  8. /** 
  9. * @var array Array of defaults for the option 
  10. * Shouldn't be requested directly, use $this->get_defaults(); 
  11. */ 
  12. protected $defaults = array( 
  13. 'cleanpermalinks' => false,  
  14. 'cleanpermalink-extravars' => '', // Text field. 
  15. 'cleanpermalink-googlecampaign' => false,  
  16. 'cleanpermalink-googlesitesearch' => false,  
  17. 'cleanreplytocom' => false,  
  18. 'cleanslugs' => true,  
  19. 'redirectattachment' => false,  
  20. 'stripcategorybase' => false,  
  21. 'trailingslash' => false,  
  22. ); 
  23.  
  24.  
  25. /** 
  26. * Add the actions and filters for the option 
  27. * @todo [JRF => testers] Check if the extra actions below would run into problems if an option 
  28. * is updated early on and if so, change the call to schedule these for a later action on add/update 
  29. * instead of running them straight away 
  30. * @return \WPSEO_Option_Permalinks 
  31. */ 
  32. protected function __construct() { 
  33. parent::__construct(); 
  34. add_action( 'update_option_' . $this->option_name, array( 'WPSEO_Utils', 'clear_rewrites' ) ); 
  35.  
  36.  
  37. /** 
  38. * Get the singleton instance of this class 
  39. * @return object 
  40. */ 
  41. public static function get_instance() { 
  42. if ( ! ( self::$instance instanceof self ) ) { 
  43. self::$instance = new self(); 
  44.  
  45. return self::$instance; 
  46.  
  47.  
  48. /** 
  49. * Validate the option 
  50. * @param array $dirty New value for the option. 
  51. * @param array $clean Clean value for the option, normally the defaults. 
  52. * @param array $old Old value of the option (not used here as all fields will always be in the form). 
  53. * @return array Validated clean value for the option to be saved to the database 
  54. */ 
  55. protected function validate_option( $dirty, $clean, $old ) { 
  56.  
  57. foreach ( $clean as $key => $value ) { 
  58. switch ( $key ) { 
  59. /** text fields */ 
  60. case 'cleanpermalink-extravars': 
  61. if ( isset( $dirty[ $key ] ) && $dirty[ $key ] !== '' ) { 
  62. $clean[ $key ] = sanitize_text_field( $dirty[ $key ] ); 
  63. break; 
  64.  
  65. /** 
  66. Boolean (checkbox) fields 
  67. */ 
  68.  
  69. /** 
  70. Covers: 
  71. * 'cleanpermalinks' 
  72. * 'cleanpermalink-googlesitesearch' 
  73. * 'cleanpermalink-googlecampaign' 
  74. * 'cleanreplytocom' 
  75. * 'cleanslugs' 
  76. * 'hide-rsdlink' 
  77. * 'hide-wlwmanifest' 
  78. * 'hide-shortlink' 
  79. * 'hide-feedlinks' 
  80. * 'redirectattachment' 
  81. * 'stripcategorybase' 
  82. * 'trailingslash' 
  83. */ 
  84. default: 
  85. $clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false ); 
  86. break; 
  87.  
  88. return $clean; 
  89.  
  90.  
  91. /** 
  92. * Clean a given option value 
  93. * @param array $option_value Old (not merged with defaults or filtered) option value to 
  94. * clean according to the rules for this option. 
  95. * @param string $current_version (optional) Version from which to upgrade, if not set,  
  96. * version specific upgrades will be disregarded. 
  97. * @param array $all_old_option_values (optional) Only used when importing old options to have 
  98. * access to the real old values, in contrast to the saved ones. 
  99. * @return array Cleaned option 
  100. */ 
  101.  
  102. /** 
  103. Protected function clean_option( $option_value, $current_version = null, $all_old_option_values = null ) { 
  104.   
  105. return $option_value; 
  106. */