base_dir = $base_dir; } /** * Performs the installer if it hasn't been done yet. * * A notice will be shown in the admin if the installer failed. * * @return void */ public function install_yoast_seo_from_repository() { \add_action( 'admin_notices', [ $this, 'show_install_yoast_seo_notification' ] ); \add_action( 'network_admin_notices', [ $this, 'show_install_yoast_seo_notification' ] ); \add_action( 'plugins_loaded', [ $this, 'validate_installation_status' ] ); if ( ! $this->get_status() ) { try { $this->install(); } catch ( Exception $e ) { // Auto installation failed, the notice will be displayed. return; } } elseif ( $this->get_status() === 'started' ) { require_once \ABSPATH . 'wp-admin/includes/plugin.php'; $this->detect_yoast_seo(); if ( \is_plugin_active( $this->yoast_seo_file ) ) { // Yoast SEO is active so mark installation as successful. \update_option( self::OPTION_KEY, 'completed', true ); // Enable tracking. if ( \class_exists( WPSEO_Options::class ) ) { WPSEO_Premium_Option::register_option(); if ( WPSEO_Options::get( 'toggled_tracking' ) !== true ) { WPSEO_Options::set( 'tracking', true ); } WPSEO_Options::set( 'should_redirect_after_install', true ); } if ( \class_exists( WPSEO_Capability_Manager_Factory::class ) ) { \do_action( 'wpseo_register_capabilities_premium' ); WPSEO_Capability_Manager_Factory::get( 'premium' )->add(); } } } } /** * Performs the installer if it hasn't been done yet. * Otherwise attempts to load Yoast SEO from the vendor directory. * * @deprecated 21.9 * @codeCoverageIgnore * * @return void */ public function install_or_load_yoast_seo_from_vendor_directory() { \_deprecated_function( __METHOD__, 'Yoast SEO Premium 21.9' ); } /** * Displays a notification to install Yoast SEO. * * @return void */ public function show_install_yoast_seo_notification() { if ( ! $this->should_show_notification() ) { return; } require_once \ABSPATH . 'wp-admin/includes/plugin.php'; $this->detect_yoast_seo(); $action = $this->get_notification_action(); if ( ! $action ) { return; } echo ( '
' . \sprintf( /* translators: %1$s: Yoast SEO, %2$s: The minimum Yoast SEO version required, %3$s: Yoast SEO Premium. */ \esc_html__( '%1$s %2$s must be installed and activated in order to use %3$s.', 'wordpress-seo-premium' ), 'Yoast SEO', \esc_html( self::MINIMUM_YOAST_SEO_VERSION ), 'Yoast SEO Premium' ) . '
' . '' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is escaped above. . $action . '
' . '