| @@ -14,9 +14,9 @@ | ||
| 14 | 14 | /** |
| 15 | 15 | * {@internal Nobody should be able to overrule the real version number as this can cause |
| 16 | 16 | * serious issues with the options, so no if ( ! defined() ).}} |
| 17 | 17 | */ |
| 18 | -define( 'WPSEO_VERSION', '18.4' ); | |
| 18 | +define( 'WPSEO_VERSION', '28.5' ); | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | if ( ! defined( 'WPSEO_PATH' ) ) { |
| 22 | 22 | define( 'WPSEO_PATH', plugin_dir_path( WPSEO_FILE ) ); |
| @@ -33,11 +33,11 @@ | ||
| 33 | 33 | define( 'YOAST_VENDOR_NS_PREFIX', 'YoastSEO_Vendor' ); |
| 34 | 34 | define( 'YOAST_VENDOR_DEFINE_PREFIX', 'YOASTSEO_VENDOR__' ); |
| 35 | 35 | define( 'YOAST_VENDOR_PREFIX_DIRECTORY', 'vendor_prefixed' ); |
| 36 | 36 | |
| 37 | -define( 'YOAST_SEO_PHP_REQUIRED', '5.6' ); | |
| 38 | -define( 'YOAST_SEO_WP_TESTED', '5.9.2' ); | |
| 39 | -define( 'YOAST_SEO_WP_REQUIRED', '5.8' ); | |
| 37 | +define( 'YOAST_SEO_PHP_REQUIRED', '7.4' ); | |
| 38 | +define( 'YOAST_SEO_WP_TESTED', '7.1' ); | |
| 39 | +define( 'YOAST_SEO_WP_REQUIRED', '6.9' ); | |
| 40 | 40 | |
| 41 | 41 | if ( ! defined( 'WPSEO_NAMESPACES' ) ) { |
| 42 | 42 | define( 'WPSEO_NAMESPACES', true ); |
| 43 | 43 | } |
| @@ -54,14 +54,12 @@ | ||
| 54 | 54 | */ |
| 55 | 55 | function wpseo_auto_load( $class_name ) { |
| 56 | 56 | static $classes = null; |
| 57 | 57 | |
| 58 | - if ( $classes === null ) { | |
| 59 | - $classes = [ | |
| 60 | - 'wp_list_table' => ABSPATH . 'wp-admin/includes/class-wp-list-table.php', | |
| 61 | - 'walker_category' => ABSPATH . 'wp-includes/category-template.php', | |
| 62 | - ]; | |
| 63 | - } | |
| 58 | + $classes ??= [ | |
| 59 | + 'wp_list_table' => ABSPATH . 'wp-admin/includes/class-wp-list-table.php', | |
| 60 | + 'walker_category' => ABSPATH . 'wp-includes/category-template.php', | |
| 61 | + ]; | |
| 64 | 62 | |
| 65 | 63 | $cn = strtolower( $class_name ); |
| 66 | 64 | |
| 67 | 65 | if ( ! class_exists( $class_name ) && isset( $classes[ $cn ] ) ) { |
| @@ -79,8 +77,19 @@ | ||
| 79 | 77 | |
| 80 | 78 | return; |
| 81 | 79 | } |
| 82 | 80 | |
| 81 | +/** | |
| 82 | + * Include the file from the `symfony/deprecation-contracts` dependency instead of autoloading it via composer. | |
| 83 | + * | |
| 84 | + * We need to do that because autoloading via composer prevents the vendor-prefixing of the dependency itself. | |
| 85 | + * Note that we don't expect the function to be ever called since the OAuth2 library should not provide invalid input. | |
| 86 | + */ | |
| 87 | +$deprecation_contracts_file = WPSEO_PATH . 'vendor_prefixed/symfony/deprecation-contracts/functions.php'; | |
| 88 | +if ( is_readable( $deprecation_contracts_file ) ) { | |
| 89 | + include $deprecation_contracts_file; | |
| 90 | +} | |
| 91 | + | |
| 83 | 92 | if ( function_exists( 'spl_autoload_register' ) ) { |
| 84 | 93 | spl_autoload_register( 'wpseo_auto_load' ); |
| 85 | 94 | } |
| 86 | 95 | require_once WPSEO_PATH . 'src/functions.php'; |
| @@ -104,13 +113,13 @@ | ||
| 104 | 113 | * As this is only loaded in development removing this action is not a concern. |
| 105 | 114 | * |
| 106 | 115 | * @return void |
| 107 | 116 | */ |
| 108 | - static function() use ( $yoast_autoloader ) { | |
| 117 | + static function () use ( $yoast_autoloader ) { | |
| 109 | 118 | $yoast_autoloader->unregister(); |
| 110 | 119 | $yoast_autoloader->register( true ); |
| 111 | 120 | }, |
| 112 | - 1 | |
| 121 | + 1, | |
| 113 | 122 | ); |
| 114 | 123 | } |
| 115 | 124 | |
| 116 | 125 | /** |
| @@ -125,8 +134,10 @@ | ||
| 125 | 134 | /** |
| 126 | 135 | * Run single site / network-wide activation of the plugin. |
| 127 | 136 | * |
| 128 | 137 | * @param bool $networkwide Whether the plugin is being activated network-wide. |
| 138 | + * | |
| 139 | + * @return void | |
| 129 | 140 | */ |
| 130 | 141 | function wpseo_activate( $networkwide = false ) { |
| 131 | 142 | if ( ! is_multisite() || ! $networkwide ) { |
| 132 | 143 | _wpseo_activate(); |
| @@ -143,8 +154,10 @@ | ||
| 143 | 154 | /** |
| 144 | 155 | * Run single site / network-wide de-activation of the plugin. |
| 145 | 156 | * |
| 146 | 157 | * @param bool $networkwide Whether the plugin is being de-activated network-wide. |
| 158 | + * | |
| 159 | + * @return void | |
| 147 | 160 | */ |
| 148 | 161 | function wpseo_deactivate( $networkwide = false ) { |
| 149 | 162 | if ( ! is_multisite() || ! $networkwide ) { |
| 150 | 163 | _wpseo_deactivate(); |
| @@ -158,8 +171,10 @@ | ||
| 158 | 171 | /** |
| 159 | 172 | * Run network-wide (de-)activation of the plugin. |
| 160 | 173 | * |
| 161 | 174 | * @param bool $activate True for plugin activation, false for de-activation. |
| 175 | + * | |
| 176 | + * @return void | |
| 162 | 177 | */ |
| 163 | 178 | function wpseo_network_activate_deactivate( $activate = true ) { |
| 164 | 179 | global $wpdb; |
| 165 | 180 | |
| @@ -182,15 +197,15 @@ | ||
| 182 | 197 | } |
| 183 | 198 | |
| 184 | 199 | /** |
| 185 | 200 | * Runs on activation of the plugin. |
| 201 | + * | |
| 202 | + * @return void | |
| 186 | 203 | */ |
| 187 | 204 | function _wpseo_activate() { |
| 188 | 205 | require_once WPSEO_PATH . 'inc/wpseo-functions.php'; |
| 189 | 206 | require_once WPSEO_PATH . 'inc/class-wpseo-installation.php'; |
| 190 | 207 | |
| 191 | - wpseo_load_textdomain(); // Make sure we have our translations available for the defaults. | |
| 192 | - | |
| 193 | 208 | new WPSEO_Installation(); |
| 194 | 209 | |
| 195 | 210 | WPSEO_Options::get_instance(); |
| 196 | 211 | if ( ! is_multisite() ) { |
| @@ -200,24 +215,14 @@ | ||
| 200 | 215 | WPSEO_Options::maybe_set_multisite_defaults( true ); |
| 201 | 216 | } |
| 202 | 217 | WPSEO_Options::ensure_options_exist(); |
| 203 | 218 | |
| 204 | - if ( is_multisite() && ms_is_switched() ) { | |
| 205 | - delete_option( 'rewrite_rules' ); | |
| 219 | + if ( ! is_multisite() || ! ms_is_switched() ) { | |
| 220 | + // Constructor has side effects so this registers all hooks. | |
| 221 | + $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); | |
| 206 | 222 | } |
| 207 | - else { | |
| 208 | - if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { | |
| 209 | - // Constructor has side effects so this registers all hooks. | |
| 210 | - $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); | |
| 211 | - } | |
| 212 | - add_action( 'shutdown', 'flush_rewrite_rules' ); | |
| 213 | - } | |
| 223 | + add_action( 'shutdown', [ 'WPSEO_Utils', 'clear_rewrites' ] ); | |
| 214 | 224 | |
| 215 | - // Reset tracking to be disabled by default. | |
| 216 | - if ( ! YoastSEO()->helpers->product->is_premium() ) { | |
| 217 | - WPSEO_Options::set( 'tracking', false ); | |
| 218 | - } | |
| 219 | - | |
| 220 | 225 | WPSEO_Options::set( 'indexing_reason', 'first_install' ); |
| 221 | 226 | WPSEO_Options::set( 'first_time_install', true ); |
| 222 | 227 | if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
| 223 | 228 | WPSEO_Options::set( 'should_redirect_after_install_free', true ); |
| @@ -222,11 +227,15 @@ | ||
| 222 | 227 | if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { |
| 223 | 228 | WPSEO_Options::set( 'should_redirect_after_install_free', true ); |
| 224 | 229 | } |
| 225 | 230 | else { |
| 226 | - WPSEO_Options::set( 'activation_redirect_timestamp_free', \time() ); | |
| 231 | + WPSEO_Options::set( 'activation_redirect_timestamp_free', time() ); | |
| 227 | 232 | } |
| 228 | 233 | |
| 234 | + // Reset tracking to be disabled by default. | |
| 235 | + if ( ! YoastSEO()->helpers->product->is_premium() && WPSEO_Options::get( 'toggled_tracking' ) !== true ) { | |
| 236 | + WPSEO_Options::set( 'tracking', false ); | |
| 237 | + } | |
| 229 | 238 | do_action( 'wpseo_register_roles' ); |
| 230 | 239 | WPSEO_Role_Manager_Factory::get()->add(); |
| 231 | 240 | |
| 232 | 241 | do_action( 'wpseo_register_capabilities' ); |
| @@ -234,27 +243,20 @@ | ||
| 234 | 243 | |
| 235 | 244 | // Clear cache so the changes are obvious. |
| 236 | 245 | WPSEO_Utils::clear_cache(); |
| 237 | 246 | |
| 238 | - // Schedule cronjob when it doesn't exists on activation. | |
| 239 | - $wpseo_ryte = new WPSEO_Ryte(); | |
| 240 | - $wpseo_ryte->activate_hooks(); | |
| 241 | - | |
| 242 | 247 | do_action( 'wpseo_activate' ); |
| 243 | 248 | } |
| 244 | 249 | |
| 245 | 250 | /** |
| 246 | 251 | * On deactivation, flush the rewrite rules so XML sitemaps stop working. |
| 252 | + * | |
| 253 | + * @return void | |
| 247 | 254 | */ |
| 248 | 255 | function _wpseo_deactivate() { |
| 249 | 256 | require_once WPSEO_PATH . 'inc/wpseo-functions.php'; |
| 250 | 257 | |
| 251 | - if ( is_multisite() && ms_is_switched() ) { | |
| 252 | - delete_option( 'rewrite_rules' ); | |
| 253 | - } | |
| 254 | - else { | |
| 255 | - add_action( 'shutdown', 'flush_rewrite_rules' ); | |
| 256 | - } | |
| 258 | + add_action( 'shutdown', [ 'WPSEO_Utils', 'clear_rewrites' ] ); | |
| 257 | 259 | |
| 258 | 260 | // Register capabilities, to make sure they are cleaned up. |
| 259 | 261 | do_action( 'wpseo_register_roles' ); |
| 260 | 262 | do_action( 'wpseo_register_capabilities' ); |
| @@ -278,8 +280,10 @@ | ||
| 278 | 280 | * {@internal Unfortunately will fail if the plugin is in the must-use directory. |
| 279 | 281 | * {@link https://core.trac.wordpress.org/ticket/24205} }} |
| 280 | 282 | * |
| 281 | 283 | * @param int|WP_Site $blog_id Blog ID. |
| 284 | + * | |
| 285 | + * @return void | |
| 282 | 286 | */ |
| 283 | 287 | function wpseo_on_activate_blog( $blog_id ) { |
| 284 | 288 | if ( ! function_exists( 'is_plugin_active_for_network' ) ) { |
| 285 | 289 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| @@ -297,28 +301,24 @@ | ||
| 297 | 301 | } |
| 298 | 302 | |
| 299 | 303 | /* ***************************** PLUGIN LOADING *************************** */ |
| 300 | 304 | |
| 305 | + | |
| 301 | 306 | /** |
| 302 | 307 | * Load translations. |
| 308 | + * | |
| 309 | + * @deprecated 27.0 | |
| 310 | + * @codeCoverageIgnore | |
| 311 | + * | |
| 312 | + * @return void | |
| 303 | 313 | */ |
| 304 | 314 | function wpseo_load_textdomain() { |
| 305 | - $wpseo_path = str_replace( '\\', '/', WPSEO_PATH ); | |
| 306 | - $mu_path = str_replace( '\\', '/', WPMU_PLUGIN_DIR ); | |
| 307 | - | |
| 308 | - if ( stripos( $wpseo_path, $mu_path ) !== false ) { | |
| 309 | - load_muplugin_textdomain( 'wordpress-seo', dirname( WPSEO_BASENAME ) . '/languages/' ); | |
| 310 | - } | |
| 311 | - else { | |
| 312 | - load_plugin_textdomain( 'wordpress-seo', false, dirname( WPSEO_BASENAME ) . '/languages/' ); | |
| 313 | - } | |
| 315 | + _deprecated_function( __FUNCTION__, 'Yoast SEO 27.0' ); | |
| 314 | 316 | } |
| 315 | - | |
| 316 | -add_action( 'plugins_loaded', 'wpseo_load_textdomain' ); | |
| 317 | - | |
| 318 | - | |
| 319 | 317 | /** |
| 320 | 318 | * On plugins_loaded: load the minimum amount of essential files for this plugin. |
| 319 | + * | |
| 320 | + * @return void | |
| 321 | 321 | */ |
| 322 | 322 | function wpseo_init() { |
| 323 | 323 | require_once WPSEO_PATH . 'inc/wpseo-functions.php'; |
| 324 | 324 | require_once WPSEO_PATH . 'inc/wpseo-functions-deprecated.php'; |
| @@ -326,10 +326,24 @@ | ||
| 326 | 326 | // Make sure our option and meta value validation routines and default values are always registered and available. |
| 327 | 327 | WPSEO_Options::get_instance(); |
| 328 | 328 | WPSEO_Meta::init(); |
| 329 | 329 | |
| 330 | - if ( version_compare( WPSEO_Options::get( 'version', 1 ), WPSEO_VERSION, '<' ) ) { | |
| 331 | - if ( function_exists( 'opcache_reset' ) ) { | |
| 330 | + if ( version_compare( WPSEO_Options::get( 'version', 1, [ 'wpseo' ] ), WPSEO_VERSION, '<' ) ) { | |
| 331 | + // Invalidate the opcache in 50% of the cases, randomly staggered based on the site URL. | |
| 332 | + // @TODO: Move the staggering logic to its own class, but only after a few releases after the complete sunset of the opcache invalidation. Make sure to document that in the future, maybe `12` should be used as modulus, so that it's easier to tinker the percentage (divisible by 2, 3, 4, 6). (see the technical choices of https://github.com/Yoast/wordpress-seo/pull/22812). | |
| 333 | + $random_seed = hexdec( substr( hash( 'sha256', site_url() ), 0, 8 ) ); | |
| 334 | + $should_invalidate_opcache = ( $random_seed % 2 ) !== 0; | |
| 335 | + | |
| 336 | + /** | |
| 337 | + * Filter: 'Yoast\WP\SEO\should_invalidate_opcache' - Allow developers to enable / disable | |
| 338 | + * opcache invalidation upon upgrade of the Yoast SEO plugin. | |
| 339 | + * | |
| 340 | + * @since 26.1 | |
| 341 | + * | |
| 342 | + * @param bool $should_invalidate Whether opcache should be invalidated. | |
| 343 | + */ | |
| 344 | + $should_invalidate_opcache = (bool) apply_filters( 'Yoast\WP\SEO\should_invalidate_opcache', $should_invalidate_opcache ); | |
| 345 | + if ( $should_invalidate_opcache && function_exists( 'opcache_reset' ) ) { | |
| 332 | 346 | // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Prevent notices when opcache.restrict_api is set. |
| 333 | 347 | @opcache_reset(); |
| 334 | 348 | } |
| 335 | 349 | |
| @@ -336,13 +350,11 @@ | ||
| 336 | 350 | new WPSEO_Upgrade(); |
| 337 | 351 | // Get a cleaned up version of the $options. |
| 338 | 352 | } |
| 339 | 353 | |
| 340 | - if ( WPSEO_Options::get( 'stripcategorybase' ) === true ) { | |
| 341 | - $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); | |
| 342 | - } | |
| 354 | + $GLOBALS['wpseo_rewrite'] = new WPSEO_Rewrite(); | |
| 343 | 355 | |
| 344 | - if ( WPSEO_Options::get( 'enable_xml_sitemap' ) === true ) { | |
| 356 | + if ( WPSEO_Options::get( 'enable_xml_sitemap', null, [ 'wpseo' ] ) === true ) { | |
| 345 | 357 | $GLOBALS['wpseo_sitemaps'] = new WPSEO_Sitemaps(); |
| 346 | 358 | } |
| 347 | 359 | |
| 348 | 360 | if ( ! wp_doing_ajax() ) { |
| @@ -348,11 +360,8 @@ | ||
| 348 | 360 | if ( ! wp_doing_ajax() ) { |
| 349 | 361 | require_once WPSEO_PATH . 'inc/wpseo-non-ajax-functions.php'; |
| 350 | 362 | } |
| 351 | 363 | |
| 352 | - // Init it here because the filter must be present on the frontend as well or it won't work in the customizer. | |
| 353 | - new WPSEO_Customizer(); | |
| 354 | - | |
| 355 | 364 | $integrations = []; |
| 356 | 365 | $integrations[] = new WPSEO_Slug_Change_Watcher(); |
| 357 | 366 | |
| 358 | 367 | foreach ( $integrations as $integration ) { |
| @@ -357,16 +366,14 @@ | ||
| 357 | 366 | |
| 358 | 367 | foreach ( $integrations as $integration ) { |
| 359 | 368 | $integration->register_hooks(); |
| 360 | 369 | } |
| 361 | - | |
| 362 | - // Loading Ryte integration. | |
| 363 | - $wpseo_ryte = new WPSEO_Ryte(); | |
| 364 | - $wpseo_ryte->register_hooks(); | |
| 365 | 370 | } |
| 366 | 371 | |
| 367 | 372 | /** |
| 368 | 373 | * Loads the rest api endpoints. |
| 374 | + * | |
| 375 | + * @return void | |
| 369 | 376 | */ |
| 370 | 377 | function wpseo_init_rest_api() { |
| 371 | 378 | // We can't do anything when requirements are not met. |
| 372 | 379 | if ( ! WPSEO_Utils::is_api_available() ) { |
| @@ -386,74 +393,25 @@ | ||
| 386 | 393 | } |
| 387 | 394 | |
| 388 | 395 | /** |
| 389 | 396 | * Used to load the required files on the plugins_loaded hook, instead of immediately. |
| 397 | + * | |
| 398 | + * @return void | |
| 390 | 399 | */ |
| 391 | 400 | function wpseo_admin_init() { |
| 392 | 401 | new WPSEO_Admin_Init(); |
| 393 | 402 | } |
| 394 | 403 | |
| 395 | -/** | |
| 396 | - * Initialize the WP-CLI integration. | |
| 397 | - * | |
| 398 | - * The WP-CLI integration needs PHP 5.3 support, which should be automatically | |
| 399 | - * enforced by the check for the WP_CLI constant. As WP-CLI itself only runs | |
| 400 | - * on PHP 5.3+, the constant should only be set when requirements are met. | |
| 401 | - */ | |
| 402 | -function wpseo_cli_init() { | |
| 403 | - if ( YoastSEO()->helpers->product->is_premium() ) { | |
| 404 | - WP_CLI::add_command( | |
| 405 | - 'yoast redirect list', | |
| 406 | - 'WPSEO_CLI_Redirect_List_Command', | |
| 407 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 408 | - ); | |
| 409 | - | |
| 410 | - WP_CLI::add_command( | |
| 411 | - 'yoast redirect create', | |
| 412 | - 'WPSEO_CLI_Redirect_Create_Command', | |
| 413 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 414 | - ); | |
| 415 | - | |
| 416 | - WP_CLI::add_command( | |
| 417 | - 'yoast redirect update', | |
| 418 | - 'WPSEO_CLI_Redirect_Update_Command', | |
| 419 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 420 | - ); | |
| 421 | - | |
| 422 | - WP_CLI::add_command( | |
| 423 | - 'yoast redirect delete', | |
| 424 | - 'WPSEO_CLI_Redirect_Delete_Command', | |
| 425 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 426 | - ); | |
| 427 | - | |
| 428 | - WP_CLI::add_command( | |
| 429 | - 'yoast redirect has', | |
| 430 | - 'WPSEO_CLI_Redirect_Has_Command', | |
| 431 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 432 | - ); | |
| 433 | - | |
| 434 | - WP_CLI::add_command( | |
| 435 | - 'yoast redirect follow', | |
| 436 | - 'WPSEO_CLI_Redirect_Follow_Command', | |
| 437 | - [ 'before_invoke' => 'WPSEO_CLI_Premium_Requirement::enforce' ] | |
| 438 | - ); | |
| 439 | - } | |
| 440 | -} | |
| 441 | - | |
| 442 | 404 | /* ***************************** BOOTSTRAP / HOOK INTO WP *************************** */ |
| 443 | 405 | $spl_autoload_exists = function_exists( 'spl_autoload_register' ); |
| 444 | -$filter_exists = function_exists( 'filter_input' ); | |
| 445 | 406 | |
| 446 | 407 | if ( ! $spl_autoload_exists ) { |
| 447 | 408 | add_action( 'admin_init', 'yoast_wpseo_missing_spl', 1 ); |
| 448 | 409 | } |
| 449 | 410 | |
| 450 | -if ( ! $filter_exists ) { | |
| 451 | - add_action( 'admin_init', 'yoast_wpseo_missing_filter', 1 ); | |
| 452 | -} | |
| 453 | - | |
| 454 | -if ( ! wp_installing() && ( $spl_autoload_exists && $filter_exists ) ) { | |
| 411 | +if ( ! wp_installing() && ( $spl_autoload_exists ) ) { | |
| 455 | 412 | add_action( 'plugins_loaded', 'wpseo_init', 14 ); |
| 413 | + add_action( 'setup_theme', [ 'Yoast_Dynamic_Rewrites', 'instance' ], 1 ); | |
| 456 | 414 | add_action( 'rest_api_init', 'wpseo_init_rest_api' ); |
| 457 | 415 | |
| 458 | 416 | if ( is_admin() ) { |
| 459 | 417 | |
| @@ -467,10 +425,14 @@ | ||
| 467 | 425 | |
| 468 | 426 | // Plugin conflict ajax hooks. |
| 469 | 427 | new Yoast_Plugin_Conflict_Ajax(); |
| 470 | 428 | |
| 471 | - if ( filter_input( INPUT_POST, 'action' ) === 'inline-save' ) { | |
| 472 | - add_action( 'plugins_loaded', 'wpseo_admin_init', 15 ); | |
| 429 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information but only loading the admin init class. | |
| 430 | + if ( isset( $_POST['action'] ) && is_string( $_POST['action'] ) ) { | |
| 431 | + // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information but only loading the admin init class, We are strictly comparing only. | |
| 432 | + if ( wp_unslash( $_POST['action'] ) === 'inline-save' ) { | |
| 433 | + add_action( 'plugins_loaded', 'wpseo_admin_init', 15 ); | |
| 434 | + } | |
| 473 | 435 | } |
| 474 | 436 | } |
| 475 | 437 | else { |
| 476 | 438 | add_action( 'plugins_loaded', 'wpseo_admin_init', 15 ); |
| @@ -478,12 +440,8 @@ | ||
| 478 | 440 | } |
| 479 | 441 | |
| 480 | 442 | add_action( 'plugins_loaded', 'load_yoast_notifications' ); |
| 481 | 443 | |
| 482 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
| 483 | - add_action( 'plugins_loaded', 'wpseo_cli_init', 20 ); | |
| 484 | - } | |
| 485 | - | |
| 486 | 444 | add_action( 'init', [ 'WPSEO_Replace_Vars', 'setup_statics_once' ] ); |
| 487 | 445 | |
| 488 | 446 | // Initializes the Yoast indexables for the first time. |
| 489 | 447 | YoastSEO(); |
| @@ -497,17 +455,9 @@ | ||
| 497 | 455 | // Activation and deactivation hook. |
| 498 | 456 | register_activation_hook( WPSEO_FILE, 'wpseo_activate' ); |
| 499 | 457 | register_deactivation_hook( WPSEO_FILE, 'wpseo_deactivate' ); |
| 500 | 458 | |
| 501 | -// Wpmu_new_blog has been deprecated in 5.1 and replaced by wp_insert_site. | |
| 502 | -global $wp_version; | |
| 503 | -if ( version_compare( $wp_version, '5.1', '<' ) ) { | |
| 504 | - add_action( 'wpmu_new_blog', 'wpseo_on_activate_blog' ); | |
| 505 | -} | |
| 506 | -else { | |
| 507 | - add_action( 'wp_initialize_site', 'wpseo_on_activate_blog', 99 ); | |
| 508 | -} | |
| 509 | - | |
| 459 | +add_action( 'wp_initialize_site', 'wpseo_on_activate_blog', 99 ); | |
| 510 | 460 | add_action( 'activate_blog', 'wpseo_on_activate_blog' ); |
| 511 | 461 | |
| 512 | 462 | // Registers SEO capabilities. |
| 513 | 463 | $wpseo_register_capabilities = new WPSEO_Register_Capabilities(); |
| @@ -518,8 +468,10 @@ | ||
| 518 | 468 | $wpseo_register_capabilities->register_hooks(); |
| 519 | 469 | |
| 520 | 470 | /** |
| 521 | 471 | * Wraps for notifications center class. |
| 472 | + * | |
| 473 | + * @return void | |
| 522 | 474 | */ |
| 523 | 475 | function load_yoast_notifications() { |
| 524 | 476 | // Init Yoast_Notification_Center class. |
| 525 | 477 | Yoast_Notification_Center::get(); |
| @@ -542,8 +494,10 @@ | ||
| 542 | 494 | } |
| 543 | 495 | |
| 544 | 496 | /** |
| 545 | 497 | * Returns the notice in case of missing spl extension. |
| 498 | + * | |
| 499 | + * @return void | |
| 546 | 500 | */ |
| 547 | 501 | function yoast_wpseo_missing_spl_notice() { |
| 548 | 502 | $message = esc_html__( 'The Standard PHP Library (SPL) extension seem to be unavailable. Please ask your web host to enable it.', 'wordpress-seo' ); |
| 549 | 503 | yoast_wpseo_activation_failed_notice( $message ); |
| @@ -563,8 +517,10 @@ | ||
| 563 | 517 | } |
| 564 | 518 | |
| 565 | 519 | /** |
| 566 | 520 | * Returns the notice in case of missing Composer autoload. |
| 521 | + * | |
| 522 | + * @return void | |
| 567 | 523 | */ |
| 568 | 524 | function yoast_wpseo_missing_autoload_notice() { |
| 569 | 525 | /* translators: %1$s expands to Yoast SEO, %2$s / %3$s: links to the installation manual in the Readme for the Yoast SEO code repository on GitHub */ |
| 570 | 526 | $message = esc_html__( 'The %1$s plugin installation is incomplete. Please refer to %2$sinstallation instructions%3$s.', 'wordpress-seo' ); |
| @@ -575,25 +531,27 @@ | ||
| 575 | 531 | /** |
| 576 | 532 | * Throw an error if the filter extension is disabled (prevent white screens) and self-deactivate plugin. |
| 577 | 533 | * |
| 578 | 534 | * @since 2.0 |
| 535 | + * @deprecated 23.3 | |
| 536 | + * @codeCoverageIgnore | |
| 579 | 537 | * |
| 580 | 538 | * @return void |
| 581 | 539 | */ |
| 582 | 540 | function yoast_wpseo_missing_filter() { |
| 583 | - if ( is_admin() ) { | |
| 584 | - add_action( 'admin_notices', 'yoast_wpseo_missing_filter_notice' ); | |
| 585 | - | |
| 586 | - yoast_wpseo_self_deactivate(); | |
| 587 | - } | |
| 541 | + _deprecated_function( __FUNCTION__, 'Yoast SEO 23.3' ); | |
| 588 | 542 | } |
| 589 | 543 | |
| 590 | 544 | /** |
| 591 | 545 | * Returns the notice in case of missing filter extension. |
| 546 | + * | |
| 547 | + * @deprecated 23.3 | |
| 548 | + * @codeCoverageIgnore | |
| 549 | + * | |
| 550 | + * @return void | |
| 592 | 551 | */ |
| 593 | 552 | function yoast_wpseo_missing_filter_notice() { |
| 594 | - $message = esc_html__( 'The filter extension seem to be unavailable. Please ask your web host to enable it.', 'wordpress-seo' ); | |
| 595 | - yoast_wpseo_activation_failed_notice( $message ); | |
| 553 | + _deprecated_function( __FUNCTION__, 'Yoast SEO 23.3' ); | |
| 596 | 554 | } |
| 597 | 555 | |
| 598 | 556 | /** |
| 599 | 557 | * Echo's the Activation failed notice with any given message. |
| @@ -598,16 +556,26 @@ | ||
| 598 | 556 | /** |
| 599 | 557 | * Echo's the Activation failed notice with any given message. |
| 600 | 558 | * |
| 601 | 559 | * @param string $message Message string. |
| 560 | + * | |
| 561 | + * @return void | |
| 602 | 562 | */ |
| 603 | 563 | function yoast_wpseo_activation_failed_notice( $message ) { |
| 564 | + $title = sprintf( | |
| 565 | + /* translators: %s: Yoast SEO. */ | |
| 566 | + esc_html__( '%s activation failed', 'wordpress-seo' ), | |
| 567 | + 'Yoast SEO', | |
| 568 | + ); | |
| 569 | + | |
| 604 | 570 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- This function is only called in 3 places that are safe. |
| 605 | - echo '<div class="error"><p>' . esc_html__( 'Activation failed:', 'wordpress-seo' ) . ' ' . strip_tags( $message, '<a>' ) . '</p></div>'; | |
| 571 | + echo '<div class="error yoast-migrated-notice"><h4 class="yoast-notice-migrated-header">' . $title . '</h4><div class="notice-yoast-content"><p>' . strip_tags( $message, '<a>' ) . '</p></div></div>'; | |
| 606 | 572 | } |
| 607 | 573 | |
| 608 | 574 | /** |
| 609 | 575 | * The method will deactivate the plugin, but only once, done by the static $is_deactivated. |
| 576 | + * | |
| 577 | + * @return void | |
| 610 | 578 | */ |
| 611 | 579 | function yoast_wpseo_self_deactivate() { |
| 612 | 580 | static $is_deactivated; |
| 613 | 581 | |
| @@ -617,30 +585,8 @@ | ||
| 617 | 585 | if ( isset( $_GET['activate'] ) ) { |
| 618 | 586 | unset( $_GET['activate'] ); |
| 619 | 587 | } |
| 620 | 588 | } |
| 621 | -} | |
| 622 | - | |
| 623 | -/* ********************* DEPRECATED METHODS ********************* */ | |
| 624 | - | |
| 625 | -/** | |
| 626 | - * Instantiate the different social classes on the frontend. | |
| 627 | - * | |
| 628 | - * @deprecated 14.0 | |
| 629 | - * @codeCoverageIgnore | |
| 630 | - */ | |
| 631 | -function wpseo_frontend_head_init() { | |
| 632 | - _deprecated_function( __METHOD__, 'WPSEO 14.0' ); | |
| 633 | -} | |
| 634 | - | |
| 635 | -/** | |
| 636 | - * Used to load the required files on the plugins_loaded hook, instead of immediately. | |
| 637 | - * | |
| 638 | - * @deprecated 14.0 | |
| 639 | - * @codeCoverageIgnore | |
| 640 | - */ | |
| 641 | -function wpseo_frontend_init() { | |
| 642 | - _deprecated_function( __METHOD__, 'WPSEO 14.0' ); | |
| 643 | 589 | } |
| 644 | 590 | |
| 645 | 591 | /** |
| 646 | 592 | * Aliasses added in order to keep compatibility with Yoast SEO: Local. |