Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../inc/options
File: class-wpseo-option-ms.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Internals\Options
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Site option for Multisite installs only
[8] Fix | Delete
*
[9] Fix | Delete
* Overloads a number of methods of the abstract class to ensure the use of the correct site_option
[10] Fix | Delete
* WP functions.
[11] Fix | Delete
*/
[12] Fix | Delete
class WPSEO_Option_MS extends WPSEO_Option {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Option name.
[16] Fix | Delete
*
[17] Fix | Delete
* @var string
[18] Fix | Delete
*/
[19] Fix | Delete
public $option_name = 'wpseo_ms';
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Option group name for use in settings forms.
[23] Fix | Delete
*
[24] Fix | Delete
* @var string
[25] Fix | Delete
*/
[26] Fix | Delete
public $group_name = 'yoast_wpseo_multisite_options';
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Whether to include the option in the return for WPSEO_Options::get_all().
[30] Fix | Delete
*
[31] Fix | Delete
* @var bool
[32] Fix | Delete
*/
[33] Fix | Delete
public $include_in_all = false;
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Whether this option is only for when the install is multisite.
[37] Fix | Delete
*
[38] Fix | Delete
* @var bool
[39] Fix | Delete
*/
[40] Fix | Delete
public $multisite_only = true;
[41] Fix | Delete
[42] Fix | Delete
/**
[43] Fix | Delete
* Array of defaults for the option.
[44] Fix | Delete
*
[45] Fix | Delete
* Shouldn't be requested directly, use $this->get_defaults();
[46] Fix | Delete
*
[47] Fix | Delete
* @var array
[48] Fix | Delete
*/
[49] Fix | Delete
protected $defaults = [];
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Available options for the 'access' setting. Used for input validation.
[53] Fix | Delete
*
[54] Fix | Delete
* {@internal Important: Make sure the options added to the array here are in line
[55] Fix | Delete
* with the keys for the options set for the select box in the
[56] Fix | Delete
* admin/pages/network.php file.}}
[57] Fix | Delete
*
[58] Fix | Delete
* @var array
[59] Fix | Delete
*/
[60] Fix | Delete
public static $allowed_access_options = [
[61] Fix | Delete
'admin',
[62] Fix | Delete
'superadmin',
[63] Fix | Delete
];
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Get the singleton instance of this class.
[67] Fix | Delete
*
[68] Fix | Delete
* @return object
[69] Fix | Delete
*/
[70] Fix | Delete
public static function get_instance() {
[71] Fix | Delete
if ( ! ( self::$instance instanceof self ) ) {
[72] Fix | Delete
self::$instance = new self();
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
return self::$instance;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Only run parent constructor in multisite context.
[80] Fix | Delete
*/
[81] Fix | Delete
public function __construct() {
[82] Fix | Delete
$allow_prefix = self::ALLOW_KEY_PREFIX;
[83] Fix | Delete
$this->defaults = [
[84] Fix | Delete
'access' => 'admin',
[85] Fix | Delete
'defaultblog' => '', // Numeric blog ID or empty.
[86] Fix | Delete
"{$allow_prefix}disableadvanced_meta" => true,
[87] Fix | Delete
"{$allow_prefix}ryte_indexability" => false,
[88] Fix | Delete
"{$allow_prefix}content_analysis_active" => true,
[89] Fix | Delete
"{$allow_prefix}keyword_analysis_active" => true,
[90] Fix | Delete
"{$allow_prefix}inclusive_language_analysis_active" => true,
[91] Fix | Delete
"{$allow_prefix}enable_admin_bar_menu" => true,
[92] Fix | Delete
"{$allow_prefix}enable_cornerstone_content" => true,
[93] Fix | Delete
"{$allow_prefix}enable_xml_sitemap" => true,
[94] Fix | Delete
"{$allow_prefix}enable_text_link_counter" => true,
[95] Fix | Delete
"{$allow_prefix}enable_headless_rest_endpoints" => true,
[96] Fix | Delete
"{$allow_prefix}enable_metabox_insights" => true,
[97] Fix | Delete
"{$allow_prefix}enable_link_suggestions" => true,
[98] Fix | Delete
"{$allow_prefix}tracking" => true,
[99] Fix | Delete
"{$allow_prefix}enable_enhanced_slack_sharing" => true,
[100] Fix | Delete
"{$allow_prefix}semrush_integration_active" => true,
[101] Fix | Delete
"{$allow_prefix}zapier_integration_active" => true,
[102] Fix | Delete
"{$allow_prefix}wincher_integration_active" => false,
[103] Fix | Delete
"{$allow_prefix}remove_feed_global" => true,
[104] Fix | Delete
"{$allow_prefix}remove_feed_global_comments" => true,
[105] Fix | Delete
"{$allow_prefix}remove_feed_post_comments" => true,
[106] Fix | Delete
"{$allow_prefix}enable_index_now" => true,
[107] Fix | Delete
"{$allow_prefix}enable_ai_generator" => true,
[108] Fix | Delete
"{$allow_prefix}remove_feed_authors" => true,
[109] Fix | Delete
"{$allow_prefix}remove_feed_categories" => true,
[110] Fix | Delete
"{$allow_prefix}remove_feed_tags" => true,
[111] Fix | Delete
"{$allow_prefix}remove_feed_custom_taxonomies" => true,
[112] Fix | Delete
"{$allow_prefix}remove_feed_post_types" => true,
[113] Fix | Delete
"{$allow_prefix}remove_feed_search" => true,
[114] Fix | Delete
"{$allow_prefix}remove_atom_rdf_feeds" => true,
[115] Fix | Delete
"{$allow_prefix}remove_shortlinks" => true,
[116] Fix | Delete
"{$allow_prefix}remove_rest_api_links" => true,
[117] Fix | Delete
"{$allow_prefix}remove_rsd_wlw_links" => true,
[118] Fix | Delete
"{$allow_prefix}remove_oembed_links" => true,
[119] Fix | Delete
"{$allow_prefix}remove_generator" => true,
[120] Fix | Delete
"{$allow_prefix}remove_emoji_scripts" => true,
[121] Fix | Delete
"{$allow_prefix}remove_powered_by_header" => true,
[122] Fix | Delete
"{$allow_prefix}remove_pingback_header" => true,
[123] Fix | Delete
"{$allow_prefix}clean_campaign_tracking_urls" => true,
[124] Fix | Delete
"{$allow_prefix}clean_permalinks" => true,
[125] Fix | Delete
"{$allow_prefix}search_cleanup" => true,
[126] Fix | Delete
"{$allow_prefix}search_cleanup_emoji" => true,
[127] Fix | Delete
"{$allow_prefix}search_cleanup_patterns" => true,
[128] Fix | Delete
"{$allow_prefix}redirect_search_pretty_urls" => true,
[129] Fix | Delete
"{$allow_prefix}algolia_integration_active" => true,
[130] Fix | Delete
];
[131] Fix | Delete
[132] Fix | Delete
if ( is_multisite() ) {
[133] Fix | Delete
parent::__construct();
[134] Fix | Delete
[135] Fix | Delete
add_filter( 'admin_title', [ 'Yoast_Input_Validation', 'add_yoast_admin_document_title_errors' ] );
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Add filters to make sure that the option default is returned if the option is not set
[141] Fix | Delete
*
[142] Fix | Delete
* @return void
[143] Fix | Delete
*/
[144] Fix | Delete
public function add_default_filters() {
[145] Fix | Delete
// Don't change, needs to check for false as could return prio 0 which would evaluate to false.
[146] Fix | Delete
if ( has_filter( 'default_site_option_' . $this->option_name, [ $this, 'get_defaults' ] ) === false ) {
[147] Fix | Delete
add_filter( 'default_site_option_' . $this->option_name, [ $this, 'get_defaults' ] );
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
/**
[152] Fix | Delete
* Remove the default filters.
[153] Fix | Delete
* Called from the validate() method to prevent failure to add new options.
[154] Fix | Delete
*
[155] Fix | Delete
* @return void
[156] Fix | Delete
*/
[157] Fix | Delete
public function remove_default_filters() {
[158] Fix | Delete
remove_filter( 'default_site_option_' . $this->option_name, [ $this, 'get_defaults' ] );
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Add filters to make sure that the option is merged with its defaults before being returned.
[163] Fix | Delete
*
[164] Fix | Delete
* @return void
[165] Fix | Delete
*/
[166] Fix | Delete
public function add_option_filters() {
[167] Fix | Delete
// Don't change, needs to check for false as could return prio 0 which would evaluate to false.
[168] Fix | Delete
if ( has_filter( 'site_option_' . $this->option_name, [ $this, 'get_option' ] ) === false ) {
[169] Fix | Delete
add_filter( 'site_option_' . $this->option_name, [ $this, 'get_option' ] );
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
/**
[174] Fix | Delete
* Remove the option filters.
[175] Fix | Delete
* Called from the clean_up methods to make sure we retrieve the original old option.
[176] Fix | Delete
*
[177] Fix | Delete
* @return void
[178] Fix | Delete
*/
[179] Fix | Delete
public function remove_option_filters() {
[180] Fix | Delete
remove_filter( 'site_option_' . $this->option_name, [ $this, 'get_option' ] );
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
/* *********** METHODS influencing add_uption(), update_option() and saving from admin pages *********** */
[184] Fix | Delete
[185] Fix | Delete
/**
[186] Fix | Delete
* Validate the option.
[187] Fix | Delete
*
[188] Fix | Delete
* @param array $dirty New value for the option.
[189] Fix | Delete
* @param array $clean Clean value for the option, normally the defaults.
[190] Fix | Delete
* @param array $old Old value of the option.
[191] Fix | Delete
*
[192] Fix | Delete
* @return array Validated clean value for the option to be saved to the database.
[193] Fix | Delete
*/
[194] Fix | Delete
protected function validate_option( $dirty, $clean, $old ) {
[195] Fix | Delete
[196] Fix | Delete
foreach ( $clean as $key => $value ) {
[197] Fix | Delete
switch ( $key ) {
[198] Fix | Delete
case 'access':
[199] Fix | Delete
if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], self::$allowed_access_options, true ) ) {
[200] Fix | Delete
$clean[ $key ] = $dirty[ $key ];
[201] Fix | Delete
}
[202] Fix | Delete
elseif ( function_exists( 'add_settings_error' ) ) {
[203] Fix | Delete
add_settings_error(
[204] Fix | Delete
$this->group_name, // Slug title of the setting.
[205] Fix | Delete
$key, // Suffix-ID for the error message box.
[206] Fix | Delete
/* translators: %1$s expands to the option name and %2$sexpands to Yoast SEO */
[207] Fix | Delete
sprintf( __( '%1$s is not a valid choice for who should be allowed access to the %2$s settings. Value reset to the default.', 'wordpress-seo' ), esc_html( sanitize_text_field( $dirty[ $key ] ) ), 'Yoast SEO' ), // The error message.
[208] Fix | Delete
'error' // Message type.
[209] Fix | Delete
);
[210] Fix | Delete
}
[211] Fix | Delete
break;
[212] Fix | Delete
[213] Fix | Delete
case 'defaultblog':
[214] Fix | Delete
if ( isset( $dirty[ $key ] ) && ( $dirty[ $key ] !== '' && $dirty[ $key ] !== '-' ) ) {
[215] Fix | Delete
$int = WPSEO_Utils::validate_int( $dirty[ $key ] );
[216] Fix | Delete
if ( $int !== false && $int > 0 ) {
[217] Fix | Delete
// Check if a valid blog number has been received.
[218] Fix | Delete
$exists = get_blog_details( $int, false );
[219] Fix | Delete
if ( $exists && $exists->deleted === '0' ) {
[220] Fix | Delete
$clean[ $key ] = $int;
[221] Fix | Delete
}
[222] Fix | Delete
elseif ( function_exists( 'add_settings_error' ) ) {
[223] Fix | Delete
add_settings_error(
[224] Fix | Delete
$this->group_name, // Slug title of the setting.
[225] Fix | Delete
$key, // Suffix-ID for the error message box.
[226] Fix | Delete
esc_html__( 'The default blog setting must be the numeric blog id of the blog you want to use as default.', 'wordpress-seo' )
[227] Fix | Delete
. '<br>'
[228] Fix | Delete
. sprintf(
[229] Fix | Delete
/* translators: %s is the ID number of a blog. */
[230] Fix | Delete
esc_html__( 'This must be an existing blog. Blog %s does not exist or has been marked as deleted.', 'wordpress-seo' ),
[231] Fix | Delete
'<strong>' . esc_html( sanitize_text_field( $dirty[ $key ] ) ) . '</strong>'
[232] Fix | Delete
), // The error message.
[233] Fix | Delete
'error' // Message type.
[234] Fix | Delete
);
[235] Fix | Delete
}
[236] Fix | Delete
unset( $exists );
[237] Fix | Delete
}
[238] Fix | Delete
elseif ( function_exists( 'add_settings_error' ) ) {
[239] Fix | Delete
add_settings_error(
[240] Fix | Delete
$this->group_name, // Slug title of the setting.
[241] Fix | Delete
$key, // Suffix-ID for the error message box.
[242] Fix | Delete
esc_html__( 'The default blog setting must be the numeric blog id of the blog you want to use as default.', 'wordpress-seo' ) . '<br>' . esc_html__( 'No numeric value was received.', 'wordpress-seo' ), // The error message.
[243] Fix | Delete
'error' // Message type.
[244] Fix | Delete
);
[245] Fix | Delete
}
[246] Fix | Delete
unset( $int );
[247] Fix | Delete
}
[248] Fix | Delete
break;
[249] Fix | Delete
[250] Fix | Delete
default:
[251] Fix | Delete
$clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false );
[252] Fix | Delete
break;
[253] Fix | Delete
}
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
return $clean;
[257] Fix | Delete
}
[258] Fix | Delete
}
[259] Fix | Delete
[260] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function