Skip to content

Commit

Permalink
[2.5] Create new function to prevent endpoint indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiosanches committed Mar 1, 2016
1 parent 1ed8ccb commit 8df33ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 0 additions & 13 deletions includes/class-wc-cache-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,6 @@ public static function prevent_caching() {
}
}
}

// Noindex for endpoints
if ( is_wc_endpoint_url() || isset( $_GET['download_file'] ) ) {
self::noindex();
}
}

/**
Expand All @@ -206,14 +201,6 @@ private static function nocache() {
nocache_headers();
}

/**
* Set noindex headers.
* @access private
*/
private static function noindex() {
@header( 'X-Robots-Tag: noindex' );
}

/**
* notices function.
*/
Expand Down
13 changes: 13 additions & 0 deletions includes/wc-template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 8df33ad

Please sign in to comment.