Created
July 26, 2013 21:44
-
-
Save jjeaton/6092488 to your computer and use it in GitHub Desktop.
A plugin that modifies the `admin_email` and `blogname` and `blog_public` options for staging sites.
This file contains 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: Staging Option Tweaks | |
* Plugin URI: http://www.josheaton.org/ | |
* Description: Checks the health of your WordPress install | |
* Author: Josh Eaton | |
* Version: 0.1 | |
* Author URI: http://www.josheaton.org/ | |
* | |
* A plugin that modifies the `admin_email` and `blogname` and `blog_public` options for staging sites. | |
* Typically used as a mu-plugin so I can pull down a production DB and automatically override certain values with Staging values and I don't have to remember to manually change them each time. | |
* | |
* The core option filters: | |
* | |
* `option_{option_name}`: Filter that runs on the option value after it has been retrieved and before it's returned. | |
* `pre_option_{option_name}`: Filter that runs before getting the option from the DB (it 'short-circuits' the get_option call to allow plugins to override it) | |
* | |
* Both are in `wp-includes/option.php` starting on line 40 | |
*/ | |
/** | |
* Override admin email | |
* | |
* @param string $email | |
* @return string | |
*/ | |
function jje_admin_email( $email ) { | |
return '[email protected]'; | |
} | |
add_filter( 'pre_option_admin_email', 'jje_admin_email' ); | |
/** | |
* Override site name | |
* | |
* @param string $email | |
* @return string | |
*/ | |
function jje_site_name( $email ) { | |
return 'Staging Site Name'; | |
} | |
add_filter( 'pre_option_blogname', 'jje_site_name' ); | |
add_filter( 'pre_option_blog_public', '__return_zero' ); // Force blog privacy, robots no-follow metatag |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment