. */ if ( ! defined( 'WPSEO_FILE' ) ) { define( 'WPSEO_FILE', __FILE__ ); } if ( ! defined( 'WPSEO_PREMIUM_PLUGIN_FILE' ) ) { define( 'WPSEO_PREMIUM_PLUGIN_FILE', __FILE__ ); } $wpseo_premium_dir = plugin_dir_path( WPSEO_PREMIUM_PLUGIN_FILE ) . 'premium/'; // Run the redirects when frontend is being opened. if ( ! is_admin() ) { require_once $wpseo_premium_dir . 'classes/redirect/redirect-util.php'; require_once $wpseo_premium_dir . 'classes/redirect/redirect-handler.php'; $wpseo_redirect_handler = new WPSEO_Redirect_Handler(); $wpseo_redirect_handler->load(); } /** * Filters the defaults for the `wpseo` option. * * @param array $wpseo_defaults The defaults for the `wpseo` option. * * @return array */ function wpseo_premium_add_general_option_defaults( array $wpseo_defaults ) { $premium_defaults = [ 'enable_metabox_insights' => true, 'enable_link_suggestions' => true, ]; return array_merge( $wpseo_defaults, $premium_defaults ); } add_filter( 'wpseo_option_wpseo_defaults', 'wpseo_premium_add_general_option_defaults' ); // Load the WordPress SEO plugin. require_once dirname( WPSEO_FILE ) . '/wp-seo-main.php'; $yoast_seo_premium_autoload_file = plugin_dir_path( WPSEO_PREMIUM_PLUGIN_FILE ) . 'vendor/autoload.php'; if ( is_readable( $yoast_seo_premium_autoload_file ) ) { require $yoast_seo_premium_autoload_file; } elseif ( ! class_exists( 'WPSEO_Options' ) ) { // Still checking since might be site-level autoload R. add_action( 'admin_init', 'yoast_wpseo_missing_autoload', 1 ); return; } $wpseo_premium_capabilities = new WPSEO_Premium_Register_Capabilities(); $wpseo_premium_capabilities->register_hooks(); /** * Run the upgrade for Yoast SEO Premium. */ function wpseo_premium_run_upgrade() { $upgrade_manager = new WPSEO_Upgrade_Manager(); $upgrade_manager->run_upgrade( WPSEO_VERSION ); } /* * If the user is admin, check for the upgrade manager. * Considered to use 'admin_init' but that is called too late in the process. */ if ( is_admin() ) { add_action( 'init', 'wpseo_premium_run_upgrade' ); } /** * The premium setup */ function wpseo_premium_init() { new WPSEO_Premium(); } if ( ! wp_installing() ) { add_action( 'plugins_loaded', 'wpseo_premium_init', 14 ); } // Activation hook. if ( is_admin() ) { register_activation_hook( __FILE__, [ 'WPSEO_Premium', 'install' ] ); }