Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking for a way to remove theme, change theme button and WP version from the "right now" admin dashboard, but using only functions. Any help?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

Ah, one of those things that seem easy until admin dashboard internals throw you into depths of despair. :)

Basically there is no easy and intended way to do this, so need to get creative. My idea would be to override temporarily couple of capabilities that control parts of output and kill the rest with filters in translation mechanisms.

PS ehm, while I was messing with this it slipped me that you want to change some part and not remove everything. Well you can just remove and produce your own output or build on top of translation filter. See wp_dashboard_right_now() source for what is inside that widget.

add_action('right_now_discussion_table_end','turn_off_caps');
add_action('rightnow_end','turn_on_caps');

function turn_off_caps() {

    add_filter('ngettext','disable_theme');
    add_filter('map_meta_cap','disable_caps',10,2);
}

function turn_on_caps() {

    remove_filter('ngettext','disable_theme');
    remove_filter('map_meta_cap','disable_caps',10,2);
}

function disable_caps($caps,$cap) {

    if( 'update_core' == $cap )
            $caps[] = 'do_not_allow';

    if( 'switch_themes' == $cap )
            $caps[] = 'do_not_allow';

    return $caps;
}

function disable_theme($text) {

    if('Theme' == substr($text,0,5))
        return '';

    return $text;
}
share|improve this answer
    
I looked briefly but didn't see a quick clean way, i'd have also opted for capability juggling to get rid of the unwanted parts to, nicely done... +1 –  t31os Apr 12 '11 at 13:45
    
Thanks and well done! It hide everything, except the "You are using x" bit - but will do. Cheers! –  PauloP Apr 13 '11 at 8:53
    
@PauloP hm, that should be removed as well from my tests... well, as long as it works for you :) –  Rarst Apr 13 '11 at 11:25
add comment

I found an easy way to kill the update in the right now section, and it doesn't break anyting. Here it is (I am working with wordpress 3.3.1 and it worked just fine without breaking anything. Find this line of code:

    // Called directly from dashboard
    function update_right_now_message() {
$msg = sprintf( __('You are using <span class="b">WordPress %s</span>.'), $GLOBALS['wp_version'] );
if ( current_user_can('update_core') ) {
    $cur = get_preferred_from_update_core();
    if ( isset( $cur->response ) && $cur->response == 'upgrade'  )
        $msg .= " <a href='" . network_admin_url( 'update-core.php' ) . "' class='button'>" . sprintf( __('Update to %s'), $cur->current ? $cur->current : __( 'Latest' ) ) . '</a>';
}
echo "<span id='wp-version-message'>$msg</span>";
    }

Now, replace the bottom line of that code at the very bottom with whatever you want, or leave it blank. I used the following:

    }
echo "<p>Stef Stole The Update Button!?!?</p>";
    }

this works without breaking anything, and helps to stop accidental updates I have found

share|improve this answer
    
Now you have created a fork of WordPress that cannot be updated automatically anymore with the built-in updater. Please add detailed update instructions (and you should really update your own site too). –  toscho Nov 7 '12 at 4:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.