', esc_attr( $identifier ), esc_attr( $class ) );
+
+ $tab_filter_name = sprintf( '%s_%s', $option_tabs->get_base(), $tab->get_name() );
+
+ /**
+ * Allows to override the content that is display on the specific option tab.
+ *
+ * @internal For internal Yoast SEO use only.
+ *
+ * @param string|null $tab_contents The content that should be displayed for this tab. Leave empty for default behaviour.
+ * @param WPSEO_Option_Tabs $option_tabs The registered option tabs.
+ * @param WPSEO_Option_Tab $tab The tab that is being displayed.
+ */
+ $option_tab_content = apply_filters( 'wpseo_option_tab-' . $tab_filter_name, null, $option_tabs, $tab );
+ if ( ! empty( $option_tab_content ) ) {
+ echo wp_kses_post( $option_tab_content );
+ }
+
+ if ( empty( $option_tab_content ) ) {
+ // Output the settings view for all tabs.
+ $tab_view = $this->get_tab_view( $option_tabs, $tab );
+
+ if ( is_file( $tab_view ) ) {
+ $yform = Yoast_Form::get_instance();
+ require $tab_view;
+ }
+ }
+
+ echo '
';
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-option-tabs.php b/wp-content/plugins/wordpress-seo/admin/class-option-tabs.php
new file mode 100644
index 00000000..fb0c4512
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-option-tabs.php
@@ -0,0 +1,124 @@
+base = sanitize_title( $base );
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ $tab = isset( $_GET['tab'] ) && is_string( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '';
+ $this->active_tab = empty( $tab ) ? $active_tab : $tab;
+ }
+
+ /**
+ * Get the base.
+ *
+ * @return string
+ */
+ public function get_base() {
+ return $this->base;
+ }
+
+ /**
+ * Add a tab.
+ *
+ * @param WPSEO_Option_Tab $tab Tab to add.
+ *
+ * @return $this
+ */
+ public function add_tab( WPSEO_Option_Tab $tab ) {
+ $this->tabs[] = $tab;
+
+ return $this;
+ }
+
+ /**
+ * Get active tab.
+ *
+ * @return WPSEO_Option_Tab|null Get the active tab.
+ */
+ public function get_active_tab() {
+ if ( empty( $this->active_tab ) ) {
+ return null;
+ }
+
+ $active_tabs = array_filter( $this->tabs, [ $this, 'is_active_tab' ] );
+ if ( ! empty( $active_tabs ) ) {
+ $active_tabs = array_values( $active_tabs );
+ if ( count( $active_tabs ) === 1 ) {
+ return $active_tabs[0];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Is the tab the active tab.
+ *
+ * @param WPSEO_Option_Tab $tab Tab to check for active tab.
+ *
+ * @return bool
+ */
+ public function is_active_tab( WPSEO_Option_Tab $tab ) {
+ return ( $tab->get_name() === $this->active_tab );
+ }
+
+ /**
+ * Get all tabs.
+ *
+ * @return WPSEO_Option_Tab[]
+ */
+ public function get_tabs() {
+ return $this->tabs;
+ }
+
+ /**
+ * Display the tabs.
+ *
+ * @param Yoast_Form $yform Yoast Form needed in the views.
+ *
+ * @return void
+ */
+ public function display( Yoast_Form $yform ) {
+ $formatter = new WPSEO_Option_Tabs_Formatter();
+ $formatter->run( $this, $yform );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-paper-presenter.php b/wp-content/plugins/wordpress-seo/admin/class-paper-presenter.php
new file mode 100644
index 00000000..99550e4a
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-paper-presenter.php
@@ -0,0 +1,141 @@
+ null,
+ 'paper_id_prefix' => 'wpseo-',
+ 'collapsible' => false,
+ 'collapsible_header_class' => '',
+ 'expanded' => false,
+ 'help_text' => '',
+ 'title_after' => '',
+ 'class' => '',
+ 'content' => '',
+ 'view_data' => [],
+ ];
+
+ $this->settings = wp_parse_args( $settings, $defaults );
+ $this->title = $title;
+ $this->view_file = $view_file;
+ }
+
+ /**
+ * Renders the collapsible paper and returns it as a string.
+ *
+ * @return string The rendered paper.
+ */
+ public function get_output() {
+ $view_variables = $this->get_view_variables();
+
+ extract( $view_variables, EXTR_SKIP );
+
+ $content = $this->settings['content'];
+
+ if ( $this->view_file !== null ) {
+ ob_start();
+ require $this->view_file;
+ $content = ob_get_clean();
+ }
+
+ ob_start();
+ require WPSEO_PATH . 'admin/views/paper-collapsible.php';
+ $rendered_output = ob_get_clean();
+
+ return $rendered_output;
+ }
+
+ /**
+ * Retrieves the view variables.
+ *
+ * @return array The view variables.
+ */
+ private function get_view_variables() {
+ if ( $this->settings['help_text'] instanceof WPSEO_Admin_Help_Panel === false ) {
+ $this->settings['help_text'] = new WPSEO_Admin_Help_Panel( '', '', '' );
+ }
+
+ $view_variables = [
+ 'class' => $this->settings['class'],
+ 'collapsible' => $this->settings['collapsible'],
+ 'collapsible_config' => $this->collapsible_config(),
+ 'collapsible_header_class' => $this->settings['collapsible_header_class'],
+ 'title_after' => $this->settings['title_after'],
+ 'help_text' => $this->settings['help_text'],
+ 'view_file' => $this->view_file,
+ 'title' => $this->title,
+ 'paper_id' => $this->settings['paper_id'],
+ 'paper_id_prefix' => $this->settings['paper_id_prefix'],
+ 'yform' => Yoast_Form::get_instance(),
+ ];
+
+ return array_merge( $this->settings['view_data'], $view_variables );
+ }
+
+ /**
+ * Retrieves the collapsible config based on the settings.
+ *
+ * @return array The config.
+ */
+ protected function collapsible_config() {
+ if ( empty( $this->settings['collapsible'] ) ) {
+ return [
+ 'toggle_icon' => '',
+ 'class' => '',
+ 'expanded' => '',
+ ];
+ }
+
+ if ( ! empty( $this->settings['expanded'] ) ) {
+ return [
+ 'toggle_icon' => 'dashicons-arrow-up-alt2',
+ 'class' => 'toggleable-container',
+ 'expanded' => 'true',
+ ];
+ }
+
+ return [
+ 'toggle_icon' => 'dashicons-arrow-down-alt2',
+ 'class' => 'toggleable-container toggleable-container-hidden',
+ 'expanded' => 'false',
+ ];
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-plugin-availability.php b/wp-content/plugins/wordpress-seo/admin/class-plugin-availability.php
new file mode 100644
index 00000000..4d321dd6
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-plugin-availability.php
@@ -0,0 +1,336 @@
+register_yoast_plugins();
+ $this->register_yoast_plugins_status();
+ }
+
+ /**
+ * Registers all the available Yoast SEO plugins.
+ *
+ * @return void
+ */
+ protected function register_yoast_plugins() {
+ $this->plugins = [
+ 'yoast-seo-premium' => [
+ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/1y7' ),
+ 'title' => 'Yoast SEO Premium',
+ 'description' => sprintf(
+ /* translators: %1$s expands to Yoast SEO */
+ __( 'The premium version of %1$s with more features & support.', 'wordpress-seo' ),
+ 'Yoast SEO'
+ ),
+ 'installed' => false,
+ 'slug' => 'wordpress-seo-premium/wp-seo-premium.php',
+ 'version_sync' => true,
+ 'premium' => true,
+ ],
+
+ 'video-seo-for-wordpress-seo-by-yoast' => [
+ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/1y8' ),
+ 'title' => 'Video SEO',
+ 'description' => __( 'Optimize your videos to show them off in search results and get more clicks!', 'wordpress-seo' ),
+ 'installed' => false,
+ 'slug' => 'wpseo-video/video-seo.php',
+ 'version_sync' => true,
+ 'premium' => true,
+ ],
+
+ 'yoast-news-seo' => [
+ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/1y9' ),
+ 'title' => 'News SEO',
+ 'description' => __( 'Are you in Google News? Increase your traffic from Google News by optimizing for it!', 'wordpress-seo' ),
+ 'installed' => false,
+ 'slug' => 'wpseo-news/wpseo-news.php',
+ 'version_sync' => true,
+ 'premium' => true,
+ ],
+
+ 'local-seo-for-yoast-seo' => [
+ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/1ya' ),
+ 'title' => 'Local SEO',
+ 'description' => __( 'Rank better locally and in Google Maps, without breaking a sweat!', 'wordpress-seo' ),
+ 'installed' => false,
+ 'slug' => 'wordpress-seo-local/local-seo.php',
+ 'version_sync' => true,
+ 'premium' => true,
+ ],
+
+ 'yoast-woocommerce-seo' => [
+ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/1o0' ),
+ 'title' => 'Yoast WooCommerce SEO',
+ 'description' => sprintf(
+ /* translators: %1$s expands to Yoast SEO */
+ __( 'Seamlessly integrate WooCommerce with %1$s and get extra features!', 'wordpress-seo' ),
+ 'Yoast SEO'
+ ),
+ '_dependencies' => [
+ 'WooCommerce' => [
+ 'slug' => 'woocommerce/woocommerce.php', // Kept for backwards compatibility, in case external code uses get_dependencies(). Deprecated in 22.4.
+ 'conditional' => new WooCommerce_Conditional(),
+ ],
+ ],
+ 'installed' => false,
+ 'slug' => 'wpseo-woocommerce/wpseo-woocommerce.php',
+ 'version_sync' => true,
+ 'premium' => true,
+ ],
+ ];
+ }
+
+ /**
+ * Sets certain plugin properties based on WordPress' status.
+ *
+ * @return void
+ */
+ protected function register_yoast_plugins_status() {
+
+ foreach ( $this->plugins as $name => $plugin ) {
+
+ $plugin_slug = $plugin['slug'];
+ $plugin_path = WP_PLUGIN_DIR . '/' . $plugin_slug;
+
+ if ( file_exists( $plugin_path ) ) {
+ $plugin_data = get_plugin_data( $plugin_path, false, false );
+ $this->plugins[ $name ]['installed'] = true;
+ $this->plugins[ $name ]['version'] = $plugin_data['Version'];
+ $this->plugins[ $name ]['active'] = is_plugin_active( $plugin_slug );
+ }
+ }
+ }
+
+ /**
+ * Checks whether or not a plugin is known within the Yoast SEO collection.
+ *
+ * @param string $plugin The plugin to search for.
+ *
+ * @return bool Whether or not the plugin is exists.
+ */
+ protected function plugin_exists( $plugin ) {
+ return isset( $this->plugins[ $plugin ] );
+ }
+
+ /**
+ * Gets all the possibly available plugins.
+ *
+ * @return array Array containing the information about the plugins.
+ */
+ public function get_plugins() {
+ return $this->plugins;
+ }
+
+ /**
+ * Gets a specific plugin. Returns an empty array if it cannot be found.
+ *
+ * @param string $plugin The plugin to search for.
+ *
+ * @return array The plugin properties.
+ */
+ public function get_plugin( $plugin ) {
+ if ( ! $this->plugin_exists( $plugin ) ) {
+ return [];
+ }
+
+ return $this->plugins[ $plugin ];
+ }
+
+ /**
+ * Gets the version of the plugin.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return string The version associated with the plugin.
+ */
+ public function get_version( $plugin ) {
+ if ( ! isset( $plugin['version'] ) ) {
+ return '';
+ }
+
+ return $plugin['version'];
+ }
+
+ /**
+ * Checks if there are dependencies available for the plugin.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return bool Whether or not there is a dependency present.
+ */
+ public function has_dependencies( $plugin ) {
+ return ( isset( $plugin['_dependencies'] ) && ! empty( $plugin['_dependencies'] ) );
+ }
+
+ /**
+ * Gets the dependencies for the plugin.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return array Array containing all the dependencies associated with the plugin.
+ */
+ public function get_dependencies( $plugin ) {
+ if ( ! $this->has_dependencies( $plugin ) ) {
+ return [];
+ }
+
+ return $plugin['_dependencies'];
+ }
+
+ /**
+ * Checks if all dependencies are satisfied.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return bool Whether or not the dependencies are satisfied.
+ */
+ public function dependencies_are_satisfied( $plugin ) {
+ if ( ! $this->has_dependencies( $plugin ) ) {
+ return true;
+ }
+
+ $dependencies = $this->get_dependencies( $plugin );
+ $active_dependencies = array_filter( $dependencies, [ $this, 'is_dependency_active' ] );
+
+ return count( $active_dependencies ) === count( $dependencies );
+ }
+
+ /**
+ * Checks whether or not one of the plugins is properly installed and usable.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return bool Whether or not the plugin is properly installed.
+ */
+ public function is_installed( $plugin ) {
+ if ( empty( $plugin ) ) {
+ return false;
+ }
+
+ return $this->is_available( $plugin );
+ }
+
+ /**
+ * Gets all installed plugins.
+ *
+ * @return array The installed plugins.
+ */
+ public function get_installed_plugins() {
+ $installed = [];
+
+ foreach ( $this->plugins as $plugin_key => $plugin ) {
+ if ( $this->is_installed( $plugin ) ) {
+ $installed[ $plugin_key ] = $plugin;
+ }
+ }
+
+ return $installed;
+ }
+
+ /**
+ * Checks for the availability of the plugin.
+ *
+ * @param array $plugin The information available about the plugin.
+ *
+ * @return bool Whether or not the plugin is available.
+ */
+ public function is_available( $plugin ) {
+ return isset( $plugin['installed'] ) && $plugin['installed'] === true;
+ }
+
+ /**
+ * Checks whether a dependency is active.
+ *
+ * @param array $dependency The information about the dependency to look for.
+ *
+ * @return bool Whether or not the dependency is active.
+ */
+ public function is_dependency_active( $dependency ) {
+ return $dependency['conditional']->is_met();
+ }
+
+ /**
+ * Checks whether a dependency is available.
+ *
+ * @deprecated 22.4
+ * @codeCoverageIgnore
+ *
+ * @param array $dependency The information about the dependency to look for.
+ *
+ * @return bool Whether or not the dependency is available.
+ */
+ public function is_dependency_available( $dependency ) {
+ _deprecated_function( __METHOD__, 'Yoast SEO 22.4' );
+
+ return isset( get_plugins()[ $dependency['slug'] ] );
+ }
+
+ /**
+ * Gets the names of the dependencies.
+ *
+ * @param array $plugin The plugin to get the dependency names from.
+ *
+ * @return array Array containing the names of the associated dependencies.
+ */
+ public function get_dependency_names( $plugin ) {
+ if ( ! $this->has_dependencies( $plugin ) ) {
+ return [];
+ }
+
+ return array_keys( $plugin['_dependencies'] );
+ }
+
+ /**
+ * Gets an array of plugins that have defined dependencies.
+ *
+ * @return array Array of the plugins that have dependencies.
+ */
+ public function get_plugins_with_dependencies() {
+ return array_filter( $this->plugins, [ $this, 'has_dependencies' ] );
+ }
+
+ /**
+ * Determines whether or not a plugin is active.
+ *
+ * @param string $plugin The plugin slug to check.
+ *
+ * @return bool Whether or not the plugin is active.
+ */
+ public function is_active( $plugin ) {
+ return is_plugin_active( $plugin );
+ }
+
+ /**
+ * Determines whether or not a plugin is a Premium product.
+ *
+ * @param array $plugin The plugin to check.
+ *
+ * @return bool Whether or not the plugin is a Premium product.
+ */
+ public function is_premium( $plugin ) {
+ return isset( $plugin['premium'] ) && $plugin['premium'] === true;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php b/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php
new file mode 100644
index 00000000..a90e8acd
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-plugin-conflict.php
@@ -0,0 +1,94 @@
+>
+ */
+ protected $plugins = [
+ // The plugin which are writing OG metadata.
+ 'open_graph' => Conflicting_Plugins::OPEN_GRAPH_PLUGINS,
+ 'xml_sitemaps' => Conflicting_Plugins::XML_SITEMAPS_PLUGINS,
+ 'cloaking' => Conflicting_Plugins::CLOAKING_PLUGINS,
+ 'seo' => Conflicting_Plugins::SEO_PLUGINS,
+ ];
+
+ /**
+ * Overrides instance to set with this class as class.
+ *
+ * @param string $class_name Optional class name.
+ *
+ * @return Yoast_Plugin_Conflict
+ */
+ public static function get_instance( $class_name = self::class ) {
+ return parent::get_instance( $class_name );
+ }
+
+ /**
+ * After activating any plugin, this method will be executed by a hook.
+ *
+ * If the activated plugin is conflicting with ours a notice will be shown.
+ *
+ * @param string|bool $plugin Optional plugin basename to check.
+ *
+ * @return void
+ */
+ public static function hook_check_for_plugin_conflicts( $plugin = false ) {
+ // The instance of the plugin.
+ $instance = self::get_instance();
+
+ // Only add the plugin as an active plugin if $plugin isn't false.
+ if ( $plugin && is_string( $plugin ) ) {
+ $instance->add_active_plugin( $instance->find_plugin_category( $plugin ), $plugin );
+ }
+
+ $plugin_sections = [];
+
+ // Only check for open graph problems when they are enabled.
+ if ( WPSEO_Options::get( 'opengraph' ) ) {
+ /* translators: %1$s expands to Yoast SEO, %2$s: 'Facebook' plugin name of possibly conflicting plugin with regard to creating OpenGraph output. */
+ $plugin_sections['open_graph'] = __( 'Both %1$s and %2$s create Open Graph output, which might make Facebook, X, LinkedIn and other social networks use the wrong texts and images when your pages are being shared.', 'wordpress-seo' )
+ . '
'
+ . ''
+ /* translators: %1$s expands to Yoast SEO. */
+ . sprintf( __( 'Configure %1$s\'s Open Graph settings', 'wordpress-seo' ), 'Yoast SEO' )
+ . '';
+ }
+
+ // Only check for XML conflicts if sitemaps are enabled.
+ if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) {
+ /* translators: %1$s expands to Yoast SEO, %2$s: 'Google XML Sitemaps' plugin name of possibly conflicting plugin with regard to the creation of sitemaps. */
+ $plugin_sections['xml_sitemaps'] = __( 'Both %1$s and %2$s can create XML sitemaps. Having two XML sitemaps is not beneficial for search engines and might slow down your site.', 'wordpress-seo' )
+ . '
'
+ . ''
+ /* translators: %1$s expands to Yoast SEO. */
+ . sprintf( __( 'Toggle %1$s\'s XML Sitemap', 'wordpress-seo' ), 'Yoast SEO' )
+ . '';
+ }
+
+ /* translators: %2$s expands to 'RS Head Cleaner' plugin name of possibly conflicting plugin with regard to differentiating output between search engines and normal users. */
+ $plugin_sections['cloaking'] = __( 'The plugin %2$s changes your site\'s output and in doing that differentiates between search engines and normal users, a process that\'s called cloaking. We highly recommend that you disable it.', 'wordpress-seo' );
+
+ /* translators: %1$s expands to Yoast SEO, %2$s: 'SEO' plugin name of possibly conflicting plugin with regard to the creation of duplicate SEO meta. */
+ $plugin_sections['seo'] = __( 'Both %1$s and %2$s manage the SEO of your site. Running two SEO plugins at the same time is detrimental.', 'wordpress-seo' );
+
+ $instance->check_plugin_conflicts( $plugin_sections );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-premium-popup.php b/wp-content/plugins/wordpress-seo/admin/class-premium-popup.php
new file mode 100644
index 00000000..00887694
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-premium-popup.php
@@ -0,0 +1,105 @@
+identifier = $identifier;
+ $this->heading_level = $heading_level;
+ $this->title = $title;
+ $this->content = $content;
+ $this->url = $url;
+ }
+
+ /**
+ * Returns the premium popup as an HTML string.
+ *
+ * @param bool $popup Show this message as a popup show it straight away.
+ *
+ * @return string
+ */
+ public function get_premium_message( $popup = true ) {
+ // Don't show in Premium.
+ if ( defined( 'WPSEO_PREMIUM_FILE' ) ) {
+ return '';
+ }
+
+ $assets_uri = trailingslashit( plugin_dir_url( WPSEO_FILE ) );
+
+ /* translators: %s expands to Yoast SEO Premium */
+ $cta_text = esc_html( sprintf( __( 'Get %s', 'wordpress-seo' ), 'Yoast SEO Premium' ) );
+ /* translators: Hidden accessibility text. */
+ $new_tab_message = '' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . '';
+ $caret_icon = '';
+ $classes = '';
+ if ( $popup ) {
+ $classes = ' hidden';
+ }
+ $micro_copy = __( '1 year free support and updates included!', 'wordpress-seo' );
+
+ $popup = <<
+
+ <{$this->heading_level} id="wpseo-contact-support-popup-title" class="wpseo-premium-popup-title">{$this->title}{$this->heading_level}>
+ {$this->content}
+
+ {$cta_text} {$new_tab_message} {$caret_icon}
+
+ {$micro_copy}
+
+EO_POPUP;
+
+ return $popup;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-premium-upsell-admin-block.php b/wp-content/plugins/wordpress-seo/admin/class-premium-upsell-admin-block.php
new file mode 100644
index 00000000..143d08be
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-premium-upsell-admin-block.php
@@ -0,0 +1,165 @@
+hook = $hook;
+ }
+
+ /**
+ * Registers WordPress hooks.
+ *
+ * @return void
+ */
+ public function register_hooks() {
+ add_action( $this->hook, [ $this, 'render' ] );
+ }
+
+ /**
+ * Renders the upsell block.
+ *
+ * @return void
+ */
+ public function render() {
+ $url = WPSEO_Shortlinker::get( 'https://yoa.st/17h' );
+
+ $arguments = [
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$sAI%2$s: Better SEO titles and meta descriptions, faster.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$sMultiple keywords%2$s: Rank higher for more searches.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$sSuper fast%2$s internal linking suggestions.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$sNo more broken links%2$s: Automatic redirect manager.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$sAppealing social previews%2$s people actually want to click on.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ sprintf(
+ /* translators: %1$s expands to a strong opening tag, %2$s expands to a strong closing tag. */
+ esc_html__( '%1$s24/7 support%2$s: Also on evenings and weekends.', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ '' . esc_html__( 'No ads!', 'wordpress-seo' ) . '',
+ ];
+
+ $arguments_html = implode( '', array_map( [ $this, 'get_argument_html' ], $arguments ) );
+
+ $class = $this->get_html_class();
+
+ /* translators: %s expands to Yoast SEO Premium */
+ $button_text = YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2023-promotion' ) ? esc_html__( 'Claim your 30% off now!', 'wordpress-seo' ) : sprintf( esc_html__( 'Explore %s now!', 'wordpress-seo' ), 'Yoast SEO Premium' );
+ /* translators: Hidden accessibility text. */
+ $button_text .= '' . esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' ) . ''
+ . '';
+
+ $upgrade_button = sprintf(
+ '%3$s',
+ esc_attr( 'wpseo-' . $this->identifier . '-popup-button' ),
+ esc_url( $url ),
+ $button_text
+ );
+
+ echo '
' . PHP_EOL . PHP_EOL;
+ }
+
+ /**
+ * Creates a toggle switch to define whether an indexable should be indexed or not.
+ *
+ * @param string $variable The variable within the option to create the radio buttons for.
+ * @param string $label The visual label for the radio buttons group, used as the fieldset legend.
+ * @param string $help Inline Help that will be printed out before the visible toggles text.
+ * @param array $attr Extra attributes to add to the index switch.
+ *
+ * @return void
+ */
+ public function index_switch( $variable, $label, $help = '', $attr = [] ) {
+ $defaults = [
+ 'disabled' => false,
+ ];
+ $attr = wp_parse_args( $attr, $defaults );
+
+ $index_switch_values = [
+ 'off' => __( 'On', 'wordpress-seo' ),
+ 'on' => __( 'Off', 'wordpress-seo' ),
+ ];
+
+ $is_disabled = ( isset( $attr['disabled'] ) && $attr['disabled'] );
+
+ $this->toggle_switch(
+ $variable,
+ $index_switch_values,
+ sprintf(
+ /* translators: %s expands to an indexable object's name, like a post type or taxonomy */
+ esc_html__( 'Show %s in search results?', 'wordpress-seo' ),
+ $label
+ ),
+ $help,
+ [ 'disabled' => $is_disabled ]
+ );
+ }
+
+ /**
+ * Creates a toggle switch to show hide certain options.
+ *
+ * @param string $variable The variable within the option to create the radio buttons for.
+ * @param string $label The visual label for the radio buttons group, used as the fieldset legend.
+ * @param bool $inverse_keys Whether or not the option keys need to be inverted to support older functions.
+ * @param string $help Inline Help that will be printed out before the visible toggles text.
+ * @param array $attr Extra attributes to add to the show-hide switch.
+ *
+ * @return void
+ */
+ public function show_hide_switch( $variable, $label, $inverse_keys = false, $help = '', $attr = [] ) {
+ $defaults = [
+ 'disabled' => false,
+ ];
+ $attr = wp_parse_args( $attr, $defaults );
+
+ $on_key = ( $inverse_keys ) ? 'off' : 'on';
+ $off_key = ( $inverse_keys ) ? 'on' : 'off';
+
+ $show_hide_switch = [
+ $on_key => __( 'On', 'wordpress-seo' ),
+ $off_key => __( 'Off', 'wordpress-seo' ),
+ ];
+
+ $is_disabled = ( isset( $attr['disabled'] ) && $attr['disabled'] );
+
+ $this->toggle_switch(
+ $variable,
+ $show_hide_switch,
+ $label,
+ $help,
+ [ 'disabled' => $is_disabled ]
+ );
+ }
+
+ /**
+ * Retrieves the value for the form field.
+ *
+ * @param string $field_name The field name to retrieve the value for.
+ * @param string|null $default_value The default value, when field has no value.
+ *
+ * @return mixed|null The retrieved value.
+ */
+ protected function get_field_value( $field_name, $default_value = null ) {
+ // On multisite subsites, the Usage tracking feature should always be set to Off.
+ if ( $this->is_tracking_on_subsite( $field_name ) ) {
+ return false;
+ }
+
+ return WPSEO_Options::get( $field_name, $default_value );
+ }
+
+ /**
+ * Checks whether a given control should be disabled.
+ *
+ * @param string $variable The variable within the option to check whether its control should be disabled.
+ *
+ * @return bool True if control should be disabled, false otherwise.
+ */
+ protected function is_control_disabled( $variable ) {
+ if ( $this->option_instance === null ) {
+ return false;
+ }
+
+ // Disable the Usage tracking feature for multisite subsites.
+ if ( $this->is_tracking_on_subsite( $variable ) ) {
+ return true;
+ }
+
+ return $this->option_instance->is_disabled( $variable );
+ }
+
+ /**
+ * Gets the explanation note to print if a given control is disabled.
+ *
+ * @param string $variable The variable within the option to print a disabled note for.
+ * @param string $custom_note An optional custom note to print instead.
+ *
+ * @return string Explanation note HTML string, or empty string if no note necessary.
+ */
+ protected function get_disabled_note( $variable, $custom_note = '' ) {
+ if ( $custom_note === '' && ! $this->is_control_disabled( $variable ) ) {
+ return '';
+ }
+ $disabled_message = esc_html__( 'This feature has been disabled by the network admin.', 'wordpress-seo' );
+
+ // The explanation to show when disabling the Usage tracking feature for multisite subsites.
+ if ( $this->is_tracking_on_subsite( $variable ) ) {
+ $disabled_message = esc_html__( 'This feature has been disabled since subsites never send tracking data.', 'wordpress-seo' );
+ }
+
+ if ( $custom_note ) {
+ $disabled_message = esc_html( $custom_note );
+ }
+
+ return '
' . $disabled_message . '
';
+ }
+
+ /**
+ * Determines whether we are dealing with the Usage tracking feature on a multisite subsite.
+ * This feature requires specific behavior for the toggle switch.
+ *
+ * @param string $feature_setting The feature setting.
+ *
+ * @return bool True if we are dealing with the Usage tracking feature on a multisite subsite.
+ */
+ protected function is_tracking_on_subsite( $feature_setting ) {
+ return ( $feature_setting === 'tracking' && ! is_network_admin() && ! is_main_site() );
+ }
+
+ /**
+ * Returns the disabled attribute HTML.
+ *
+ * @param string $variable The variable within the option of the related form element.
+ * @param array $attr Extra attributes added to the form element.
+ *
+ * @return string The disabled attribute HTML.
+ */
+ protected function get_disabled_attribute( $variable, $attr ) {
+ if ( $this->is_control_disabled( $variable ) || ( isset( $attr['disabled'] ) && $attr['disabled'] ) ) {
+ return ' disabled';
+ }
+
+ return '';
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-input-validation.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-input-validation.php
new file mode 100644
index 00000000..573840e6
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-input-validation.php
@@ -0,0 +1,328 @@
+ 0 ) {
+ return sprintf(
+ /* translators: %1$s: amount of errors, %2$s: the admin page title */
+ _n( 'The form contains %1$s error. %2$s', 'The form contains %1$s errors. %2$s', $error_count, 'wordpress-seo' ),
+ number_format_i18n( $error_count ),
+ $admin_title
+ );
+ }
+
+ return $admin_title;
+ }
+
+ /**
+ * Checks whether a specific form input field was submitted with an invalid value.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Must be the same slug-name used for the field variable and for `add_settings_error()`.
+ *
+ * @return bool Whether or not the submitted input field contained an invalid value.
+ */
+ public static function yoast_form_control_has_error( $error_code ) {
+ $errors = get_settings_errors();
+
+ foreach ( $errors as $error ) {
+ if ( $error['code'] === $error_code ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Sets the error descriptions.
+ *
+ * @since 12.1
+ *
+ * @param array $descriptions An associative array of error descriptions.
+ * For each entry, the key must be the setting variable.
+ *
+ * @return void
+ */
+ public static function set_error_descriptions( $descriptions = [] ) {
+ $defaults = [
+ 'baiduverify' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Baidu verification codes can only contain letters, numbers, hyphens, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'baiduverify' )
+ ),
+ 'facebook_site' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the Facebook Page URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'facebook_site' )
+ ),
+ 'googleverify' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Google verification codes can only contain letters, numbers, hyphens, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'googleverify' )
+ ),
+ 'instagram_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the Instagram URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'instagram_url' )
+ ),
+ 'linkedin_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the LinkedIn URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'linkedin_url' )
+ ),
+ 'msverify' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Bing confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'msverify' )
+ ),
+ 'myspace_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the MySpace URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'myspace_url' )
+ ),
+ 'pinterest_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the Pinterest URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'pinterest_url' )
+ ),
+ 'pinterestverify' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Pinterest confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'pinterestverify' )
+ ),
+ 'twitter_site' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Twitter usernames can only contain letters, numbers, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'twitter_site' )
+ ),
+ 'wikipedia_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the Wikipedia URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'wikipedia_url' )
+ ),
+ 'yandexverify' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Yandex confirmation codes can only contain letters from A to F, numbers, hyphens, and underscores. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'yandexverify' )
+ ),
+ 'youtube_url' => sprintf(
+ /* translators: %s: additional message with the submitted invalid value */
+ esc_html__( 'Please check the format of the YouTube URL you entered. %s', 'wordpress-seo' ),
+ self::get_dirty_value_message( 'youtube_url' )
+ ),
+ ];
+
+ $descriptions = wp_parse_args( $descriptions, $defaults );
+
+ self::$error_descriptions = $descriptions;
+ }
+
+ /**
+ * Gets all the error descriptions.
+ *
+ * @since 12.1
+ *
+ * @return array An associative array of error descriptions.
+ */
+ public static function get_error_descriptions() {
+ return self::$error_descriptions;
+ }
+
+ /**
+ * Gets a specific error description.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string|null The error description.
+ */
+ public static function get_error_description( $error_code ) {
+ if ( ! isset( self::$error_descriptions[ $error_code ] ) ) {
+ return null;
+ }
+
+ return self::$error_descriptions[ $error_code ];
+ }
+
+ /**
+ * Gets the aria-invalid HTML attribute based on the submitted invalid value.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string The aria-invalid HTML attribute or empty string.
+ */
+ public static function get_the_aria_invalid_attribute( $error_code ) {
+ if ( self::yoast_form_control_has_error( $error_code ) ) {
+ return ' aria-invalid="true"';
+ }
+
+ return '';
+ }
+
+ /**
+ * Gets the aria-describedby HTML attribute based on the submitted invalid value.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string The aria-describedby HTML attribute or empty string.
+ */
+ public static function get_the_aria_describedby_attribute( $error_code ) {
+ if ( self::yoast_form_control_has_error( $error_code ) && self::get_error_description( $error_code ) ) {
+ return ' aria-describedby="' . esc_attr( $error_code ) . '-error-description"';
+ }
+
+ return '';
+ }
+
+ /**
+ * Gets the error description wrapped in a HTML paragraph.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string The error description HTML or empty string.
+ */
+ public static function get_the_error_description( $error_code ) {
+ $error_description = self::get_error_description( $error_code );
+
+ if ( self::yoast_form_control_has_error( $error_code ) && $error_description ) {
+ return '
' . $error_description . '
';
+ }
+
+ return '';
+ }
+
+ /**
+ * Adds the submitted invalid value to the WordPress `$wp_settings_errors` global.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ * @param string $dirty_value The submitted invalid value.
+ *
+ * @return void
+ */
+ public static function add_dirty_value_to_settings_errors( $error_code, $dirty_value ) {
+ global $wp_settings_errors;
+
+ if ( ! is_array( $wp_settings_errors ) ) {
+ return;
+ }
+
+ foreach ( $wp_settings_errors as $index => $error ) {
+ if ( $error['code'] === $error_code ) {
+ // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- This is a deliberate action.
+ $wp_settings_errors[ $index ]['yoast_dirty_value'] = $dirty_value;
+ }
+ }
+ }
+
+ /**
+ * Gets an invalid submitted value.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string The submitted invalid input field value.
+ */
+ public static function get_dirty_value( $error_code ) {
+ $errors = get_settings_errors();
+
+ foreach ( $errors as $error ) {
+ if ( $error['code'] === $error_code && isset( $error['yoast_dirty_value'] ) ) {
+ return $error['yoast_dirty_value'];
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * Gets a specific invalid value message.
+ *
+ * @since 12.1
+ *
+ * @param string $error_code Code of the error set via `add_settings_error()`, normally the variable name.
+ *
+ * @return string The error invalid value message or empty string.
+ */
+ public static function get_dirty_value_message( $error_code ) {
+ $dirty_value = self::get_dirty_value( $error_code );
+
+ if ( $dirty_value ) {
+ return sprintf(
+ /* translators: %s: form value as submitted. */
+ esc_html__( 'The submitted value was: %s', 'wordpress-seo' ),
+ esc_html( $dirty_value )
+ );
+ }
+
+ return '';
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-network-admin.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-network-admin.php
new file mode 100644
index 00000000..01f8f2f3
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-network-admin.php
@@ -0,0 +1,334 @@
+ $site_label pairs.
+ */
+ public function get_site_choices( $include_empty = false, $show_title = false ) {
+ $choices = [];
+
+ if ( $include_empty ) {
+ $choices['-'] = __( 'None', 'wordpress-seo' );
+ }
+
+ $criteria = [
+ 'deleted' => 0,
+ 'network_id' => get_current_network_id(),
+ ];
+ $sites = get_sites( $criteria );
+
+ foreach ( $sites as $site ) {
+ $site_name = $site->domain . $site->path;
+ if ( $show_title ) {
+ $site_name = $site->blogname . ' (' . $site->domain . $site->path . ')';
+ }
+ $choices[ $site->blog_id ] = $site->blog_id . ': ' . $site_name;
+
+ $site_states = $this->get_site_states( $site );
+ if ( ! empty( $site_states ) ) {
+ $choices[ $site->blog_id ] .= ' [' . implode( ', ', $site_states ) . ']';
+ }
+ }
+
+ return $choices;
+ }
+
+ /**
+ * Gets the states of a site.
+ *
+ * @param WP_Site $site Site object.
+ *
+ * @return array Array of $state_slug => $state_label pairs.
+ */
+ public function get_site_states( $site ) {
+ $available_states = [
+ 'public' => __( 'public', 'wordpress-seo' ),
+ 'archived' => __( 'archived', 'wordpress-seo' ),
+ 'mature' => __( 'mature', 'wordpress-seo' ),
+ 'spam' => __( 'spam', 'wordpress-seo' ),
+ 'deleted' => __( 'deleted', 'wordpress-seo' ),
+ ];
+
+ $site_states = [];
+ foreach ( $available_states as $state_slug => $state_label ) {
+ if ( $site->$state_slug === '1' ) {
+ $site_states[ $state_slug ] = $state_label;
+ }
+ }
+
+ return $site_states;
+ }
+
+ /**
+ * Handles a request to update plugin network options.
+ *
+ * This method works similar to how option updates are handled in `wp-admin/options.php` and
+ * `wp-admin/network/settings.php`.
+ *
+ * @return void
+ */
+ public function handle_update_options_request() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: Nonce verification will happen in verify_request below.
+ if ( ! isset( $_POST['network_option_group'] ) || ! is_string( $_POST['network_option_group'] ) ) {
+ return;
+ }
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: Nonce verification will happen in verify_request below.
+ $option_group = sanitize_text_field( wp_unslash( $_POST['network_option_group'] ) );
+
+ if ( empty( $option_group ) ) {
+ return;
+ }
+
+ $this->verify_request( "{$option_group}-network-options" );
+
+ $whitelist_options = Yoast_Network_Settings_API::get()->get_whitelist_options( $option_group );
+
+ if ( empty( $whitelist_options ) ) {
+ add_settings_error( $option_group, 'settings_updated', __( 'You are not allowed to modify unregistered network settings.', 'wordpress-seo' ), 'error' );
+
+ $this->terminate_request();
+ return;
+ }
+
+ // phpcs:disable WordPress.Security.NonceVerification -- Nonce verified via `verify_request()` above.
+ foreach ( $whitelist_options as $option_name ) {
+ $value = null;
+ if ( isset( $_POST[ $option_name ] ) ) {
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: Adding sanitize_text_field around this will break the saving of settings because it expects a string: https://github.com/Yoast/wordpress-seo/issues/12440.
+ $value = wp_unslash( $_POST[ $option_name ] );
+ }
+
+ WPSEO_Options::update_site_option( $option_name, $value );
+ }
+ // phpcs:enable WordPress.Security.NonceVerification
+
+ $settings_errors = get_settings_errors();
+ if ( empty( $settings_errors ) ) {
+ add_settings_error( $option_group, 'settings_updated', __( 'Settings Updated.', 'wordpress-seo' ), 'updated' );
+ }
+
+ $this->terminate_request();
+ }
+
+ /**
+ * Handles a request to restore a site's default settings.
+ *
+ * @return void
+ */
+ public function handle_restore_site_request() {
+ $this->verify_request( 'wpseo-network-restore', 'restore_site_nonce' );
+
+ $option_group = 'wpseo_ms';
+
+ // phpcs:ignore WordPress.Security.NonceVerification -- Nonce verified via `verify_request()` above.
+ $site_id = ! empty( $_POST[ $option_group ]['site_id'] ) ? (int) $_POST[ $option_group ]['site_id'] : 0;
+ if ( ! $site_id ) {
+ add_settings_error( $option_group, 'settings_updated', __( 'No site has been selected to restore.', 'wordpress-seo' ), 'error' );
+
+ $this->terminate_request();
+ return;
+ }
+
+ $site = get_site( $site_id );
+ if ( ! $site ) {
+ /* translators: %s expands to the ID of a site within a multisite network. */
+ add_settings_error( $option_group, 'settings_updated', sprintf( __( 'Site with ID %d not found.', 'wordpress-seo' ), $site_id ), 'error' );
+ }
+ else {
+ WPSEO_Options::reset_ms_blog( $site_id );
+
+ /* translators: %s expands to the name of a site within a multisite network. */
+ add_settings_error( $option_group, 'settings_updated', sprintf( __( '%s restored to default SEO settings.', 'wordpress-seo' ), esc_html( $site->blogname ) ), 'updated' );
+ }
+
+ $this->terminate_request();
+ }
+
+ /**
+ * Outputs nonce, action and option group fields for a network settings page in the plugin.
+ *
+ * @param string $option_group Option group name for the current page.
+ *
+ * @return void
+ */
+ public function settings_fields( $option_group ) {
+ ?>
+
+
+ enqueue_script( 'network-admin' );
+
+ $translations = [
+ /* translators: %s: success message */
+ 'success_prefix' => __( 'Success: %s', 'wordpress-seo' ),
+ /* translators: %s: error message */
+ 'error_prefix' => __( 'Error: %s', 'wordpress-seo' ),
+ ];
+ $asset_manager->localize_script(
+ 'network-admin',
+ 'wpseoNetworkAdminGlobalL10n',
+ $translations
+ );
+ }
+
+ /**
+ * Hooks in the necessary actions and filters.
+ *
+ * @return void
+ */
+ public function register_hooks() {
+
+ if ( ! $this->meets_requirements() ) {
+ return;
+ }
+
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
+
+ add_action( 'admin_action_' . self::UPDATE_OPTIONS_ACTION, [ $this, 'handle_update_options_request' ] );
+ add_action( 'admin_action_' . self::RESTORE_SITE_ACTION, [ $this, 'handle_restore_site_request' ] );
+ }
+
+ /**
+ * Hooks in the necessary AJAX actions.
+ *
+ * @return void
+ */
+ public function register_ajax_hooks() {
+ add_action( 'wp_ajax_' . self::UPDATE_OPTIONS_ACTION, [ $this, 'handle_update_options_request' ] );
+ add_action( 'wp_ajax_' . self::RESTORE_SITE_ACTION, [ $this, 'handle_restore_site_request' ] );
+ }
+
+ /**
+ * Checks whether the requirements to use this class are met.
+ *
+ * @return bool True if requirements are met, false otherwise.
+ */
+ public function meets_requirements() {
+ return is_multisite() && is_network_admin();
+ }
+
+ /**
+ * Verifies that the current request is valid.
+ *
+ * @param string $action Nonce action.
+ * @param string $query_arg Optional. Nonce query argument. Default '_wpnonce'.
+ *
+ * @return void
+ */
+ public function verify_request( $action, $query_arg = '_wpnonce' ) {
+ $has_access = current_user_can( 'wpseo_manage_network_options' );
+
+ if ( wp_doing_ajax() ) {
+ check_ajax_referer( $action, $query_arg );
+
+ if ( ! $has_access ) {
+ wp_die( -1, 403 );
+ }
+ return;
+ }
+
+ check_admin_referer( $action, $query_arg );
+
+ if ( ! $has_access ) {
+ wp_die( esc_html__( 'You are not allowed to perform this action.', 'wordpress-seo' ) );
+ }
+ }
+
+ /**
+ * Terminates the current request by either redirecting back or sending an AJAX response.
+ *
+ * @return void
+ */
+ public function terminate_request() {
+ if ( wp_doing_ajax() ) {
+ $settings_errors = get_settings_errors();
+
+ if ( ! empty( $settings_errors ) && $settings_errors[0]['type'] === 'updated' ) {
+ wp_send_json_success( $settings_errors, 200 );
+ }
+
+ wp_send_json_error( $settings_errors, 400 );
+ }
+
+ $this->persist_settings_errors();
+ $this->redirect_back( [ 'settings-updated' => 'true' ] );
+ }
+
+ /**
+ * Persists settings errors.
+ *
+ * Settings errors are stored in a transient for 30 seconds so that this transient
+ * can be retrieved on the next page load.
+ *
+ * @return void
+ */
+ protected function persist_settings_errors() {
+ /*
+ * A regular transient is used here, since it is automatically cleared right after the redirect.
+ * A network transient would be cleaner, but would require a lot of copied code from core for
+ * just a minor adjustment when displaying settings errors.
+ */
+ set_transient( 'settings_errors', get_settings_errors(), 30 );
+ }
+
+ /**
+ * Redirects back to the referer URL, with optional query arguments.
+ *
+ * @param array $query_args Optional. Query arguments to add to the redirect URL. Default none.
+ *
+ * @return void
+ */
+ protected function redirect_back( $query_args = [] ) {
+ $sendback = wp_get_referer();
+
+ if ( ! empty( $query_args ) ) {
+ $sendback = add_query_arg( $query_args, $sendback );
+ }
+
+ wp_safe_redirect( $sendback );
+ exit;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-network-settings-api.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-network-settings-api.php
new file mode 100644
index 00000000..990f78ad
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-network-settings-api.php
@@ -0,0 +1,164 @@
+ $option_group,
+ 'sanitize_callback' => null,
+ ];
+ $args = wp_parse_args( $args, $defaults );
+
+ if ( ! isset( $this->whitelist_options[ $option_group ] ) ) {
+ $this->whitelist_options[ $option_group ] = [];
+ }
+
+ $this->whitelist_options[ $option_group ][] = $option_name;
+
+ if ( ! empty( $args['sanitize_callback'] ) ) {
+ add_filter( "sanitize_option_{$option_name}", [ $this, 'filter_sanitize_option' ], 10, 2 );
+ }
+
+ if ( array_key_exists( 'default', $args ) ) {
+ add_filter( "default_site_option_{$option_name}", [ $this, 'filter_default_option' ], 10, 2 );
+ }
+
+ $this->registered_settings[ $option_name ] = $args;
+ }
+
+ /**
+ * Gets the registered settings and their data.
+ *
+ * @return array Array of $option_name => $data pairs.
+ */
+ public function get_registered_settings() {
+ return $this->registered_settings;
+ }
+
+ /**
+ * Gets the whitelisted options for a given option group.
+ *
+ * @param string $option_group Option group.
+ *
+ * @return array List of option names, or empty array if unknown option group.
+ */
+ public function get_whitelist_options( $option_group ) {
+ if ( ! isset( $this->whitelist_options[ $option_group ] ) ) {
+ return [];
+ }
+
+ return $this->whitelist_options[ $option_group ];
+ }
+
+ /**
+ * Filters sanitization for a network option value.
+ *
+ * This method is added as a filter to `sanitize_option_{$option}` for network options that are
+ * registered with a sanitize callback.
+ *
+ * @param string $value The sanitized option value.
+ * @param string $option The option name.
+ *
+ * @return string The filtered sanitized option value.
+ */
+ public function filter_sanitize_option( $value, $option ) {
+
+ if ( empty( $this->registered_settings[ $option ] ) ) {
+ return $value;
+ }
+
+ return call_user_func( $this->registered_settings[ $option ]['sanitize_callback'], $value );
+ }
+
+ /**
+ * Filters the default value for a network option.
+ *
+ * This function is added as a filter to `default_site_option_{$option}` for network options that
+ * are registered with a default.
+ *
+ * @param mixed $default_value Existing default value to return.
+ * @param string $option The option name.
+ *
+ * @return mixed The filtered default value.
+ */
+ public function filter_default_option( $default_value, $option ) {
+
+ // If a default value was manually passed to the function, allow it to override.
+ if ( $default_value !== false ) {
+ return $default_value;
+ }
+
+ if ( empty( $this->registered_settings[ $option ] ) ) {
+ return $default_value;
+ }
+
+ return $this->registered_settings[ $option ]['default'];
+ }
+
+ /**
+ * Checks whether the requirements to use this class are met.
+ *
+ * @return bool True if requirements are met, false otherwise.
+ */
+ public function meets_requirements() {
+ return is_multisite();
+ }
+
+ /**
+ * Gets the singleton instance of this class.
+ *
+ * @return Yoast_Network_Settings_API The singleton instance.
+ */
+ public static function get() {
+
+ if ( self::$instance === null ) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php
new file mode 100644
index 00000000..fcbc734d
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-notification-center.php
@@ -0,0 +1,954 @@
+get_notification_by_id( $notification_id );
+ if ( ( $notification instanceof Yoast_Notification ) === false ) {
+
+ // Permit legacy.
+ $options = [
+ 'id' => $notification_id,
+ 'dismissal_key' => $notification_id,
+ ];
+ $notification = new Yoast_Notification( '', $options );
+ }
+
+ if ( self::maybe_dismiss_notification( $notification ) ) {
+ die( '1' );
+ }
+
+ die( '-1' );
+ }
+
+ /**
+ * Check if the user has dismissed a notification.
+ *
+ * @param Yoast_Notification $notification The notification to check for dismissal.
+ * @param int|null $user_id User ID to check on.
+ *
+ * @return bool
+ */
+ public static function is_notification_dismissed( Yoast_Notification $notification, $user_id = null ) {
+
+ $user_id = self::get_user_id( $user_id );
+ $dismissal_key = $notification->get_dismissal_key();
+
+ // This checks both the site-specific user option and the meta value.
+ $current_value = get_user_option( $dismissal_key, $user_id );
+
+ // Migrate old user meta to user option on-the-fly.
+ if ( ! empty( $current_value )
+ && metadata_exists( 'user', $user_id, $dismissal_key )
+ && update_user_option( $user_id, $dismissal_key, $current_value ) ) {
+ delete_user_meta( $user_id, $dismissal_key );
+ }
+
+ return ! empty( $current_value );
+ }
+
+ /**
+ * Checks if the notification is being dismissed.
+ *
+ * @param Yoast_Notification $notification Notification to check dismissal of.
+ * @param string $meta_value Value to set the meta value to if dismissed.
+ *
+ * @return bool True if dismissed.
+ */
+ public static function maybe_dismiss_notification( Yoast_Notification $notification, $meta_value = 'seen' ) {
+
+ // Only persistent notifications are dismissible.
+ if ( ! $notification->is_persistent() ) {
+ return false;
+ }
+
+ // If notification is already dismissed, we're done.
+ if ( self::is_notification_dismissed( $notification ) ) {
+ return true;
+ }
+
+ $dismissal_key = $notification->get_dismissal_key();
+ $notification_id = $notification->get_id();
+
+ $is_dismissing = ( $dismissal_key === self::get_user_input( 'notification' ) );
+ if ( ! $is_dismissing ) {
+ $is_dismissing = ( $notification_id === self::get_user_input( 'notification' ) );
+ }
+
+ // Fallback to ?dismissal_key=1&nonce=bla when JavaScript fails.
+ if ( ! $is_dismissing ) {
+ $is_dismissing = ( self::get_user_input( $dismissal_key ) === '1' );
+ }
+
+ if ( ! $is_dismissing ) {
+ return false;
+ }
+
+ $user_nonce = self::get_user_input( 'nonce' );
+ if ( wp_verify_nonce( $user_nonce, $notification_id ) === false ) {
+ return false;
+ }
+
+ return self::dismiss_notification( $notification, $meta_value );
+ }
+
+ /**
+ * Dismisses a notification.
+ *
+ * @param Yoast_Notification $notification Notification to dismiss.
+ * @param string $meta_value Value to save in the dismissal.
+ *
+ * @return bool True if dismissed, false otherwise.
+ */
+ public static function dismiss_notification( Yoast_Notification $notification, $meta_value = 'seen' ) {
+ // Dismiss notification.
+ return update_user_option( get_current_user_id(), $notification->get_dismissal_key(), $meta_value ) !== false;
+ }
+
+ /**
+ * Restores a notification.
+ *
+ * @param Yoast_Notification $notification Notification to restore.
+ *
+ * @return bool True if restored, false otherwise.
+ */
+ public static function restore_notification( Yoast_Notification $notification ) {
+
+ $user_id = get_current_user_id();
+ $dismissal_key = $notification->get_dismissal_key();
+
+ // Restore notification.
+ $restored = delete_user_option( $user_id, $dismissal_key );
+
+ // Delete unprefixed user meta too for backward-compatibility.
+ if ( metadata_exists( 'user', $user_id, $dismissal_key ) ) {
+ $restored = delete_user_meta( $user_id, $dismissal_key ) && $restored;
+ }
+
+ return $restored;
+ }
+
+ /**
+ * Clear dismissal information for the specified Notification.
+ *
+ * When a cause is resolved, the next time it is present we want to show
+ * the message again.
+ *
+ * @param string|Yoast_Notification $notification Notification to clear the dismissal of.
+ *
+ * @return bool
+ */
+ public function clear_dismissal( $notification ) {
+
+ global $wpdb;
+
+ if ( $notification instanceof Yoast_Notification ) {
+ $dismissal_key = $notification->get_dismissal_key();
+ }
+
+ if ( is_string( $notification ) ) {
+ $dismissal_key = $notification;
+ }
+
+ if ( empty( $dismissal_key ) ) {
+ return false;
+ }
+
+ // Remove notification dismissal for all users.
+ $deleted = delete_metadata( 'user', 0, $wpdb->get_blog_prefix() . $dismissal_key, '', true );
+
+ // Delete unprefixed user meta too for backward-compatibility.
+ $deleted = delete_metadata( 'user', 0, $dismissal_key, '', true ) || $deleted;
+
+ return $deleted;
+ }
+
+ /**
+ * Retrieves notifications from the storage and merges in previous notification changes.
+ *
+ * The current user in WordPress is not loaded shortly before the 'init' hook, but the plugin
+ * sometimes needs to add or remove notifications before that. In such cases, the transactions
+ * are not actually executed, but added to a queue. That queue is then handled in this method,
+ * after notifications for the current user have been set up.
+ *
+ * @return void
+ */
+ public function setup_current_notifications() {
+ $this->retrieve_notifications_from_storage( get_current_user_id() );
+
+ foreach ( $this->queued_transactions as $transaction ) {
+ list( $callback, $args ) = $transaction;
+
+ call_user_func_array( $callback, $args );
+ }
+
+ $this->queued_transactions = [];
+ }
+
+ /**
+ * Add notification to the cookie.
+ *
+ * @param Yoast_Notification $notification Notification object instance.
+ *
+ * @return void
+ */
+ public function add_notification( Yoast_Notification $notification ) {
+
+ $callback = [ $this, __FUNCTION__ ];
+ $args = func_get_args();
+ if ( $this->queue_transaction( $callback, $args ) ) {
+ return;
+ }
+
+ // Don't add if the user can't see it.
+ if ( ! $notification->display_for_current_user() ) {
+ return;
+ }
+
+ $notification_id = $notification->get_id();
+ $user_id = $notification->get_user_id();
+
+ // Empty notifications are always added.
+ if ( $notification_id !== '' ) {
+
+ // If notification ID exists in notifications, don't add again.
+ $present_notification = $this->get_notification_by_id( $notification_id, $user_id );
+ if ( ! is_null( $present_notification ) ) {
+ $this->remove_notification( $present_notification, false );
+ }
+
+ if ( is_null( $present_notification ) ) {
+ $this->new[] = $notification_id;
+ }
+ }
+
+ // Add to list.
+ $this->notifications[ $user_id ][] = $notification;
+
+ $this->notifications_need_storage = true;
+ }
+
+ /**
+ * Get the notification by ID and user ID.
+ *
+ * @param string $notification_id The ID of the notification to search for.
+ * @param int|null $user_id The ID of the user.
+ *
+ * @return Yoast_Notification|null
+ */
+ public function get_notification_by_id( $notification_id, $user_id = null ) {
+ $user_id = self::get_user_id( $user_id );
+
+ $notifications = $this->get_notifications_for_user( $user_id );
+
+ foreach ( $notifications as $notification ) {
+ if ( $notification_id === $notification->get_id() ) {
+ return $notification;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Display the notifications.
+ *
+ * @param bool $echo_as_json True when notifications should be printed directly.
+ *
+ * @return void
+ */
+ public function display_notifications( $echo_as_json = false ) {
+
+ // Never display notifications for network admin.
+ if ( is_network_admin() ) {
+ return;
+ }
+
+ $sorted_notifications = $this->get_sorted_notifications();
+ $notifications = array_filter( $sorted_notifications, [ $this, 'is_notification_persistent' ] );
+
+ if ( empty( $notifications ) ) {
+ return;
+ }
+
+ array_walk( $notifications, [ $this, 'remove_notification' ] );
+
+ $notifications = array_unique( $notifications );
+ if ( $echo_as_json ) {
+ $notification_json = [];
+
+ foreach ( $notifications as $notification ) {
+ $notification_json[] = $notification->render();
+ }
+
+ // phpcs:ignore WordPress.Security.EscapeOutput -- Reason: WPSEO_Utils::format_json_encode is safe.
+ echo WPSEO_Utils::format_json_encode( $notification_json );
+
+ return;
+ }
+
+ foreach ( $notifications as $notification ) {
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Temporarily disabled, see: https://github.com/Yoast/wordpress-seo-premium/issues/2510 and https://github.com/Yoast/wordpress-seo-premium/issues/2511.
+ echo $notification;
+ }
+ }
+
+ /**
+ * Remove notification after it has been displayed.
+ *
+ * @param Yoast_Notification $notification Notification to remove.
+ * @param bool $resolve Resolve as fixed.
+ *
+ * @return void
+ */
+ public function remove_notification( Yoast_Notification $notification, $resolve = true ) {
+
+ $callback = [ $this, __FUNCTION__ ];
+ $args = func_get_args();
+ if ( $this->queue_transaction( $callback, $args ) ) {
+ return;
+ }
+
+ $index = false;
+
+ // ID of the user to show the notification for, defaults to current user id.
+ $user_id = $notification->get_user_id();
+ $notifications = $this->get_notifications_for_user( $user_id );
+
+ // Match persistent Notifications by ID, non persistent by item in the array.
+ if ( $notification->is_persistent() ) {
+ foreach ( $notifications as $current_index => $present_notification ) {
+ if ( $present_notification->get_id() === $notification->get_id() ) {
+ $index = $current_index;
+ break;
+ }
+ }
+ }
+ else {
+ $index = array_search( $notification, $notifications, true );
+ }
+
+ if ( $index === false ) {
+ return;
+ }
+
+ if ( $notification->is_persistent() && $resolve ) {
+ ++$this->resolved;
+ $this->clear_dismissal( $notification );
+ }
+
+ unset( $notifications[ $index ] );
+ $this->notifications[ $user_id ] = array_values( $notifications );
+
+ $this->notifications_need_storage = true;
+ }
+
+ /**
+ * Removes a notification by its ID.
+ *
+ * @param string $notification_id The notification id.
+ * @param bool $resolve Resolve as fixed.
+ *
+ * @return void
+ */
+ public function remove_notification_by_id( $notification_id, $resolve = true ) {
+ $notification = $this->get_notification_by_id( $notification_id );
+
+ if ( $notification === null ) {
+ return;
+ }
+
+ $this->remove_notification( $notification, $resolve );
+ $this->notifications_need_storage = true;
+ }
+
+ /**
+ * Get the notification count.
+ *
+ * @param bool $dismissed Count dismissed notifications.
+ *
+ * @return int Number of notifications
+ */
+ public function get_notification_count( $dismissed = false ) {
+
+ $notifications = $this->get_notifications_for_user( get_current_user_id() );
+ $notifications = array_filter( $notifications, [ $this, 'filter_persistent_notifications' ] );
+
+ if ( ! $dismissed ) {
+ $notifications = array_filter( $notifications, [ $this, 'filter_dismissed_notifications' ] );
+ }
+
+ return count( $notifications );
+ }
+
+ /**
+ * Get the number of notifications resolved this execution.
+ *
+ * These notifications have been resolved and should be counted when active again.
+ *
+ * @return int
+ */
+ public function get_resolved_notification_count() {
+
+ return $this->resolved;
+ }
+
+ /**
+ * Return the notifications sorted on type and priority.
+ *
+ * @return array|Yoast_Notification[] Sorted Notifications
+ */
+ public function get_sorted_notifications() {
+ $notifications = $this->get_notifications_for_user( get_current_user_id() );
+ if ( empty( $notifications ) ) {
+ return [];
+ }
+
+ // Sort by severity, error first.
+ usort( $notifications, [ $this, 'sort_notifications' ] );
+
+ return $notifications;
+ }
+
+ /**
+ * AJAX display notifications.
+ *
+ * @return void
+ */
+ public function ajax_get_notifications() {
+ $echo = false;
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form data.
+ if ( isset( $_POST['version'] ) && is_string( $_POST['version'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable in a condition.
+ $echo = wp_unslash( $_POST['version'] ) === '2';
+ }
+
+ // Display the notices.
+ $this->display_notifications( $echo );
+
+ // AJAX die.
+ exit;
+ }
+
+ /**
+ * Remove storage when the plugin is deactivated.
+ *
+ * @return void
+ */
+ public function deactivate_hook() {
+
+ $this->clear_notifications();
+ }
+
+ /**
+ * Returns the given user ID if it exists.
+ * Otherwise, this function returns the ID of the current user.
+ *
+ * @param int $user_id The user ID to check.
+ *
+ * @return int The user ID to use.
+ */
+ private static function get_user_id( $user_id ) {
+ if ( $user_id ) {
+ return $user_id;
+ }
+ return get_current_user_id();
+ }
+
+ /**
+ * Splits the notifications on user ID.
+ *
+ * In other terms, it returns an associative array,
+ * mapping user ID to a list of notifications for this user.
+ *
+ * @param array|Yoast_Notification[] $notifications The notifications to split.
+ *
+ * @return array The notifications, split on user ID.
+ */
+ private function split_on_user_id( $notifications ) {
+ $split_notifications = [];
+ foreach ( $notifications as $notification ) {
+ $split_notifications[ $notification->get_user_id() ][] = $notification;
+ }
+ return $split_notifications;
+ }
+
+ /**
+ * Save persistent notifications to storage.
+ *
+ * We need to be able to retrieve these so they can be dismissed at any time during the execution.
+ *
+ * @since 3.2
+ *
+ * @return void
+ */
+ public function update_storage() {
+
+ $notifications = $this->notifications;
+
+ /**
+ * One array of Yoast_Notifications, merged from multiple arrays.
+ *
+ * @var Yoast_Notification[] $merged_notifications
+ */
+ $merged_notifications = [];
+ if ( ! empty( $notifications ) ) {
+ $merged_notifications = array_merge( ...$notifications );
+ }
+
+ /**
+ * Filter: 'yoast_notifications_before_storage' - Allows developer to filter notifications before saving them.
+ *
+ * @param Yoast_Notification[] $notifications
+ */
+ $filtered_merged_notifications = apply_filters( 'yoast_notifications_before_storage', $merged_notifications );
+
+ // The notifications were filtered and therefore need to be stored.
+ if ( $merged_notifications !== $filtered_merged_notifications ) {
+ $merged_notifications = $filtered_merged_notifications;
+ $this->notifications_need_storage = true;
+ }
+
+ $notifications = $this->split_on_user_id( $merged_notifications );
+
+ // No notifications to store, clear storage if it was previously present.
+ if ( empty( $notifications ) ) {
+ $this->remove_storage();
+
+ return;
+ }
+
+ // Only store notifications if changes are made.
+ if ( $this->notifications_need_storage ) {
+ array_walk( $notifications, [ $this, 'store_notifications_for_user' ] );
+ }
+ }
+
+ /**
+ * Stores the notifications to its respective user's storage.
+ *
+ * @param array|Yoast_Notification[] $notifications The notifications to store.
+ * @param int $user_id The ID of the user for which to store the notifications.
+ *
+ * @return void
+ */
+ private function store_notifications_for_user( $notifications, $user_id ) {
+ $notifications_as_arrays = array_map( [ $this, 'notification_to_array' ], $notifications );
+ update_user_option( $user_id, self::STORAGE_KEY, $notifications_as_arrays );
+ }
+
+ /**
+ * Provide a way to verify present notifications.
+ *
+ * @return array|Yoast_Notification[] Registered notifications.
+ */
+ public function get_notifications() {
+ if ( ! $this->notifications ) {
+ return [];
+ }
+ return array_merge( ...$this->notifications );
+ }
+
+ /**
+ * Returns the notifications for the given user.
+ *
+ * @param int $user_id The id of the user to check.
+ *
+ * @return Yoast_Notification[] The notifications for the user with the given ID.
+ */
+ public function get_notifications_for_user( $user_id ) {
+ if ( array_key_exists( $user_id, $this->notifications ) ) {
+ return $this->notifications[ $user_id ];
+ }
+ return [];
+ }
+
+ /**
+ * Get newly added notifications.
+ *
+ * @return array
+ */
+ public function get_new_notifications() {
+
+ return array_map( [ $this, 'get_notification_by_id' ], $this->new );
+ }
+
+ /**
+ * Get information from the User input.
+ *
+ * Note that this function does not handle nonce verification.
+ *
+ * @param string $key Key to retrieve.
+ *
+ * @return string non-sanitized value of key if set, an empty string otherwise.
+ */
+ private static function get_user_input( $key ) {
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information and only using this variable in a comparison.
+ $request_method = isset( $_SERVER['REQUEST_METHOD'] ) && is_string( $_SERVER['REQUEST_METHOD'] ) ? strtoupper( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '';
+ // phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: This function does not sanitize variables.
+ // phpcs:disable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing -- Reason: This function does not verify a nonce.
+ if ( $request_method === 'POST' ) {
+ if ( isset( $_POST[ $key ] ) && is_string( $_POST[ $key ] ) ) {
+ return wp_unslash( $_POST[ $key ] );
+ }
+ }
+ elseif ( isset( $_GET[ $key ] ) && is_string( $_GET[ $key ] ) ) {
+ return wp_unslash( $_GET[ $key ] );
+ }
+ // phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ return '';
+ }
+
+ /**
+ * Retrieve the notifications from storage and fill the relevant property.
+ *
+ * @param int $user_id The ID of the user to retrieve notifications for.
+ *
+ * @return void
+ */
+ private function retrieve_notifications_from_storage( $user_id ) {
+ if ( $this->notifications_retrieved ) {
+ return;
+ }
+
+ $this->notifications_retrieved = true;
+
+ $stored_notifications = get_user_option( self::STORAGE_KEY, $user_id );
+
+ // Check if notifications are stored.
+ if ( empty( $stored_notifications ) ) {
+ return;
+ }
+
+ if ( is_array( $stored_notifications ) ) {
+ $notifications = array_map( [ $this, 'array_to_notification' ], $stored_notifications );
+
+ // Apply array_values to ensure we get a 0-indexed array.
+ $notifications = array_values( array_filter( $notifications, [ $this, 'filter_notification_current_user' ] ) );
+
+ $this->notifications[ $user_id ] = $notifications;
+ }
+ }
+
+ /**
+ * Sort on type then priority.
+ *
+ * @param Yoast_Notification $a Compare with B.
+ * @param Yoast_Notification $b Compare with A.
+ *
+ * @return int 1, 0 or -1 for sorting offset.
+ */
+ private function sort_notifications( Yoast_Notification $a, Yoast_Notification $b ) {
+
+ $a_type = $a->get_type();
+ $b_type = $b->get_type();
+
+ if ( $a_type === $b_type ) {
+ return WPSEO_Utils::calc( $b->get_priority(), 'compare', $a->get_priority() );
+ }
+
+ if ( $a_type === 'error' ) {
+ return -1;
+ }
+
+ if ( $b_type === 'error' ) {
+ return 1;
+ }
+
+ return 0;
+ }
+
+ /**
+ * Clear local stored notifications.
+ *
+ * @return void
+ */
+ private function clear_notifications() {
+
+ $this->notifications = [];
+ $this->notifications_retrieved = false;
+ }
+
+ /**
+ * Filter out non-persistent notifications.
+ *
+ * @since 3.2
+ *
+ * @param Yoast_Notification $notification Notification to test for persistent.
+ *
+ * @return bool
+ */
+ private function filter_persistent_notifications( Yoast_Notification $notification ) {
+
+ return $notification->is_persistent();
+ }
+
+ /**
+ * Filter out dismissed notifications.
+ *
+ * @param Yoast_Notification $notification Notification to check.
+ *
+ * @return bool
+ */
+ private function filter_dismissed_notifications( Yoast_Notification $notification ) {
+
+ return ! self::maybe_dismiss_notification( $notification );
+ }
+
+ /**
+ * Convert Notification to array representation.
+ *
+ * @since 3.2
+ *
+ * @param Yoast_Notification $notification Notification to convert.
+ *
+ * @return array
+ */
+ private function notification_to_array( Yoast_Notification $notification ) {
+
+ $notification_data = $notification->to_array();
+
+ if ( isset( $notification_data['nonce'] ) ) {
+ unset( $notification_data['nonce'] );
+ }
+
+ return $notification_data;
+ }
+
+ /**
+ * Convert stored array to Notification.
+ *
+ * @param array $notification_data Array to convert to Notification.
+ *
+ * @return Yoast_Notification
+ */
+ private function array_to_notification( $notification_data ) {
+
+ if ( isset( $notification_data['options']['nonce'] ) ) {
+ unset( $notification_data['options']['nonce'] );
+ }
+
+ if ( isset( $notification_data['message'] )
+ && is_subclass_of( $notification_data['message'], Abstract_Presenter::class, false )
+ ) {
+ $notification_data['message'] = $notification_data['message']->present();
+ }
+
+ if ( isset( $notification_data['options']['user'] ) ) {
+ $notification_data['options']['user_id'] = $notification_data['options']['user']->ID;
+ unset( $notification_data['options']['user'] );
+
+ $this->notifications_need_storage = true;
+ }
+
+ return new Yoast_Notification(
+ $notification_data['message'],
+ $notification_data['options']
+ );
+ }
+
+ /**
+ * Filter notifications that should not be displayed for the current user.
+ *
+ * @param Yoast_Notification $notification Notification to test.
+ *
+ * @return bool
+ */
+ private function filter_notification_current_user( Yoast_Notification $notification ) {
+ return $notification->display_for_current_user();
+ }
+
+ /**
+ * Checks if given notification is persistent.
+ *
+ * @param Yoast_Notification $notification The notification to check.
+ *
+ * @return bool True when notification is not persistent.
+ */
+ private function is_notification_persistent( Yoast_Notification $notification ) {
+ return ! $notification->is_persistent();
+ }
+
+ /**
+ * Queues a notification transaction for later execution if notifications are not yet set up.
+ *
+ * @param callable $callback Callback that performs the transaction.
+ * @param array $args Arguments to pass to the callback.
+ *
+ * @return bool True if transaction was queued, false if it can be performed immediately.
+ */
+ private function queue_transaction( $callback, $args ) {
+ if ( $this->notifications_retrieved ) {
+ return false;
+ }
+
+ $this->add_transaction_to_queue( $callback, $args );
+
+ return true;
+ }
+
+ /**
+ * Adds a notification transaction to the queue for later execution.
+ *
+ * @param callable $callback Callback that performs the transaction.
+ * @param array $args Arguments to pass to the callback.
+ *
+ * @return void
+ */
+ private function add_transaction_to_queue( $callback, $args ) {
+ $this->queued_transactions[] = [ $callback, $args ];
+ }
+
+ /**
+ * Removes all notifications from storage.
+ *
+ * @return bool True when notifications got removed.
+ */
+ protected function remove_storage() {
+ if ( ! $this->has_stored_notifications() ) {
+ return false;
+ }
+
+ delete_user_option( get_current_user_id(), self::STORAGE_KEY );
+ return true;
+ }
+
+ /**
+ * Checks if there are stored notifications.
+ *
+ * @return bool True when there are stored notifications.
+ */
+ protected function has_stored_notifications() {
+ $stored_notifications = $this->get_stored_notifications();
+
+ return ! empty( $stored_notifications );
+ }
+
+ /**
+ * Retrieves the stored notifications.
+ *
+ * @codeCoverageIgnore
+ *
+ * @return array|false Array with notifications or false when not set.
+ */
+ protected function get_stored_notifications() {
+ return get_user_option( self::STORAGE_KEY, get_current_user_id() );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-notification.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-notification.php
new file mode 100644
index 00000000..3191827b
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-notification.php
@@ -0,0 +1,429 @@
+ self::UPDATED,
+ 'id' => '',
+ 'user_id' => null,
+ 'nonce' => null,
+ 'priority' => 0.5,
+ 'data_json' => [],
+ 'dismissal_key' => null,
+ 'capabilities' => [],
+ 'capability_check' => self::MATCH_ALL,
+ 'yoast_branding' => false,
+ ];
+
+ /**
+ * The message for the notification.
+ *
+ * @var string
+ */
+ private $message;
+
+ /**
+ * Notification class constructor.
+ *
+ * @param string $message Message string.
+ * @param array $options Set of options.
+ */
+ public function __construct( $message, $options = [] ) {
+ $this->message = $message;
+ $this->options = $this->normalize_options( $options );
+ }
+
+ /**
+ * Retrieve notification ID string.
+ *
+ * @return string
+ */
+ public function get_id() {
+ return $this->options['id'];
+ }
+
+ /**
+ * Retrieve the user to show the notification for.
+ *
+ * @deprecated 21.6
+ * @codeCoverageIgnore
+ *
+ * @return WP_User The user to show this notification for.
+ */
+ public function get_user() {
+ _deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
+ return null;
+ }
+
+ /**
+ * Retrieve the id of the user to show the notification for.
+ *
+ * Returns the id of the current user if not user has been sent.
+ *
+ * @return int The user id
+ */
+ public function get_user_id() {
+ return ( $this->options['user_id'] ?? get_current_user_id() );
+ }
+
+ /**
+ * Retrieve nonce identifier.
+ *
+ * @return string|null Nonce for this Notification.
+ */
+ public function get_nonce() {
+ if ( $this->options['id'] && empty( $this->options['nonce'] ) ) {
+ $this->options['nonce'] = wp_create_nonce( $this->options['id'] );
+ }
+
+ return $this->options['nonce'];
+ }
+
+ /**
+ * Make sure the nonce is up to date.
+ *
+ * @return void
+ */
+ public function refresh_nonce() {
+ if ( $this->options['id'] ) {
+ $this->options['nonce'] = wp_create_nonce( $this->options['id'] );
+ }
+ }
+
+ /**
+ * Get the type of the notification.
+ *
+ * @return string
+ */
+ public function get_type() {
+ return $this->options['type'];
+ }
+
+ /**
+ * Priority of the notification.
+ *
+ * Relative to the type.
+ *
+ * @return float Returns the priority between 0 and 1.
+ */
+ public function get_priority() {
+ return $this->options['priority'];
+ }
+
+ /**
+ * Get the User Meta key to check for dismissal of notification.
+ *
+ * @return string User Meta Option key that registers dismissal.
+ */
+ public function get_dismissal_key() {
+ if ( empty( $this->options['dismissal_key'] ) ) {
+ return $this->options['id'];
+ }
+
+ return $this->options['dismissal_key'];
+ }
+
+ /**
+ * Is this Notification persistent.
+ *
+ * @return bool True if persistent, False if fire and forget.
+ */
+ public function is_persistent() {
+ $id = $this->get_id();
+
+ return ! empty( $id );
+ }
+
+ /**
+ * Check if the notification is relevant for the current user.
+ *
+ * @return bool True if a user needs to see this notification, false if not.
+ */
+ public function display_for_current_user() {
+ // If the notification is for the current page only, always show.
+ if ( ! $this->is_persistent() ) {
+ return true;
+ }
+
+ // If the current user doesn't match capabilities.
+ return $this->match_capabilities();
+ }
+
+ /**
+ * Does the current user match required capabilities.
+ *
+ * @return bool
+ */
+ public function match_capabilities() {
+ // Super Admin can do anything.
+ if ( is_multisite() && is_super_admin( $this->options['user_id'] ) ) {
+ return true;
+ }
+
+ /**
+ * Filter capabilities that enable the displaying of this notification.
+ *
+ * @param array $capabilities The capabilities that must be present for this notification.
+ * @param Yoast_Notification $notification The notification object.
+ *
+ * @return array Array of capabilities or empty for no restrictions.
+ *
+ * @since 3.2
+ */
+ $capabilities = apply_filters( 'wpseo_notification_capabilities', $this->options['capabilities'], $this );
+
+ // Should be an array.
+ if ( ! is_array( $capabilities ) ) {
+ $capabilities = (array) $capabilities;
+ }
+
+ /**
+ * Filter capability check to enable all or any capabilities.
+ *
+ * @param string $capability_check The type of check that will be used to determine if an capability is present.
+ * @param Yoast_Notification $notification The notification object.
+ *
+ * @return string self::MATCH_ALL or self::MATCH_ANY.
+ *
+ * @since 3.2
+ */
+ $capability_check = apply_filters( 'wpseo_notification_capability_check', $this->options['capability_check'], $this );
+
+ if ( ! in_array( $capability_check, [ self::MATCH_ALL, self::MATCH_ANY ], true ) ) {
+ $capability_check = self::MATCH_ALL;
+ }
+
+ if ( ! empty( $capabilities ) ) {
+
+ $has_capabilities = array_filter( $capabilities, [ $this, 'has_capability' ] );
+
+ switch ( $capability_check ) {
+ case self::MATCH_ALL:
+ return $has_capabilities === $capabilities;
+ case self::MATCH_ANY:
+ return ! empty( $has_capabilities );
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Array filter function to find matched capabilities.
+ *
+ * @param string $capability Capability to test.
+ *
+ * @return bool
+ */
+ private function has_capability( $capability ) {
+ $user_id = $this->options['user_id'];
+ if ( ! is_numeric( $user_id ) ) {
+ return false;
+ }
+ $user = get_user_by( 'id', $user_id );
+ if ( ! $user ) {
+ return false;
+ }
+
+ return $user->has_cap( $capability );
+ }
+
+ /**
+ * Return the object properties as an array.
+ *
+ * @return array
+ */
+ public function to_array() {
+ return [
+ 'message' => $this->message,
+ 'options' => $this->options,
+ ];
+ }
+
+ /**
+ * Adds string (view) behaviour to the notification.
+ *
+ * @return string
+ */
+ public function __toString() {
+ return $this->render();
+ }
+
+ /**
+ * Renders the notification as a string.
+ *
+ * @return string The rendered notification.
+ */
+ public function render() {
+ $attributes = [];
+
+ // Default notification classes.
+ $classes = [
+ 'yoast-notification',
+ ];
+
+ // Maintain WordPress visualisation of notifications when they are not persistent.
+ if ( ! $this->is_persistent() ) {
+ $classes[] = 'notice';
+ $classes[] = $this->get_type();
+ }
+
+ if ( ! empty( $classes ) ) {
+ $attributes['class'] = implode( ' ', $classes );
+ }
+
+ // Combined attribute key and value into a string.
+ array_walk( $attributes, [ $this, 'parse_attributes' ] );
+
+ $message = null;
+ if ( $this->options['yoast_branding'] ) {
+ $message = $this->wrap_yoast_seo_icon( $this->message );
+ }
+
+ if ( $message === null ) {
+ $message = wpautop( $this->message );
+ }
+
+ // Build the output DIV.
+ return '
' . $message . '
' . PHP_EOL;
+ }
+
+ /**
+ * Wraps the message with a Yoast SEO icon.
+ *
+ * @param string $message The message to wrap.
+ *
+ * @return string The wrapped message.
+ */
+ private function wrap_yoast_seo_icon( $message ) {
+ $out = sprintf(
+ '',
+ esc_url( plugin_dir_url( WPSEO_FILE ) . 'packages/js/images/Yoast_SEO_Icon.svg' ),
+ 60,
+ 60
+ );
+ $out .= '
';
+ $out .= $message;
+ $out .= '
';
+
+ return $out;
+ }
+
+ /**
+ * Get the JSON if provided.
+ *
+ * @return false|string
+ */
+ public function get_json() {
+ if ( empty( $this->options['data_json'] ) ) {
+ return '';
+ }
+
+ return WPSEO_Utils::format_json_encode( $this->options['data_json'] );
+ }
+
+ /**
+ * Make sure we only have values that we can work with.
+ *
+ * @param array $options Options to normalize.
+ *
+ * @return array
+ */
+ private function normalize_options( $options ) {
+ $options = wp_parse_args( $options, $this->defaults );
+
+ // Should not exceed 0 or 1.
+ $options['priority'] = min( 1, max( 0, $options['priority'] ) );
+
+ // Set default capabilities when not supplied.
+ if ( empty( $options['capabilities'] ) || $options['capabilities'] === [] ) {
+ $options['capabilities'] = [ 'wpseo_manage_options' ];
+ }
+
+ // Set to the id of the current user if not supplied.
+ if ( $options['user_id'] === null ) {
+ $options['user_id'] = get_current_user_id();
+ }
+
+ return $options;
+ }
+
+ /**
+ * Format HTML element attributes.
+ *
+ * @param string $value Attribute value.
+ * @param string $key Attribute name.
+ *
+ * @return void
+ */
+ private function parse_attributes( &$value, $key ) {
+ $value = sprintf( '%s="%s"', sanitize_key( $key ), esc_attr( $value ) );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-notifications.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-notifications.php
new file mode 100644
index 00000000..c3847e01
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-notifications.php
@@ -0,0 +1,319 @@
+add_hooks();
+ }
+
+ /**
+ * Add hooks
+ *
+ * @return void
+ */
+ private function add_hooks() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ $page = sanitize_text_field( wp_unslash( $_GET['page'] ) );
+ if ( $page === self::ADMIN_PAGE ) {
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
+ }
+ }
+
+ // Needed for adminbar and Notifications page.
+ add_action( 'admin_init', [ self::class, 'collect_notifications' ], 99 );
+
+ // Add AJAX hooks.
+ add_action( 'wp_ajax_yoast_dismiss_notification', [ $this, 'ajax_dismiss_notification' ] );
+ add_action( 'wp_ajax_yoast_restore_notification', [ $this, 'ajax_restore_notification' ] );
+ }
+
+ /**
+ * Enqueue assets.
+ *
+ * @return void
+ */
+ public function enqueue_assets() {
+ $asset_manager = new WPSEO_Admin_Asset_Manager();
+
+ $asset_manager->enqueue_style( 'notifications' );
+ }
+
+ /**
+ * Handle ajax request to dismiss a notification.
+ *
+ * @return void
+ */
+ public function ajax_dismiss_notification() {
+
+ $notification = $this->get_notification_from_ajax_request();
+ if ( $notification ) {
+ $notification_center = Yoast_Notification_Center::get();
+ $notification_center->maybe_dismiss_notification( $notification );
+
+ $this->output_ajax_response( $notification->get_type() );
+ }
+
+ wp_die();
+ }
+
+ /**
+ * Handle ajax request to restore a notification.
+ *
+ * @return void
+ */
+ public function ajax_restore_notification() {
+
+ $notification = $this->get_notification_from_ajax_request();
+ if ( $notification ) {
+ $notification_center = Yoast_Notification_Center::get();
+ $notification_center->restore_notification( $notification );
+
+ $this->output_ajax_response( $notification->get_type() );
+ }
+
+ wp_die();
+ }
+
+ /**
+ * Create AJAX response data.
+ *
+ * @param string $type Notification type.
+ *
+ * @return void
+ */
+ private function output_ajax_response( $type ) {
+
+ $html = $this->get_view_html( $type );
+ // phpcs:disable WordPress.Security.EscapeOutput -- Reason: WPSEO_Utils::format_json_encode is safe.
+ echo WPSEO_Utils::format_json_encode(
+ [
+ 'html' => $html,
+ 'total' => self::get_active_notification_count(),
+ ]
+ );
+ // phpcs:enable -- Reason: WPSEO_Utils::format_json_encode is safe.
+ }
+
+ /**
+ * Get the HTML to return in the AJAX request.
+ *
+ * @param string $type Notification type.
+ *
+ * @return bool|string
+ */
+ private function get_view_html( $type ) {
+
+ switch ( $type ) {
+ case 'error':
+ $view = 'errors';
+ break;
+
+ case 'warning':
+ default:
+ $view = 'warnings';
+ break;
+ }
+
+ // Re-collect notifications.
+ self::collect_notifications();
+
+ /**
+ * Stops PHPStorm from nagging about this variable being unused. The variable is used in the view.
+ *
+ * @noinspection PhpUnusedLocalVariableInspection
+ */
+ $notifications_data = self::get_template_variables();
+
+ ob_start();
+ include WPSEO_PATH . 'admin/views/partial-notifications-' . $view . '.php';
+ $html = ob_get_clean();
+
+ return $html;
+ }
+
+ /**
+ * Extract the Yoast Notification from the AJAX request.
+ *
+ * This function does not handle nonce verification.
+ *
+ * @return Yoast_Notification|null A Yoast_Notification on success, null on failure.
+ */
+ private function get_notification_from_ajax_request() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: This function does not handle nonce verification.
+ if ( ! isset( $_POST['notification'] ) || ! is_string( $_POST['notification'] ) ) {
+ return null;
+ }
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: This function does not handle nonce verification.
+ $notification_id = sanitize_text_field( wp_unslash( $_POST['notification'] ) );
+
+ if ( empty( $notification_id ) ) {
+ return null;
+ }
+ $notification_center = Yoast_Notification_Center::get();
+ return $notification_center->get_notification_by_id( $notification_id );
+ }
+
+ /**
+ * Collect the notifications and group them together.
+ *
+ * @return void
+ */
+ public static function collect_notifications() {
+
+ $notification_center = Yoast_Notification_Center::get();
+
+ $notifications = $notification_center->get_sorted_notifications();
+ self::$notification_count = count( $notifications );
+
+ self::$errors = array_filter( $notifications, [ self::class, 'filter_error_notifications' ] );
+ self::$dismissed_errors = array_filter( self::$errors, [ self::class, 'filter_dismissed_notifications' ] );
+ self::$active_errors = array_diff( self::$errors, self::$dismissed_errors );
+
+ self::$warnings = array_filter( $notifications, [ self::class, 'filter_warning_notifications' ] );
+ self::$dismissed_warnings = array_filter( self::$warnings, [ self::class, 'filter_dismissed_notifications' ] );
+ self::$active_warnings = array_diff( self::$warnings, self::$dismissed_warnings );
+ }
+
+ /**
+ * Get the variables needed in the views.
+ *
+ * @return array
+ */
+ public static function get_template_variables() {
+
+ return [
+ 'metrics' => [
+ 'total' => self::$notification_count,
+ 'active' => self::get_active_notification_count(),
+ 'errors' => count( self::$errors ),
+ 'warnings' => count( self::$warnings ),
+ ],
+ 'errors' => [
+ 'dismissed' => self::$dismissed_errors,
+ 'active' => self::$active_errors,
+ ],
+ 'warnings' => [
+ 'dismissed' => self::$dismissed_warnings,
+ 'active' => self::$active_warnings,
+ ],
+ ];
+ }
+
+ /**
+ * Get the number of active notifications.
+ *
+ * @return int
+ */
+ public static function get_active_notification_count() {
+
+ return ( count( self::$active_errors ) + count( self::$active_warnings ) );
+ }
+
+ /**
+ * Filter out any non-errors.
+ *
+ * @param Yoast_Notification $notification Notification to test.
+ *
+ * @return bool
+ */
+ private static function filter_error_notifications( Yoast_Notification $notification ) {
+
+ return $notification->get_type() === 'error';
+ }
+
+ /**
+ * Filter out any non-warnings.
+ *
+ * @param Yoast_Notification $notification Notification to test.
+ *
+ * @return bool
+ */
+ private static function filter_warning_notifications( Yoast_Notification $notification ) {
+
+ return $notification->get_type() !== 'error';
+ }
+
+ /**
+ * Filter out any dismissed notifications.
+ *
+ * @param Yoast_Notification $notification Notification to test.
+ *
+ * @return bool
+ */
+ private static function filter_dismissed_notifications( Yoast_Notification $notification ) {
+
+ return Yoast_Notification_Center::is_notification_dismissed( $notification );
+ }
+}
+
+class_alias( Yoast_Notifications::class, 'Yoast_Alerts' );
diff --git a/wp-content/plugins/wordpress-seo/admin/class-yoast-plugin-conflict.php b/wp-content/plugins/wordpress-seo/admin/class-yoast-plugin-conflict.php
new file mode 100644
index 00000000..302cd495
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/class-yoast-plugin-conflict.php
@@ -0,0 +1,342 @@
+plugins the active plugins will be stored in this
+ * property.
+ *
+ * @var array
+ */
+ protected $active_conflicting_plugins = [];
+
+ /**
+ * Property for holding instance of itself.
+ *
+ * @var Yoast_Plugin_Conflict
+ */
+ protected static $instance;
+
+ /**
+ * For the use of singleton pattern. Create instance of itself and return this instance.
+ *
+ * @param string $class_name Give the classname to initialize. If classname is
+ * false (empty) it will use it's own __CLASS__.
+ *
+ * @return Yoast_Plugin_Conflict
+ */
+ public static function get_instance( $class_name = '' ) {
+
+ if ( is_null( self::$instance ) ) {
+ if ( ! is_string( $class_name ) || $class_name === '' ) {
+ $class_name = self::class;
+ }
+
+ self::$instance = new $class_name();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Setting instance, all active plugins and search for active plugins.
+ *
+ * Protected constructor to prevent creating a new instance of the
+ * *Singleton* via the `new` operator from outside this class.
+ */
+ protected function __construct() {
+ // Set active plugins.
+ $this->all_active_plugins = get_option( 'active_plugins' );
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['action'] ) && is_string( $_GET['action'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information and only comparing the variable in a condition.
+ $action = wp_unslash( $_GET['action'] );
+ if ( $action === 'deactivate' ) {
+ $this->remove_deactivated_plugin();
+ }
+ }
+
+ // Search for active plugins.
+ $this->search_active_plugins();
+ }
+
+ /**
+ * Check if there are conflicting plugins for given $plugin_section.
+ *
+ * @param string $plugin_section Type of plugin conflict (such as Open Graph or sitemap).
+ *
+ * @return bool
+ */
+ public function check_for_conflicts( $plugin_section ) {
+
+ static $sections_checked;
+
+ // Return early if there are no active conflicting plugins at all.
+ if ( empty( $this->active_conflicting_plugins ) ) {
+ return false;
+ }
+
+ if ( $sections_checked === null ) {
+ $sections_checked = [];
+ }
+
+ if ( ! in_array( $plugin_section, $sections_checked, true ) ) {
+ $sections_checked[] = $plugin_section;
+ return ( ! empty( $this->active_conflicting_plugins[ $plugin_section ] ) );
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks for given $plugin_sections for conflicts.
+ *
+ * @param array $plugin_sections Set of sections.
+ *
+ * @return void
+ */
+ public function check_plugin_conflicts( $plugin_sections ) {
+ foreach ( $plugin_sections as $plugin_section => $readable_plugin_section ) {
+ // Check for conflicting plugins and show error if there are conflicts.
+ if ( $this->check_for_conflicts( $plugin_section ) ) {
+ $this->set_error( $plugin_section, $readable_plugin_section );
+ }
+ }
+
+ // List of all active sections.
+ $sections = array_keys( $plugin_sections );
+ // List of all sections.
+ $all_plugin_sections = array_keys( $this->plugins );
+
+ /*
+ * Get all sections that are inactive.
+ * These plugins need to be cleared.
+ *
+ * This happens when Sitemaps or OpenGraph implementations toggle active/disabled.
+ */
+ $inactive_sections = array_diff( $all_plugin_sections, $sections );
+ if ( ! empty( $inactive_sections ) ) {
+ foreach ( $inactive_sections as $section ) {
+ array_walk( $this->plugins[ $section ], [ $this, 'clear_error' ] );
+ }
+ }
+
+ // For active sections clear errors for inactive plugins.
+ foreach ( $sections as $section ) {
+ // By default, clear errors for all plugins of the section.
+ $inactive_plugins = $this->plugins[ $section ];
+
+ // If there are active plugins, filter them from being cleared.
+ if ( isset( $this->active_conflicting_plugins[ $section ] ) ) {
+ $inactive_plugins = array_diff( $this->plugins[ $section ], $this->active_conflicting_plugins[ $section ] );
+ }
+
+ array_walk( $inactive_plugins, [ $this, 'clear_error' ] );
+ }
+ }
+
+ /**
+ * Setting an error on the screen.
+ *
+ * @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
+ * @param string $readable_plugin_section This is the value for the translation.
+ *
+ * @return void
+ */
+ protected function set_error( $plugin_section, $readable_plugin_section ) {
+
+ $notification_center = Yoast_Notification_Center::get();
+
+ foreach ( $this->active_conflicting_plugins[ $plugin_section ] as $plugin_file ) {
+
+ $plugin_name = $this->get_plugin_name( $plugin_file );
+
+ $error_message = '';
+ /* translators: %1$s: 'Facebook & Open Graph' plugin name(s) of possibly conflicting plugin(s), %2$s to Yoast SEO */
+ $error_message .= '
' . sprintf( __( 'The %1$s plugin might cause issues when used in conjunction with %2$s.', 'wordpress-seo' ), '' . $plugin_name . '', 'Yoast SEO' ) . '
';
+
+ /* translators: %s: 'Facebook' plugin name of possibly conflicting plugin */
+ $error_message .= '' . sprintf( __( 'Deactivate %s', 'wordpress-seo' ), $this->get_plugin_name( $plugin_file ) ) . ' ';
+
+ $identifier = $this->get_notification_identifier( $plugin_file );
+
+ // Add the message to the notifications center.
+ $notification_center->add_notification(
+ new Yoast_Notification(
+ $error_message,
+ [
+ 'type' => Yoast_Notification::ERROR,
+ 'id' => 'wpseo-conflict-' . $identifier,
+ ]
+ )
+ );
+ }
+ }
+
+ /**
+ * Clear the notification for a plugin.
+ *
+ * @param string $plugin_file Clear the optional notification for this plugin.
+ *
+ * @return void
+ */
+ public function clear_error( $plugin_file ) {
+ $identifier = $this->get_notification_identifier( $plugin_file );
+
+ $notification_center = Yoast_Notification_Center::get();
+ $notification_center->remove_notification_by_id( 'wpseo-conflict-' . $identifier );
+ }
+
+ /**
+ * Loop through the $this->plugins to check if one of the plugins is active.
+ *
+ * This method will store the active plugins in $this->active_plugins.
+ *
+ * @return void
+ */
+ protected function search_active_plugins() {
+ foreach ( $this->plugins as $plugin_section => $plugins ) {
+ $this->check_plugins_active( $plugins, $plugin_section );
+ }
+ }
+
+ /**
+ * Loop through plugins and check if each plugin is active.
+ *
+ * @param array $plugins Set of plugins.
+ * @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
+ *
+ * @return void
+ */
+ protected function check_plugins_active( $plugins, $plugin_section ) {
+ foreach ( $plugins as $plugin ) {
+ if ( $this->check_plugin_is_active( $plugin ) ) {
+ $this->add_active_plugin( $plugin_section, $plugin );
+ }
+ }
+ }
+
+ /**
+ * Check if given plugin exists in array with all_active_plugins.
+ *
+ * @param string $plugin Plugin basename string.
+ *
+ * @return bool
+ */
+ protected function check_plugin_is_active( $plugin ) {
+ return in_array( $plugin, $this->all_active_plugins, true );
+ }
+
+ /**
+ * Add plugin to the list of active plugins.
+ *
+ * This method will check first if key $plugin_section exists, if not it will create an empty array
+ * If $plugin itself doesn't exist it will be added.
+ *
+ * @param string $plugin_section Type of conflict group (such as Open Graph or sitemap).
+ * @param string $plugin Plugin basename string.
+ *
+ * @return void
+ */
+ protected function add_active_plugin( $plugin_section, $plugin ) {
+ if ( ! array_key_exists( $plugin_section, $this->active_conflicting_plugins ) ) {
+ $this->active_conflicting_plugins[ $plugin_section ] = [];
+ }
+
+ if ( ! in_array( $plugin, $this->active_conflicting_plugins[ $plugin_section ], true ) ) {
+ $this->active_conflicting_plugins[ $plugin_section ][] = $plugin;
+ }
+ }
+
+ /**
+ * Search in $this->plugins for the given $plugin.
+ *
+ * If there is a result it will return the plugin category.
+ *
+ * @param string $plugin Plugin basename string.
+ *
+ * @return int|string
+ */
+ protected function find_plugin_category( $plugin ) {
+ foreach ( $this->plugins as $plugin_section => $plugins ) {
+ if ( in_array( $plugin, $plugins, true ) ) {
+ return $plugin_section;
+ }
+ }
+ }
+
+ /**
+ * Get plugin name from file.
+ *
+ * @param string $plugin Plugin path relative to plugins directory.
+ *
+ * @return string|bool Plugin name or false when no name is set.
+ */
+ protected function get_plugin_name( $plugin ) {
+ $plugin_details = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
+
+ if ( $plugin_details['Name'] !== '' ) {
+ return $plugin_details['Name'];
+ }
+
+ return false;
+ }
+
+ /**
+ * When being in the deactivation process the currently deactivated plugin has to be removed.
+ *
+ * @return void
+ */
+ private function remove_deactivated_plugin() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: On the deactivation screen the nonce is already checked by WordPress itself.
+ if ( ! isset( $_GET['plugin'] ) || ! is_string( $_GET['plugin'] ) ) {
+ return;
+ }
+
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: On the deactivation screen the nonce is already checked by WordPress itself.
+ $deactivated_plugin = sanitize_text_field( wp_unslash( $_GET['plugin'] ) );
+ $key_to_remove = array_search( $deactivated_plugin, $this->all_active_plugins, true );
+
+ if ( $key_to_remove !== false ) {
+ unset( $this->all_active_plugins[ $key_to_remove ] );
+ }
+ }
+
+ /**
+ * Get the identifier from the plugin file.
+ *
+ * @param string $plugin_file Plugin file to get Identifier from.
+ *
+ * @return string
+ */
+ private function get_notification_identifier( $plugin_file ) {
+ return md5( $plugin_file );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-file-size.php b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-file-size.php
new file mode 100644
index 00000000..9f2bec07
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-file-size.php
@@ -0,0 +1,85 @@
+service = $service;
+ }
+
+ /**
+ * Registers the routes for the endpoints.
+ *
+ * @return void
+ */
+ public function register() {
+ $route_args = [
+ 'methods' => 'GET',
+ 'args' => [
+ 'url' => [
+ 'required' => true,
+ 'type' => 'string',
+ 'description' => 'The url to retrieve',
+ ],
+ ],
+ 'callback' => [
+ $this->service,
+ 'get',
+ ],
+ 'permission_callback' => [
+ $this,
+ 'can_retrieve_data',
+ ],
+ ];
+ register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_SINGULAR, $route_args );
+ }
+
+ /**
+ * Determines whether or not data can be retrieved for the registered endpoints.
+ *
+ * @return bool Whether or not data can be retrieved.
+ */
+ public function can_retrieve_data() {
+ return current_user_can( self::CAPABILITY_RETRIEVE );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-statistics.php b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-statistics.php
new file mode 100644
index 00000000..392d1c13
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint-statistics.php
@@ -0,0 +1,73 @@
+service = $service;
+ }
+
+ /**
+ * Registers the REST routes that are available on the endpoint.
+ *
+ * @return void
+ */
+ public function register() {
+ // Register fetch config.
+ $route_args = [
+ 'methods' => 'GET',
+ 'callback' => [ $this->service, 'get_statistics' ],
+ 'permission_callback' => [ $this, 'can_retrieve_data' ],
+ ];
+ register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_RETRIEVE, $route_args );
+ }
+
+ /**
+ * Determines whether or not data can be retrieved for the registered endpoints.
+ *
+ * @return bool Whether or not data can be retrieved.
+ */
+ public function can_retrieve_data() {
+ return current_user_can( self::CAPABILITY_RETRIEVE );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint.php b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint.php
new file mode 100644
index 00000000..abbc9d0e
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/endpoints/class-endpoint.php
@@ -0,0 +1,26 @@
+is_filter_active() ) {
+ add_action( 'restrict_manage_posts', [ $this, 'render_hidden_input' ] );
+ }
+
+ if ( $this->is_filter_active() && $this->get_explanation() !== null ) {
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_explanation_assets' ] );
+ }
+ }
+
+ /**
+ * Adds the filter links to the view_edit screens to give the user a filter link.
+ *
+ * @return void
+ */
+ public function add_filter_links() {
+ foreach ( $this->get_post_types() as $post_type ) {
+ add_filter( 'views_edit-' . $post_type, [ $this, 'add_filter_link' ] );
+ }
+ }
+
+ /**
+ * Enqueues the necessary assets to display a filter explanation.
+ *
+ * @return void
+ */
+ public function enqueue_explanation_assets() {
+ $asset_manager = new WPSEO_Admin_Asset_Manager();
+ $asset_manager->enqueue_script( 'filter-explanation' );
+ $asset_manager->enqueue_style( 'filter-explanation' );
+ $asset_manager->localize_script(
+ 'filter-explanation',
+ 'yoastFilterExplanation',
+ [ 'text' => $this->get_explanation() ]
+ );
+ }
+
+ /**
+ * Adds a filter link to the views.
+ *
+ * @param array $views Array with the views.
+ *
+ * @return array Array of views including the added view.
+ */
+ public function add_filter_link( $views ) {
+ $views[ 'yoast_' . $this->get_query_val() ] = sprintf(
+ '%3$s (%4$s)',
+ esc_url( $this->get_filter_url() ),
+ ( $this->is_filter_active() ) ? ' class="current" aria-current="page"' : '',
+ $this->get_label(),
+ $this->get_post_total()
+ );
+
+ return $views;
+ }
+
+ /**
+ * Returns a text explaining this filter. Null if no explanation is necessary.
+ *
+ * @return string|null The explanation or null.
+ */
+ protected function get_explanation() {
+ return null;
+ }
+
+ /**
+ * Renders a hidden input to preserve this filter's state when using sub-filters.
+ *
+ * @return void
+ */
+ public function render_hidden_input() {
+ echo '';
+ }
+
+ /**
+ * Returns an url to edit.php with post_type and this filter as the query arguments.
+ *
+ * @return string The url to activate this filter.
+ */
+ protected function get_filter_url() {
+ $query_args = [
+ self::FILTER_QUERY_ARG => $this->get_query_val(),
+ 'post_type' => $this->get_current_post_type(),
+ ];
+
+ return add_query_arg( $query_args, 'edit.php' );
+ }
+
+ /**
+ * Returns true when the filter is active.
+ *
+ * @return bool Whether the filter is active.
+ */
+ protected function is_filter_active() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET[ self::FILTER_QUERY_ARG ] ) && is_string( $_GET[ self::FILTER_QUERY_ARG ] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ return sanitize_text_field( wp_unslash( $_GET[ self::FILTER_QUERY_ARG ] ) ) === $this->get_query_val();
+ }
+ return false;
+ }
+
+ /**
+ * Returns the current post type.
+ *
+ * @return string The current post type.
+ */
+ protected function get_current_post_type() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['post_type'] ) && is_string( $_GET['post_type'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ $post_type = sanitize_text_field( wp_unslash( $_GET['post_type'] ) );
+ if ( ! empty( $post_type ) ) {
+ return $post_type;
+ }
+ }
+ return 'post';
+ }
+
+ /**
+ * Returns the post types to which this filter should be added.
+ *
+ * @return array The post types to which this filter should be added.
+ */
+ protected function get_post_types() {
+ return WPSEO_Post_Type::get_accessible_post_types();
+ }
+
+ /**
+ * Checks if the post type is supported.
+ *
+ * @param string $post_type Post type to check against.
+ *
+ * @return bool True when it is supported.
+ */
+ protected function is_supported_post_type( $post_type ) {
+ return in_array( $post_type, $this->get_post_types(), true );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/filters/class-cornerstone-filter.php b/wp-content/plugins/wordpress-seo/admin/filters/class-cornerstone-filter.php
new file mode 100644
index 00000000..19831289
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/filters/class-cornerstone-filter.php
@@ -0,0 +1,150 @@
+is_filter_active() ) {
+ global $wpdb;
+
+ $where .= $wpdb->prepare(
+ " AND {$wpdb->posts}.ID IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = '1' ) ",
+ WPSEO_Meta::$meta_prefix . self::META_NAME
+ );
+ }
+
+ return $where;
+ }
+
+ /**
+ * Filters the post types that have the metabox disabled.
+ *
+ * @param array $post_types The post types to filter.
+ *
+ * @return array The filtered post types.
+ */
+ public function filter_metabox_disabled( $post_types ) {
+ $filtered_post_types = [];
+ foreach ( $post_types as $post_type_key => $post_type ) {
+ if ( ! WPSEO_Post_Type::has_metabox_enabled( $post_type_key ) ) {
+ continue;
+ }
+
+ $filtered_post_types[ $post_type_key ] = $post_type;
+ }
+
+ return $filtered_post_types;
+ }
+
+ /**
+ * Returns the label for this filter.
+ *
+ * @return string The label for this filter.
+ */
+ protected function get_label() {
+ return __( 'Cornerstone content', 'wordpress-seo' );
+ }
+
+ /**
+ * Returns a text explaining this filter.
+ *
+ * @return string|null The explanation.
+ */
+ protected function get_explanation() {
+ $post_type_object = get_post_type_object( $this->get_current_post_type() );
+
+ if ( $post_type_object === null ) {
+ return null;
+ }
+
+ return sprintf(
+ /* translators: %1$s expands to the posttype label, %2$s expands anchor to blog post about cornerstone content, %3$s expands to */
+ __( 'Mark the most important %1$s as \'cornerstone content\' to improve your site structure. %2$sLearn more about cornerstone content%3$s.', 'wordpress-seo' ),
+ strtolower( $post_type_object->labels->name ),
+ '',
+ ''
+ );
+ }
+
+ /**
+ * Returns the total amount of articles marked as cornerstone content.
+ *
+ * @return int
+ */
+ protected function get_post_total() {
+ global $wpdb;
+
+ return (int) $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT COUNT( 1 )
+ FROM {$wpdb->postmeta}
+ WHERE post_id IN( SELECT ID FROM {$wpdb->posts} WHERE post_type = %s ) AND
+ meta_key = %s AND meta_value = '1'
+ ",
+ $this->get_current_post_type(),
+ WPSEO_Meta::$meta_prefix . self::META_NAME
+ )
+ );
+ }
+
+ /**
+ * Returns the post types to which this filter should be added.
+ *
+ * @return array The post types to which this filter should be added.
+ */
+ protected function get_post_types() {
+ /**
+ * Filter: 'wpseo_cornerstone_post_types' - Filters post types to exclude the cornerstone feature for.
+ *
+ * @param array $post_types The accessible post types to filter.
+ */
+ $post_types = apply_filters( 'wpseo_cornerstone_post_types', parent::get_post_types() );
+ if ( ! is_array( $post_types ) ) {
+ return [];
+ }
+
+ return $post_types;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/formatter/class-metabox-formatter.php b/wp-content/plugins/wordpress-seo/admin/formatter/class-metabox-formatter.php
new file mode 100644
index 00000000..2c4e8d7b
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/formatter/class-metabox-formatter.php
@@ -0,0 +1,208 @@
+formatter = $formatter;
+ }
+
+ /**
+ * Returns the values.
+ *
+ * @return array|bool|int>
+ */
+ public function get_values() {
+ $defaults = $this->get_defaults();
+ $values = $this->formatter->get_values();
+
+ return ( $values + $defaults );
+ }
+
+ /**
+ * Returns array with all the values always needed by a scraper object.
+ *
+ * @return array|bool|int> Default settings for the metabox.
+ */
+ private function get_defaults() {
+ $schema_types = new Schema_Types();
+ $host = YoastSEO()->helpers->url->get_url_host( get_site_url() );
+
+ $defaults = [
+ 'author_name' => get_the_author_meta( 'display_name' ),
+ 'sitewide_social_image' => WPSEO_Options::get( 'og_default_image' ),
+ 'translations' => $this->get_translations(),
+ 'keyword_usage' => [],
+ 'title_template' => '',
+ 'metadesc_template' => '',
+ 'showSocial' => [
+ 'facebook' => WPSEO_Options::get( 'opengraph', false ),
+ 'twitter' => WPSEO_Options::get( 'twitter', false ),
+ ],
+ 'schema' => [
+ 'displayFooter' => WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ),
+ 'pageTypeOptions' => $schema_types->get_page_type_options(),
+ 'articleTypeOptions' => $schema_types->get_article_type_options(),
+ ],
+ 'twitterCardType' => 'summary_large_image',
+ 'publish_box' => [
+ 'labels' => [
+ 'keyword' => [
+ 'na' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
+ __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Not available', 'wordpress-seo' ) . ''
+ ),
+ 'bad' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
+ __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Needs improvement', 'wordpress-seo' ) . ''
+ ),
+ 'ok' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
+ __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'OK', 'wordpress-seo' ) . ''
+ ),
+ 'good' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the SEO score. */
+ __( '%1$sSEO%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Good', 'wordpress-seo' ) . ''
+ ),
+ ],
+ 'content' => [
+ 'na' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
+ __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Not available', 'wordpress-seo' ) . ''
+ ),
+ 'bad' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
+ __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Needs improvement', 'wordpress-seo' ) . ''
+ ),
+ 'ok' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
+ __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'OK', 'wordpress-seo' ) . ''
+ ),
+ 'good' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the readability score. */
+ __( '%1$sReadability%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Good', 'wordpress-seo' ) . ''
+ ),
+ ],
+ 'inclusive-language' => [
+ 'na' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
+ __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Not available', 'wordpress-seo' ) . ''
+ ),
+ 'bad' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
+ __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Needs improvement', 'wordpress-seo' ) . ''
+ ),
+ 'ok' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
+ __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Potentially non-inclusive', 'wordpress-seo' ) . ''
+ ),
+ 'good' => sprintf(
+ /* translators: %1$s expands to the opening anchor tag, %2$s to the closing anchor tag, %3$s to the inclusive language score. */
+ __( '%1$sInclusive language%2$s: %3$s', 'wordpress-seo' ),
+ '',
+ '',
+ '' . __( 'Good', 'wordpress-seo' ) . ''
+ ),
+ ],
+ ],
+ ],
+ /**
+ * Filter to determine if the markers should be enabled or not.
+ *
+ * @param bool $showMarkers Should the markers being enabled. Default = true.
+ */
+ 'show_markers' => apply_filters( 'wpseo_enable_assessment_markers', true ),
+ 'zapierIntegrationActive' => WPSEO_Options::get( 'zapier_integration_active', false ) ? 1 : 0,
+ 'zapierConnectedStatus' => ! empty( WPSEO_Options::get( 'zapier_subscription', [] ) ) ? 1 : 0,
+ 'getJetpackBoostPrePublishLink' => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-get-prepublish?domain=' . $host ),
+ 'upgradeJetpackBoostPrePublishLink' => WPSEO_Shortlinker::get( 'https://yoa.st/jetpack-boost-upgrade-prepublish?domain=' . $host ),
+ 'woocommerceUpsellSchemaLink' => WPSEO_Shortlinker::get( 'https://yoa.st/product-schema-metabox' ),
+ 'woocommerceUpsellGooglePreviewLink' => WPSEO_Shortlinker::get( 'https://yoa.st/product-google-preview-metabox' ),
+ ];
+
+ $integration_information_repo = YoastSEO()->classes->get( Integration_Information_Repository::class );
+
+ $enabled_integrations = $integration_information_repo->get_integration_information();
+ $defaults = array_merge( $defaults, $enabled_integrations );
+ $enabled_features_repo = YoastSEO()->classes->get( Enabled_Analysis_Features_Repository::class );
+
+ $enabled_features = $enabled_features_repo->get_enabled_features()->parse_to_legacy_array();
+ return array_merge( $defaults, $enabled_features );
+ }
+
+ /**
+ * Returns Jed compatible YoastSEO.js translations.
+ *
+ * @return string[]
+ */
+ private function get_translations() {
+ $locale = get_user_locale();
+
+ $file = WPSEO_PATH . 'languages/wordpress-seo-' . $locale . '.json';
+ if ( file_exists( $file ) ) {
+ // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Retrieving a local file.
+ $file = file_get_contents( $file );
+ if ( is_string( $file ) && $file !== '' ) {
+ return json_decode( $file, true );
+ }
+ }
+
+ return [];
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/formatter/class-post-metabox-formatter.php b/wp-content/plugins/wordpress-seo/admin/formatter/class-post-metabox-formatter.php
new file mode 100644
index 00000000..a9d3e0d0
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/formatter/class-post-metabox-formatter.php
@@ -0,0 +1,93 @@
+post = $post;
+ $this->permalink = $structure;
+ }
+
+ /**
+ * Determines whether the social templates should be used.
+ *
+ * @deprecated 23.1
+ * @codeCoverageIgnore
+ */
+ public function use_social_templates() {
+ _deprecated_function( __METHOD__, 'Yoast SEO 23.1' );
+ }
+
+ /**
+ * Returns the translated values.
+ *
+ * @return array
+ */
+ public function get_values() {
+
+ $values = [
+ 'metaDescriptionDate' => '',
+ ];
+
+ if ( $this->post instanceof WP_Post ) {
+
+ /** @var Post_Seo_Information_Repository $repo */
+ $repo = YoastSEO()->classes->get( Post_Seo_Information_Repository::class );
+ $repo->set_post( $this->post );
+
+ $values_to_set = [
+ 'isInsightsEnabled' => $this->is_insights_enabled(),
+ ];
+
+ $values = ( $values_to_set + $values );
+ $values = ( $repo->get_seo_data() + $values );
+ }
+
+ /**
+ * Filter: 'wpseo_post_edit_values' - Allows changing the values Yoast SEO uses inside the post editor.
+ *
+ * @param array $values The key-value map Yoast SEO uses inside the post editor.
+ * @param WP_Post $post The post opened in the editor.
+ */
+ return apply_filters( 'wpseo_post_edit_values', $values, $this->post );
+ }
+
+ /**
+ * Determines whether the insights feature is enabled for this post.
+ *
+ * @return bool
+ */
+ protected function is_insights_enabled() {
+ return WPSEO_Options::get( 'enable_metabox_insights', false );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/formatter/class-term-metabox-formatter.php b/wp-content/plugins/wordpress-seo/admin/formatter/class-term-metabox-formatter.php
new file mode 100644
index 00000000..29218d38
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/formatter/class-term-metabox-formatter.php
@@ -0,0 +1,98 @@
+taxonomy = $taxonomy;
+ $this->term = $term;
+
+ $this->use_social_templates = $this->use_social_templates();
+ }
+
+ /**
+ * Determines whether the social templates should be used.
+ *
+ * @return bool Whether the social templates should be used.
+ */
+ public function use_social_templates() {
+ return WPSEO_Options::get( 'opengraph', false ) === true;
+ }
+
+ /**
+ * Returns the translated values.
+ *
+ * @return array
+ */
+ public function get_values() {
+ $values = [];
+
+ // Todo: a column needs to be added on the termpages to add a filter for the keyword, so this can be used in the focus keyphrase doubles.
+ if ( is_object( $this->term ) && property_exists( $this->term, 'taxonomy' ) ) {
+ $values = [
+ 'taxonomy' => $this->term->taxonomy,
+ 'semrushIntegrationActive' => 0,
+ 'wincherIntegrationActive' => 0,
+ 'isInsightsEnabled' => $this->is_insights_enabled(),
+ ];
+
+ $repo = YoastSEO()->classes->get( Term_Seo_Information_Repository::class );
+ $repo->set_term( $this->term );
+ $values = ( $repo->get_seo_data() + $values );
+ }
+
+ return $values;
+ }
+
+ /**
+ * Determines whether the insights feature is enabled for this taxonomy.
+ *
+ * @return bool
+ */
+ protected function is_insights_enabled() {
+ return WPSEO_Options::get( 'enable_metabox_insights', false );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/formatter/interface-metabox-formatter.php b/wp-content/plugins/wordpress-seo/admin/formatter/interface-metabox-formatter.php
new file mode 100644
index 00000000..8c220480
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/formatter/interface-metabox-formatter.php
@@ -0,0 +1,19 @@
+admin_header( false, 'wpseo-gsc', false, 'yoast_wpseo_gsc_options' );
+
+// GSC Error notification.
+$gsc_url = 'https://search.google.com/search-console/index';
+$gsc_post_url = 'https://yoa.st/google-search-console-deprecated';
+$gsc_style_alert = '
+ display: flex;
+ align-items: baseline;
+ position: relative;
+ padding: 16px;
+ border: 1px solid rgba(0, 0, 0, 0.2);
+ font-size: 14px;
+ font-weight: 400;
+ line-height: 1.5;
+ margin: 16px 0;
+ color: #450c11;
+ background: #f8d7da;
+';
+$gsc_style_alert_icon = 'display: block; margin-right: 8px;';
+$gsc_style_alert_content = 'max-width: 600px;';
+$gsc_style_alert_link = 'color: #004973;';
+$gsc_notification = sprintf(
+ /* Translators: %1$s: expands to opening anchor tag, %2$s expands to closing anchor tag. */
+ __( 'Google has discontinued its Crawl Errors API. Therefore, any possible crawl errors you might have cannot be displayed here anymore. %1$sRead our statement on this for further information%2$s.', 'wordpress-seo' ),
+ '',
+ WPSEO_Admin_Utils::get_new_tab_message() . ''
+);
+$gsc_notification .= '
';
+$gsc_notification .= sprintf(
+ /* Translators: %1$s: expands to opening anchor tag, %2$s expands to closing anchor tag. */
+ __( 'To view your current crawl errors, %1$splease visit Google Search Console%2$s.', 'wordpress-seo' ),
+ '',
+ WPSEO_Admin_Utils::get_new_tab_message() . ''
+);
+?>
+
+
+
+
+
+
+';
+printf(
+ /* Translators: %s: expands to Yoast SEO Premium */
+ esc_html__( 'Creating redirects is a %s feature', 'wordpress-seo' ),
+ 'Yoast SEO Premium'
+);
+echo '';
+echo '
';
+printf(
+ /* Translators: %1$s: expands to 'Yoast SEO Premium', %2$s: links to Yoast SEO Premium plugin page. */
+ esc_html__( 'To be able to create a redirect and fix this issue, you need %1$s. You can buy the plugin, including one year of support and updates, on %2$s.', 'wordpress-seo' ),
+ 'Yoast SEO Premium',
+ 'yoast.com'
+);
+echo '
';
+echo '';
diff --git a/wp-content/plugins/wordpress-seo/admin/import/class-import-detector.php b/wp-content/plugins/wordpress-seo/admin/import/class-import-detector.php
new file mode 100644
index 00000000..48d31cc1
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/class-import-detector.php
@@ -0,0 +1,36 @@
+status->status ) {
+ $this->needs_import[ $importer_class ] = $importer->get_plugin_name();
+ }
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/class-import-plugin.php b/wp-content/plugins/wordpress-seo/admin/import/class-import-plugin.php
new file mode 100644
index 00000000..d71fff83
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/class-import-plugin.php
@@ -0,0 +1,63 @@
+importer = $importer;
+
+ switch ( $action ) {
+ case 'cleanup':
+ $this->status = $this->importer->run_cleanup();
+ break;
+ case 'import':
+ $this->status = $this->importer->run_import();
+ break;
+ case 'detect':
+ default:
+ $this->status = $this->importer->run_detect();
+ }
+
+ $this->status->set_msg( $this->complete_msg( $this->status->get_msg() ) );
+ }
+
+ /**
+ * Convenience function to replace %s with plugin name in import message.
+ *
+ * @param string $msg Message string.
+ *
+ * @return string Returns message with plugin name instead of replacement variables.
+ */
+ protected function complete_msg( $msg ) {
+ return sprintf( $msg, $this->importer->get_plugin_name() );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/class-import-settings.php b/wp-content/plugins/wordpress-seo/admin/import/class-import-settings.php
new file mode 100644
index 00000000..3bec4c8f
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/class-import-settings.php
@@ -0,0 +1,127 @@
+status = new WPSEO_Import_Status( 'import', false );
+ }
+
+ /**
+ * Imports the data submitted by the user.
+ *
+ * @return void
+ */
+ public function import() {
+ check_admin_referer( self::NONCE_ACTION );
+
+ if ( ! WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ) ) {
+ return;
+ }
+
+ if ( ! isset( $_POST['settings_import'] ) || ! is_string( $_POST['settings_import'] ) ) {
+ return;
+ }
+
+ // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: The raw content will be parsed afterwards.
+ $content = wp_unslash( $_POST['settings_import'] );
+
+ if ( empty( $content ) ) {
+ return;
+ }
+
+ $this->parse_options( $content );
+ }
+
+ /**
+ * Parse the options.
+ *
+ * @param string $raw_options The content to parse.
+ *
+ * @return void
+ */
+ protected function parse_options( $raw_options ) {
+ $options = parse_ini_string( $raw_options, true, INI_SCANNER_RAW );
+
+ if ( is_array( $options ) && $options !== [] ) {
+ $this->import_options( $options );
+
+ return;
+ }
+
+ $this->status->set_msg( __( 'Settings could not be imported:', 'wordpress-seo' ) . ' ' . __( 'No settings found.', 'wordpress-seo' ) );
+ }
+
+ /**
+ * Parse the option group and import it.
+ *
+ * @param string $name Name string.
+ * @param array $option_group Option group data.
+ * @param array $options Options data.
+ *
+ * @return void
+ */
+ protected function parse_option_group( $name, $option_group, $options ) {
+ // Make sure that the imported options are cleaned/converted on import.
+ $option_instance = WPSEO_Options::get_option_instance( $name );
+ if ( is_object( $option_instance ) && method_exists( $option_instance, 'import' ) ) {
+ $option_instance->import( $option_group, $this->old_wpseo_version, $options );
+ }
+ }
+
+ /**
+ * Imports the options if found.
+ *
+ * @param array $options The options parsed from the provided settings.
+ *
+ * @return void
+ */
+ protected function import_options( $options ) {
+ if ( isset( $options['wpseo']['version'] ) && $options['wpseo']['version'] !== '' ) {
+ $this->old_wpseo_version = $options['wpseo']['version'];
+ }
+
+ foreach ( $options as $name => $option_group ) {
+ $this->parse_option_group( $name, $option_group, $options );
+ }
+
+ $this->status->set_msg( __( 'Settings successfully imported.', 'wordpress-seo' ) );
+ $this->status->set_status( true );
+
+ // Reset the cached option values.
+ WPSEO_Options::clear_cache();
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/class-import-status.php b/wp-content/plugins/wordpress-seo/admin/import/class-import-status.php
new file mode 100644
index 00000000..c105d4a7
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/class-import-status.php
@@ -0,0 +1,131 @@
+action = $action;
+ $this->status = $status;
+ $this->msg = $msg;
+ }
+
+ /**
+ * Get the import message.
+ *
+ * @return string Message about current status.
+ */
+ public function get_msg() {
+ if ( $this->msg !== '' ) {
+ return $this->msg;
+ }
+
+ if ( $this->status === false ) {
+ /* translators: %s is replaced with the name of the plugin we're trying to find data from. */
+ return __( '%s data not found.', 'wordpress-seo' );
+ }
+
+ return $this->get_default_success_message();
+ }
+
+ /**
+ * Get the import action.
+ *
+ * @return string Import action type.
+ */
+ public function get_action() {
+ return $this->action;
+ }
+
+ /**
+ * Set the import action, set status to false.
+ *
+ * @param string $action The type of action to set as import action.
+ *
+ * @return void
+ */
+ public function set_action( $action ) {
+ $this->action = $action;
+ $this->status = false;
+ }
+
+ /**
+ * Sets the importer status message.
+ *
+ * @param string $msg The message to set.
+ *
+ * @return void
+ */
+ public function set_msg( $msg ) {
+ $this->msg = $msg;
+ }
+
+ /**
+ * Sets the importer status.
+ *
+ * @param bool $status The status to set.
+ *
+ * @return WPSEO_Import_Status The current object.
+ */
+ public function set_status( $status ) {
+ $this->status = (bool) $status;
+
+ return $this;
+ }
+
+ /**
+ * Returns a success message depending on the action.
+ *
+ * @return string Returns a success message for the current action.
+ */
+ private function get_default_success_message() {
+ switch ( $this->action ) {
+ case 'import':
+ /* translators: %s is replaced with the name of the plugin we're importing data from. */
+ return __( '%s data successfully imported.', 'wordpress-seo' );
+ case 'cleanup':
+ /* translators: %s is replaced with the name of the plugin we're removing data from. */
+ return __( '%s data successfully removed.', 'wordpress-seo' );
+ case 'detect':
+ default:
+ /* translators: %s is replaced with the name of the plugin we've found data from. */
+ return __( '%s data found.', 'wordpress-seo' );
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-abstract-plugin-importer.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-abstract-plugin-importer.php
new file mode 100644
index 00000000..6f5674f2
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-abstract-plugin-importer.php
@@ -0,0 +1,329 @@
+plugin_name;
+ }
+
+ /**
+ * Imports the settings and post meta data from another SEO plugin.
+ *
+ * @return WPSEO_Import_Status Import status object.
+ */
+ public function run_import() {
+ $this->status = new WPSEO_Import_Status( 'import', false );
+
+ if ( ! $this->detect() ) {
+ return $this->status;
+ }
+
+ $this->status->set_status( $this->import() );
+
+ // Flush the entire cache, as we no longer know what's valid and what's not.
+ wp_cache_flush();
+
+ return $this->status;
+ }
+
+ /**
+ * Handles post meta data to import.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ return $this->meta_keys_clone( $this->clone_keys );
+ }
+
+ /**
+ * Removes the plugin data from the database.
+ *
+ * @return WPSEO_Import_Status Import status object.
+ */
+ public function run_cleanup() {
+ $this->status = new WPSEO_Import_Status( 'cleanup', false );
+
+ if ( ! $this->detect() ) {
+ return $this->status;
+ }
+
+ return $this->status->set_status( $this->cleanup() );
+ }
+
+ /**
+ * Removes the plugin data from the database.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ global $wpdb;
+ if ( empty( $this->meta_key ) ) {
+ return true;
+ }
+ $wpdb->query(
+ $wpdb->prepare(
+ "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE %s",
+ $this->meta_key
+ )
+ );
+ $result = $wpdb->__get( 'result' );
+ if ( ! $result ) {
+ $this->cleanup_error_msg();
+ }
+
+ return $result;
+ }
+
+ /**
+ * Sets the status message for when a cleanup has gone bad.
+ *
+ * @return void
+ */
+ protected function cleanup_error_msg() {
+ /* translators: %s is replaced with the plugin's name. */
+ $this->status->set_msg( sprintf( __( 'Cleanup of %s data failed.', 'wordpress-seo' ), $this->plugin_name ) );
+ }
+
+ /**
+ * Detects whether an import for this plugin is needed.
+ *
+ * @return WPSEO_Import_Status Import status object.
+ */
+ public function run_detect() {
+ $this->status = new WPSEO_Import_Status( 'detect', false );
+
+ if ( ! $this->detect() ) {
+ return $this->status;
+ }
+
+ return $this->status->set_status( true );
+ }
+
+ /**
+ * Detects whether there is post meta data to import.
+ *
+ * @return bool Boolean indicating whether there is something to import.
+ */
+ protected function detect() {
+ global $wpdb;
+
+ $meta_keys = wp_list_pluck( $this->clone_keys, 'old_key' );
+ $result = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT COUNT(*) AS `count`
+ FROM {$wpdb->postmeta}
+ WHERE meta_key IN ( " . implode( ', ', array_fill( 0, count( $meta_keys ), '%s' ) ) . ' )',
+ $meta_keys
+ )
+ );
+
+ if ( $result === '0' ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Helper function to clone meta keys and (optionally) change their values in bulk.
+ *
+ * @param string $old_key The existing meta key.
+ * @param string $new_key The new meta key.
+ * @param array $replace_values An array, keys old value, values new values.
+ *
+ * @return bool Clone status.
+ */
+ protected function meta_key_clone( $old_key, $new_key, $replace_values = [] ) {
+ global $wpdb;
+
+ // First we create a temp table with all the values for meta_key.
+ $result = $wpdb->query(
+ $wpdb->prepare(
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- This is intentional + temporary.
+ "CREATE TEMPORARY TABLE tmp_meta_table SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s",
+ $old_key
+ )
+ );
+ if ( $result === false ) {
+ $this->set_missing_db_rights_status();
+ return false;
+ }
+
+ // Delete all the values in our temp table for posts that already have data for $new_key.
+ $wpdb->query(
+ $wpdb->prepare(
+ "DELETE FROM tmp_meta_table WHERE post_id IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s )",
+ WPSEO_Meta::$meta_prefix . $new_key
+ )
+ );
+
+ /*
+ * We set meta_id to NULL so on re-insert into the postmeta table, MYSQL can set
+ * new meta_id's and we don't get duplicates.
+ */
+ $wpdb->query( 'UPDATE tmp_meta_table SET meta_id = NULL' );
+
+ // Now we rename the meta_key.
+ $wpdb->query(
+ $wpdb->prepare(
+ 'UPDATE tmp_meta_table SET meta_key = %s',
+ WPSEO_Meta::$meta_prefix . $new_key
+ )
+ );
+
+ $this->meta_key_clone_replace( $replace_values );
+
+ // With everything done, we insert all our newly cloned lines into the postmeta table.
+ $wpdb->query( "INSERT INTO {$wpdb->postmeta} SELECT * FROM tmp_meta_table" );
+
+ // Now we drop our temporary table.
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- This is intentional + a temporary table.
+ $wpdb->query( 'DROP TEMPORARY TABLE IF EXISTS tmp_meta_table' );
+
+ return true;
+ }
+
+ /**
+ * Clones multiple meta keys.
+ *
+ * @param array $clone_keys The keys to clone.
+ *
+ * @return bool Success status.
+ */
+ protected function meta_keys_clone( $clone_keys ) {
+ foreach ( $clone_keys as $clone_key ) {
+ $result = $this->meta_key_clone( $clone_key['old_key'], $clone_key['new_key'], ( $clone_key['convert'] ?? [] ) );
+ if ( ! $result ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Sets the import status to false and returns a message about why it failed.
+ *
+ * @return void
+ */
+ protected function set_missing_db_rights_status() {
+ $this->status->set_status( false );
+ /* translators: %s is replaced with Yoast SEO. */
+ $this->status->set_msg( sprintf( __( 'The %s importer functionality uses temporary database tables. It seems your WordPress install does not have the capability to do this, please consult your hosting provider.', 'wordpress-seo' ), 'Yoast SEO' ) );
+ }
+
+ /**
+ * Helper function to search for a key in an array and maybe save it as a meta field.
+ *
+ * @param string $plugin_key The key in the $data array to check.
+ * @param string $yoast_key The identifier we use in our meta settings.
+ * @param array $data The array of data for this post to sift through.
+ * @param int $post_id The post ID.
+ *
+ * @return void
+ */
+ protected function import_meta_helper( $plugin_key, $yoast_key, $data, $post_id ) {
+ if ( ! empty( $data[ $plugin_key ] ) ) {
+ $this->maybe_save_post_meta( $yoast_key, $data[ $plugin_key ], $post_id );
+ }
+ }
+
+ /**
+ * Saves a post meta value if it doesn't already exist.
+ *
+ * @param string $new_key The key to save.
+ * @param mixed $value The value to set the key to.
+ * @param int $post_id The Post to save the meta for.
+ *
+ * @return void
+ */
+ protected function maybe_save_post_meta( $new_key, $value, $post_id ) {
+ // Big. Fat. Sigh. Mostly used for _yst_is_cornerstone, but might be useful for other hidden meta's.
+ $key = WPSEO_Meta::$meta_prefix . $new_key;
+ $wpseo_meta = true;
+ if ( substr( $new_key, 0, 1 ) === '_' ) {
+ $key = $new_key;
+ $wpseo_meta = false;
+ }
+
+ $existing_value = get_post_meta( $post_id, $key, true );
+ if ( empty( $existing_value ) ) {
+ if ( $wpseo_meta ) {
+ WPSEO_Meta::set_value( $new_key, $value, $post_id );
+ return;
+ }
+ update_post_meta( $post_id, $new_key, $value );
+ }
+ }
+
+ /**
+ * Replaces values in our temporary table according to our settings.
+ *
+ * @param array $replace_values Key value pair of values to replace with other values.
+ *
+ * @return void
+ */
+ protected function meta_key_clone_replace( $replace_values ) {
+ global $wpdb;
+
+ // Now we replace values if needed.
+ if ( is_array( $replace_values ) && $replace_values !== [] ) {
+ foreach ( $replace_values as $old_value => $new_value ) {
+ $wpdb->query(
+ $wpdb->prepare(
+ 'UPDATE tmp_meta_table SET meta_value = %s WHERE meta_value = %s',
+ $new_value,
+ $old_value
+ )
+ );
+ }
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo-v4.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo-v4.php
new file mode 100644
index 00000000..122ce46d
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo-v4.php
@@ -0,0 +1,241 @@
+ '_aioseo_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_aioseo_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_aioseo_og_title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => '_aioseo_og_description',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => '_aioseo_twitter_title',
+ 'new_key' => 'twitter-title',
+ ],
+ [
+ 'old_key' => '_aioseo_twitter_description',
+ 'new_key' => 'twitter-description',
+ ],
+ ];
+
+ /**
+ * Mapping between the AiOSEO replace vars and the Yoast replace vars.
+ *
+ * @var array
+ *
+ * @see https://yoast.com/help/list-available-snippet-variables-yoast-seo/
+ */
+ protected $replace_vars = [
+ // They key is the AiOSEO replace var, the value is the Yoast replace var (see class-wpseo-replace-vars).
+ '#author_first_name' => '%%author_first_name%%',
+ '#author_last_name' => '%%author_last_name%%',
+ '#author_name' => '%%name%%',
+ '#categories' => '%%category%%',
+ '#current_date' => '%%currentdate%%',
+ '#current_day' => '%%currentday%%',
+ '#current_month' => '%%currentmonth%%',
+ '#current_year' => '%%currentyear%%',
+ '#permalink' => '%%permalink%%',
+ '#post_content' => '%%post_content%%',
+ '#post_date' => '%%date%%',
+ '#post_day' => '%%post_day%%',
+ '#post_month' => '%%post_month%%',
+ '#post_title' => '%%title%%',
+ '#post_year' => '%%post_year%%',
+ '#post_excerpt_only' => '%%excerpt_only%%',
+ '#post_excerpt' => '%%excerpt%%',
+ '#separator_sa' => '%%sep%%',
+ '#site_title' => '%%sitename%%',
+ '#tagline' => '%%sitedesc%%',
+ '#taxonomy_title' => '%%category_title%%',
+ ];
+
+ /**
+ * Replaces the AiOSEO variables in our temporary table with Yoast variables (replace vars).
+ *
+ * @param array $replace_values Key value pair of values to replace with other values. This is only used in the base class but not here.
+ * That is because this class doesn't have any `convert` keys in `$clone_keys`.
+ * For that reason, we're overwriting the base class' `meta_key_clone_replace()` function without executing that base functionality.
+ *
+ * @return void
+ */
+ protected function meta_key_clone_replace( $replace_values ) {
+ global $wpdb;
+
+ // At this point we're already looping through all the $clone_keys (this happens in meta_keys_clone() in the abstract class).
+ // Now, we'll also loop through the replace_vars array, which holds the mappings between the AiOSEO variables and the Yoast variables.
+ // We'll replace all the AiOSEO variables in the temporary table with their Yoast equivalents.
+ foreach ( $this->replace_vars as $aioseo_variable => $yoast_variable ) {
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
+ $wpdb->query(
+ $wpdb->prepare(
+ 'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
+ $aioseo_variable,
+ $yoast_variable
+ )
+ );
+ }
+
+ // The AiOSEO custom fields take the form of `#custom_field-myfield`.
+ // These should be mapped to %%cf_myfield%%.
+ $meta_values_with_custom_fields = $this->get_meta_values_with_custom_field_or_taxonomy( $wpdb, 'custom_field' );
+ $unique_custom_fields = $this->get_unique_custom_fields_or_taxonomies( $meta_values_with_custom_fields, 'custom_field' );
+ $this->replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields, $wpdb, 'custom_field', 'cf' );
+
+ // Map `#tax_name-{tax-slug}` to `%%ct_{tax-slug}%%``.
+ $meta_values_with_custom_taxonomies = $this->get_meta_values_with_custom_field_or_taxonomy( $wpdb, 'tax_name' );
+ $unique_custom_taxonomies = $this->get_unique_custom_fields_or_taxonomies( $meta_values_with_custom_taxonomies, 'tax_name' );
+ $this->replace_custom_field_or_taxonomy_replace_vars( $unique_custom_taxonomies, $wpdb, 'tax_name', 'ct' );
+ }
+
+ /**
+ * Filters out all unique custom fields/taxonomies/etc. used in an AiOSEO replace var.
+ *
+ * @param string[] $meta_values An array of all the meta values that
+ * contain one or more AIOSEO custom field replace vars
+ * (in the form `#custom_field-xyz`).
+ * @param string $aioseo_prefix The AiOSEO prefix to use
+ * (e.g. `custom-field` for custom fields or `tax_name` for custom taxonomies).
+ *
+ * @return string[] An array of all the unique custom fields/taxonomies/etc. used in the replace vars.
+ * E.g. `xyz` in the above example.
+ */
+ protected function get_unique_custom_fields_or_taxonomies( $meta_values, $aioseo_prefix ) {
+ $unique_custom_fields_or_taxonomies = [];
+
+ foreach ( $meta_values as $meta_value ) {
+ // Find all custom field replace vars, store them in `$matches`.
+ preg_match_all(
+ "/#$aioseo_prefix-([\w-]+)/",
+ $meta_value,
+ $matches
+ );
+
+ /*
+ * `$matches[1]` contain the captured matches of the
+ * first capturing group (the `([\w-]+)` in the regex above).
+ */
+ $custom_fields_or_taxonomies = $matches[1];
+
+ foreach ( $custom_fields_or_taxonomies as $custom_field_or_taxonomy ) {
+ $unique_custom_fields_or_taxonomies[ trim( $custom_field_or_taxonomy ) ] = 1;
+ }
+ }
+
+ return array_keys( $unique_custom_fields_or_taxonomies );
+ }
+
+ /**
+ * Replaces every AIOSEO custom field/taxonomy/etc. replace var with the Yoast version.
+ *
+ * E.g. `#custom_field-xyz` becomes `%%cf_xyz%%`.
+ *
+ * @param string[] $unique_custom_fields_or_taxonomies An array of unique custom fields to replace the replace vars of.
+ * @param wpdb $wpdb The WordPress database object.
+ * @param string $aioseo_prefix The AiOSEO prefix to use
+ * (e.g. `custom-field` for custom fields or `tax_name` for custom taxonomies).
+ * @param string $yoast_prefix The Yoast prefix to use (e.g. `cf` for custom fields).
+ *
+ * @return void
+ */
+ protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom_fields_or_taxonomies, $wpdb, $aioseo_prefix, $yoast_prefix ) {
+ foreach ( $unique_custom_fields_or_taxonomies as $unique_custom_field_or_taxonomy ) {
+ $aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
+ $yoast_variable = "%%{$yoast_prefix}_{$unique_custom_field_or_taxonomy}%%";
+
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
+ $wpdb->query(
+ $wpdb->prepare(
+ 'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
+ $aioseo_variable,
+ $yoast_variable
+ )
+ );
+ }
+ }
+
+ // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
+
+ /**
+ * Retrieve all the meta values from the temporary meta table that contain
+ * at least one AiOSEO custom field replace var.
+ *
+ * @param wpdb $wpdb The WordPress database object.
+ * @param string $aioseo_prefix The AiOSEO prefix to use
+ * (e.g. `custom-field` for custom fields or `tax_name` for custom taxonomies).
+ *
+ * @return string[] All meta values that contain at least one AioSEO custom field replace var.
+ */
+ protected function get_meta_values_with_custom_field_or_taxonomy( $wpdb, $aioseo_prefix ) {
+ return $wpdb->get_col(
+ $wpdb->prepare(
+ 'SELECT meta_value FROM tmp_meta_table WHERE meta_value LIKE %s',
+ "%#$aioseo_prefix-%"
+ )
+ );
+ }
+
+ // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
+
+ /**
+ * Detects whether there is AIOSEO data to import by looking whether the AIOSEO data have been cleaned up.
+ *
+ * @return bool Boolean indicating whether there is something to import.
+ */
+ protected function detect() {
+ $aioseo_cleanup_action = YoastSEO()->classes->get( Aioseo_Cleanup_Action::class );
+ return ( $aioseo_cleanup_action->get_total_unindexed() > 0 );
+ }
+
+ /**
+ * Import AIOSEO post data from their custom indexable table. Not currently used.
+ *
+ * @return void
+ */
+ protected function import() {
+ // This is overriden from the import.js and never run.
+ $aioseo_posts_import_action = YoastSEO()->classes->get( Aioseo_Posts_Importing_Action::class );
+ $aioseo_posts_import_action->index();
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo.php
new file mode 100644
index 00000000..cf7ab491
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-aioseo.php
@@ -0,0 +1,110 @@
+ 'opengraph-title',
+ 'aioseop_opengraph_settings_desc' => 'opengraph-description',
+ 'aioseop_opengraph_settings_customimg' => 'opengraph-image',
+ 'aioseop_opengraph_settings_customimg_twitter' => 'twitter-image',
+ ];
+
+ /**
+ * Array of meta keys to detect and import.
+ *
+ * @var array
+ */
+ protected $clone_keys = [
+ [
+ 'old_key' => '_aioseop_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_aioseop_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_aioseop_noindex',
+ 'new_key' => 'meta-robots-noindex',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ [
+ 'old_key' => '_aioseop_nofollow',
+ 'new_key' => 'meta-robots-nofollow',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ ];
+
+ /**
+ * Import All In One SEO meta values.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ $status = parent::import();
+ if ( $status ) {
+ $this->import_opengraph();
+ }
+ return $status;
+ }
+
+ /**
+ * Imports the OpenGraph and Twitter settings for all posts.
+ *
+ * @return bool
+ */
+ protected function import_opengraph() {
+ $query_posts = new WP_Query( 'post_type=any&meta_key=_aioseop_opengraph_settings&order=ASC&fields=ids&nopaging=true' );
+
+ if ( ! empty( $query_posts->posts ) ) {
+ foreach ( array_values( $query_posts->posts ) as $post_id ) {
+ $this->import_post_opengraph( $post_id );
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Imports the OpenGraph and Twitter settings for a single post.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function import_post_opengraph( $post_id ) {
+ $meta = get_post_meta( $post_id, '_aioseop_opengraph_settings', true );
+ $meta = maybe_unserialize( $meta );
+
+ foreach ( $this->import_keys as $old_key => $new_key ) {
+ $this->maybe_save_post_meta( $new_key, $meta[ $old_key ], $post_id );
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-greg-high-performance-seo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-greg-high-performance-seo.php
new file mode 100644
index 00000000..8925421f
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-greg-high-performance-seo.php
@@ -0,0 +1,42 @@
+ '_ghpseo_alternative_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_ghpseo_secondary_title',
+ 'new_key' => 'title',
+ ],
+ ];
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-headspace.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-headspace.php
new file mode 100644
index 00000000..3a43d169
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-headspace.php
@@ -0,0 +1,54 @@
+ '_headspace_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_headspace_page_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_headspace_noindex',
+ 'new_key' => 'meta-robots-noindex',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ [
+ 'old_key' => '_headspace_nofollow',
+ 'new_key' => 'meta-robots-nofollow',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ ];
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-jetpack.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-jetpack.php
new file mode 100644
index 00000000..5f57d816
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-jetpack.php
@@ -0,0 +1,40 @@
+ 'advanced_seo_description',
+ 'new_key' => 'metadesc',
+ ],
+ ];
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-platinum-seo-pack.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-platinum-seo-pack.php
new file mode 100644
index 00000000..16a5ce9e
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-platinum-seo-pack.php
@@ -0,0 +1,138 @@
+ 'description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => 'title',
+ 'new_key' => 'title',
+ ],
+ ];
+
+ /**
+ * Runs the import of post meta keys stored by Platinum SEO Pack.
+ *
+ * @return bool
+ */
+ protected function import() {
+ $return = parent::import();
+ if ( $return ) {
+ $this->import_robots_meta();
+ }
+
+ return $return;
+ }
+
+ /**
+ * Cleans up all the meta values Platinum SEO pack creates.
+ *
+ * @return bool
+ */
+ protected function cleanup() {
+ $this->meta_key = 'title';
+ parent::cleanup();
+
+ $this->meta_key = 'description';
+ parent::cleanup();
+
+ $this->meta_key = 'metarobots';
+ parent::cleanup();
+
+ return true;
+ }
+
+ /**
+ * Finds all the robotsmeta fields to import and deals with them.
+ *
+ * There are four potential values that Platinum SEO stores:
+ * - index,folllow
+ * - index,nofollow
+ * - noindex,follow
+ * - noindex,nofollow
+ *
+ * We only have to deal with the latter 3, the first is our default.
+ *
+ * @return void
+ */
+ protected function import_robots_meta() {
+ $this->import_by_meta_robots( 'index,nofollow', [ 'nofollow' ] );
+ $this->import_by_meta_robots( 'noindex,follow', [ 'noindex' ] );
+ $this->import_by_meta_robots( 'noindex,nofollow', [ 'noindex', 'nofollow' ] );
+ }
+
+ /**
+ * Imports the values for all index, nofollow posts.
+ *
+ * @param string $value The meta robots value to find posts for.
+ * @param array $metas The meta field(s) to save.
+ *
+ * @return void
+ */
+ protected function import_by_meta_robots( $value, $metas ) {
+ $posts = $this->find_posts_by_robots_meta( $value );
+ if ( ! $posts ) {
+ return;
+ }
+
+ foreach ( $posts as $post_id ) {
+ foreach ( $metas as $meta ) {
+ $this->maybe_save_post_meta( 'meta-robots-' . $meta, 1, $post_id );
+ }
+ }
+ }
+
+ /**
+ * Finds posts by a given meta robots value.
+ *
+ * @param string $meta_value Robots meta value.
+ *
+ * @return array|bool Array of Post IDs on success, false on failure.
+ */
+ protected function find_posts_by_robots_meta( $meta_value ) {
+ $posts = get_posts(
+ [
+ 'post_type' => 'any',
+ 'meta_key' => 'robotsmeta',
+ 'meta_value' => $meta_value,
+ 'order' => 'ASC',
+ 'fields' => 'ids',
+ 'nopaging' => true,
+ ]
+ );
+ if ( empty( $posts ) ) {
+ return false;
+ }
+ return $posts;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-premium-seo-pack.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-premium-seo-pack.php
new file mode 100644
index 00000000..bd93b91e
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-premium-seo-pack.php
@@ -0,0 +1,39 @@
+table_name = $wpdb->prefix . 'psp';
+ $this->meta_key = '';
+ }
+
+ /**
+ * Returns the query to return an identifier for the posts to import.
+ *
+ * @return string
+ */
+ protected function retrieve_posts_query() {
+ return "SELECT URL AS identifier FROM {$this->table_name} WHERE blog_id = %d";
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-rankmath.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-rankmath.php
new file mode 100644
index 00000000..68e7c0c1
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-rankmath.php
@@ -0,0 +1,179 @@
+ 'rank_math_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => 'rank_math_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => 'rank_math_canonical_url',
+ 'new_key' => 'canonical',
+ ],
+ [
+ 'old_key' => 'rank_math_primary_category',
+ 'new_key' => 'primary_category',
+ ],
+ [
+ 'old_key' => 'rank_math_facebook_title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => 'rank_math_facebook_description',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => 'rank_math_facebook_image',
+ 'new_key' => 'opengraph-image',
+ ],
+ [
+ 'old_key' => 'rank_math_facebook_image_id',
+ 'new_key' => 'opengraph-image-id',
+ ],
+ [
+ 'old_key' => 'rank_math_twitter_title',
+ 'new_key' => 'twitter-title',
+ ],
+ [
+ 'old_key' => 'rank_math_twitter_description',
+ 'new_key' => 'twitter-description',
+ ],
+ [
+ 'old_key' => 'rank_math_twitter_image',
+ 'new_key' => 'twitter-image',
+ ],
+ [
+ 'old_key' => 'rank_math_twitter_image_id',
+ 'new_key' => 'twitter-image-id',
+ ],
+ [
+ 'old_key' => 'rank_math_focus_keyword',
+ 'new_key' => 'focuskw',
+ ],
+ ];
+
+ /**
+ * Handles post meta data to import.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ global $wpdb;
+ // Replace % with %% as their variables are the same except for that.
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = REPLACE( meta_value, '%', '%%' ) WHERE meta_key IN ( 'rank_math_description', 'rank_math_title' )" );
+
+ $this->import_meta_robots();
+ $return = $this->meta_keys_clone( $this->clone_keys );
+
+ // Return %% to % so our import is non-destructive.
+ $wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = REPLACE( meta_value, '%%', '%' ) WHERE meta_key IN ( 'rank_math_description', 'rank_math_title' )" );
+
+ if ( $return ) {
+ $this->import_settings();
+ }
+
+ return $return;
+ }
+
+ /**
+ * RankMath stores robots meta quite differently, so we have to parse it out.
+ *
+ * @return void
+ */
+ private function import_meta_robots() {
+ global $wpdb;
+ $post_metas = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = 'rank_math_robots'" );
+ foreach ( $post_metas as $post_meta ) {
+ // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- Reason: We can't control the form in which Rankmath sends the data.
+ $robots_values = unserialize( $post_meta->meta_value );
+ foreach ( [ 'noindex', 'nofollow' ] as $directive ) {
+ $directive_key = array_search( $directive, $robots_values, true );
+ if ( $directive_key !== false ) {
+ update_post_meta( $post_meta->post_id, '_yoast_wpseo_meta-robots-' . $directive, 1 );
+ unset( $robots_values[ $directive_key ] );
+ }
+ }
+ if ( count( $robots_values ) > 0 ) {
+ $value = implode( ',', $robots_values );
+ update_post_meta( $post_meta->post_id, '_yoast_wpseo_meta-robots-adv', $value );
+ }
+ }
+ }
+
+ /**
+ * Imports some of the RankMath settings.
+ *
+ * @return void
+ */
+ private function import_settings() {
+ $settings = [
+ 'title_separator' => 'separator',
+ 'homepage_title' => 'title-home-wpseo',
+ 'homepage_description' => 'metadesc-home-wpseo',
+ 'author_archive_title' => 'title-author-wpseo',
+ 'date_archive_title' => 'title-archive-wpseo',
+ 'search_title' => 'title-search-wpseo',
+ '404_title' => 'title-404-wpseo',
+ 'pt_post_title' => 'title-post',
+ 'pt_page_title' => 'title-page',
+ ];
+ $options = get_option( 'rank-math-options-titles' );
+
+ foreach ( $settings as $import_setting_key => $setting_key ) {
+ if ( ! empty( $options[ $import_setting_key ] ) ) {
+ $value = $options[ $import_setting_key ];
+ // Make sure replace vars work.
+ $value = str_replace( '%', '%%', $value );
+ WPSEO_Options::set( $setting_key, $value );
+ }
+ }
+ }
+
+ /**
+ * Removes the plugin data from the database.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ $return = parent::cleanup();
+ if ( $return ) {
+ global $wpdb;
+ $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'rank-math-%'" );
+ $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '%rank_math%'" );
+ }
+
+ return $return;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seo-framework.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seo-framework.php
new file mode 100644
index 00000000..8a8ac9e1
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seo-framework.php
@@ -0,0 +1,94 @@
+ '_genesis_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_genesis_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_genesis_noindex',
+ 'new_key' => 'meta-robots-noindex',
+ ],
+ [
+ 'old_key' => '_genesis_nofollow',
+ 'new_key' => 'meta-robots-nofollow',
+ ],
+ [
+ 'old_key' => '_genesis_canonical_uri',
+ 'new_key' => 'canonical',
+ ],
+ [
+ 'old_key' => '_open_graph_title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => '_open_graph_description',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => '_social_image_url',
+ 'new_key' => 'opengraph-image',
+ ],
+ [
+ 'old_key' => '_twitter_title',
+ 'new_key' => 'twitter-title',
+ ],
+ [
+ 'old_key' => '_twitter_description',
+ 'new_key' => 'twitter-description',
+ ],
+ ];
+
+ /**
+ * Removes all the metadata set by the SEO Framework plugin.
+ *
+ * @return bool
+ */
+ protected function cleanup() {
+ $set1 = parent::cleanup();
+
+ $this->meta_key = '_social_image_%';
+ $set2 = parent::cleanup();
+
+ $this->meta_key = '_twitter_%';
+ $set3 = parent::cleanup();
+
+ $this->meta_key = '_open_graph_%';
+ $set4 = parent::cleanup();
+
+ return ( $set1 || $set2 || $set3 || $set4 );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seopressor.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seopressor.php
new file mode 100644
index 00000000..4009c798
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-seopressor.php
@@ -0,0 +1,175 @@
+ '_seop_settings',
+ ],
+ ];
+
+ /**
+ * Imports the post meta values to Yoast SEO.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ // Query for all the posts that have an _seop_settings meta set.
+ $query_posts = new WP_Query( 'post_type=any&meta_key=_seop_settings&order=ASC&fields=ids&nopaging=true' );
+ foreach ( $query_posts->posts as $post_id ) {
+ $this->import_post_focus_keywords( $post_id );
+ $this->import_seopressor_post_settings( $post_id );
+ }
+
+ return true;
+ }
+
+ /**
+ * Removes all the post meta fields SEOpressor creates.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ global $wpdb;
+
+ // If we get to replace the data, let's do some proper cleanup.
+ return $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_seop_%'" );
+ }
+
+ /**
+ * Imports the data. SEOpressor stores most of the data in one post array, this loops over it.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function import_seopressor_post_settings( $post_id ) {
+ $settings = get_post_meta( $post_id, '_seop_settings', true );
+
+ foreach (
+ [
+ 'fb_description' => 'opengraph-description',
+ 'fb_title' => 'opengraph-title',
+ 'fb_type' => 'og_type',
+ 'fb_img' => 'opengraph-image',
+ 'meta_title' => 'title',
+ 'meta_description' => 'metadesc',
+ 'meta_canonical' => 'canonical',
+ 'tw_description' => 'twitter-description',
+ 'tw_title' => 'twitter-title',
+ 'tw_image' => 'twitter-image',
+ ] as $seopressor_key => $yoast_key ) {
+ $this->import_meta_helper( $seopressor_key, $yoast_key, $settings, $post_id );
+ }
+
+ if ( isset( $settings['meta_rules'] ) ) {
+ $this->import_post_robots( $settings['meta_rules'], $post_id );
+ }
+ }
+
+ /**
+ * Imports the focus keywords, and stores them for later use.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return void
+ */
+ private function import_post_focus_keywords( $post_id ) {
+ // Import the focus keyword.
+ $focuskw = trim( get_post_meta( $post_id, '_seop_kw_1', true ) );
+ $this->maybe_save_post_meta( 'focuskw', $focuskw, $post_id );
+
+ // Import additional focus keywords for use in premium.
+ $focuskw2 = trim( get_post_meta( $post_id, '_seop_kw_2', true ) );
+ $focuskw3 = trim( get_post_meta( $post_id, '_seop_kw_3', true ) );
+
+ $focus_keywords = [];
+ if ( ! empty( $focuskw2 ) ) {
+ $focus_keywords[] = $focuskw2;
+ }
+ if ( ! empty( $focuskw3 ) ) {
+ $focus_keywords[] = $focuskw3;
+ }
+
+ if ( $focus_keywords !== [] ) {
+ $this->maybe_save_post_meta( 'focuskeywords', WPSEO_Utils::format_json_encode( $focus_keywords ), $post_id );
+ }
+ }
+
+ /**
+ * Retrieves the SEOpressor robot value and map this to Yoast SEO values.
+ *
+ * @param string $meta_rules The meta rules taken from the SEOpressor settings array.
+ * @param int $post_id The post id of the current post.
+ *
+ * @return void
+ */
+ private function import_post_robots( $meta_rules, $post_id ) {
+ $seopressor_robots = explode( '#|#|#', $meta_rules );
+ $robot_value = $this->get_robot_value( $seopressor_robots );
+
+ // Saving the new meta values for Yoast SEO.
+ $this->maybe_save_post_meta( 'meta-robots-noindex', $robot_value['index'], $post_id );
+ $this->maybe_save_post_meta( 'meta-robots-nofollow', $robot_value['follow'], $post_id );
+ $this->maybe_save_post_meta( 'meta-robots-adv', $robot_value['advanced'], $post_id );
+ }
+
+ /**
+ * Gets the robot config by given SEOpressor robots value.
+ *
+ * @param array $seopressor_robots The value in SEOpressor that needs to be converted to the Yoast format.
+ *
+ * @return array The robots values in Yoast format.
+ */
+ private function get_robot_value( $seopressor_robots ) {
+ $return = [
+ 'index' => 2,
+ 'follow' => 0,
+ 'advanced' => '',
+ ];
+
+ if ( in_array( 'noindex', $seopressor_robots, true ) ) {
+ $return['index'] = 1;
+ }
+ if ( in_array( 'nofollow', $seopressor_robots, true ) ) {
+ $return['follow'] = 1;
+ }
+ foreach ( [ 'noarchive', 'nosnippet', 'noimageindex' ] as $needle ) {
+ if ( in_array( $needle, $seopressor_robots, true ) ) {
+ $return['advanced'] .= $needle . ',';
+ }
+ }
+ $return['advanced'] = rtrim( $return['advanced'], ',' );
+
+ return $return;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-smartcrawl.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-smartcrawl.php
new file mode 100644
index 00000000..507120c6
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-smartcrawl.php
@@ -0,0 +1,151 @@
+ '_wds_metadesc',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_wds_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_wds_canonical',
+ 'new_key' => 'canonical',
+ ],
+ [
+ 'old_key' => '_wds_focus-keywords',
+ 'new_key' => 'focuskw',
+ ],
+ [
+ 'old_key' => '_wds_meta-robots-noindex',
+ 'new_key' => 'meta-robots-noindex',
+ ],
+ [
+ 'old_key' => '_wds_meta-robots-nofollow',
+ 'new_key' => 'meta-robots-nofollow',
+ ],
+ ];
+
+ /**
+ * Used for importing Twitter and Facebook meta's.
+ *
+ * @var array
+ */
+ protected $social_keys = [];
+
+ /**
+ * Handles post meta data to import.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ $return = parent::import();
+ if ( $return ) {
+ $this->import_opengraph();
+ $this->import_twitter();
+ }
+
+ return $return;
+ }
+
+ /**
+ * Imports the OpenGraph meta keys saved by Smartcrawl.
+ *
+ * @return bool Import status.
+ */
+ protected function import_opengraph() {
+ $this->social_keys = [
+ 'title' => 'opengraph-title',
+ 'description' => 'opengraph-description',
+ 'images' => 'opengraph-image',
+ ];
+ return $this->post_find_import( '_wds_opengraph' );
+ }
+
+ /**
+ * Imports the Twitter meta keys saved by Smartcrawl.
+ *
+ * @return bool Import status.
+ */
+ protected function import_twitter() {
+ $this->social_keys = [
+ 'title' => 'twitter-title',
+ 'description' => 'twitter-description',
+ ];
+ return $this->post_find_import( '_wds_twitter' );
+ }
+
+ /**
+ * Imports a post's serialized post meta values.
+ *
+ * @param int $post_id Post ID.
+ * @param string $key The meta key to import.
+ *
+ * @return void
+ */
+ protected function import_serialized_post_meta( $post_id, $key ) {
+ $data = get_post_meta( $post_id, $key, true );
+ $data = maybe_unserialize( $data );
+ foreach ( $this->social_keys as $key => $meta_key ) {
+ if ( ! isset( $data[ $key ] ) ) {
+ return;
+ }
+ $value = $data[ $key ];
+ if ( is_array( $value ) ) {
+ $value = $value[0];
+ }
+ $this->maybe_save_post_meta( $meta_key, $value, $post_id );
+ }
+ }
+
+ /**
+ * Finds all the posts with a certain meta key and imports its values.
+ *
+ * @param string $key The meta key to search for.
+ *
+ * @return bool Import status.
+ */
+ protected function post_find_import( $key ) {
+ $query_posts = new WP_Query( 'post_type=any&meta_key=' . $key . '&order=ASC&fields=ids&nopaging=true' );
+
+ if ( empty( $query_posts->posts ) ) {
+ return false;
+ }
+
+ foreach ( array_values( $query_posts->posts ) as $post_id ) {
+ $this->import_serialized_post_meta( $post_id, $key );
+ }
+
+ return true;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-squirrly.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-squirrly.php
new file mode 100644
index 00000000..2c088e26
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-squirrly.php
@@ -0,0 +1,224 @@
+ 'meta-robots-noindex',
+ 'nofollow' => 'meta-robots-nofollow',
+ 'title' => 'title',
+ 'description' => 'metadesc',
+ 'canonical' => 'canonical',
+ 'cornerstone' => '_yst_is_cornerstone',
+ 'tw_media' => 'twitter-image',
+ 'tw_title' => 'twitter-title',
+ 'tw_description' => 'twitter-description',
+ 'og_title' => 'opengraph-title',
+ 'og_description' => 'opengraph-description',
+ 'og_media' => 'opengraph-image',
+ 'focuskw' => 'focuskw',
+ ];
+
+ /**
+ * WPSEO_Import_Squirrly constructor.
+ */
+ public function __construct() {
+ parent::__construct();
+
+ global $wpdb;
+ $this->table_name = $wpdb->prefix . 'qss';
+ }
+
+ /**
+ * Imports the post meta values to Yoast SEO.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ $results = $this->retrieve_posts();
+ foreach ( $results as $post ) {
+ $return = $this->import_post_values( $post->identifier );
+ if ( ! $return ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Retrieve the posts from the Squirrly Database.
+ *
+ * @return array Array of post IDs from the DB.
+ */
+ protected function retrieve_posts() {
+ global $wpdb;
+ return $wpdb->get_results(
+ $wpdb->prepare(
+ $this->retrieve_posts_query(),
+ get_current_blog_id()
+ )
+ );
+ }
+
+ /**
+ * Returns the query to return an identifier for the posts to import.
+ *
+ * @return string Query to get post ID's from the DB.
+ */
+ protected function retrieve_posts_query() {
+ return "SELECT post_id AS identifier FROM {$this->table_name} WHERE blog_id = %d";
+ }
+
+ /**
+ * Removes the DB table and the post meta field Squirrly creates.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ global $wpdb;
+
+ // If we can clean, let's clean.
+ $wpdb->query( "DROP TABLE {$this->table_name}" );
+
+ // This removes the post meta field for the focus keyword from the DB.
+ parent::cleanup();
+
+ // If we can still see the table, something went wrong.
+ if ( $this->detect() ) {
+ $this->cleanup_error_msg();
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Detects whether there is post meta data to import.
+ *
+ * @return bool Boolean indicating whether there is something to import.
+ */
+ protected function detect() {
+ global $wpdb;
+
+ $result = $wpdb->get_var( "SHOW TABLES LIKE '{$this->table_name}'" );
+ if ( is_wp_error( $result ) || is_null( $result ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Imports the data of a post out of Squirrly's DB table.
+ *
+ * @param mixed $post_identifier Post identifier, can be ID or string.
+ *
+ * @return bool Import status.
+ */
+ private function import_post_values( $post_identifier ) {
+ $data = $this->retrieve_post_data( $post_identifier );
+ if ( ! $data ) {
+ return false;
+ }
+
+ if ( ! is_numeric( $post_identifier ) ) {
+ $post_id = url_to_postid( $post_identifier );
+ }
+
+ if ( is_numeric( $post_identifier ) ) {
+ $post_id = (int) $post_identifier;
+ $data['focuskw'] = $this->maybe_add_focus_kw( $post_identifier );
+ }
+
+ foreach ( $this->seo_field_keys as $squirrly_key => $yoast_key ) {
+ $this->import_meta_helper( $squirrly_key, $yoast_key, $data, $post_id );
+ }
+ return true;
+ }
+
+ /**
+ * Retrieves the Squirrly SEO data for a post from the DB.
+ *
+ * @param int $post_identifier Post ID.
+ *
+ * @return array|bool Array of data or false.
+ */
+ private function retrieve_post_data( $post_identifier ) {
+ global $wpdb;
+
+ if ( is_numeric( $post_identifier ) ) {
+ $post_identifier = (int) $post_identifier;
+ $query_where = 'post_id = %d';
+ }
+ if ( ! is_numeric( $post_identifier ) ) {
+ $query_where = 'URL = %s';
+ }
+
+ $replacements = [
+ get_current_blog_id(),
+ $post_identifier,
+ ];
+
+ $data = $wpdb->get_var(
+ $wpdb->prepare(
+ "SELECT seo FROM {$this->table_name} WHERE blog_id = %d AND " . $query_where,
+ $replacements
+ )
+ );
+ if ( ! $data || is_wp_error( $data ) ) {
+ return false;
+ }
+ $data = maybe_unserialize( $data );
+ return $data;
+ }
+
+ /**
+ * Squirrly stores the focus keyword in post meta.
+ *
+ * @param int $post_id Post ID.
+ *
+ * @return string The focus keyword.
+ */
+ private function maybe_add_focus_kw( $post_id ) {
+ $focuskw = get_post_meta( $post_id, '_sq_post_keyword', true );
+ if ( $focuskw ) {
+ $focuskw = json_decode( $focuskw );
+ return $focuskw->keyword;
+ }
+ return '';
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-ultimate-seo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-ultimate-seo.php
new file mode 100644
index 00000000..a5113650
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-ultimate-seo.php
@@ -0,0 +1,64 @@
+ '_su_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_su_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_su_og_title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => '_su_og_description',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => '_su_og_image',
+ 'new_key' => 'opengraph-image',
+ ],
+ [
+ 'old_key' => '_su_meta_robots_noindex',
+ 'new_key' => 'meta-robots-noindex',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ [
+ 'old_key' => '_su_meta_robots_nofollow',
+ 'new_key' => 'meta-robots-nofollow',
+ 'convert' => [ 'on' => 1 ],
+ ],
+ ];
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-woothemes-seo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-woothemes-seo.php
new file mode 100644
index 00000000..5ee943c3
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-woothemes-seo.php
@@ -0,0 +1,138 @@
+ 'seo_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => 'seo_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => 'seo_noindex',
+ 'new_key' => 'meta-robots-noindex',
+ ],
+ [
+ 'old_key' => 'seo_follow',
+ 'new_key' => 'meta-robots-nofollow',
+ ],
+ ];
+
+ /**
+ * Holds the meta fields we can delete after import.
+ *
+ * @var array
+ */
+ protected $cleanup_metas = [
+ 'seo_follow',
+ 'seo_noindex',
+ 'seo_title',
+ 'seo_description',
+ 'seo_keywords',
+ ];
+
+ /**
+ * Holds the options we can delete after import.
+ *
+ * @var array
+ */
+ protected $cleanup_options = [
+ 'seo_woo_archive_layout',
+ 'seo_woo_single_layout',
+ 'seo_woo_page_layout',
+ 'seo_woo_wp_title',
+ 'seo_woo_meta_single_desc',
+ 'seo_woo_meta_single_key',
+ 'seo_woo_home_layout',
+ ];
+
+ /**
+ * Cleans up the WooThemes SEO settings.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ $result = $this->cleanup_meta();
+ if ( $result ) {
+ $this->cleanup_options();
+ }
+ return $result;
+ }
+
+ /**
+ * Removes the Woo Options from the database.
+ *
+ * @return void
+ */
+ private function cleanup_options() {
+ foreach ( $this->cleanup_options as $option ) {
+ delete_option( $option );
+ }
+ }
+
+ /**
+ * Removes the post meta fields from the database.
+ *
+ * @return bool Cleanup status.
+ */
+ private function cleanup_meta() {
+ foreach ( $this->cleanup_metas as $key ) {
+ $result = $this->cleanup_meta_key( $key );
+ if ( ! $result ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Removes a single meta field from the postmeta table in the database.
+ *
+ * @param string $key The meta_key to delete.
+ *
+ * @return bool Cleanup status.
+ */
+ private function cleanup_meta_key( $key ) {
+ global $wpdb;
+
+ $wpdb->query(
+ $wpdb->prepare(
+ "DELETE FROM {$wpdb->postmeta} WHERE meta_key = %s",
+ $key
+ )
+ );
+ return $wpdb->__get( 'result' );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wp-meta-seo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wp-meta-seo.php
new file mode 100644
index 00000000..e6a55efb
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wp-meta-seo.php
@@ -0,0 +1,82 @@
+ '_metaseo_metadesc',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_metaseo_metatitle',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_metaseo_metaopengraph-title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => '_metaseo_metaopengraph-desc',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => '_metaseo_metaopengraph-image',
+ 'new_key' => 'opengraph-image',
+ ],
+ [
+ 'old_key' => '_metaseo_metatwitter-title',
+ 'new_key' => 'twitter-title',
+ ],
+ [
+ 'old_key' => '_metaseo_metatwitter-desc',
+ 'new_key' => 'twitter-description',
+ ],
+ [
+ 'old_key' => '_metaseo_metatwitter-image',
+ 'new_key' => 'twitter-image',
+ ],
+ [
+ 'old_key' => '_metaseo_metaindex',
+ 'new_key' => 'meta-robots-noindex',
+ 'convert' => [
+ 'index' => 0,
+ 'noindex' => 1,
+ ],
+ ],
+ [
+ 'old_key' => '_metaseo_metafollow',
+ 'new_key' => 'meta-robots-nofollow',
+ 'convert' => [
+ 'follow' => 0,
+ 'nofollow' => 1,
+ ],
+ ],
+ ];
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wpseo.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wpseo.php
new file mode 100644
index 00000000..0d138f2b
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-import-wpseo.php
@@ -0,0 +1,310 @@
+ '_wpseo_edit_description',
+ 'new_key' => 'metadesc',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_title',
+ 'new_key' => 'title',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_canonical',
+ 'new_key' => 'canonical',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_og_title',
+ 'new_key' => 'opengraph-title',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_og_description',
+ 'new_key' => 'opengraph-description',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_og_image',
+ 'new_key' => 'opengraph-image',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_twittercard_title',
+ 'new_key' => 'twitter-title',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_twittercard_description',
+ 'new_key' => 'twitter-description',
+ ],
+ [
+ 'old_key' => '_wpseo_edit_twittercard_image',
+ 'new_key' => 'twitter-image',
+ ],
+ ];
+
+ /**
+ * The values 1 - 6 are the configured values from wpSEO. This array will map the values of wpSEO to our values.
+ *
+ * There are some double array like 1-6 and 3-4. The reason is they only set the index value. The follow value is
+ * the default we use in the cases there isn't a follow value present.
+ *
+ * @var array
+ */
+ private $robot_values = [
+ // In wpSEO: index, follow.
+ 1 => [
+ 'index' => 2,
+ 'follow' => 0,
+ ],
+ // In wpSEO: index, nofollow.
+ 2 => [
+ 'index' => 2,
+ 'follow' => 1,
+ ],
+ // In wpSEO: noindex.
+ 3 => [
+ 'index' => 1,
+ 'follow' => 0,
+ ],
+ // In wpSEO: noindex, follow.
+ 4 => [
+ 'index' => 1,
+ 'follow' => 0,
+ ],
+ // In wpSEO: noindex, nofollow.
+ 5 => [
+ 'index' => 1,
+ 'follow' => 1,
+ ],
+ // In wpSEO: index.
+ 6 => [
+ 'index' => 2,
+ 'follow' => 0,
+ ],
+ ];
+
+ /**
+ * Imports wpSEO settings.
+ *
+ * @return bool Import success status.
+ */
+ protected function import() {
+ $status = parent::import();
+ if ( $status ) {
+ $this->import_post_robots();
+ $this->import_taxonomy_metas();
+ }
+
+ return $status;
+ }
+
+ /**
+ * Removes wpseo.de post meta's.
+ *
+ * @return bool Cleanup status.
+ */
+ protected function cleanup() {
+ $this->cleanup_term_meta();
+ $result = $this->cleanup_post_meta();
+ return $result;
+ }
+
+ /**
+ * Detects whether there is post meta data to import.
+ *
+ * @return bool Boolean indicating whether there is something to import.
+ */
+ protected function detect() {
+ if ( parent::detect() ) {
+ return true;
+ }
+
+ global $wpdb;
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->options} WHERE option_name LIKE 'wpseo_category_%'" );
+ if ( $count !== '0' ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Imports the robot values from WPSEO plugin. These have to be converted to the Yoast format.
+ *
+ * @return void
+ */
+ private function import_post_robots() {
+ $query_posts = new WP_Query( 'post_type=any&meta_key=_wpseo_edit_robots&order=ASC&fields=ids&nopaging=true' );
+
+ if ( ! empty( $query_posts->posts ) ) {
+ foreach ( array_values( $query_posts->posts ) as $post_id ) {
+ $this->import_post_robot( $post_id );
+ }
+ }
+ }
+
+ /**
+ * Gets the wpSEO robot value and map this to Yoast SEO values.
+ *
+ * @param int $post_id The post id of the current post.
+ *
+ * @return void
+ */
+ private function import_post_robot( $post_id ) {
+ $wpseo_robots = get_post_meta( $post_id, '_wpseo_edit_robots', true );
+ $robot_value = $this->get_robot_value( $wpseo_robots );
+
+ // Saving the new meta values for Yoast SEO.
+ $this->maybe_save_post_meta( 'meta-robots-noindex', $robot_value['index'], $post_id );
+ $this->maybe_save_post_meta( 'meta-robots-nofollow', $robot_value['follow'], $post_id );
+ }
+
+ /**
+ * Imports the taxonomy metas from wpSEO.
+ *
+ * @return void
+ */
+ private function import_taxonomy_metas() {
+ $terms = get_terms(
+ [
+ 'taxonomy' => get_taxonomies(),
+ 'hide_empty' => false,
+ ]
+ );
+ $tax_meta = get_option( 'wpseo_taxonomy_meta' );
+
+ foreach ( $terms as $term ) {
+ $this->import_taxonomy_description( $tax_meta, $term->taxonomy, $term->term_id );
+ $this->import_taxonomy_robots( $tax_meta, $term->taxonomy, $term->term_id );
+ }
+
+ update_option( 'wpseo_taxonomy_meta', $tax_meta );
+ }
+
+ /**
+ * Imports the meta description to Yoast SEO.
+ *
+ * @param array $tax_meta The array with the current metadata.
+ * @param string $taxonomy String with the name of the taxonomy.
+ * @param string $term_id The ID of the current term.
+ *
+ * @return void
+ */
+ private function import_taxonomy_description( &$tax_meta, $taxonomy, $term_id ) {
+ $description = get_option( 'wpseo_' . $taxonomy . '_' . $term_id, false );
+ if ( $description !== false ) {
+ // Import description.
+ $tax_meta[ $taxonomy ][ $term_id ]['wpseo_desc'] = $description;
+ }
+ }
+
+ /**
+ * Imports the robot value to Yoast SEO.
+ *
+ * @param array $tax_meta The array with the current metadata.
+ * @param string $taxonomy String with the name of the taxonomy.
+ * @param string $term_id The ID of the current term.
+ *
+ * @return void
+ */
+ private function import_taxonomy_robots( &$tax_meta, $taxonomy, $term_id ) {
+ $wpseo_robots = get_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots', false );
+ if ( $wpseo_robots === false ) {
+ return;
+ }
+ // The value 1, 2 and 6 are the index values in wpSEO.
+ $new_robot_value = 'noindex';
+
+ if ( in_array( (int) $wpseo_robots, [ 1, 2, 6 ], true ) ) {
+ $new_robot_value = 'index';
+ }
+
+ $tax_meta[ $taxonomy ][ $term_id ]['wpseo_noindex'] = $new_robot_value;
+ }
+
+ /**
+ * Deletes the wpSEO taxonomy meta data.
+ *
+ * @param string $taxonomy String with the name of the taxonomy.
+ * @param string $term_id The ID of the current term.
+ *
+ * @return void
+ */
+ private function delete_taxonomy_metas( $taxonomy, $term_id ) {
+ delete_option( 'wpseo_' . $taxonomy . '_' . $term_id );
+ delete_option( 'wpseo_' . $taxonomy . '_' . $term_id . '_robots' );
+ }
+
+ /**
+ * Gets the robot config by given wpSEO robots value.
+ *
+ * @param string $wpseo_robots The value in wpSEO that needs to be converted to the Yoast format.
+ *
+ * @return string The correct robot value.
+ */
+ private function get_robot_value( $wpseo_robots ) {
+ if ( array_key_exists( $wpseo_robots, $this->robot_values ) ) {
+ return $this->robot_values[ $wpseo_robots ];
+ }
+
+ return $this->robot_values[1];
+ }
+
+ /**
+ * Deletes wpSEO postmeta from the database.
+ *
+ * @return bool Cleanup status.
+ */
+ private function cleanup_post_meta() {
+ global $wpdb;
+
+ // If we get to replace the data, let's do some proper cleanup.
+ return $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '_wpseo_edit_%'" );
+ }
+
+ /**
+ * Cleans up the wpSEO term meta.
+ *
+ * @return void
+ */
+ private function cleanup_term_meta() {
+ $terms = get_terms(
+ [
+ 'taxonomy' => get_taxonomies(),
+ 'hide_empty' => false,
+ ]
+ );
+
+ foreach ( $terms as $term ) {
+ $this->delete_taxonomy_metas( $term->taxonomy, $term->term_id );
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/import/plugins/class-importers.php b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-importers.php
new file mode 100644
index 00000000..d2336ecd
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/import/plugins/class-importers.php
@@ -0,0 +1,47 @@
+get_manage_capability();
+ $page_identifier = $this->get_page_identifier();
+ $admin_page_callback = $this->get_admin_page_callback();
+
+ // Get all submenu pages.
+ $submenu_pages = $this->get_submenu_pages();
+
+ foreach ( $submenu_pages as $submenu_page ) {
+ if ( WPSEO_Capability_Utils::current_user_can( $submenu_page[3] ) ) {
+ $manage_capability = $submenu_page[3];
+ $page_identifier = $submenu_page[4];
+ $admin_page_callback = $submenu_page[5];
+ break;
+ }
+ }
+
+ foreach ( $submenu_pages as $index => $submenu_page ) {
+ $submenu_pages[ $index ][0] = $page_identifier;
+ }
+
+ /*
+ * The current user has the capability to control anything.
+ * This means that all submenus and dashboard can be shown.
+ */
+ global $admin_page_hooks;
+
+ add_menu_page(
+ 'Yoast SEO: ' . __( 'Dashboard', 'wordpress-seo' ),
+ 'Yoast SEO ' . $this->get_notification_counter(),
+ $manage_capability,
+ $page_identifier,
+ $admin_page_callback,
+ $this->get_icon_svg(),
+ 99
+ );
+
+ // Wipe notification bits from hooks.
+ // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- This is a deliberate action.
+ $admin_page_hooks[ $page_identifier ] = 'seo';
+
+ // Add submenu items to the main menu if possible.
+ $this->register_submenu_pages( $submenu_pages );
+ }
+
+ /**
+ * Returns the list of registered submenu pages.
+ *
+ * @return array List of registered submenu pages.
+ */
+ public function get_submenu_pages() {
+ global $wpseo_admin;
+
+ $search_console_callback = null;
+
+ // Account for when the available submenu pages are requested from outside the admin.
+ if ( isset( $wpseo_admin ) ) {
+ $google_search_console = new WPSEO_GSC();
+ $search_console_callback = [ $google_search_console, 'display' ];
+ }
+
+ // Submenu pages.
+ $submenu_pages = [
+ $this->get_submenu_page( __( 'General', 'wordpress-seo' ), $this->get_page_identifier() ),
+ $this->get_submenu_page(
+ __( 'Search Console', 'wordpress-seo' ),
+ 'wpseo_search_console',
+ $search_console_callback
+ ),
+ $this->get_submenu_page( __( 'Tools', 'wordpress-seo' ), 'wpseo_tools' ),
+ $this->get_submenu_page( $this->get_license_page_title(), 'wpseo_licenses' ),
+ ];
+
+ /**
+ * Filter: 'wpseo_submenu_pages' - Collects all submenus that need to be shown.
+ *
+ * @param array $submenu_pages List with all submenu pages.
+ */
+ return (array) apply_filters( 'wpseo_submenu_pages', $submenu_pages );
+ }
+
+ /**
+ * Returns the notification count in HTML format.
+ *
+ * @return string The notification count in HTML format.
+ */
+ protected function get_notification_counter() {
+ $notification_center = Yoast_Notification_Center::get();
+ $notification_count = $notification_center->get_notification_count();
+
+ // Add main page.
+ /* translators: Hidden accessibility text; %s: number of notifications. */
+ $notifications = sprintf( _n( '%s notification', '%s notifications', $notification_count, 'wordpress-seo' ), number_format_i18n( $notification_count ) );
+
+ return sprintf( '%1$d%2$s', $notification_count, $notifications );
+ }
+
+ /**
+ * Returns the capability that is required to manage all options.
+ *
+ * @return string Capability to check against.
+ */
+ protected function get_manage_capability() {
+ return 'wpseo_manage_options';
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-base-menu.php b/wp-content/plugins/wordpress-seo/admin/menu/class-base-menu.php
new file mode 100644
index 00000000..1d91eaa8
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-base-menu.php
@@ -0,0 +1,287 @@
+menu = $menu;
+ }
+
+ /**
+ * Returns the list of registered submenu pages.
+ *
+ * @return array List of registered submenu pages.
+ */
+ abstract public function get_submenu_pages();
+
+ /**
+ * Creates a submenu formatted array.
+ *
+ * @param string $page_title Page title to use.
+ * @param string $page_slug Page slug to use.
+ * @param callable|null $callback Optional. Callback which handles the page request.
+ * @param callable[]|null $hook Optional. Hook to trigger when the page is registered.
+ *
+ * @return array Formatted submenu.
+ */
+ protected function get_submenu_page( $page_title, $page_slug, $callback = null, $hook = null ) {
+ if ( $callback === null ) {
+ $callback = $this->get_admin_page_callback();
+ }
+
+ return [
+ $this->get_page_identifier(),
+ '',
+ $page_title,
+ $this->get_manage_capability(),
+ $page_slug,
+ $callback,
+ $hook,
+ ];
+ }
+
+ /**
+ * Registers submenu pages as menu pages.
+ *
+ * This method should only be used if the user does not have the required capabilities
+ * to access the parent menu page.
+ *
+ * @param array $submenu_pages List of submenu pages to register.
+ *
+ * @return void
+ */
+ protected function register_menu_pages( $submenu_pages ) {
+ if ( ! is_array( $submenu_pages ) || empty( $submenu_pages ) ) {
+ return;
+ }
+
+ // Loop through submenu pages and add them.
+ array_walk( $submenu_pages, [ $this, 'register_menu_page' ] );
+ }
+
+ /**
+ * Registers submenu pages.
+ *
+ * @param array $submenu_pages List of submenu pages to register.
+ *
+ * @return void
+ */
+ protected function register_submenu_pages( $submenu_pages ) {
+ if ( ! is_array( $submenu_pages ) || empty( $submenu_pages ) ) {
+ return;
+ }
+
+ // Loop through submenu pages and add them.
+ array_walk( $submenu_pages, [ $this, 'register_submenu_page' ] );
+ }
+
+ /**
+ * Registers a submenu page as a menu page.
+ *
+ * This method should only be used if the user does not have the required capabilities
+ * to access the parent menu page.
+ *
+ * @param array $submenu_page {
+ * Submenu page definition.
+ *
+ * @type string $0 Parent menu page slug.
+ * @type string $1 Page title, currently unused.
+ * @type string $2 Title to display in the menu.
+ * @type string $3 Required capability to access the page.
+ * @type string $4 Page slug.
+ * @type callable $5 Callback to run when the page is rendered.
+ * @type array $6 Optional. List of callbacks to run when the page is loaded.
+ * }
+ *
+ * @return void
+ */
+ protected function register_menu_page( $submenu_page ) {
+
+ // If the submenu page requires the general manage capability, it must be added as an actual submenu page.
+ if ( $submenu_page[3] === $this->get_manage_capability() ) {
+ return;
+ }
+
+ $page_title = 'Yoast SEO: ' . $submenu_page[2];
+
+ // Register submenu page as menu page.
+ $hook_suffix = add_menu_page(
+ $page_title,
+ $submenu_page[2],
+ $submenu_page[3],
+ $submenu_page[4],
+ $submenu_page[5],
+ $this->get_icon_svg(),
+ 99
+ );
+
+ // If necessary, add hooks for the submenu page.
+ if ( isset( $submenu_page[6] ) && ( is_array( $submenu_page[6] ) ) ) {
+ $this->add_page_hooks( $hook_suffix, $submenu_page[6] );
+ }
+ }
+
+ /**
+ * Registers a submenu page.
+ *
+ * This method will override the capability of the page to automatically use the
+ * general manage capability. Use the `register_menu_page()` method if the submenu
+ * page should actually use a different capability.
+ *
+ * @param array $submenu_page {
+ * Submenu page definition.
+ *
+ * @type string $0 Parent menu page slug.
+ * @type string $1 Page title, currently unused.
+ * @type string $2 Title to display in the menu.
+ * @type string $3 Required capability to access the page.
+ * @type string $4 Page slug.
+ * @type callable $5 Callback to run when the page is rendered.
+ * @type array $6 Optional. List of callbacks to run when the page is loaded.
+ * }
+ *
+ * @return void
+ */
+ protected function register_submenu_page( $submenu_page ) {
+ $page_title = $submenu_page[2];
+
+ // We cannot use $submenu_page[1] because add-ons define that, so hard-code this value.
+ if ( $submenu_page[4] === 'wpseo_licenses' ) {
+ $page_title = $this->get_license_page_title();
+ }
+
+ /*
+ * Handle the Google Search Console special case by passing a fake parent
+ * page slug. This way, the sub-page is stil registered and can be accessed
+ * directly. Its menu item won't be displayed.
+ */
+ if ( $submenu_page[4] === 'wpseo_search_console' ) {
+ // Set the parent page slug to a non-existing one.
+ $submenu_page[0] = 'wpseo_fake_menu_parent_page_slug';
+ }
+
+ $page_title .= ' - Yoast SEO';
+
+ // Register submenu page.
+ $hook_suffix = add_submenu_page(
+ $submenu_page[0],
+ $page_title,
+ $submenu_page[2],
+ $submenu_page[3],
+ $submenu_page[4],
+ $submenu_page[5]
+ );
+
+ // If necessary, add hooks for the submenu page.
+ if ( isset( $submenu_page[6] ) && ( is_array( $submenu_page[6] ) ) ) {
+ $this->add_page_hooks( $hook_suffix, $submenu_page[6] );
+ }
+ }
+
+ /**
+ * Adds hook callbacks for a given admin page hook suffix.
+ *
+ * @param string $hook_suffix Admin page hook suffix, as returned by `add_menu_page()`
+ * or `add_submenu_page()`.
+ * @param array $callbacks Callbacks to add.
+ *
+ * @return void
+ */
+ protected function add_page_hooks( $hook_suffix, array $callbacks ) {
+ foreach ( $callbacks as $callback ) {
+ add_action( 'load-' . $hook_suffix, $callback );
+ }
+ }
+
+ /**
+ * Gets the main admin page identifier.
+ *
+ * @return string Admin page identifier.
+ */
+ protected function get_page_identifier() {
+ return $this->menu->get_page_identifier();
+ }
+
+ /**
+ * Checks whether the current user has capabilities to manage all options.
+ *
+ * @return bool True if capabilities are sufficient, false otherwise.
+ */
+ protected function check_manage_capability() {
+ return WPSEO_Capability_Utils::current_user_can( $this->get_manage_capability() );
+ }
+
+ /**
+ * Returns the capability that is required to manage all options.
+ *
+ * @return string Capability to check against.
+ */
+ abstract protected function get_manage_capability();
+
+ /**
+ * Returns the page handler callback.
+ *
+ * @return array Callback page handler.
+ */
+ protected function get_admin_page_callback() {
+ return [ $this->menu, 'load_page' ];
+ }
+
+ /**
+ * Returns the page title to use for the licenses page.
+ *
+ * @return string The title for the license page.
+ */
+ protected function get_license_page_title() {
+ static $title = null;
+
+ if ( $title === null ) {
+ $title = __( 'Upgrades', 'wordpress-seo' );
+ }
+
+ if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2023-promotion' ) && ! YoastSEO()->helpers->product->is_premium() ) {
+ $title = __( 'Upgrades', 'wordpress-seo' ) . '' . __( '30% OFF', 'wordpress-seo' ) . '';
+ }
+
+ return $title;
+ }
+
+ /**
+ * Returns a base64 URL for the svg for use in the menu.
+ *
+ * @param bool $base64 Whether or not to return base64'd output.
+ *
+ * @return string SVG icon.
+ */
+ public function get_icon_svg( $base64 = true ) {
+ $svg = '';
+
+ if ( $base64 ) {
+ //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- This encoding is intended.
+ return 'data:image/svg+xml;base64,' . base64_encode( $svg );
+ }
+
+ return $svg;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-menu.php b/wp-content/plugins/wordpress-seo/admin/menu/class-menu.php
new file mode 100644
index 00000000..bc3ab3e0
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-menu.php
@@ -0,0 +1,96 @@
+register_hooks();
+
+ if ( WPSEO_Utils::is_plugin_network_active() ) {
+ $network_admin_menu = new WPSEO_Network_Admin_Menu( $this );
+ $network_admin_menu->register_hooks();
+ }
+
+ $capability_normalizer = new WPSEO_Submenu_Capability_Normalize();
+ $capability_normalizer->register_hooks();
+ }
+
+ /**
+ * Returns the main menu page identifier.
+ *
+ * @return string Page identifier to use.
+ */
+ public function get_page_identifier() {
+ return self::PAGE_IDENTIFIER;
+ }
+
+ /**
+ * Loads the requested admin settings page.
+ *
+ * @return void
+ */
+ public function load_page() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ $page = sanitize_text_field( wp_unslash( $_GET['page'] ) );
+ $this->show_page( $page );
+ }
+ }
+
+ /**
+ * Shows an admin settings page.
+ *
+ * @param string $page Page to display.
+ *
+ * @return void
+ */
+ protected function show_page( $page ) {
+ switch ( $page ) {
+ case 'wpseo_tools':
+ require_once WPSEO_PATH . 'admin/pages/tools.php';
+ break;
+
+ case 'wpseo_licenses':
+ require_once WPSEO_PATH . 'admin/pages/licenses.php';
+ break;
+
+ case 'wpseo_files':
+ require_once WPSEO_PATH . 'admin/views/tool-file-editor.php';
+ break;
+
+ default:
+ require_once WPSEO_PATH . 'admin/pages/dashboard.php';
+ break;
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-network-admin-menu.php b/wp-content/plugins/wordpress-seo/admin/menu/class-network-admin-menu.php
new file mode 100644
index 00000000..b440cc10
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-network-admin-menu.php
@@ -0,0 +1,97 @@
+check_manage_capability() ) {
+ return;
+ }
+
+ add_menu_page(
+ __( 'Network Settings', 'wordpress-seo' ) . ' - Yoast SEO',
+ 'Yoast SEO',
+ $this->get_manage_capability(),
+ $this->get_page_identifier(),
+ [ $this, 'network_config_page' ],
+ $this->get_icon_svg()
+ );
+
+ $submenu_pages = $this->get_submenu_pages();
+ $this->register_submenu_pages( $submenu_pages );
+ }
+
+ /**
+ * Returns the list of registered submenu pages.
+ *
+ * @return array List of registered submenu pages.
+ */
+ public function get_submenu_pages() {
+
+ // Submenu pages.
+ $submenu_pages = [
+ $this->get_submenu_page(
+ __( 'General', 'wordpress-seo' ),
+ $this->get_page_identifier(),
+ [ $this, 'network_config_page' ]
+ ),
+ ];
+
+ if ( WPSEO_Utils::allow_system_file_edit() === true ) {
+ $submenu_pages[] = $this->get_submenu_page( __( 'Edit Files', 'wordpress-seo' ), 'wpseo_files' );
+ }
+
+ $submenu_pages[] = $this->get_submenu_page( __( 'Extensions', 'wordpress-seo' ), 'wpseo_licenses' );
+
+ return $submenu_pages;
+ }
+
+ /**
+ * Loads the form for the network configuration page.
+ *
+ * @return void
+ */
+ public function network_config_page() {
+ require_once WPSEO_PATH . 'admin/pages/network.php';
+ }
+
+ /**
+ * Checks whether the current user has capabilities to manage all options.
+ *
+ * @return bool True if capabilities are sufficient, false otherwise.
+ */
+ protected function check_manage_capability() {
+ return current_user_can( $this->get_manage_capability() );
+ }
+
+ /**
+ * Returns the capability that is required to manage all options.
+ *
+ * @return string Capability to check against.
+ */
+ protected function get_manage_capability() {
+ return 'wpseo_manage_network_options';
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-editor.php b/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-editor.php
new file mode 100644
index 00000000..7f3b8201
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-editor.php
@@ -0,0 +1,159 @@
+ true,
+ 'label_title' => '',
+ 'label_description' => '',
+ 'description_placeholder' => '',
+ 'has_new_badge' => false,
+ 'is_disabled' => false,
+ 'has_premium_badge' => false,
+ ]
+ );
+
+ $this->validate_arguments( $arguments );
+
+ $this->yform = $yform;
+ $this->arguments = [
+ 'title' => (string) $arguments['title'],
+ 'description' => (string) $arguments['description'],
+ 'page_type_recommended' => (string) $arguments['page_type_recommended'],
+ 'page_type_specific' => (string) $arguments['page_type_specific'],
+ 'paper_style' => (bool) $arguments['paper_style'],
+ 'label_title' => (string) $arguments['label_title'],
+ 'label_description' => (string) $arguments['label_description'],
+ 'description_placeholder' => (string) $arguments['description_placeholder'],
+ 'has_new_badge' => (bool) $arguments['has_new_badge'],
+ 'is_disabled' => (bool) $arguments['is_disabled'],
+ 'has_premium_badge' => (bool) $arguments['has_premium_badge'],
+ ];
+ }
+
+ /**
+ * Renders a div for the react application to mount to, and hidden inputs where
+ * the app should store it's value so they will be properly saved when the form
+ * is submitted.
+ *
+ * @return void
+ */
+ public function render() {
+ $this->yform->hidden( $this->arguments['title'], $this->arguments['title'] );
+ $this->yform->hidden( $this->arguments['description'], $this->arguments['description'] );
+
+ printf(
+ '',
+ esc_attr( $this->arguments['title'] ),
+ esc_attr( $this->arguments['description'] ),
+ esc_attr( $this->arguments['page_type_recommended'] ),
+ esc_attr( $this->arguments['page_type_specific'] ),
+ esc_attr( $this->arguments['paper_style'] ),
+ esc_attr( $this->arguments['label_title'] ),
+ esc_attr( $this->arguments['label_description'] ),
+ esc_attr( $this->arguments['description_placeholder'] ),
+ esc_attr( $this->arguments['has_new_badge'] ),
+ esc_attr( $this->arguments['is_disabled'] ),
+ esc_attr( $this->arguments['has_premium_badge'] )
+ );
+ }
+
+ /**
+ * Validates the replacement variable editor arguments.
+ *
+ * @param array $arguments The arguments to validate.
+ *
+ * @throws InvalidArgumentException Thrown when not all required arguments are present.
+ *
+ * @return void
+ */
+ protected function validate_arguments( array $arguments ) {
+ $required_arguments = [
+ 'title',
+ 'description',
+ 'page_type_recommended',
+ 'page_type_specific',
+ 'paper_style',
+ ];
+
+ foreach ( $required_arguments as $field_name ) {
+ if ( ! array_key_exists( $field_name, $arguments ) ) {
+ throw new InvalidArgumentException(
+ sprintf(
+ /* translators: %1$s expands to the missing field name. */
+ __( 'Not all required fields are given. Missing field %1$s', 'wordpress-seo' ),
+ $field_name
+ )
+ );
+ }
+ }
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-field.php b/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-field.php
new file mode 100644
index 00000000..e94d2c73
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-replacevar-field.php
@@ -0,0 +1,88 @@
+yform = $yform;
+ $this->field_id = $field_id;
+ $this->label = $label;
+ $this->page_type_recommended = $page_type_recommended;
+ $this->page_type_specific = $page_type_specific;
+ }
+
+ /**
+ * Renders a div for the react application to mount to, and hidden inputs where
+ * the app should store it's value so they will be properly saved when the form
+ * is submitted.
+ *
+ * @return void
+ */
+ public function render() {
+ $this->yform->hidden( $this->field_id, $this->field_id );
+
+ printf(
+ '',
+ esc_attr( $this->field_id ),
+ esc_attr( $this->label ),
+ esc_attr( $this->page_type_recommended ),
+ esc_attr( $this->page_type_specific )
+ );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/menu/class-submenu-capability-normalize.php b/wp-content/plugins/wordpress-seo/admin/menu/class-submenu-capability-normalize.php
new file mode 100644
index 00000000..6e35718f
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/menu/class-submenu-capability-normalize.php
@@ -0,0 +1,41 @@
+ $submenu_page ) {
+ if ( $submenu_page[3] === 'manage_options' ) {
+ $submenu_pages[ $index ][3] = 'wpseo_manage_options';
+ }
+ }
+
+ return $submenu_pages;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-abstract-sectioned-metabox-tab.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-abstract-sectioned-metabox-tab.php
new file mode 100644
index 00000000..29ec6e90
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-abstract-sectioned-metabox-tab.php
@@ -0,0 +1,97 @@
+ '',
+ 'link_class' => '',
+ 'link_aria_label' => '',
+ ];
+
+ $options = array_merge( $default_options, $options );
+
+ $this->name = $name;
+
+ $this->link_content = $link_content;
+ $this->link_title = $options['link_title'];
+ $this->link_class = $options['link_class'];
+ $this->link_aria_label = $options['link_aria_label'];
+ }
+
+ /**
+ * Outputs the section link if any section has been added.
+ *
+ * @return void
+ */
+ public function display_link() {
+ if ( $this->has_sections() ) {
+ printf(
+ '
',
+ esc_attr( $this->name ),
+ esc_attr( $this->link_class ),
+ ( $this->link_title !== '' ) ? ' title="' . esc_attr( $this->link_title ) . '"' : '',
+ ( $this->link_aria_label !== '' ) ? ' aria-label="' . esc_attr( $this->link_aria_label ) . '"' : '',
+ $this->link_content
+ );
+ }
+ }
+
+ /**
+ * Checks whether the tab has any sections.
+ *
+ * @return bool Whether the tab has any sections
+ */
+ abstract protected function has_sections();
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-inclusive-language.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-inclusive-language.php
new file mode 100644
index 00000000..1fe2a1fd
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-inclusive-language.php
@@ -0,0 +1,58 @@
+is_globally_enabled() && $this->is_user_enabled() && $this->is_current_version_supported()
+ && YoastSEO()->helpers->language->has_inclusive_language_support( WPSEO_Language_Utils::get_language( get_locale() ) );
+ }
+
+ /**
+ * Whether or not this analysis is enabled by the user.
+ *
+ * @return bool Whether or not this analysis is enabled by the user.
+ */
+ public function is_user_enabled() {
+ return ! get_the_author_meta( 'wpseo_inclusive_language_analysis_disable', get_current_user_id() );
+ }
+
+ /**
+ * Whether or not this analysis is enabled globally.
+ *
+ * @return bool Whether or not this analysis is enabled globally.
+ */
+ public function is_globally_enabled() {
+ return WPSEO_Options::get( 'inclusive_language_analysis_active', false );
+ }
+
+ /**
+ * Whether the inclusive language analysis should be loaded in Free.
+ *
+ * It should always be loaded when Premium is not active. If Premium is active, it depends on the version. Some Premium
+ * versions also have inclusive language code (when it was still a Premium only feature) which would result in rendering
+ * the analysis twice. In those cases, the analysis should be only loaded from the Premium side.
+ *
+ * @return bool Whether or not the inclusive language analysis should be loaded.
+ */
+ private function is_current_version_supported() {
+ $is_premium = YoastSEO()->helpers->product->is_premium();
+ $premium_version = YoastSEO()->helpers->product->get_premium_version();
+
+ return ! $is_premium
+ || version_compare( $premium_version, '19.6-RC0', '>=' )
+ || version_compare( $premium_version, '19.2', '==' );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-readability.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-readability.php
new file mode 100644
index 00000000..65345c48
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-readability.php
@@ -0,0 +1,39 @@
+is_globally_enabled() && $this->is_user_enabled();
+ }
+
+ /**
+ * Whether or not this analysis is enabled by the user.
+ *
+ * @return bool Whether or not this analysis is enabled by the user.
+ */
+ public function is_user_enabled() {
+ return ! get_the_author_meta( 'wpseo_content_analysis_disable', get_current_user_id() );
+ }
+
+ /**
+ * Whether or not this analysis is enabled globally.
+ *
+ * @return bool Whether or not this analysis is enabled globally.
+ */
+ public function is_globally_enabled() {
+ return WPSEO_Options::get( 'content_analysis_active', true );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-seo.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-seo.php
new file mode 100644
index 00000000..8225defb
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-analysis-seo.php
@@ -0,0 +1,39 @@
+is_globally_enabled() && $this->is_user_enabled();
+ }
+
+ /**
+ * Whether or not this analysis is enabled by the user.
+ *
+ * @return bool Whether or not this analysis is enabled by the user.
+ */
+ public function is_user_enabled() {
+ return ! get_the_author_meta( 'wpseo_keyword_analysis_disable', get_current_user_id() );
+ }
+
+ /**
+ * Whether or not this analysis is enabled globally.
+ *
+ * @return bool Whether or not this analysis is enabled globally.
+ */
+ public function is_globally_enabled() {
+ return WPSEO_Options::get( 'keyword_analysis_active', true );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsible.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsible.php
new file mode 100644
index 00000000..c5d378cd
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsible.php
@@ -0,0 +1,84 @@
+name = $name;
+ $this->content = $content;
+ $this->link_content = $link_content;
+ }
+
+ /**
+ * Returns the html for the tab link.
+ *
+ * @return string
+ */
+ public function link() {
+ return $this->link_content;
+ }
+
+ /**
+ * Returns the html for the tab content.
+ *
+ * @return string
+ */
+ public function content() {
+ $collapsible_paper = new WPSEO_Paper_Presenter(
+ $this->link(),
+ null,
+ [
+ 'content' => $this->content,
+ 'collapsible' => true,
+ 'class' => 'metabox wpseo-form wpseo-collapsible-container',
+ 'paper_id' => 'collapsible-' . $this->name,
+ ]
+ );
+
+ return $collapsible_paper->get_output();
+ }
+
+ /**
+ * Returns the collapsible's unique identifier.
+ *
+ * @return string
+ */
+ public function get_name() {
+ return $this->name;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsibles-section.php b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsibles-section.php
new file mode 100644
index 00000000..14e8638e
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox-collapsibles-section.php
@@ -0,0 +1,65 @@
+collapsibles = $collapsibles;
+ }
+
+ /**
+ * Outputs the section content if any tab has been added.
+ *
+ * @return void
+ */
+ public function display_content() {
+ if ( $this->has_sections() ) {
+ printf( '
';
+ }
+
+ /**
+ * WARNING: This hook is intended for internal use only.
+ * Don't use it in your code as it will be removed shortly.
+ */
+ do_action( 'wpseo_tools_overview_list_items_internal' );
+
+ echo '
';
+}
+else {
+ echo '', esc_html__( '« Back to Tools page', 'wordpress-seo' ), '';
+
+ $tool_pages = [ 'bulk-editor', 'import-export' ];
+
+ if ( WPSEO_Utils::allow_system_file_edit() === true && ! is_multisite() ) {
+ $tool_pages[] = 'file-editor';
+ }
+
+ if ( in_array( $tool_page, $tool_pages, true ) ) {
+ require_once WPSEO_PATH . 'admin/views/tool-' . $tool_page . '.php';
+ }
+}
+
+$yform->admin_footer( false );
diff --git a/wp-content/plugins/wordpress-seo/admin/roles/class-abstract-role-manager.php b/wp-content/plugins/wordpress-seo/admin/roles/class-abstract-role-manager.php
new file mode 100644
index 00000000..39edad49
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/roles/class-abstract-role-manager.php
@@ -0,0 +1,149 @@
+roles[ $role ] = (object) [
+ 'display_name' => $display_name,
+ 'template' => $template,
+ ];
+ }
+
+ /**
+ * Returns the list of registered roles.
+ *
+ * @return string[] List or registered roles.
+ */
+ public function get_roles() {
+ return array_keys( $this->roles );
+ }
+
+ /**
+ * Adds the registered roles.
+ *
+ * @return void
+ */
+ public function add() {
+ foreach ( $this->roles as $role => $data ) {
+ $capabilities = $this->get_capabilities( $data->template );
+ $capabilities = $this->filter_existing_capabilties( $role, $capabilities );
+
+ $this->add_role( $role, $data->display_name, $capabilities );
+ }
+ }
+
+ /**
+ * Removes the registered roles.
+ *
+ * @return void
+ */
+ public function remove() {
+ $roles = array_keys( $this->roles );
+ array_map( [ $this, 'remove_role' ], $roles );
+ }
+
+ /**
+ * Returns the capabilities for the specified role.
+ *
+ * @param string $role Role to fetch capabilities from.
+ *
+ * @return array List of capabilities.
+ */
+ protected function get_capabilities( $role ) {
+ if ( ! is_string( $role ) || empty( $role ) ) {
+ return [];
+ }
+
+ $wp_role = get_role( $role );
+ if ( ! $wp_role ) {
+ return [];
+ }
+
+ return $wp_role->capabilities;
+ }
+
+ /**
+ * Returns true if the capability exists on the role.
+ *
+ * @param WP_Role $role Role to check capability against.
+ * @param string $capability Capability to check.
+ *
+ * @return bool True if the capability is defined for the role.
+ */
+ protected function capability_exists( WP_Role $role, $capability ) {
+ return ! array_key_exists( $capability, $role->capabilities );
+ }
+
+ /**
+ * Filters out capabilities that are already set for the role.
+ *
+ * This makes sure we don't override configurations that have been previously set.
+ *
+ * @param string $role The role to check against.
+ * @param array $capabilities The capabilities that should be set.
+ *
+ * @return array Capabilties that can be safely set.
+ */
+ protected function filter_existing_capabilties( $role, array $capabilities ) {
+ if ( $capabilities === [] ) {
+ return $capabilities;
+ }
+
+ $wp_role = get_role( $role );
+ if ( ! $wp_role ) {
+ return $capabilities;
+ }
+
+ foreach ( $capabilities as $capability => $grant ) {
+ if ( $this->capability_exists( $wp_role, $capability ) ) {
+ unset( $capabilities[ $capability ] );
+ }
+ }
+
+ return $capabilities;
+ }
+
+ /**
+ * Adds a role to the system.
+ *
+ * @param string $role Role to add.
+ * @param string $display_name Name to display for the role.
+ * @param array $capabilities Capabilities to add to the role.
+ *
+ * @return void
+ */
+ abstract protected function add_role( $role, $display_name, array $capabilities = [] );
+
+ /**
+ * Removes a role from the system.
+ *
+ * @param string $role Role to remove.
+ *
+ * @return void
+ */
+ abstract protected function remove_role( $role );
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/roles/class-register-roles.php b/wp-content/plugins/wordpress-seo/admin/roles/class-register-roles.php
new file mode 100644
index 00000000..9636237e
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/roles/class-register-roles.php
@@ -0,0 +1,33 @@
+register( 'wpseo_manager', 'SEO Manager', 'editor' );
+ $role_manager->register( 'wpseo_editor', 'SEO Editor', 'editor' );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager-factory.php b/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager-factory.php
new file mode 100644
index 00000000..d22753a2
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager-factory.php
@@ -0,0 +1,27 @@
+ $grant ) {
+ $wp_role->add_cap( $capability, $grant );
+ }
+
+ return;
+ }
+
+ add_role( $role, $display_name, $capabilities );
+ }
+
+ /**
+ * Removes a role from the system.
+ *
+ * @param string $role Role to remove.
+ *
+ * @return void
+ */
+ protected function remove_role( $role ) {
+ remove_role( $role );
+ }
+
+ /**
+ * Formats the capabilities to the required format.
+ *
+ * @param array $capabilities Capabilities to format.
+ * @param bool $enabled Whether these capabilities should be enabled or not.
+ *
+ * @return array Formatted capabilities.
+ */
+ protected function format_capabilities( array $capabilities, $enabled = true ) {
+ // Flip keys and values.
+ $capabilities = array_flip( $capabilities );
+
+ // Set all values to $enabled.
+ return array_fill_keys( array_keys( $capabilities ), $enabled );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager.php b/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager.php
new file mode 100644
index 00000000..7f9d82bb
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/roles/class-role-manager.php
@@ -0,0 +1,44 @@
+get_file_url( $request );
+
+ return new WP_REST_Response(
+ [
+ 'type' => 'success',
+ 'size_in_bytes' => $this->get_file_size( $file_url ),
+ ],
+ 200
+ );
+ }
+ catch ( WPSEO_File_Size_Exception $exception ) {
+ return new WP_REST_Response(
+ [
+ 'type' => 'failure',
+ 'response' => $exception->getMessage(),
+ ],
+ 404
+ );
+ }
+ }
+
+ /**
+ * Retrieves the file url.
+ *
+ * @param WP_REST_Request $request The request to retrieve file url from.
+ *
+ * @return string The file url.
+ * @throws WPSEO_File_Size_Exception The file is hosted externally.
+ */
+ protected function get_file_url( WP_REST_Request $request ) {
+ $file_url = rawurldecode( $request->get_param( 'url' ) );
+
+ if ( ! $this->is_externally_hosted( $file_url ) ) {
+ return $file_url;
+ }
+
+ throw WPSEO_File_Size_Exception::externally_hosted( $file_url );
+ }
+
+ /**
+ * Checks if the file is hosted externally.
+ *
+ * @param string $file_url The file url.
+ *
+ * @return bool True if it is hosted externally.
+ */
+ protected function is_externally_hosted( $file_url ) {
+ return wp_parse_url( home_url(), PHP_URL_HOST ) !== wp_parse_url( $file_url, PHP_URL_HOST );
+ }
+
+ /**
+ * Returns the file size.
+ *
+ * @param string $file_url The file url to get the size for.
+ *
+ * @return int The file size.
+ * @throws WPSEO_File_Size_Exception Retrieval of file size went wrong for unknown reasons.
+ */
+ protected function get_file_size( $file_url ) {
+ $file_config = wp_upload_dir();
+ $file_url = str_replace( $file_config['baseurl'], '', $file_url );
+ $file_size = $this->calculate_file_size( $file_url );
+
+ if ( ! $file_size ) {
+ throw WPSEO_File_Size_Exception::unknown_error( $file_url );
+ }
+
+ return $file_size;
+ }
+
+ /**
+ * Calculates the file size using the Utils class.
+ *
+ * @param string $file_url The file to retrieve the size for.
+ *
+ * @return int|bool The file size or False if it could not be retrieved.
+ */
+ protected function calculate_file_size( $file_url ) {
+ return WPSEO_Image_Utils::get_file_size(
+ [
+ 'path' => $file_url,
+ ]
+ );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/statistics/class-statistics-integration.php b/wp-content/plugins/wordpress-seo/admin/statistics/class-statistics-integration.php
new file mode 100644
index 00000000..756f314c
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/statistics/class-statistics-integration.php
@@ -0,0 +1,36 @@
+statistics = $statistics;
+ }
+
+ /**
+ * Fetches statistics by REST request.
+ *
+ * @return WP_REST_Response The response object.
+ */
+ public function get_statistics() {
+ // Switch to the user locale with fallback to the site locale.
+ switch_to_locale( get_user_locale() );
+
+ $this->labels = $this->labels();
+ $statistics = $this->statistic_items();
+
+ $data = [
+ 'header' => $this->get_header_from_statistics( $statistics ),
+ 'seo_scores' => $statistics['scores'],
+ ];
+
+ return new WP_REST_Response( $data );
+ }
+
+ /**
+ * Gets a header summarizing the given statistics results.
+ *
+ * @param array $statistics The statistics results.
+ *
+ * @return string The header summing up the statistics results.
+ */
+ private function get_header_from_statistics( array $statistics ) {
+ // Personal interpretation to allow release, should be looked at later.
+ if ( $statistics['division'] === false ) {
+ return __( 'You don\'t have any published posts, your SEO scores will appear here once you make your first post!', 'wordpress-seo' );
+ }
+
+ if ( $statistics['division']['good'] > 0.66 ) {
+ return __( 'Hey, your SEO is doing pretty well! Check out the stats:', 'wordpress-seo' );
+ }
+
+ return __( 'Below are your published posts\' SEO scores. Now is as good a time as any to start improving some of your posts!', 'wordpress-seo' );
+ }
+
+ /**
+ * An array representing items to be added to the At a Glance dashboard widget.
+ *
+ * @return array The statistics for the current user.
+ */
+ private function statistic_items() {
+ $transient = $this->get_transient();
+ $user_id = get_current_user_id();
+
+ if ( isset( $transient[ $user_id ] ) ) {
+ return $transient[ $user_id ];
+ }
+
+ return $this->set_statistic_items_for_user( $transient, $user_id );
+ }
+
+ /**
+ * Gets the statistics transient value. Returns array if transient wasn't set.
+ *
+ * @return array|mixed Returns the transient or an empty array if the transient doesn't exist.
+ */
+ private function get_transient() {
+ $transient = get_transient( self::CACHE_TRANSIENT_KEY );
+
+ if ( $transient === false ) {
+ return [];
+ }
+
+ return $transient;
+ }
+
+ /**
+ * Set the statistics transient cache for a specific user.
+ *
+ * @param array $transient The current stored transient with the cached data.
+ * @param int $user The user's ID to assign the retrieved values to.
+ *
+ * @return array The statistics transient for the user.
+ */
+ private function set_statistic_items_for_user( $transient, $user ) {
+ $scores = $this->get_seo_scores_with_post_count();
+ $division = $this->get_seo_score_division( $scores );
+
+ $transient[ $user ] = [
+ // Use array_values because array_filter may return non-zero indexed arrays.
+ 'scores' => array_values( array_filter( $scores, [ $this, 'filter_items' ] ) ),
+ 'division' => $division,
+ ];
+
+ set_transient( self::CACHE_TRANSIENT_KEY, $transient, DAY_IN_SECONDS );
+
+ return $transient[ $user ];
+ }
+
+ /**
+ * Gets the division of SEO scores.
+ *
+ * @param array $scores The SEO scores.
+ *
+ * @return array|bool The division of SEO scores, false if there are no posts.
+ */
+ private function get_seo_score_division( array $scores ) {
+ $total = 0;
+ $division = [];
+
+ foreach ( $scores as $score ) {
+ $total += $score['count'];
+ }
+
+ if ( $total === 0 ) {
+ return false;
+ }
+
+ foreach ( $scores as $score ) {
+ $division[ $score['seo_rank'] ] = ( $score['count'] / $total );
+ }
+
+ return $division;
+ }
+
+ /**
+ * Get all SEO ranks and data associated with them.
+ *
+ * @return array An array of SEO scores and associated data.
+ */
+ private function get_seo_scores_with_post_count() {
+ $ranks = WPSEO_Rank::get_all_ranks();
+
+ return array_map( [ $this, 'map_rank_to_widget' ], $ranks );
+ }
+
+ /**
+ * Converts a rank to data usable in the dashboard widget.
+ *
+ * @param WPSEO_Rank $rank The rank to map.
+ *
+ * @return array The mapped rank.
+ */
+ private function map_rank_to_widget( WPSEO_Rank $rank ) {
+ return [
+ 'seo_rank' => $rank->get_rank(),
+ 'label' => $this->get_label_for_rank( $rank ),
+ 'count' => $this->statistics->get_post_count( $rank ),
+ 'link' => $this->get_link_for_rank( $rank ),
+ ];
+ }
+
+ /**
+ * Returns a dashboard widget label to use for a certain rank.
+ *
+ * @param WPSEO_Rank $rank The rank to return a label for.
+ *
+ * @return string The label for the rank.
+ */
+ private function get_label_for_rank( WPSEO_Rank $rank ) {
+ return $this->labels[ $rank->get_rank() ];
+ }
+
+ /**
+ * Determines the labels for the various scoring ranks that are known within Yoast SEO.
+ *
+ * @return array Array containing the translatable labels.
+ */
+ private function labels() {
+ return [
+ WPSEO_Rank::NO_FOCUS => sprintf(
+ /* translators: %1$s expands to an opening strong tag, %2$s expands to a closing strong tag */
+ __( 'Posts %1$swithout%2$s a focus keyphrase', 'wordpress-seo' ),
+ '',
+ ''
+ ),
+ WPSEO_Rank::BAD => sprintf(
+ /* translators: %s expands to the score */
+ __( 'Posts with the SEO score: %s', 'wordpress-seo' ),
+ '' . __( 'Needs improvement', 'wordpress-seo' ) . ''
+ ),
+ WPSEO_Rank::OK => sprintf(
+ /* translators: %s expands to the score */
+ __( 'Posts with the SEO score: %s', 'wordpress-seo' ),
+ '' . __( 'OK', 'wordpress-seo' ) . ''
+ ),
+ WPSEO_Rank::GOOD => sprintf(
+ /* translators: %s expands to the score */
+ __( 'Posts with the SEO score: %s', 'wordpress-seo' ),
+ '' . __( 'Good', 'wordpress-seo' ) . ''
+ ),
+ WPSEO_Rank::NO_INDEX => __( 'Posts that should not show up in search results', 'wordpress-seo' ),
+ ];
+ }
+
+ /**
+ * Filter items if they have a count of zero.
+ *
+ * @param array $item The item to potentially filter out.
+ *
+ * @return bool Whether or not the count is zero.
+ */
+ private function filter_items( $item ) {
+ return $item['count'] !== 0;
+ }
+
+ /**
+ * Returns a link for the overview of posts of a certain rank.
+ *
+ * @param WPSEO_Rank $rank The rank to return a link for.
+ *
+ * @return string The link that shows an overview of posts with that rank.
+ */
+ private function get_link_for_rank( WPSEO_Rank $rank ) {
+ if ( current_user_can( 'edit_others_posts' ) === false ) {
+ return esc_url( admin_url( 'edit.php?post_status=publish&post_type=post&seo_filter=' . $rank->get_rank() . '&author=' . get_current_user_id() ) );
+ }
+
+ return esc_url( admin_url( 'edit.php?post_status=publish&post_type=post&seo_filter=' . $rank->get_rank() ) );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-columns.php b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-columns.php
new file mode 100644
index 00000000..fda2f19c
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-columns.php
@@ -0,0 +1,231 @@
+taxonomy = $this->get_taxonomy();
+
+ if ( ! empty( $this->taxonomy ) ) {
+ add_filter( 'manage_edit-' . $this->taxonomy . '_columns', [ $this, 'add_columns' ] );
+ add_filter( 'manage_' . $this->taxonomy . '_custom_column', [ $this, 'parse_column' ], 10, 3 );
+ }
+
+ $this->analysis_seo = new WPSEO_Metabox_Analysis_SEO();
+ $this->analysis_readability = new WPSEO_Metabox_Analysis_Readability();
+ $this->indexable_repository = YoastSEO()->classes->get( Indexable_Repository::class );
+ $this->score_icon_helper = YoastSEO()->helpers->score_icon;
+ }
+
+ /**
+ * Adds an SEO score column to the terms table, right after the description column.
+ *
+ * @param array $columns Current set columns.
+ *
+ * @return array
+ */
+ public function add_columns( array $columns ) {
+ if ( $this->display_metabox( $this->taxonomy ) === false ) {
+ return $columns;
+ }
+
+ $new_columns = [];
+
+ foreach ( $columns as $column_name => $column_value ) {
+ $new_columns[ $column_name ] = $column_value;
+
+ if ( $column_name === 'description' && $this->analysis_seo->is_enabled() ) {
+ $new_columns['wpseo-score'] = ''
+ . __( 'SEO score', 'wordpress-seo' ) . '';
+ }
+
+ if ( $column_name === 'description' && $this->analysis_readability->is_enabled() ) {
+ $new_columns['wpseo-score-readability'] = ''
+ . __( 'Readability score', 'wordpress-seo' ) . '';
+ }
+ }
+
+ return $new_columns;
+ }
+
+ /**
+ * Parses the column.
+ *
+ * @param string $content The current content of the column.
+ * @param string $column_name The name of the column.
+ * @param int $term_id ID of requested taxonomy.
+ *
+ * @return string
+ */
+ public function parse_column( $content, $column_name, $term_id ) {
+
+ switch ( $column_name ) {
+ case 'wpseo-score':
+ return $this->get_score_value( $term_id );
+
+ case 'wpseo-score-readability':
+ return $this->get_score_readability_value( $term_id );
+ }
+
+ return $content;
+ }
+
+ /**
+ * Retrieves the taxonomy from the $_GET or $_POST variable.
+ *
+ * @return string|null The current taxonomy or null when it is not set.
+ */
+ public function get_current_taxonomy() {
+ // phpcs:disable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( ! empty( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
+ if ( isset( $_POST['taxonomy'] ) && is_string( $_POST['taxonomy'] ) ) {
+ return sanitize_text_field( wp_unslash( $_POST['taxonomy'] ) );
+ }
+ }
+ elseif ( isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) {
+ return sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) );
+ }
+ // phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
+ return null;
+ }
+
+ /**
+ * Returns the posted/get taxonomy value if it is set.
+ *
+ * @return string|null
+ */
+ private function get_taxonomy() {
+ // phpcs:disable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( wp_doing_ajax() ) {
+ if ( isset( $_POST['taxonomy'] ) && is_string( $_POST['taxonomy'] ) ) {
+ return sanitize_text_field( wp_unslash( $_POST['taxonomy'] ) );
+ }
+ }
+ elseif ( isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) {
+ return sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) );
+ }
+ // phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
+ return null;
+ }
+
+ /**
+ * Parses the value for the score column.
+ *
+ * @param int $term_id ID of requested term.
+ *
+ * @return string
+ */
+ private function get_score_value( $term_id ) {
+ $indexable = $this->indexable_repository->find_by_id_and_type( (int) $term_id, 'term' );
+
+ return $this->score_icon_helper->for_seo( $indexable, '', __( 'Term is set to noindex.', 'wordpress-seo' ) );
+ }
+
+ /**
+ * Parses the value for the readability score column.
+ *
+ * @param int $term_id ID of the requested term.
+ *
+ * @return string The HTML for the readability score indicator.
+ */
+ private function get_score_readability_value( $term_id ) {
+ $score = (int) WPSEO_Taxonomy_Meta::get_term_meta( $term_id, $this->taxonomy, 'content_score' );
+
+ return $this->score_icon_helper->for_readability( $score );
+ }
+
+ /**
+ * Check if the taxonomy is indexable.
+ *
+ * @param mixed $term The current term.
+ *
+ * @return bool Whether the term is indexable.
+ */
+ private function is_indexable( $term ) {
+ // When the no_index value is not empty and not default, check if its value is index.
+ $no_index = WPSEO_Taxonomy_Meta::get_term_meta( $term->term_id, $this->taxonomy, 'noindex' );
+
+ // Check if the default for taxonomy is empty (this will be index).
+ if ( ! empty( $no_index ) && $no_index !== 'default' ) {
+ return ( $no_index === 'index' );
+ }
+
+ if ( is_object( $term ) ) {
+ $no_index_key = 'noindex-tax-' . $term->taxonomy;
+
+ // If the option is false, this means we want to index it.
+ return WPSEO_Options::get( $no_index_key, false ) === false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Wraps the WPSEO_Metabox check to determine whether the metabox should be displayed either by
+ * choice of the admin or because the taxonomy is not public.
+ *
+ * @since 7.0
+ *
+ * @param string|null $taxonomy Optional. The taxonomy to test, defaults to the current taxonomy.
+ *
+ * @return bool Whether the meta box (and associated columns etc) should be hidden.
+ */
+ private function display_metabox( $taxonomy = null ) {
+ $current_taxonomy = $this->get_current_taxonomy();
+
+ if ( ! isset( $taxonomy ) && ! empty( $current_taxonomy ) ) {
+ $taxonomy = $current_taxonomy;
+ }
+
+ return WPSEO_Utils::is_metabox_active( $taxonomy, 'taxonomy' );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-fields-presenter.php b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-fields-presenter.php
new file mode 100644
index 00000000..9ab28b0c
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy-fields-presenter.php
@@ -0,0 +1,221 @@
+tax_meta = WPSEO_Taxonomy_Meta::get_term_meta( (int) $term->term_id, $term->taxonomy );
+ }
+
+ /**
+ * Displaying the form fields.
+ *
+ * @param array $fields Array with the fields that will be displayed.
+ *
+ * @return string
+ */
+ public function html( array $fields ) {
+ $content = '';
+ foreach ( $fields as $field_name => $field_configuration ) {
+ $content .= $this->form_row( 'wpseo_' . $field_name, $field_configuration );
+ }
+ return $content;
+ }
+
+ /**
+ * Create a row in the form table.
+ *
+ * @param string $field_name Variable the row controls.
+ * @param array $field_configuration Array with the field configuration.
+ *
+ * @return string
+ */
+ private function form_row( $field_name, array $field_configuration ) {
+ $esc_field_name = esc_attr( $field_name );
+
+ $options = (array) $field_configuration['options'];
+
+ if ( ! empty( $field_configuration['description'] ) ) {
+ $options['description'] = $field_configuration['description'];
+ }
+
+ $label = $this->get_label( $field_configuration['label'], $esc_field_name );
+ $field = $this->get_field( $field_configuration['type'], $esc_field_name, $this->get_field_value( $field_name ), $options );
+ $help_content = ( $field_configuration['options']['help'] ?? '' );
+ $help_button_text = ( $field_configuration['options']['help-button'] ?? '' );
+ $help = new WPSEO_Admin_Help_Panel( $field_name, $help_button_text, $help_content );
+
+ return $this->parse_row( $label, $help, $field );
+ }
+
+ /**
+ * Generates the html for the given field config.
+ *
+ * @param string $field_type The fieldtype, e.g: text, checkbox, etc.
+ * @param string $field_name The name of the field.
+ * @param string $field_value The value of the field.
+ * @param array $options Array with additional options.
+ *
+ * @return string
+ */
+ private function get_field( $field_type, $field_name, $field_value, array $options ) {
+
+ $class = $this->get_class( $options );
+ $field = '';
+ $description = '';
+ $aria_describedby = '';
+
+ if ( ! empty( $options['description'] ) ) {
+ $aria_describedby = ' aria-describedby="' . $field_name . '-desc"';
+ $description = '
';
+ }
+
+ /**
+ * Returns the relevant metabox sections for the current view.
+ *
+ * @return WPSEO_Metabox_Section[]
+ */
+ private function get_tabs() {
+ $tabs = [];
+
+ $label = __( 'SEO', 'wordpress-seo' );
+ if ( $this->seo_analysis->is_enabled() ) {
+ $label = '' . $label;
+ }
+
+ $tabs[] = new WPSEO_Metabox_Section_React( 'content', $label );
+
+ if ( $this->readability_analysis->is_enabled() ) {
+ $tabs[] = new WPSEO_Metabox_Section_Readability();
+ }
+
+ if ( $this->inclusive_language_analysis->is_enabled() ) {
+ $tabs[] = new WPSEO_Metabox_Section_Inclusive_Language();
+ }
+
+ if ( $this->is_social_enabled ) {
+ $tabs[] = new WPSEO_Metabox_Section_React(
+ 'social',
+ '' . __( 'Social', 'wordpress-seo' ),
+ '',
+ [
+ 'html_after' => '',
+ ]
+ );
+ }
+
+ $tabs = array_merge( $tabs, $this->get_additional_tabs() );
+
+ return $tabs;
+ }
+
+ /**
+ * Returns the metabox tabs that have been added by other plugins.
+ *
+ * @return WPSEO_Metabox_Section_Additional[]
+ */
+ protected function get_additional_tabs() {
+ $tabs = [];
+
+ /**
+ * Private filter: 'yoast_free_additional_taxonomy_metabox_sections'.
+ *
+ * Meant for internal use only. Allows adding additional tabs to the Yoast SEO metabox for taxonomies.
+ *
+ * @param array[] $tabs {
+ * An array of arrays with tab specifications.
+ *
+ * @type array $tab {
+ * A tab specification.
+ *
+ * @type string $name The name of the tab. Used in the HTML IDs, href and aria properties.
+ * @type string $link_content The content of the tab link.
+ * @type string $content The content of the tab.
+ * @type array $options {
+ * Optional. Extra options.
+ *
+ * @type string $link_class Optional. The class for the tab link.
+ * @type string $link_aria_label Optional. The aria label of the tab link.
+ * }
+ * }
+ * }
+ */
+ $requested_tabs = apply_filters( 'yoast_free_additional_taxonomy_metabox_sections', [] );
+
+ foreach ( $requested_tabs as $tab ) {
+ if ( is_array( $tab ) && array_key_exists( 'name', $tab ) && array_key_exists( 'link_content', $tab ) && array_key_exists( 'content', $tab ) ) {
+ $options = array_key_exists( 'options', $tab ) ? $tab['options'] : [];
+ $tabs[] = new WPSEO_Metabox_Section_Additional(
+ $tab['name'],
+ $tab['link_content'],
+ $tab['content'],
+ $options
+ );
+ }
+ }
+
+ return $tabs;
+ }
+
+ /**
+ * Retrieves the product title.
+ *
+ * @return string The product title.
+ */
+ protected function get_product_title() {
+ return YoastSEO()->helpers->product->get_product_name();
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy.php b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy.php
new file mode 100644
index 00000000..41edb10c
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/taxonomy/class-taxonomy.php
@@ -0,0 +1,492 @@
+taxonomy = $this::get_taxonomy();
+
+ add_action( 'edit_term', [ $this, 'update_term' ], 99, 3 );
+ add_action( 'init', [ $this, 'custom_category_descriptions_allow_html' ] );
+ add_action( 'admin_init', [ $this, 'admin_init' ] );
+
+ if ( self::is_term_overview( $GLOBALS['pagenow'] ) ) {
+ new WPSEO_Taxonomy_Columns();
+ }
+ $this->analysis_seo = new WPSEO_Metabox_Analysis_SEO();
+ $this->analysis_readability = new WPSEO_Metabox_Analysis_Readability();
+ $this->analysis_inclusive_language = new WPSEO_Metabox_Analysis_Inclusive_Language();
+ }
+
+ /**
+ * Add hooks late enough for taxonomy object to be available for checks.
+ *
+ * @return void
+ */
+ public function admin_init() {
+
+ $taxonomy = get_taxonomy( $this->taxonomy );
+
+ if ( empty( $taxonomy ) || empty( $taxonomy->public ) || ! $this->show_metabox() ) {
+ return;
+ }
+
+ // Adds custom category description editor. Needs a hook that runs before the description field.
+ add_action( "{$this->taxonomy}_term_edit_form_top", [ $this, 'custom_category_description_editor' ] );
+
+ add_action( sanitize_text_field( $this->taxonomy ) . '_edit_form', [ $this, 'term_metabox' ], 90, 1 );
+ add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
+ }
+
+ /**
+ * Show the SEO inputs for term.
+ *
+ * @param stdClass|WP_Term $term Term to show the edit boxes for.
+ *
+ * @return void
+ */
+ public function term_metabox( $term ) {
+ if ( WPSEO_Metabox::is_internet_explorer() ) {
+ $this->show_internet_explorer_notice();
+ return;
+ }
+
+ $metabox = new WPSEO_Taxonomy_Metabox( $this->taxonomy, $term );
+ $metabox->display();
+ }
+
+ /**
+ * Renders the content for the internet explorer metabox.
+ *
+ * @return void
+ */
+ private function show_internet_explorer_notice() {
+ $product_title = YoastSEO()->helpers->product->get_product_name();
+
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: $product_title is hardcoded.
+ printf( '
%1$s
', $product_title );
+ echo '
';
+
+ $content = sprintf(
+ /* translators: 1: Link start tag to the Firefox website, 2: Link start tag to the Chrome website, 3: Link start tag to the Edge website, 4: Link closing tag. */
+ esc_html__( 'The browser you are currently using is unfortunately rather dated. Since we strive to give you the best experience possible, we no longer support this browser. Instead, please use %1$sFirefox%4$s, %2$sChrome%4$s or %3$sMicrosoft Edge%4$s.', 'wordpress-seo' ),
+ '',
+ '',
+ '',
+ ''
+ );
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output escaped above.
+ echo new Alert_Presenter( $content );
+
+ echo '
';
+ }
+
+ /**
+ * Queue assets for taxonomy screens.
+ *
+ * @since 1.5.0
+ *
+ * @return void
+ */
+ public function admin_enqueue_scripts() {
+
+ $pagenow = $GLOBALS['pagenow'];
+
+ if ( ! ( self::is_term_edit( $pagenow ) || self::is_term_overview( $pagenow ) ) ) {
+ return;
+ }
+
+ $asset_manager = new WPSEO_Admin_Asset_Manager();
+ $asset_manager->enqueue_style( 'scoring' );
+ $asset_manager->enqueue_style( 'monorepo' );
+
+ $tag_id = $this::get_tag_id();
+
+ if (
+ self::is_term_edit( $pagenow )
+ && ! is_null( $tag_id )
+ ) {
+ wp_enqueue_media(); // Enqueue files needed for upload functionality.
+
+ $asset_manager->enqueue_style( 'metabox-css' );
+ $asset_manager->enqueue_style( 'ai-generator' );
+ $asset_manager->enqueue_script( 'term-edit' );
+
+ /**
+ * Remove the emoji script as it is incompatible with both React and any
+ * contenteditable fields.
+ */
+ remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
+
+ $asset_manager->localize_script( 'term-edit', 'wpseoAdminL10n', WPSEO_Utils::get_admin_l10n() );
+
+ $script_data = [
+ 'analysis' => [
+ 'plugins' => [
+ 'replaceVars' => [
+ 'no_parent_text' => __( '(no parent)', 'wordpress-seo' ),
+ 'replace_vars' => $this->get_replace_vars(),
+ 'recommended_replace_vars' => $this->get_recommended_replace_vars(),
+ 'scope' => $this->determine_scope(),
+ ],
+ 'shortcodes' => [
+ 'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
+ 'wpseo_filter_shortcodes_nonce' => wp_create_nonce( 'wpseo-filter-shortcodes' ),
+ ],
+ ],
+ 'worker' => [
+ 'url' => YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-analysis-worker' ),
+ 'dependencies' => YoastSEO()->helpers->asset->get_dependency_urls_by_handle( 'yoast-seo-analysis-worker' ),
+ 'keywords_assessment_url' => YoastSEO()->helpers->asset->get_asset_url( 'yoast-seo-used-keywords-assessment' ),
+ 'log_level' => WPSEO_Utils::get_analysis_worker_log_level(),
+ ],
+ ],
+ 'media' => [
+ // @todo replace this translation with JavaScript translations.
+ 'choose_image' => __( 'Use Image', 'wordpress-seo' ),
+ ],
+ 'metabox' => $this->localize_term_scraper_script( $tag_id ),
+ 'userLanguageCode' => WPSEO_Language_Utils::get_language( get_user_locale() ),
+ 'isTerm' => true,
+ 'postId' => $tag_id,
+ 'termType' => $this->get_taxonomy(),
+ 'usedKeywordsNonce' => wp_create_nonce( 'wpseo-keyword-usage' ),
+ ];
+
+ /**
+ * The website information repository.
+ *
+ * @var $repo Website_Information_Repository
+ */
+ $repo = YoastSEO()->classes->get( Website_Information_Repository::class );
+ $term_information = $repo->get_term_site_information();
+ $term_information->set_term( get_term_by( 'id', $tag_id, $this::get_taxonomy() ) );
+ $script_data = array_merge_recursive( $term_information->get_legacy_site_information(), $script_data );
+
+ $asset_manager->localize_script( 'term-edit', 'wpseoScriptData', $script_data );
+ $asset_manager->enqueue_user_language_script();
+ }
+
+ if ( self::is_term_overview( $pagenow ) ) {
+ $asset_manager->enqueue_script( 'edit-page' );
+ }
+ }
+
+ /**
+ * Update the taxonomy meta data on save.
+ *
+ * @param int $term_id ID of the term to save data for.
+ * @param int $tt_id The taxonomy_term_id for the term.
+ * @param string $taxonomy The taxonomy the term belongs to.
+ *
+ * @return void
+ */
+ public function update_term( $term_id, $tt_id, $taxonomy ) {
+ // Bail if this is a multisite installation and the site has been switched.
+ if ( is_multisite() && ms_is_switched() ) {
+ return;
+ }
+
+ /* Create post array with only our values. */
+ $new_meta_data = [];
+ foreach ( WPSEO_Taxonomy_Meta::$defaults_per_term as $key => $default ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: Nonce is already checked by WordPress before executing this action.
+ if ( isset( $_POST[ $key ] ) && is_string( $_POST[ $key ] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: $data is getting sanitized later.
+ $data = wp_unslash( $_POST[ $key ] );
+ $new_meta_data[ $key ] = ( $key !== 'wpseo_canonical' ) ? WPSEO_Utils::sanitize_text_field( $data ) : WPSEO_Utils::sanitize_url( $data );
+ }
+
+ // If analysis is disabled remove that analysis score value from the DB.
+ if ( $this->is_meta_value_disabled( $key ) ) {
+ $new_meta_data[ $key ] = '';
+ }
+ }
+
+ // Saving the values.
+ WPSEO_Taxonomy_Meta::set_values( $term_id, $taxonomy, $new_meta_data );
+ }
+
+ /**
+ * Determines if the given meta value key is disabled.
+ *
+ * @param string $key The key of the meta value.
+ * @return bool Whether the given meta value key is disabled.
+ */
+ public function is_meta_value_disabled( $key ) {
+ if ( $key === 'wpseo_linkdex' && ! $this->analysis_seo->is_enabled() ) {
+ return true;
+ }
+
+ if ( $key === 'wpseo_content_score' && ! $this->analysis_readability->is_enabled() ) {
+ return true;
+ }
+
+ if ( $key === 'wpseo_inclusive_language_score' && ! $this->analysis_inclusive_language->is_enabled() ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Allows post-kses-filtered HTML in term descriptions.
+ *
+ * @return void
+ */
+ public function custom_category_descriptions_allow_html() {
+ remove_filter( 'term_description', 'wp_kses_data' );
+ remove_filter( 'pre_term_description', 'wp_filter_kses' );
+ add_filter( 'term_description', 'wp_kses_post' );
+ add_filter( 'pre_term_description', 'wp_filter_post_kses' );
+ }
+
+ /**
+ * Output the WordPress editor.
+ *
+ * @return void
+ */
+ public function custom_category_description_editor() {
+ wp_editor( '', 'description' );
+ }
+
+ /**
+ * Pass variables to js for use with the term-scraper.
+ *
+ * @param int $term_id The ID of the term to localize the script for.
+ *
+ * @return array
+ */
+ public function localize_term_scraper_script( $term_id ) {
+ $term = get_term_by( 'id', $term_id, $this::get_taxonomy() );
+ $taxonomy = get_taxonomy( $term->taxonomy );
+
+ $term_formatter = new WPSEO_Metabox_Formatter(
+ new WPSEO_Term_Metabox_Formatter( $taxonomy, $term )
+ );
+
+ return $term_formatter->get_values();
+ }
+
+ /**
+ * Pass some variables to js for replacing variables.
+ *
+ * @return array
+ */
+ public function localize_replace_vars_script() {
+ return [
+ 'no_parent_text' => __( '(no parent)', 'wordpress-seo' ),
+ 'replace_vars' => $this->get_replace_vars(),
+ 'recommended_replace_vars' => $this->get_recommended_replace_vars(),
+ 'scope' => $this->determine_scope(),
+ ];
+ }
+
+ /**
+ * Determines the scope based on the current taxonomy.
+ * This can be used by the replacevar plugin to determine if a replacement needs to be executed.
+ *
+ * @return string String decribing the current scope.
+ */
+ private function determine_scope() {
+ $taxonomy = $this::get_taxonomy();
+
+ if ( $taxonomy === 'category' ) {
+ return 'category';
+ }
+
+ if ( $taxonomy === 'post_tag' ) {
+ return 'tag';
+ }
+
+ return 'term';
+ }
+
+ /**
+ * Determines if a given page is the term overview page.
+ *
+ * @param string $page The string to check for the term overview page.
+ *
+ * @return bool
+ */
+ public static function is_term_overview( $page ) {
+ return $page === 'edit-tags.php';
+ }
+
+ /**
+ * Determines if a given page is the term edit page.
+ *
+ * @param string $page The string to check for the term edit page.
+ *
+ * @return bool
+ */
+ public static function is_term_edit( $page ) {
+ return $page === 'term.php';
+ }
+
+ /**
+ * Function to get the labels for the current taxonomy.
+ *
+ * @return object|null Labels for the current taxonomy or null if the taxonomy is not set.
+ */
+ public static function get_labels() {
+ $term = self::get_taxonomy();
+ if ( $term !== '' ) {
+ $taxonomy = get_taxonomy( $term );
+ return $taxonomy->labels;
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves a template.
+ * Check if metabox for current taxonomy should be displayed.
+ *
+ * @return bool
+ */
+ private function show_metabox() {
+ $option_key = 'display-metabox-tax-' . $this->taxonomy;
+
+ return WPSEO_Options::get( $option_key );
+ }
+
+ /**
+ * Getting the taxonomy from the URL.
+ *
+ * @return string
+ */
+ private static function get_taxonomy() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ return sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) );
+ }
+ return '';
+ }
+
+ /**
+ * Get the current tag ID from the GET parameters.
+ *
+ * @return int|null the tag ID if it exists, null otherwise.
+ */
+ private static function get_tag_id() {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
+ if ( isset( $_GET['tag_ID'] ) && is_string( $_GET['tag_ID'] ) ) {
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer.
+ $tag_id = (int) wp_unslash( $_GET['tag_ID'] );
+ if ( $tag_id > 0 ) {
+ return $tag_id;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Prepares the replace vars for localization.
+ *
+ * @return array The replacement variables.
+ */
+ private function get_replace_vars() {
+ $term_id = $this::get_tag_id();
+ $term = get_term_by( 'id', $term_id, $this::get_taxonomy() );
+
+ $cached_replacement_vars = [];
+
+ $vars_to_cache = [
+ 'date',
+ 'id',
+ 'sitename',
+ 'sitedesc',
+ 'sep',
+ 'page',
+ 'term_title',
+ 'term_description',
+ 'term_hierarchy',
+ 'category_description',
+ 'tag_description',
+ 'searchphrase',
+ 'currentyear',
+ ];
+
+ foreach ( $vars_to_cache as $var ) {
+ $cached_replacement_vars[ $var ] = wpseo_replace_vars( '%%' . $var . '%%', $term );
+ }
+
+ return $cached_replacement_vars;
+ }
+
+ /**
+ * Prepares the recommended replace vars for localization.
+ *
+ * @return array The recommended replacement variables.
+ */
+ private function get_recommended_replace_vars() {
+ $recommended_replace_vars = new WPSEO_Admin_Recommended_Replace_Vars();
+ $taxonomy = $this::get_taxonomy();
+
+ if ( $taxonomy === '' ) {
+ return [];
+ }
+
+ // What is recommended depends on the current context.
+ $page_type = $recommended_replace_vars->determine_for_term( $taxonomy );
+
+ return $recommended_replace_vars->get_recommended_replacevars_for( $page_type );
+ }
+
+ /**
+ * Returns an array with shortcode tags for all registered shortcodes.
+ *
+ * @return array Array with shortcode tags.
+ */
+ private function get_valid_shortcode_tags() {
+ $shortcode_tags = [];
+
+ foreach ( $GLOBALS['shortcode_tags'] as $tag => $description ) {
+ $shortcode_tags[] = $tag;
+ }
+
+ return $shortcode_tags;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-addon-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-addon-data.php
new file mode 100644
index 00000000..0cbc27c7
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-addon-data.php
@@ -0,0 +1,126 @@
+is_installed( WPSEO_Addon_Manager::LOCAL_SLUG ) ) {
+ $addon_settings = $this->get_local_addon_settings( $addon_settings, 'wpseo_local', WPSEO_Addon_Manager::LOCAL_SLUG, $this->local_include_list );
+ }
+
+ if ( $addon_manager->is_installed( WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ) ) {
+ $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_woo', WPSEO_Addon_Manager::WOOCOMMERCE_SLUG, $this->woo_include_list );
+ }
+
+ if ( $addon_manager->is_installed( WPSEO_Addon_Manager::NEWS_SLUG ) ) {
+ $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_news', WPSEO_Addon_Manager::NEWS_SLUG, $this->news_include_list );
+ }
+
+ if ( $addon_manager->is_installed( WPSEO_Addon_Manager::VIDEO_SLUG ) ) {
+ $addon_settings = $this->get_addon_settings( $addon_settings, 'wpseo_video', WPSEO_Addon_Manager::VIDEO_SLUG, $this->video_include_list );
+ }
+
+ return $addon_settings;
+ }
+
+ /**
+ * Gets the tracked options from the addon
+ *
+ * @param array $addon_settings The current list of addon settings.
+ * @param string $source_name The option key of the addon.
+ * @param string $slug The addon slug.
+ * @param array $option_include_list All the options to be included in tracking.
+ *
+ * @return array
+ */
+ public function get_addon_settings( array $addon_settings, $source_name, $slug, $option_include_list ) {
+ $source_options = get_option( $source_name, [] );
+ if ( ! is_array( $source_options ) || empty( $source_options ) ) {
+ return $addon_settings;
+ }
+ $addon_settings[ $slug ] = array_intersect_key( $source_options, array_flip( $option_include_list ) );
+
+ return $addon_settings;
+ }
+
+ /**
+ * Filter business_type in local addon settings.
+ *
+ * Remove the business_type setting when 'multiple_locations_shared_business_info' setting is turned off.
+ *
+ * @param array $addon_settings The current list of addon settings.
+ * @param string $source_name The option key of the addon.
+ * @param string $slug The addon slug.
+ * @param array $option_include_list All the options to be included in tracking.
+ *
+ * @return array
+ */
+ public function get_local_addon_settings( array $addon_settings, $source_name, $slug, $option_include_list ) {
+ $source_options = get_option( $source_name, [] );
+ if ( ! is_array( $source_options ) || empty( $source_options ) ) {
+ return $addon_settings;
+ }
+ $addon_settings[ $slug ] = array_intersect_key( $source_options, array_flip( $option_include_list ) );
+
+ if ( array_key_exists( 'use_multiple_locations', $source_options ) && array_key_exists( 'business_type', $addon_settings[ $slug ] ) && $source_options['use_multiple_locations'] === 'on' && $source_options['multiple_locations_shared_business_info'] === 'off' ) {
+ $addon_settings[ $slug ]['business_type'] = 'multiple_locations';
+ }
+
+ if ( ! ( new WooCommerce_Conditional() )->is_met() ) {
+ unset( $addon_settings[ $slug ]['woocommerce_local_pickup_setting'] );
+ }
+
+ return $addon_settings;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-default-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-default-data.php
new file mode 100644
index 00000000..498e7d08
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-default-data.php
@@ -0,0 +1,60 @@
+ get_option( 'blogname' ),
+ '@timestamp' => (int) gmdate( 'Uv' ),
+ 'wpVersion' => $this->get_wordpress_version(),
+ 'homeURL' => home_url(),
+ 'adminURL' => admin_url(),
+ 'isMultisite' => is_multisite(),
+ 'siteLanguage' => get_bloginfo( 'language' ),
+ 'gmt_offset' => get_option( 'gmt_offset' ),
+ 'timezoneString' => get_option( 'timezone_string' ),
+ 'migrationStatus' => get_option( 'yoast_migrations_free' ),
+ 'countPosts' => $this->get_post_count( 'post' ),
+ 'countPages' => $this->get_post_count( 'page' ),
+ ];
+ }
+
+ /**
+ * Returns the number of posts of a certain type.
+ *
+ * @param string $post_type The post type return the count for.
+ *
+ * @return int The count for this post type.
+ */
+ protected function get_post_count( $post_type ) {
+ $count = wp_count_posts( $post_type );
+ if ( isset( $count->publish ) ) {
+ return $count->publish;
+ }
+ return 0;
+ }
+
+ /**
+ * Returns the WordPress version.
+ *
+ * @return string The version.
+ */
+ protected function get_wordpress_version() {
+ global $wp_version;
+
+ return $wp_version;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-plugin-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-plugin-data.php
new file mode 100644
index 00000000..2c585e1d
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-plugin-data.php
@@ -0,0 +1,90 @@
+ $this->get_plugin_data(),
+ ];
+ }
+
+ /**
+ * Returns all plugins.
+ *
+ * @return array The formatted plugins.
+ */
+ protected function get_plugin_data() {
+
+ if ( ! function_exists( 'get_plugin_data' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
+ }
+ $plugins = wp_get_active_and_valid_plugins();
+
+ $plugins = array_map( 'get_plugin_data', $plugins );
+ $this->set_auto_update_plugin_list();
+ $plugins = array_map( [ $this, 'format_plugin' ], $plugins );
+
+ $plugin_data = [];
+ foreach ( $plugins as $plugin ) {
+ $plugin_key = sanitize_title( $plugin['name'] );
+ $plugin_data[ $plugin_key ] = $plugin;
+ }
+
+ return $plugin_data;
+ }
+
+ /**
+ * Sets all auto updating plugin data so it can be used in the tracking list.
+ *
+ * @return void
+ */
+ public function set_auto_update_plugin_list() {
+
+ $auto_update_plugins = [];
+ $auto_update_plugin_files = get_option( 'auto_update_plugins' );
+ if ( $auto_update_plugin_files ) {
+ foreach ( $auto_update_plugin_files as $auto_update_plugin ) {
+ $data = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $auto_update_plugin );
+ $auto_update_plugins[ $data['Name'] ] = $data;
+ }
+ }
+
+ $this->auto_update_plugin_list = $auto_update_plugins;
+ }
+
+ /**
+ * Formats the plugin array.
+ *
+ * @param array $plugin The plugin details.
+ *
+ * @return array The formatted array.
+ */
+ protected function format_plugin( array $plugin ) {
+
+ return [
+ 'name' => $plugin['Name'],
+ 'version' => $plugin['Version'],
+ 'auto_updating' => array_key_exists( $plugin['Name'], $this->auto_update_plugin_list ),
+ ];
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-server-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-server-data.php
new file mode 100644
index 00000000..220753f1
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-server-data.php
@@ -0,0 +1,85 @@
+ $this->get_server_data(),
+ ];
+ }
+
+ /**
+ * Returns the values with server details.
+ *
+ * @return array Array with the value.
+ */
+ protected function get_server_data() {
+ $server_data = [];
+
+ // Validate if the server address is a valid IP-address.
+ $ipaddress = isset( $_SERVER['SERVER_ADDR'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_ADDR'] ), FILTER_VALIDATE_IP ) : '';
+ if ( $ipaddress ) {
+ $server_data['ip'] = $ipaddress;
+ $server_data['Hostname'] = gethostbyaddr( $ipaddress );
+ }
+
+ $server_data['os'] = function_exists( 'php_uname' ) ? php_uname() : PHP_OS;
+ $server_data['PhpVersion'] = PHP_VERSION;
+ $server_data['CurlVersion'] = $this->get_curl_info();
+ $server_data['PhpExtensions'] = $this->get_php_extensions();
+
+ return $server_data;
+ }
+
+ /**
+ * Returns details about the curl version.
+ *
+ * @return array|null The curl info. Or null when curl isn't available..
+ */
+ protected function get_curl_info() {
+ if ( ! function_exists( 'curl_version' ) ) {
+ return null;
+ }
+
+ $curl = curl_version();
+
+ $ssl_support = true;
+ if ( ! $curl['features'] && CURL_VERSION_SSL ) {
+ $ssl_support = false;
+ }
+
+ return [
+ 'version' => $curl['version'],
+ 'sslSupport' => $ssl_support,
+ ];
+ }
+
+ /**
+ * Returns a list with php extensions.
+ *
+ * @return array Returns the state of the php extensions.
+ */
+ protected function get_php_extensions() {
+ return [
+ 'imagick' => extension_loaded( 'imagick' ),
+ 'filter' => extension_loaded( 'filter' ),
+ 'bcmath' => extension_loaded( 'bcmath' ),
+ 'pcre' => extension_loaded( 'pcre' ),
+ 'xml' => extension_loaded( 'xml' ),
+ 'pdo_mysql' => extension_loaded( 'pdo_mysql' ),
+ ];
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-settings-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-settings-data.php
new file mode 100644
index 00000000..45e25d35
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-settings-data.php
@@ -0,0 +1,277 @@
+include_list = apply_filters( 'wpseo_tracking_settings_include_list', $this->include_list );
+
+ $options = WPSEO_Options::get_all();
+ // Returns the settings of which the keys intersect with the values of the include list.
+ $options = array_intersect_key( $options, array_flip( $this->include_list ) );
+
+ return [
+ 'settings' => $this->anonymize_settings( $options ),
+ ];
+ }
+
+ /**
+ * Anonimizes the WPSEO_Options array by replacing all $anonymous_settings values to 'used'.
+ *
+ * @param array $settings The settings.
+ *
+ * @return array The anonymized settings.
+ */
+ private function anonymize_settings( $settings ) {
+ foreach ( $this->anonymous_settings as $setting ) {
+ if ( ! empty( $settings[ $setting ] ) ) {
+ $settings[ $setting ] = 'used';
+ }
+ }
+
+ return $settings;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-theme-data.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-theme-data.php
new file mode 100644
index 00000000..e2225950
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking-theme-data.php
@@ -0,0 +1,51 @@
+ [
+ 'name' => $theme->get( 'Name' ),
+ 'url' => $theme->get( 'ThemeURI' ),
+ 'version' => $theme->get( 'Version' ),
+ 'author' => [
+ 'name' => $theme->get( 'Author' ),
+ 'url' => $theme->get( 'AuthorURI' ),
+ ],
+ 'parentTheme' => $this->get_parent_theme( $theme ),
+ 'blockTemplateSupport' => current_theme_supports( 'block-templates' ),
+ 'isBlockTheme' => function_exists( 'wp_is_block_theme' ) && wp_is_block_theme(),
+ ],
+ ];
+ }
+
+ /**
+ * Returns the name of the parent theme.
+ *
+ * @param WP_Theme $theme The theme object.
+ *
+ * @return string|null The name of the parent theme or null.
+ */
+ private function get_parent_theme( WP_Theme $theme ) {
+ if ( is_child_theme() ) {
+ return $theme->get( 'Template' );
+ }
+
+ return null;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking.php b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking.php
new file mode 100644
index 00000000..58bfdff3
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/tracking/class-tracking.php
@@ -0,0 +1,240 @@
+tracking_enabled() ) {
+ return;
+ }
+
+ $this->endpoint = $endpoint;
+ $this->threshold = $threshold;
+ $this->current_time = time();
+ }
+
+ /**
+ * Registers all hooks to WordPress.
+ *
+ * @return void
+ */
+ public function register_hooks() {
+ if ( ! $this->tracking_enabled() ) {
+ return;
+ }
+
+ // Send tracking data on `admin_init`.
+ add_action( 'admin_init', [ $this, 'send' ], 1 );
+
+ // Add an action hook that will be triggered at the specified time by `wp_schedule_single_event()`.
+ add_action( 'wpseo_send_tracking_data_after_core_update', [ $this, 'send' ] );
+ // Call `wp_schedule_single_event()` after a WordPress core update.
+ add_action( 'upgrader_process_complete', [ $this, 'schedule_tracking_data_sending' ], 10, 2 );
+ }
+
+ /**
+ * Schedules a new sending of the tracking data after a WordPress core update.
+ *
+ * @param bool|WP_Upgrader $upgrader Optional. WP_Upgrader instance or false.
+ * Depending on context, it might be a Theme_Upgrader,
+ * Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader.
+ * instance. Default false.
+ * @param array $data Array of update data.
+ *
+ * @return void
+ */
+ public function schedule_tracking_data_sending( $upgrader = false, $data = [] ) {
+ // Return if it's not a WordPress core update.
+ if ( ! $upgrader || ! isset( $data['type'] ) || $data['type'] !== 'core' ) {
+ return;
+ }
+
+ /*
+ * To uniquely identify the scheduled cron event, `wp_next_scheduled()`
+ * needs to receive the same arguments as those used when originally
+ * scheduling the event otherwise it will always return false.
+ */
+ if ( ! wp_next_scheduled( 'wpseo_send_tracking_data_after_core_update', [ true ] ) ) {
+ /*
+ * Schedule sending of data tracking 6 hours after a WordPress core
+ * update. Pass a `true` parameter for the callback `$force` argument.
+ */
+ wp_schedule_single_event( ( time() + ( HOUR_IN_SECONDS * 6 ) ), 'wpseo_send_tracking_data_after_core_update', [ true ] );
+ }
+ }
+
+ /**
+ * Sends the tracking data.
+ *
+ * @param bool $force Whether to send the tracking data ignoring the two
+ * weeks time threshold. Default false.
+ *
+ * @return void
+ */
+ public function send( $force = false ) {
+ if ( ! $this->should_send_tracking( $force ) ) {
+ return;
+ }
+
+ // Set a 'content-type' header of 'application/json'.
+ $tracking_request_args = [
+ 'headers' => [
+ 'content-type:' => 'application/json',
+ ],
+ ];
+
+ $collector = $this->get_collector();
+
+ $request = new WPSEO_Remote_Request( $this->endpoint, $tracking_request_args );
+ $request->set_body( $collector->get_as_json() );
+ $request->send();
+
+ update_option( $this->option_name, $this->current_time, 'yes' );
+ }
+
+ /**
+ * Determines whether to send the tracking data.
+ *
+ * Returns false if tracking is disabled or the current page is one of the
+ * admin plugins pages. Returns true when there's no tracking data stored or
+ * the data was sent more than two weeks ago. The two weeks interval is set
+ * when instantiating the class.
+ *
+ * @param bool $ignore_time_treshhold Whether to send the tracking data ignoring
+ * the two weeks time treshhold. Default false.
+ *
+ * @return bool True when tracking data should be sent.
+ */
+ protected function should_send_tracking( $ignore_time_treshhold = false ) {
+ global $pagenow;
+
+ // Only send tracking on the main site of a multi-site instance. This returns true on non-multisite installs.
+ if ( is_network_admin() || ! is_main_site() ) {
+ return false;
+ }
+
+ // Because we don't want to possibly block plugin actions with our routines.
+ if ( in_array( $pagenow, [ 'plugins.php', 'plugin-install.php', 'plugin-editor.php' ], true ) ) {
+ return false;
+ }
+
+ $last_time = get_option( $this->option_name );
+
+ // When tracking data haven't been sent yet or when sending data is forced.
+ if ( ! $last_time || $ignore_time_treshhold ) {
+ return true;
+ }
+
+ return $this->exceeds_treshhold( $this->current_time - $last_time );
+ }
+
+ /**
+ * Checks if the given amount of seconds exceeds the set threshold.
+ *
+ * @param int $seconds The amount of seconds to check.
+ *
+ * @return bool True when seconds is bigger than threshold.
+ */
+ protected function exceeds_treshhold( $seconds ) {
+ return ( $seconds > $this->threshold );
+ }
+
+ /**
+ * Returns the collector for collecting the data.
+ *
+ * @return WPSEO_Collector The instance of the collector.
+ */
+ public function get_collector() {
+ $collector = new WPSEO_Collector();
+ $collector->add_collection( new WPSEO_Tracking_Default_Data() );
+ $collector->add_collection( new WPSEO_Tracking_Server_Data() );
+ $collector->add_collection( new WPSEO_Tracking_Theme_Data() );
+ $collector->add_collection( new WPSEO_Tracking_Plugin_Data() );
+ $collector->add_collection( new WPSEO_Tracking_Settings_Data() );
+ $collector->add_collection( new WPSEO_Tracking_Addon_Data() );
+ $collector->add_collection( YoastSEO()->classes->get( Missing_Indexables_Collector::class ) );
+ $collector->add_collection( YoastSEO()->classes->get( To_Be_Cleaned_Indexables_Collector::class ) );
+
+ return $collector;
+ }
+
+ /**
+ * See if we should run tracking at all.
+ *
+ * @return bool True when we can track, false when we can't.
+ */
+ private function tracking_enabled() {
+ // Check if we're allowing tracking.
+ $tracking = WPSEO_Options::get( 'tracking' );
+
+ if ( $tracking === false ) {
+ return false;
+ }
+
+ // Save this state.
+ if ( $tracking === null ) {
+ /**
+ * Filter: 'wpseo_enable_tracking' - Enables the data tracking of Yoast SEO Premium and add-ons.
+ *
+ * @param string $is_enabled The enabled state. Default is false.
+ */
+ $tracking = apply_filters( 'wpseo_enable_tracking', false );
+
+ WPSEO_Options::set( 'tracking', $tracking );
+ }
+
+ if ( $tracking === false ) {
+ return false;
+ }
+
+ if ( ! YoastSEO()->helpers->environment->is_production_mode() ) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggle.php b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggle.php
new file mode 100644
index 00000000..ea61a73b
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggle.php
@@ -0,0 +1,206 @@
+ $value ) {
+ if ( property_exists( $this, $key ) ) {
+ $this->$key = $value;
+ }
+ }
+ }
+
+ /**
+ * Magic isset-er.
+ *
+ * @param string $key Key to check whether a value for it is set.
+ *
+ * @return bool True if set, false otherwise.
+ */
+ public function __isset( $key ) {
+ return isset( $this->$key );
+ }
+
+ /**
+ * Magic getter.
+ *
+ * @param string $key Key to get the value for.
+ *
+ * @return mixed Value for the key, or null if not set.
+ */
+ public function __get( $key ) {
+ if ( isset( $this->$key ) ) {
+ return $this->$key;
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks whether the feature for this toggle is enabled.
+ *
+ * @return bool True if the feature is enabled, false otherwise.
+ */
+ public function is_enabled() {
+ return (bool) WPSEO_Options::get( $this->setting );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggles.php b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggles.php
new file mode 100644
index 00000000..a4efc0d5
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-feature-toggles.php
@@ -0,0 +1,284 @@
+toggles === null ) {
+ $this->toggles = $this->load_toggles();
+ }
+
+ return $this->toggles;
+ }
+
+ /**
+ * Loads the available feature toggles.
+ *
+ * Also ensures that the toggles are all Yoast_Feature_Toggle instances and sorted by their order value.
+ *
+ * @return array List of sorted Yoast_Feature_Toggle instances.
+ */
+ protected function load_toggles() {
+ $xml_sitemap_extra = false;
+ if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) {
+ $xml_sitemap_extra = '' . esc_html__( 'See the XML sitemap.', 'wordpress-seo' ) . '';
+ }
+
+ $feature_toggles = [
+ (object) [
+ 'name' => __( 'SEO analysis', 'wordpress-seo' ),
+ 'setting' => 'keyword_analysis_active',
+ 'label' => __( 'The SEO analysis offers suggestions to improve the SEO of your text.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Learn how the SEO analysis can help you rank.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/2ak',
+ 'order' => 10,
+ ],
+ (object) [
+ 'name' => __( 'Readability analysis', 'wordpress-seo' ),
+ 'setting' => 'content_analysis_active',
+ 'label' => __( 'The readability analysis offers suggestions to improve the structure and style of your text.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Discover why readability is important for SEO.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/2ao',
+ 'order' => 20,
+ ],
+ (object) [
+ 'name' => __( 'Inclusive language analysis', 'wordpress-seo' ),
+ 'supported_languages' => Language_Helper::$languages_with_inclusive_language_support,
+ 'setting' => 'inclusive_language_analysis_active',
+ 'label' => __( 'The inclusive language analysis offers suggestions to write more inclusive copy.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Discover why inclusive language is important for SEO.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/inclusive-language-features-free',
+ 'order' => 25,
+ ],
+ (object) [
+ 'name' => __( 'Cornerstone content', 'wordpress-seo' ),
+ 'setting' => 'enable_cornerstone_content',
+ 'label' => __( 'The cornerstone content feature lets you to mark and filter cornerstone content on your website.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Find out how cornerstone content can help you improve your site structure.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/dashboard-help-cornerstone',
+ 'order' => 30,
+ ],
+ (object) [
+ 'name' => __( 'Text link counter', 'wordpress-seo' ),
+ 'setting' => 'enable_text_link_counter',
+ 'label' => __( 'The text link counter helps you improve your site structure.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Find out how the text link counter can enhance your SEO.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/2aj',
+ 'order' => 40,
+ ],
+ (object) [
+ 'name' => __( 'Insights', 'wordpress-seo' ),
+ 'setting' => 'enable_metabox_insights',
+ 'label' => __( 'Find relevant data about your content right in the Insights section in the Yoast SEO metabox. You’ll see what words you use most often and if they’re a match with your keywords! ', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Find out how Insights can help you improve your content.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/4ew',
+ 'premium_url' => 'https://yoa.st/2ai',
+ 'order' => 41,
+ ],
+ (object) [
+ 'name' => __( 'Link suggestions', 'wordpress-seo' ),
+ 'premium' => true,
+ 'setting' => 'enable_link_suggestions',
+ 'label' => __( 'Get relevant internal linking suggestions — while you’re writing! The link suggestions metabox shows a list of posts on your blog with similar content that might be interesting to link to. ', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Read more about how internal linking can improve your site structure.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/4ev',
+ 'premium_url' => 'https://yoa.st/17g',
+ 'premium_upsell_url' => 'https://yoa.st/get-link-suggestions',
+ 'order' => 42,
+ ],
+ (object) [
+ 'name' => __( 'XML sitemaps', 'wordpress-seo' ),
+ 'setting' => 'enable_xml_sitemap',
+ /* translators: %s: Yoast SEO */
+ 'label' => sprintf( __( 'Enable the XML sitemaps that %s generates.', 'wordpress-seo' ), 'Yoast SEO' ),
+ 'read_more_label' => __( 'Read why XML Sitemaps are important for your site.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/2a-',
+ 'extra' => $xml_sitemap_extra,
+ 'after' => $this->sitemaps_toggle_after(),
+ 'order' => 60,
+ ],
+ (object) [
+ 'name' => __( 'Admin bar menu', 'wordpress-seo' ),
+ 'setting' => 'enable_admin_bar_menu',
+ /* translators: 1: Yoast SEO */
+ 'label' => sprintf( __( 'The %1$s admin bar menu contains useful links to third-party tools for analyzing pages and makes it easy to see if you have new notifications.', 'wordpress-seo' ), 'Yoast SEO' ),
+ 'order' => 80,
+ ],
+ (object) [
+ 'name' => __( 'Security: no advanced or schema settings for authors', 'wordpress-seo' ),
+ 'setting' => 'disableadvanced_meta',
+ 'label' => sprintf(
+ /* translators: 1: Yoast SEO, 2: translated version of "Off" */
+ __( 'The advanced section of the %1$s meta box allows a user to remove posts from the search results or change the canonical. The settings in the schema tab allows a user to change schema meta data for a post. These are things you might not want any author to do. That\'s why, by default, only editors and administrators can do this. Setting to "%2$s" allows all users to change these settings.', 'wordpress-seo' ),
+ 'Yoast SEO',
+ __( 'Off', 'wordpress-seo' )
+ ),
+ 'order' => 90,
+ ],
+ (object) [
+ 'name' => __( 'Usage tracking', 'wordpress-seo' ),
+ 'label' => __( 'Usage tracking', 'wordpress-seo' ),
+ 'setting' => 'tracking',
+ 'read_more_label' => sprintf(
+ /* translators: 1: Yoast SEO */
+ __( 'Allow us to track some data about your site to improve our plugin.', 'wordpress-seo' ),
+ 'Yoast SEO'
+ ),
+ 'read_more_url' => 'https://yoa.st/usage-tracking-2',
+ 'order' => 95,
+ ],
+ (object) [
+ 'name' => __( 'REST API: Head endpoint', 'wordpress-seo' ),
+ 'setting' => 'enable_headless_rest_endpoints',
+ 'label' => sprintf(
+ /* translators: 1: Yoast SEO */
+ __( 'This %1$s REST API endpoint gives you all the metadata you need for a specific URL. This will make it very easy for headless WordPress sites to use %1$s for all their SEO meta output.', 'wordpress-seo' ),
+ 'Yoast SEO'
+ ),
+ 'order' => 100,
+ ],
+ (object) [
+ 'name' => __( 'Enhanced Slack sharing', 'wordpress-seo' ),
+ 'setting' => 'enable_enhanced_slack_sharing',
+ 'label' => __( 'This adds an author byline and reading time estimate to the article’s snippet when shared on Slack.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Find out how a rich snippet can improve visibility and click-through-rate.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/help-slack-share',
+ 'order' => 105,
+ ],
+ (object) [
+ 'name' => __( 'IndexNow', 'wordpress-seo' ),
+ 'premium' => true,
+ 'setting' => 'enable_index_now',
+ 'label' => __( 'Automatically ping search engines like Bing and Yandex whenever you publish, update or delete a post.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Find out how IndexNow can help your site.', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/index-now-read-more',
+ 'premium_url' => 'https://yoa.st/index-now-feature',
+ 'premium_upsell_url' => 'https://yoa.st/get-indexnow',
+ 'order' => 110,
+ ],
+ (object) [
+ 'name' => __( 'AI title & description generator', 'wordpress-seo' ),
+ 'premium' => true,
+ 'setting' => 'enable_ai_generator',
+ 'label' => __( 'Use the power of Yoast AI to automatically generate compelling titles and descriptions for your posts and pages.', 'wordpress-seo' ),
+ 'read_more_label' => __( 'Learn more', 'wordpress-seo' ),
+ 'read_more_url' => 'https://yoa.st/ai-generator-read-more',
+ 'premium_url' => 'https://yoa.st/ai-generator-feature',
+ 'premium_upsell_url' => 'https://yoa.st/get-ai-generator',
+ 'order' => 115,
+ ],
+ ];
+
+ /**
+ * Filter to add feature toggles from add-ons.
+ *
+ * @param array $feature_toggles Array with feature toggle objects where each object
+ * should have a `name`, `setting` and `label` property.
+ */
+ $feature_toggles = apply_filters( 'wpseo_feature_toggles', $feature_toggles );
+
+ $feature_toggles = array_map( [ $this, 'ensure_toggle' ], $feature_toggles );
+ usort( $feature_toggles, [ $this, 'sort_toggles_callback' ] );
+
+ return $feature_toggles;
+ }
+
+ /**
+ * Returns html for a warning that core sitemaps are enabled when yoast seo sitemaps are disabled.
+ *
+ * @return string HTML string for the warning.
+ */
+ protected function sitemaps_toggle_after() {
+ $out = '
';
+ $alert = new Alert_Presenter(
+ /* translators: %1$s: expands to an opening anchor tag, %2$s: expands to a closing anchor tag */
+ sprintf( esc_html__( 'Disabling Yoast SEO\'s XML sitemaps will not disable WordPress\' core sitemaps. In some cases, this %1$s may result in SEO errors on your site%2$s. These may be reported in Google Search Console and other tools.', 'wordpress-seo' ), '', '' ),
+ 'warning'
+ );
+ $out .= $alert->present();
+ $out .= '
';
+
+ return $out;
+ }
+
+ /**
+ * Ensures that the passed value is a Yoast_Feature_Toggle.
+ *
+ * @param Yoast_Feature_Toggle|object|array $toggle_data Feature toggle instance, or raw object or array
+ * containing feature toggle data.
+ * @return Yoast_Feature_Toggle Feature toggle instance based on $toggle_data.
+ */
+ protected function ensure_toggle( $toggle_data ) {
+ if ( $toggle_data instanceof Yoast_Feature_Toggle ) {
+ return $toggle_data;
+ }
+
+ if ( is_object( $toggle_data ) ) {
+ $toggle_data = get_object_vars( $toggle_data );
+ }
+
+ return new Yoast_Feature_Toggle( $toggle_data );
+ }
+
+ /**
+ * Callback for sorting feature toggles by their order.
+ *
+ * {@internal Once the minimum PHP version goes up to PHP 7.0, the logic in the function
+ * can be replaced with the spaceship operator `<=>`.}
+ *
+ * @param Yoast_Feature_Toggle $feature_a Feature A.
+ * @param Yoast_Feature_Toggle $feature_b Feature B.
+ *
+ * @return int An integer less than, equal to, or greater than zero indicating respectively
+ * that feature A is considered to be less than, equal to, or greater than feature B.
+ */
+ protected function sort_toggles_callback( Yoast_Feature_Toggle $feature_a, Yoast_Feature_Toggle $feature_b ) {
+ return ( $feature_a->order - $feature_b->order );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/views/class-yoast-input-select.php b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-input-select.php
new file mode 100644
index 00000000..1f2a1735
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-input-select.php
@@ -0,0 +1,146 @@
+select_id = $select_id;
+ $this->select_name = $select_name;
+ $this->select_options = $select_options;
+ $this->selected_option = $selected_option;
+ }
+
+ /**
+ * Print the rendered view.
+ *
+ * @return void
+ */
+ public function output_html() {
+ // Extract it, because we want each value accessible via a variable instead of accessing it as an array.
+ extract( $this->get_select_values() );
+
+ require WPSEO_PATH . 'admin/views/form/select.php';
+ }
+
+ /**
+ * Return the rendered view.
+ *
+ * @return string
+ */
+ public function get_html() {
+ ob_start();
+
+ $this->output_html();
+
+ $rendered_output = ob_get_contents();
+ ob_end_clean();
+
+ return $rendered_output;
+ }
+
+ /**
+ * Add an attribute to the attributes property.
+ *
+ * @param string $attribute The name of the attribute to add.
+ * @param string $value The value of the attribute.
+ *
+ * @return void
+ */
+ public function add_attribute( $attribute, $value ) {
+ $this->select_attributes[ $attribute ] = $value;
+ }
+
+ /**
+ * Return the set fields for the select.
+ *
+ * @return array
+ */
+ private function get_select_values() {
+ return [
+ 'id' => $this->select_id,
+ 'name' => $this->select_name,
+ 'attributes' => $this->get_attributes(),
+ 'options' => $this->select_options,
+ 'selected' => $this->selected_option,
+ ];
+ }
+
+ /**
+ * Return the attribute string, when there are attributes set.
+ *
+ * @return string
+ */
+ private function get_attributes() {
+ $attributes = $this->select_attributes;
+
+ if ( ! empty( $attributes ) ) {
+ array_walk( $attributes, [ $this, 'parse_attribute' ] );
+
+ return implode( ' ', $attributes ) . ' ';
+ }
+
+ return '';
+ }
+
+ /**
+ * Get an attribute from the attributes.
+ *
+ * @param string $value The value of the attribute.
+ * @param string $attribute The attribute to look for.
+ *
+ * @return void
+ */
+ private function parse_attribute( &$value, $attribute ) {
+ $value = sprintf( '%s="%s"', sanitize_key( $attribute ), esc_attr( $value ) );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/views/class-yoast-integration-toggles.php b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-integration-toggles.php
new file mode 100644
index 00000000..ac66ee0f
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/class-yoast-integration-toggles.php
@@ -0,0 +1,139 @@
+toggles === null ) {
+ $this->toggles = $this->load_toggles();
+ }
+
+ return $this->toggles;
+ }
+
+ /**
+ * Loads the available integration toggles.
+ *
+ * Also ensures that the toggles are all Yoast_Feature_Toggle instances and sorted by their order value.
+ *
+ * @return array List of sorted Yoast_Feature_Toggle instances.
+ */
+ protected function load_toggles() {
+ $integration_toggles = [
+ (object) [
+ /* translators: %s: 'Semrush' */
+ 'name' => sprintf( __( '%s integration', 'wordpress-seo' ), 'Semrush' ),
+ 'setting' => 'semrush_integration_active',
+ 'label' => sprintf(
+ /* translators: %s: 'Semrush' */
+ __( 'The %s integration offers suggestions and insights for keywords related to the entered focus keyphrase.', 'wordpress-seo' ),
+ 'Semrush'
+ ),
+ 'order' => 10,
+ ],
+ (object) [
+ /* translators: %s: Algolia. */
+ 'name' => sprintf( esc_html__( '%s integration', 'wordpress-seo' ), 'Algolia' ),
+ 'premium' => true,
+ 'setting' => 'algolia_integration_active',
+ 'label' => __( 'Improve the quality of your site search! Automatically helps your users find your cornerstone and most important content in your internal search results. It also removes noindexed posts & pages from your site’s search results.', 'wordpress-seo' ),
+ /* translators: %s: Algolia. */
+ 'read_more_label' => sprintf( __( 'Find out more about our %s integration.', 'wordpress-seo' ), 'Algolia' ),
+ 'read_more_url' => 'https://yoa.st/4eu',
+ 'premium_url' => 'https://yoa.st/4ex',
+ 'premium_upsell_url' => 'https://yoa.st/get-algolia-integration',
+ 'order' => 25,
+ ],
+ ];
+
+ /**
+ * Filter to add integration toggles from add-ons.
+ *
+ * @param array $integration_toggles Array with integration toggle objects where each object
+ * should have a `name`, `setting` and `label` property.
+ */
+ $integration_toggles = apply_filters( 'wpseo_integration_toggles', $integration_toggles );
+
+ $integration_toggles = array_map( [ $this, 'ensure_toggle' ], $integration_toggles );
+ usort( $integration_toggles, [ $this, 'sort_toggles_callback' ] );
+
+ return $integration_toggles;
+ }
+
+ /**
+ * Ensures that the passed value is a Yoast_Feature_Toggle.
+ *
+ * @param Yoast_Feature_Toggle|object|array $toggle_data Feature toggle instance, or raw object or array
+ * containing integration toggle data.
+ * @return Yoast_Feature_Toggle Feature toggle instance based on $toggle_data.
+ */
+ protected function ensure_toggle( $toggle_data ) {
+ if ( $toggle_data instanceof Yoast_Feature_Toggle ) {
+ return $toggle_data;
+ }
+
+ if ( is_object( $toggle_data ) ) {
+ $toggle_data = get_object_vars( $toggle_data );
+ }
+
+ return new Yoast_Feature_Toggle( $toggle_data );
+ }
+
+ /**
+ * Callback for sorting integration toggles by their order.
+ *
+ * {@internal Once the minimum PHP version goes up to PHP 7.0, the logic in the function
+ * can be replaced with the spaceship operator `<=>`.}
+ *
+ * @param Yoast_Feature_Toggle $feature_a Feature A.
+ * @param Yoast_Feature_Toggle $feature_b Feature B.
+ *
+ * @return int An integer less than, equal to, or greater than zero indicating respectively
+ * that feature A is considered to be less than, equal to, or greater than feature B.
+ */
+ protected function sort_toggles_callback( Yoast_Feature_Toggle $feature_a, Yoast_Feature_Toggle $feature_b ) {
+ return ( $feature_a->order - $feature_b->order );
+ }
+}
diff --git a/wp-content/plugins/wordpress-seo/admin/views/form/select.php b/wp-content/plugins/wordpress-seo/admin/views/form/select.php
new file mode 100644
index 00000000..8f3a846c
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/form/select.php
@@ -0,0 +1,26 @@
+
+
+
diff --git a/wp-content/plugins/wordpress-seo/admin/views/interface-yoast-form-element.php b/wp-content/plugins/wordpress-seo/admin/views/interface-yoast-form-element.php
new file mode 100644
index 00000000..24a8ccb3
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/interface-yoast-form-element.php
@@ -0,0 +1,19 @@
+
+
+
+
+
diff --git a/wp-content/plugins/wordpress-seo/admin/views/licenses.php b/wp-content/plugins/wordpress-seo/admin/views/licenses.php
new file mode 100644
index 00000000..69618cbe
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/licenses.php
@@ -0,0 +1,395 @@
+ WPSEO_Shortlinker::get( 'https://yoa.st/zz' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zy' ),
+ 'title' => 'Yoast SEO Premium',
+ /* translators: %1$s expands to Yoast SEO */
+ 'desc' => sprintf( __( 'The premium version of %1$s with more features & support.', 'wordpress-seo' ), 'Yoast SEO' ),
+ 'image' => plugin_dir_url( WPSEO_FILE ) . 'packages/js/images/Yoast_SEO_Icon.svg',
+ 'benefits' => [],
+];
+
+$extensions = [
+ WPSEO_Addon_Manager::LOCAL_SLUG => [
+ 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zt' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zs' ),
+ 'title' => 'Local SEO',
+ 'display_title' => __( 'Stand out for local searches', 'wordpress-seo' ),
+ 'desc' => __( 'Rank better locally and in Google Maps, without breaking a sweat!', 'wordpress-seo' ),
+ 'image' => plugins_url( 'images/local_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
+ 'benefits' => [
+ __( 'Attract more customers to your site and physical store', 'wordpress-seo' ),
+ __( 'Automatically get technical SEO best practices for local businesses', 'wordpress-seo' ),
+ __( 'Easily add maps, address finders, and opening hours to your content', 'wordpress-seo' ),
+ __( 'Optimize your business for multiple locations', 'wordpress-seo' ),
+ ],
+ ],
+ WPSEO_Addon_Manager::VIDEO_SLUG => [
+ 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zx/' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zw/' ),
+ 'title' => 'Video SEO',
+ 'display_title' => __( 'Drive more views to your videos', 'wordpress-seo' ),
+ 'desc' => __( 'Optimize your videos to show them off in search results and get more clicks!', 'wordpress-seo' ),
+ 'image' => plugins_url( 'images/video_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
+ 'benefits' => [
+ __( 'Automatically get technical SEO best practices for video content', 'wordpress-seo' ),
+ __( 'Make sure your videos load quickly for users', 'wordpress-seo' ),
+ __( 'Make your videos responsive for all screen sizes', 'wordpress-seo' ),
+ __( 'Optimize your video previews & thumbnails', 'wordpress-seo' ),
+ ],
+ ],
+ WPSEO_Addon_Manager::NEWS_SLUG => [
+ 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zv/' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zu/' ),
+ 'title' => 'News SEO',
+ 'display_title' => __( 'Rank higher in Google\'s news carousel', 'wordpress-seo' ),
+ 'desc' => __( 'Are you in Google News? Increase your traffic from Google News by optimizing for it!', 'wordpress-seo' ),
+ 'image' => plugins_url( 'images/news_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
+ 'benefits' => [
+ __( 'Optimize your site for Google News', 'wordpress-seo' ),
+ __( 'Ping Google on the publication of a new post', 'wordpress-seo' ),
+ __( 'Add all necessary schema.org markup', 'wordpress-seo' ),
+ __( 'Get XML sitemaps', 'wordpress-seo' ),
+ ],
+ ],
+];
+
+// Add Yoast WooCommerce SEO when WooCommerce is active.
+if ( YoastSEO()->helpers->woocommerce->is_active() ) {
+ $extensions[ WPSEO_Addon_Manager::WOOCOMMERCE_SLUG ] = [
+ 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zr' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/zq' ),
+ 'title' => 'Yoast WooCommerce SEO',
+ 'display_title' => __( 'Drive more traffic to your online store', 'wordpress-seo' ),
+ /* translators: %1$s expands to Yoast SEO */
+ 'desc' => sprintf( __( 'Seamlessly integrate WooCommerce with %1$s and get extra features!', 'wordpress-seo' ), 'Yoast SEO' ),
+ 'image' => plugins_url( 'images/woo_plugin_assistant.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
+ 'benefits' => [
+ __( 'Write product pages that rank using the SEO analysis', 'wordpress-seo' ),
+ __( 'Increase Google clicks with rich results', 'wordpress-seo' ),
+ __( 'Add global identifiers for variable products', 'wordpress-seo' ),
+ /* translators: %1$s expands to Yoast SEO, %2$s expands to WooCommerce */
+ sprintf( __( 'Seamless integration between %1$s and %2$s', 'wordpress-seo' ), 'Yoast SEO', 'WooCommerce' ),
+ __( 'Turn more visitors into customers!', 'wordpress-seo' ),
+ ],
+ 'buy_button' => 'WooCommerce SEO',
+ ];
+}
+
+// The total number of plugins to consider is the length of the array + 1 for Premium.
+// @phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
+$number_plugins_total = ( count( $extensions ) + 1 );
+// @phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
+$number_plugins_active = 0;
+
+$extensions['yoast-seo-plugin-subscription'] = [
+ 'buyUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/premium-page-bundle-buy' ),
+ 'infoUrl' => WPSEO_Shortlinker::get( 'https://yoa.st/premium-page-bundle-info' ),
+ /* translators: used in phrases such as "More information about all the Yoast plugins" */
+ 'title' => __( 'all the Yoast plugins', 'wordpress-seo' ),
+ 'display_title' => __( 'Cover all your SEO bases', 'wordpress-seo' ),
+ 'desc' => '',
+ 'image' => plugins_url( 'images/plugin_subscription.svg?v=' . WPSEO_VERSION, WPSEO_FILE ),
+ 'benefits' => [
+ __( 'Get all 5 Yoast plugins for WordPress at a big discount', 'wordpress-seo' ),
+ __( 'Reach new customers who live near your business', 'wordpress-seo' ),
+ __( 'Drive more views to your videos', 'wordpress-seo' ),
+ __( 'Rank higher in Google\'s news carousel', 'wordpress-seo' ),
+ __( 'Drive more traffic to your online store', 'wordpress-seo' ),
+
+ ],
+ /* translators: used in phrases such as "Buy all the Yoast plugins" */
+ 'buy_button' => __( 'all the Yoast plugins', 'wordpress-seo' ),
+];
+
+$addon_manager = new WPSEO_Addon_Manager();
+$has_valid_premium_subscription = YoastSEO()->helpers->product->is_premium() && $addon_manager->has_valid_subscription( WPSEO_Addon_Manager::PREMIUM_SLUG );
+
+/* translators: %1$s expands to Yoast SEO. */
+$wpseo_extensions_header = sprintf( __( '%1$s Extensions', 'wordpress-seo' ), 'Yoast SEO' );
+$new_tab_message = sprintf(
+ '%1$s',
+ /* translators: Hidden accessibility text. */
+ esc_html__( '(Opens in a new browser tab)', 'wordpress-seo' )
+);
+
+$sale_badge = '';
+$premium_sale_badge = '';
+
+if ( YoastSEO()->classes->get( Promotion_Manager::class )->is( 'black-friday-2023-promotion' ) ) {
+ /* translators: %1$s expands to opening span, %2$s expands to closing span */
+ $sale_badge_span = sprintf( esc_html__( '%1$sSALE 30%% OFF!%2$s', 'wordpress-seo' ), '', '' );
+
+ $sale_badge = '
+hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
diff --git a/wp-content/plugins/wordpress-seo/admin/views/tabs/network/general.php b/wp-content/plugins/wordpress-seo/admin/views/tabs/network/general.php
new file mode 100644
index 00000000..a73c722b
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/tabs/network/general.php
@@ -0,0 +1,56 @@
+';
+
+/*
+ * {@internal Important: Make sure the options added to the array here are in line with the
+ * options set in the WPSEO_Option_MS::$allowed_access_options property.}}
+ */
+$yform->select(
+ 'access',
+ /* translators: %1$s expands to Yoast SEO */
+ sprintf( __( 'Who should have access to the %1$s settings', 'wordpress-seo' ), 'Yoast SEO' ),
+ [
+ 'admin' => __( 'Site Admins (default)', 'wordpress-seo' ),
+ 'superadmin' => __( 'Super Admins only', 'wordpress-seo' ),
+ ]
+);
+
+if ( get_blog_count() <= 100 ) {
+ $network_admin = new Yoast_Network_Admin();
+
+ $yform->select(
+ 'defaultblog',
+ __( 'New sites in the network inherit their SEO settings from this site', 'wordpress-seo' ),
+ $network_admin->get_site_choices( true, true )
+ );
+ echo '
' . esc_html__( 'Choose the site whose settings you want to use as default for all sites that are added to your network. If you choose \'None\', the normal plugin defaults will be used.', 'wordpress-seo' ) . '
';
+}
+else {
+ $yform->textinput( 'defaultblog', __( 'New sites in the network inherit their SEO settings from this site', 'wordpress-seo' ) );
+ echo '
';
+ printf(
+ /* translators: 1: link open tag; 2: link close tag. */
+ esc_html__( 'Enter the %1$sSite ID%2$s for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none (i.e. the normal plugin defaults will be used).', 'wordpress-seo' ),
+ '',
+ ''
+ );
+ echo '
';
+}
+
+echo '
' . esc_html__( 'Take note:', 'wordpress-seo' ) . ' ' . esc_html__( 'Privacy sensitive (FB admins and such), theme specific (title rewrite) and a few very site specific settings will not be imported to new sites.', 'wordpress-seo' ) . '
+hidden( 'show_onboarding_notice', 'wpseo_show_onboarding_notice' );
diff --git a/wp-content/plugins/wordpress-seo/admin/views/tabs/network/restore-site.php b/wp-content/plugins/wordpress-seo/admin/views/tabs/network/restore-site.php
new file mode 100644
index 00000000..ce6701a9
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/tabs/network/restore-site.php
@@ -0,0 +1,32 @@
+' . esc_html__( 'Using this form you can reset a site to the default SEO settings.', 'wordpress-seo' ) . '
', esc_html__( 'Import from other SEO plugins', 'wordpress-seo' ), '
';
+ echo '
';
+ printf(
+ /* translators: %s expands to Yoast SEO */
+ esc_html__( '%s did not detect any plugin data from plugins it can import from.', 'wordpress-seo' ),
+ 'Yoast SEO'
+ );
+ echo '
';
+
+ return;
+}
+
+/**
+ * Creates a select box given a name and plugins array.
+ *
+ * @param string $name Name field for the select field.
+ * @param array $plugins An array of plugins and classes.
+ *
+ * @return void
+ */
+function wpseo_import_external_select( $name, $plugins ) {
+ esc_html_e( 'Plugin: ', 'wordpress-seo' );
+ echo '';
+}
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ',
+ ''
+ );
+ ?>
+
+
+
+
+
+
+
+
+
+
diff --git a/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-export.php b/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-export.php
new file mode 100644
index 00000000..d0a41961
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-export.php
@@ -0,0 +1,39 @@
+export();
+ return;
+}
+
+$wpseo_export_phrase = sprintf(
+ /* translators: %1$s expands to Yoast SEO */
+ __( 'Export your %1$s settings here, to copy them on another site.', 'wordpress-seo' ),
+ 'Yoast SEO'
+);
+?>
+
+
+
diff --git a/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-import.php b/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-import.php
new file mode 100644
index 00000000..18a5bfe9
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/views/tabs/tool/wpseo-import.php
@@ -0,0 +1,46 @@
+
+
';
+ printf(
+ /* translators: %s expands to robots.txt. */
+ esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
+ 'robots.txt'
+ );
+ echo '
';
+ printf(
+ /* translators: %s expands to robots.txt. */
+ esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
+ 'robots.txt'
+ );
+ echo '
';
+ printf(
+ /* translators: %s expands to ".htaccess". */
+ esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
+ '.htaccess'
+ );
+ echo '
';
+ printf(
+ /* translators: %s expands to ".htaccess". */
+ esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
+ '.htaccess'
+ );
+ echo '
diff --git a/wp-content/plugins/wordpress-seo/admin/watchers/class-slug-change-watcher.php b/wp-content/plugins/wordpress-seo/admin/watchers/class-slug-change-watcher.php
new file mode 100644
index 00000000..68d18616
--- /dev/null
+++ b/wp-content/plugins/wordpress-seo/admin/watchers/class-slug-change-watcher.php
@@ -0,0 +1,256 @@
+helpers->product->is_premium() ) {
+ return;
+ }
+
+ add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
+
+ // Detect a post trash.
+ add_action( 'wp_trash_post', [ $this, 'detect_post_trash' ] );
+
+ // Detect a post delete.
+ add_action( 'before_delete_post', [ $this, 'detect_post_delete' ] );
+
+ // Detects deletion of a term.
+ add_action( 'delete_term_taxonomy', [ $this, 'detect_term_delete' ] );
+ }
+
+ /**
+ * Enqueues the quick edit handler.
+ *
+ * @return void
+ */
+ public function enqueue_assets() {
+ global $pagenow;
+
+ if ( ! in_array( $pagenow, [ 'edit.php', 'edit-tags.php' ], true ) ) {
+ return;
+ }
+
+ $asset_manager = new WPSEO_Admin_Asset_Manager();
+ $asset_manager->enqueue_script( 'quick-edit-handler' );
+ }
+
+ /**
+ * Shows a message when a post is about to get trashed.
+ *
+ * @param int $post_id The current post ID.
+ *
+ * @return void
+ */
+ public function detect_post_trash( $post_id ) {
+ if ( ! $this->is_post_viewable( $post_id ) ) {
+ return;
+ }
+
+ $post_label = $this->get_post_type_label( get_post_type( $post_id ) );
+
+ /* translators: %1$s expands to the translated name of the post type. */
+ $first_sentence = sprintf( __( 'You just trashed a %1$s.', 'wordpress-seo' ), $post_label );
+ $second_sentence = __( 'Search engines and other websites can still send traffic to your trashed content.', 'wordpress-seo' );
+ $message = $this->get_message( $first_sentence, $second_sentence );
+
+ $this->add_notification( $message );
+ }
+
+ /**
+ * Shows a message when a post is about to get trashed.
+ *
+ * @param int $post_id The current post ID.
+ *
+ * @return void
+ */
+ public function detect_post_delete( $post_id ) {
+ if ( ! $this->is_post_viewable( $post_id ) ) {
+ return;
+ }
+
+ $post_label = $this->get_post_type_label( get_post_type( $post_id ) );
+
+ /* translators: %1$s expands to the translated name of the post type. */
+ $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $post_label );
+ $second_sentence = __( 'Search engines and other websites can still send traffic to your deleted content.', 'wordpress-seo' );
+ $message = $this->get_message( $first_sentence, $second_sentence );
+
+ $this->add_notification( $message );
+ }
+
+ /**
+ * Shows a message when a term is about to get deleted.
+ *
+ * @param int $term_taxonomy_id The term taxonomy ID that will be deleted.
+ *
+ * @return void
+ */
+ public function detect_term_delete( $term_taxonomy_id ) {
+ if ( ! $this->is_term_viewable( $term_taxonomy_id ) ) {
+ return;
+ }
+
+ $term = get_term_by( 'term_taxonomy_id', (int) $term_taxonomy_id );
+ $term_label = $this->get_taxonomy_label_for_term( $term->term_id );
+
+ /* translators: %1$s expands to the translated name of the term. */
+ $first_sentence = sprintf( __( 'You just deleted a %1$s.', 'wordpress-seo' ), $term_label );
+ $second_sentence = __( 'Search engines and other websites can still send traffic to your deleted content.', 'wordpress-seo' );
+ $message = $this->get_message( $first_sentence, $second_sentence );
+
+ $this->add_notification( $message );
+ }
+
+ /**
+ * Checks if the post is viewable.
+ *
+ * @param string $post_id The post id to check.
+ *
+ * @return bool Whether the post is viewable or not.
+ */
+ protected function is_post_viewable( $post_id ) {
+ $post_type = get_post_type( $post_id );
+ if ( ! WPSEO_Post_Type::is_post_type_accessible( $post_type ) ) {
+ return false;
+ }
+
+ $post_status = get_post_status( $post_id );
+ if ( ! $this->check_visible_post_status( $post_status ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if the term is viewable.
+ *
+ * @param int $term_taxonomy_id The term taxonomy ID to check.
+ *
+ * @return bool Whether the term is viewable or not.
+ */
+ protected function is_term_viewable( $term_taxonomy_id ) {
+ $term = get_term_by( 'term_taxonomy_id', (int) $term_taxonomy_id );
+
+ if ( ! $term || is_wp_error( $term ) ) {
+ return false;
+ }
+
+ $taxonomy = get_taxonomy( $term->taxonomy );
+ if ( ! $taxonomy ) {
+ return false;
+ }
+
+ return $taxonomy->publicly_queryable || $taxonomy->public;
+ }
+
+ /**
+ * Gets the taxonomy label to use for a term.
+ *
+ * @param int $term_id The term ID.
+ *
+ * @return string The taxonomy's singular label.
+ */
+ protected function get_taxonomy_label_for_term( $term_id ) {
+ $term = get_term( $term_id );
+ $taxonomy = get_taxonomy( $term->taxonomy );
+
+ return $taxonomy->labels->singular_name;
+ }
+
+ /**
+ * Retrieves the singular post type label.
+ *
+ * @param string $post_type Post type to retrieve label from.
+ *
+ * @return string The singular post type name.
+ */
+ protected function get_post_type_label( $post_type ) {
+ $post_type_object = get_post_type_object( $post_type );
+
+ // If the post type of this post wasn't registered default back to post.
+ if ( $post_type_object === null ) {
+ $post_type_object = get_post_type_object( 'post' );
+ }
+
+ return $post_type_object->labels->singular_name;
+ }
+
+ /**
+ * Checks whether the given post status is visible or not.
+ *
+ * @param string $post_status The post status to check.
+ *
+ * @return bool Whether or not the post is visible.
+ */
+ protected function check_visible_post_status( $post_status ) {
+ $visible_post_statuses = [
+ 'publish',
+ 'static',
+ 'private',
+ ];
+
+ return in_array( $post_status, $visible_post_statuses, true );
+ }
+
+ /**
+ * Returns the message around changed URLs.
+ *
+ * @param string $first_sentence The first sentence of the notification.
+ * @param string $second_sentence The second sentence of the notification.
+ *
+ * @return string The full notification.
+ */
+ protected function get_message( $first_sentence, $second_sentence ) {
+ return '
' . __( 'Make sure you don\'t miss out on traffic!', 'wordpress-seo' ) . '
'
+ . '
'
+ . $first_sentence
+ . ' ' . $second_sentence
+ . ' ' . __( 'You should create a redirect to ensure your visitors do not get a 404 error when they click on the no longer working URL.', 'wordpress-seo' )
+ /* translators: %s expands to Yoast SEO Premium */
+ . ' ' . sprintf( __( 'With %s, you can easily create such redirects.', 'wordpress-seo' ), 'Yoast SEO Premium' )
+ . '
+ Generated by Yoast SEO, this is an XML Sitemap, meant for consumption by search engines.
+ You can find more information about XML sitemaps on sitemaps.org.
+
+
+
+ This XML Sitemap Index file contains sitemaps.
+