Merge pull request #28949 from woocommerce/fix/28947

Use wp_robots_no_robots() when available
This commit is contained in:
Roy Ho 2021-01-26 15:24:22 -08:00 committed by GitHub
commit 32b502dcd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -3568,8 +3568,13 @@ function wc_empty_cart_message() {
*/ */
function wc_page_noindex() { function wc_page_noindex() {
if ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) || is_page( wc_get_page_id( 'myaccount' ) ) ) { if ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) || is_page( wc_get_page_id( 'myaccount' ) ) ) {
// Adds support for WP 5.7.
if ( function_exists( 'wp_robots_no_robots' ) ) {
wp_robots_no_robots();
} else {
wp_no_robots(); wp_no_robots();
} }
}
} }
add_action( 'wp_head', 'wc_page_noindex' ); add_action( 'wp_head', 'wc_page_noindex' );