' ), 'clean_permalinks' => \__( 'Unregistered URL parameters', 'wordpress-seo' ), ]; $this->search_cleanup_settings = [ 'search_cleanup' => \__( 'Filter search terms', 'wordpress-seo' ), 'search_cleanup_emoji' => \__( 'Filter searches with emojis and other special characters', 'wordpress-seo' ), 'search_cleanup_patterns' => \__( 'Filter searches with common spam patterns', 'wordpress-seo' ), 'deny_search_crawling' => \__( 'Prevent search engines from crawling site search URLs', 'wordpress-seo' ), 'redirect_search_pretty_urls' => \__( 'Redirect pretty URLs for search pages to raw format', 'wordpress-seo' ), ]; $this->unused_resources_settings = [ 'remove_emoji_scripts' => \__( 'Emoji scripts', 'wordpress-seo' ), 'deny_wp_json_crawling' => \__( 'Prevent search engines from crawling /wp-json/', 'wordpress-seo' ), ]; } /** * Adds a dedicated tab in the General sub-page. * * @param WPSEO_Option_Tabs $dashboard_tabs Object representing the tabs of the General sub-page. */ public function add_crawl_settings_tab( $dashboard_tabs ) { $premium = $this->product_helper->is_premium() && $this->is_premium_upgraded(); $dashboard_tabs->add_tab( new WPSEO_Option_Tab( 'crawl-settings', \__( 'Crawl settings', 'wordpress-seo' ), [ 'save_button' => $premium, 'beta' => $premium, 'premium' => ! $premium, ] ) ); } /** * Adds content to the Crawl Cleanup tab. * * @param Yoast_Form $yform The yoast form object. */ public function add_crawl_settings_tab_content( $yform ) { $this->add_crawl_settings( $yform, false ); } /** * Adds content to the Crawl Cleanup network tab. * * @param Yoast_Form $yform The yoast form object. */ public function add_crawl_settings_tab_content_network( $yform ) { $this->add_crawl_settings( $yform, true ); } /** * Print the settings sections. * * @param Yoast_Form $yform The Yoast form class. * @param bool $is_network Whether we're on the network site. * * @return void */ private function add_crawl_settings( $yform, $is_network ) { $this->display_premium_upsell_btn(); echo '
'; \esc_html_e( 'Please use a comma to separate multiple URL parameters.', 'wordpress-seo' ); echo '
'; echo '', \esc_html( $description ), '
'; } if ( empty( $toggles ) ) { $toggles = [ 'off' => \__( 'Keep', 'wordpress-seo' ), 'on' => \__( 'Remove', 'wordpress-seo' ), ]; } $setting_prefix = ''; if ( $is_network ) { $setting_prefix = WPSEO_Option::ALLOW_KEY_PREFIX; // NOTE: the off/on labels here are flipped from their actual would-be values in premium for cosmetic reasons and limitations with disabled toggles. $toggles = [ // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- Reason: text is originally from Yoast SEO. 'on' => \__( 'Allow Control', 'wordpress-seo' ), // phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- Reason: text is originally from Yoast SEO. 'off' => \__( 'Disable', 'wordpress-seo' ), ]; } foreach ( $settings as $setting => $label ) { $attr = [ 'disabled' => true, 'preserve_disabled_value' => true, ]; if ( $this->should_feature_be_disabled_multisite( $setting ) ) { $attr['preserve_disabled_value'] = false; } $yform->toggle_switch( $setting_prefix . $setting, $toggles, $label, '', $attr ); if ( $setting === 'remove_feed_global_comments' && ! $is_network ) { echo ''; echo \esc_html__( 'By removing Global comments feed, Post comments feeds will be removed too.', 'wordpress-seo' ); echo '
'; } if ( $this->should_feature_be_disabled_multisite( $setting ) ) { echo ''; \esc_html_e( 'This feature is not available for multisites.', 'wordpress-seo' ); echo '
'; } } } /** * Displays the Premium upsell button. */ public function display_premium_upsell_btn() { echo ''; $button_msg = ( $this->product_helper->is_premium() && ! $this->is_premium_upgraded() ) ? \esc_html__( 'Upgrade Premium', 'wordpress-seo' ) : \esc_html__( 'Unlock with Premium', 'wordpress-seo' ); // phpcs:ignore WordPress.Security.EscapeOutput -- Already escaped. echo $button_msg // phpcs:ignore WordPress.Security.EscapeOutput -- Already escapes correctly. . WPSEO_Admin_Utils::get_new_tab_message(); echo ''; } /** * Checks if the feature should be disabled due to the site being a multisite. * * @param string $setting The setting to be displayed. * * @return bool */ protected function should_feature_be_disabled_multisite( $setting ) { return ( \in_array( $setting, [ 'deny_search_crawling', 'deny_wp_json_crawling' ], true ) && \is_multisite() ); } }