Last active
January 15, 2016 05:24
-
-
Save BronsonQuick/c9040d4187ae93c09eac to your computer and use it in GitHub Desktop.
Don't index WP sites with staging in the URL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: United Influencers Stop Indexing On Staging | |
Plugin URI: https://hmn.md/ | |
Description: This plugin prevents search engines from indexing our staging sites. | |
Author: Human Made Limited | |
Version: 0.1 | |
Author URI: https://hmn.md/ | |
*/ | |
namespace United_Bloggers\Stop_Indexing_On_Staging; | |
/** | |
* Make sure the top level domain and subdomains are never indexed. | |
* | |
* @return string | |
*/ | |
function stop_indexing( $blog_public_option ) { | |
$server_name = $_SERVER['HTTP_HOST']; | |
if ( strpos( $server_name, 'staging.' ) !== false ) { | |
return '0'; | |
} | |
return $blog_public_option; | |
} | |
add_filter( 'pre_option_blog_public', __NAMESPACE__ . '\\stop_indexing' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment