[2.5] Create new function to prevent endpoint indexing
This commit is contained in:
parent
6f04ff1fa0
commit
3e955f6086
|
@ -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();
|
nocache_headers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set noindex headers.
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
private static function noindex() {
|
|
||||||
@header( 'X-Robots-Tag: noindex' );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notices function.
|
* notices function.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,6 +81,19 @@ function wc_send_frame_options_header() {
|
||||||
}
|
}
|
||||||
add_action( 'template_redirect', '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.
|
* When the_post is called, put product data into a global.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue