: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @package WPSEO\Internals\Options
class WPSEO_Option_Wpseo extends WPSEO_Option {
public $option_name = 'wpseo';
* Array of defaults for the option.
* {@internal Shouldn't be requested directly, use $this->get_defaults();}}
// Non-form fields, set via (ajax) function.
'toggled_tracking' => false,
'license_server_version' => false,
'ms_defaults_set' => false,
'ignore_search_engines_discouraged_notice' => false,
'indexing_first_time' => true,
'indexing_started' => null,
'indexables_indexing_completed' => false,
// Non-form field, should only be set via validation routine.
'version' => '', // Leave default as empty to ensure activation/upgrade works.
'previous_version' => '',
'disableadvanced_meta' => true,
'enable_headless_rest_endpoints' => true,
'ryte_indexability' => false,
'baiduverify' => '', // Text field.
'googleverify' => '', // Text field.
'msverify' => '', // Text field.
'site_type' => '', // List of options.
'has_multiple_authors' => '',
'environment_type' => '',
'content_analysis_active' => true,
'keyword_analysis_active' => true,
'inclusive_language_analysis_active' => false,
'enable_admin_bar_menu' => true,
'enable_cornerstone_content' => true,
'enable_xml_sitemap' => true,
'enable_text_link_counter' => true,
'enable_index_now' => true,
'enable_ai_generator' => true,
'ai_enabled_pre_default' => false,
'show_onboarding_notice' => false,
'first_activated_on' => false,
'semrush_integration_active' => true,
'semrush_country_code' => 'us',
'permalink_structure' => '',
'dynamic_permalinks' => false,
'category_base_url' => '',
'custom_taxonomy_slugs' => [],
'enable_enhanced_slack_sharing' => true,
'zapier_integration_active' => false,
'zapier_subscription' => [],
'enable_metabox_insights' => true,
'enable_link_suggestions' => true,
'algolia_integration_active' => false,
'workouts_data' => [ 'configuration' => [ 'finishedSteps' => [] ] ],
'configuration_finished_steps' => [],
'dismiss_configuration_workout_notice' => false,
'dismiss_premium_deactivated_notice' => false,
'importing_completed' => [],
'wincher_integration_active' => true,
'wincher_automatically_add_keyphrases' => false,
'wincher_website_id' => '',
'first_time_install' => false,
'should_redirect_after_install_free' => false,
'activation_redirect_timestamp_free' => 0,
'remove_feed_global' => false,
'remove_feed_global_comments' => false,
'remove_feed_post_comments' => false,
'remove_feed_authors' => false,
'remove_feed_categories' => false,
'remove_feed_tags' => false,
'remove_feed_custom_taxonomies' => false,
'remove_feed_post_types' => false,
'remove_feed_search' => false,
'remove_atom_rdf_feeds' => false,
'remove_shortlinks' => false,
'remove_rest_api_links' => false,
'remove_rsd_wlw_links' => false,
'remove_oembed_links' => false,
'remove_generator' => false,
'remove_emoji_scripts' => false,
'remove_powered_by_header' => false,
'remove_pingback_header' => false,
'clean_campaign_tracking_urls' => false,
'clean_permalinks' => false,
'clean_permalinks_extra_variables' => '',
'search_cleanup' => false,
'search_cleanup_emoji' => false,
'search_cleanup_patterns' => false,
'search_character_limit' => 50,
'deny_search_crawling' => false,
'deny_wp_json_crawling' => false,
'deny_adsbot_crawling' => false,
'deny_ccbot_crawling' => false,
'deny_google_extended_crawling' => false,
'deny_gptbot_crawling' => false,
'redirect_search_pretty_urls' => false,
'least_readability_ignore_list' => [],
'least_seo_score_ignore_list' => [],
'most_linked_ignore_list' => [],
'least_linked_ignore_list' => [],
'indexables_page_reading_list' => [ false, false, false, false, false ],
'indexables_overview_state' => 'dashboard-not-visited',
'last_known_public_post_types' => [],
'last_known_public_taxonomies' => [],
'last_known_no_unindexed' => [],
'show_new_content_type_notification' => false,
* Sub-options which should not be overloaded with multi-site defaults.
'ignore_search_engines_discouraged_notice',
* Possible values for the site_type option.
protected $site_types = [
* Possible environment types.
protected $environment_types = [
* Possible has_multiple_authors options.
protected $has_multiple_authors_options = [
* Name for an option higher in the hierarchy to override setting access.
protected $override_option_name = 'wpseo_ms';
* Add the actions and filters for the option.
* @todo [JRF => testers] Check if the extra actions below would run into problems if an option
* is updated early on and if so, change the call to schedule these for a later action on add/update
* instead of running them straight away.
protected function __construct() {
* Filter: 'wpseo_enable_tracking' - Enables the data tracking of Yoast SEO Premium.
* @param string $is_enabled The enabled state. Default is false.
$this->defaults['tracking'] = apply_filters( 'wpseo_enable_tracking', false );
/* Clear the cache on update/add. */
add_action( 'add_option_' . $this->option_name, [ 'WPSEO_Utils', 'clear_cache' ] );
add_action( 'update_option_' . $this->option_name, [ 'WPSEO_Utils', 'clear_cache' ] );
add_filter( 'admin_title', [ 'Yoast_Input_Validation', 'add_yoast_admin_document_title_errors' ] );
* Filter the `wpseo` option defaults.
* @param array $defaults Array the defaults for the `wpseo` option attributes.
$this->defaults = apply_filters( 'wpseo_option_wpseo_defaults', $this->defaults );
* Get the singleton instance of this class.
public static function get_instance() {
if ( ! ( self::$instance instanceof self ) ) {
self::$instance = new self();
* Add filters to make sure that the option is merged with its defaults before being returned.
public function add_option_filters() {
parent::add_option_filters();
list( $hookname, $callback, $priority ) = $this->get_verify_features_option_filter_hook();
if ( has_filter( $hookname, $callback ) === false ) {
add_filter( $hookname, $callback, $priority );
* Remove the option filters.
* Called from the clean_up methods to make sure we retrieve the original old option.
public function remove_option_filters() {
parent::remove_option_filters();
list( $hookname, $callback, $priority ) = $this->get_verify_features_option_filter_hook();
remove_filter( $hookname, $callback, $priority );
* Add filters to make sure that the option default is returned if the option is not set.
public function add_default_filters() {
parent::add_default_filters();
list( $hookname, $callback, $priority ) = $this->get_verify_features_default_option_filter_hook();
if ( has_filter( $hookname, $callback ) === false ) {
add_filter( $hookname, $callback, $priority );
* Remove the default filters.
* Called from the validate() method to prevent failure to add new options.
public function remove_default_filters() {
parent::remove_default_filters();
list( $hookname, $callback, $priority ) = $this->get_verify_features_default_option_filter_hook();
remove_filter( $hookname, $callback, $priority );
* @param array $dirty New value for the option.
* @param array $clean Clean value for the option, normally the defaults.
* @param array $old Old value of the option.
* @return array Validated clean value for the option to be saved to the database.
protected function validate_option( $dirty, $clean, $old ) {
foreach ( $clean as $key => $value ) {
$clean[ $key ] = WPSEO_VERSION;
case 'semrush_country_code':
case 'license_server_version':
case 'wincher_website_id':
case 'clean_permalinks_extra_variables':
case 'indexables_overview_state':
if ( isset( $dirty[ $key ] ) ) {
$clean[ $key ] = $dirty[ $key ];
if ( isset( $dirty[ $key ] ) ) {
$clean[ $key ] = sanitize_text_field( $dirty[ $key ] );
/* Verification strings. */
$this->validate_verification_string( $key, $dirty, $old, $clean );
* Boolean dismiss warnings - not fields - may not be in form
* (and don't need to be either as long as the default is false).
case 'ignore_search_engines_discouraged_notice':
if ( isset( $dirty[ $key ] ) ) {
$clean[ $key ] = WPSEO_Utils::validate_bool( $dirty[ $key ] );
elseif ( isset( $old[ $key ] ) ) {
$clean[ $key ] = WPSEO_Utils::validate_bool( $old[ $key ] );
$clean[ $key ] = $old[ $key ];
if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->site_types, true ) ) {
$clean[ $key ] = $dirty[ $key ];
$clean[ $key ] = $old[ $key ];
if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->environment_types, true ) ) {
$clean[ $key ] = $dirty[ $key ];
case 'has_multiple_authors':
$clean[ $key ] = $old[ $key ];
if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->has_multiple_authors_options, true ) ) {
$clean[ $key ] = $dirty[ $key ];
case 'first_activated_on':
case 'activation_redirect_timestamp_free':
if ( isset( $dirty[ $key ] ) ) {
if ( $dirty[ $key ] === false || WPSEO_Utils::validate_int( $dirty[ $key ] ) ) {
$clean[ $key ] = $dirty[ $key ];
$clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : null );
case 'custom_taxonomy_slugs':
case 'zapier_subscription':
case 'configuration_finished_steps':
case 'least_readability_ignore_list':
case 'least_seo_score_ignore_list':
case 'most_linked_ignore_list':
case 'least_linked_ignore_list':
case 'indexables_page_reading_list':
case 'last_known_public_post_types':
case 'last_known_public_taxonomies':
$clean[ $key ] = $old[ $key ];
if ( isset( $dirty[ $key ] ) ) {
if ( ! is_array( $items ) ) {
$items = json_decode( $dirty[ $key ], true );
if ( is_array( $items ) ) {
$clean[ $key ] = $dirty[ $key ];
case 'permalink_structure':
case 'category_base_url':
if ( isset( $dirty[ $key ] ) ) {
$clean[ $key ] = sanitize_option( $key, $dirty[ $key ] );
case 'search_character_limit':
if ( isset( $dirty[ $key ] ) ) {
$clean[ $key ] = (int) $dirty[ $key ];
case 'importing_completed':
if ( isset( $dirty[ $key ] ) && is_array( $dirty[ $key ] ) ) {
$clean[ $key ] = $dirty[ $key ];
case 'last_known_no_unindexed':
$clean[ $key ] = $old[ $key ];
if ( isset( $dirty[ $key ] ) ) {
if ( is_array( $items ) ) {
foreach ( $items as $item_key => $item ) {
if ( ! is_string( $item_key ) || ! is_numeric( $item ) ) {
unset( $items[ $item_key ] );
* Boolean (checkbox) fields.
* 'enable_headless_rest_endpoints'
* 'remove_feed_global_comments'
* 'remove_feed_post_comments'
* 'remove_feed_categories'
* 'remove_feed_custom_taxonomies'
* 'remove_feed_post_types'
* 'remove_atom_rdf_feeds'
* 'remove_rest_api_links'
* 'remove_powered_by_header'
* 'remove_pingback_header'