[2.5] Create new function to prevent endpoint indexing

This commit is contained in:
Claudio Sanches 2016-03-01 13:45:25 -03:00
parent 6f04ff1fa0
commit 3e955f6086
2 changed files with 13 additions and 13 deletions

View File

@ -182,11 +182,6 @@ class WC_Cache_Helper {
}
}
}
// Noindex for endpoints
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) {
self::noindex();
}
}
/**
@ -206,14 +201,6 @@ class WC_Cache_Helper {
nocache_headers();
}
/**
* Set noindex headers.
* @access private
*/
private static function noindex() {
@header( 'X-Robots-Tag: noindex' );
}
/**
* notices function.
*/

View File

@ -81,6 +81,19 @@ function wc_send_frame_options_header() {
}
add_action( 'template_redirect', 'wc_send_frame_options_header' );
/**
* No index our endpoints.
* Prevent indexing pages like order-received.
*
* @since 2.5.3
*/
function wc_prevent_endpoint_indexing() {
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) {
@header( 'X-Robots-Tag: noindex' );
}
}
add_action( 'template_redirect', 'wc_prevent_endpoint_indexing' );
/**
* When the_post is called, put product data into a global.
*