Remove theme, change theme button and WP version on “Right Now” admin dashboard?

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;
}