' ),
'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 '
';
$this->print_toggles( $this->basic_settings, $yform, $is_network, \__( 'Basic crawl settings', 'wordpress-seo' ), \__( 'Remove links added by WordPress to the header and <head>.', 'wordpress-seo' ) );
$this->print_toggles( $this->feed_settings, $yform, $is_network, \__( 'Feed crawl settings', 'wordpress-seo' ), \__( "Remove feed links added by WordPress that aren't needed for this site.", 'wordpress-seo' ) );
$this->print_toggles( $this->unused_resources_settings, $yform, $is_network, \__( 'Remove unused resources', 'wordpress-seo' ), \__( 'WordPress loads lots of resources, some of which your site might not need. If you’re not using these, removing them can speed up your pages and save resources.', 'wordpress-seo' ) );
$first_search_setting = \array_slice( $this->search_cleanup_settings, 0, 1 );
$rest_search_settings = \array_slice( $this->search_cleanup_settings, 1 );
$search_settings_toggles = [
'off' => \__( 'Disabled', 'wordpress-seo' ),
'on' => \__( 'Enabled', 'wordpress-seo' ),
];
$this->print_toggles( $first_search_setting, $yform, $is_network, \__( 'Search cleanup settings', 'wordpress-seo' ), \__( 'Clean up and filter searches to prevent search spam.', 'wordpress-seo' ), $search_settings_toggles );
if ( ! $is_network ) {
echo '
';
$yform->number(
'search_character_limit_free',
\__( 'Max number of characters to allow in searches', 'wordpress-seo' ),
[
'min' => 1,
'max' => 1000,
'disabled' => true,
]
);
$yform->hidden( 'search_character_limit', 'search_character_limit' );
echo '
';
}
$this->print_toggles( $rest_search_settings, $yform, $is_network, '', '', $search_settings_toggles );
$this->print_toggles( $this->permalink_cleanup_settings, $yform, $is_network, \__( 'Permalink cleanup settings', 'wordpress-seo' ), \__( 'Remove unwanted URL parameters from your URLs.', 'wordpress-seo' ) );
if ( ! $is_network ) {
echo '
';
$yform->textinput(
'clean_permalinks_extra_variables_free',
\__( 'Additional URL parameters to allow', 'wordpress-seo' ),
[
'disabled' => true,
]
);
$yform->hidden( 'clean_permalinks_extra_variables', 'clean_permalinks_extra_variables' );
echo '';
echo '
';
}
echo '
';
}
/**
* Prints a list of toggles for an array of settings with labels.
*
* @param array $settings The settings being displayed.
* @param Yoast_Form $yform The Yoast form class.
* @param bool $is_network Whether we're on the network site.
* @param string $title Optional title for the settings being displayed.
* @param string $description Optional description of the settings being displayed.
* @param array $toggles Optional naming of the toggle buttons.
*
* @return void
*/
private function print_toggles( array $settings, Yoast_Form $yform, $is_network, $title = '', $description = '', $toggles = [] ) {
if ( ! empty( $title ) ) {
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 '