Move Privacy Notice in 3.2

If you’ve already started poking around in WordPress 3.2, you may have noticed that the privacy notice that used to appear in the WordPress header has been moved to the Right Now box on the dashboard.

And if you’re like me, you probably wish it was back at the top. Fortunately, with just a few lines, we can do that:

add_action('in_admin_header', 'privacy_notice_in_header');
function privacy_notice_in_header() {
    if (1 != get_option('blog_public')) {
        $title = apply_filters('privacy_on_link_title', __('Your site is asking search engines not to index its content') );
        $content = apply_filters('privacy_on_link_text', __('Search Engines Blocked') );
        echo "<p class='alignleft' style='padding:9px 0 0;margin:0;'><a href='options-privacy.php' title='$title'>$content</a></p>";

Add Field to General Settings Page

If you need to add an option to a site, but it doesn’t really need to be on its own page. You can probably add it to one of the existing settings pages. Here’s how to add an option to the General Settings page.

In this case, I’m adding a ‘favorite color’ field, probably not the best example, so go ahead and change that. 🙂

$new_general_setting = new new_general_setting();

class new_general_setting {
    function new_general_setting( ) {
        add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
    function register_fields() {
        register_setting( 'general', 'favorite_color', 'esc_attr' );
        add_settings_field('fav_color', '<label for="favorite_color">'.__('Favorite Color?' , 'favorite_color' ).'</label>' , array(&$this, 'fields_html') , 'general' );
    function fields_html() {
        $value = get_option( 'favorite_color', '' );
        echo '<input type="text" id="favorite_color" name="favorite_color" value="' . $value . '" />';

The third argument of the register_setting() function is the name of the function that should be used to validate the input data, so customize that as needed.