$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Good way to remove unnecessary stuff from dashboard?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Good way to remove unnecessary stuff from dashboard?

matteradmin11PV0评论

To this day I have been using CSS to hide unneeeded stuff from the dashboard area in the backend of Wordpress. But I don't like this way as it is easy to make it visible again. On things I have found a way, I have been using hooks to disable them.

But there are things I haven't managed to remove easily with hooks. For example the Primary Site selection under My Sites in a multisite network.

I found this way, which seems to remove it completely before site is loading.

if ( ! function_exists( 'remove_from_my_sites' ) ) {
    function remove_from_my_sites( $subject ) {
    if (get_current_screen()->id == 'my-sites') {
        $subject = preg_replace('#<table class="form-table(.*?)</table>#s', '', $subject, 1);
    }
    return $subject;
    }
    function subject_start_my_sites() {
    if ( current_user_can('read') ) {
            ob_start( 'remove_from_my_sites' );
    }
    }
    function subject_end_my_sites() {
    if ( current_user_can('read') ) {
            ob_end_flush();
    }
    }
}
add_action( 'admin_head', 'subject_start_my_sites' );
add_action( 'admin_footer', 'subject_end_my_sites' );

Is this a good way to remove stuff? Or will it reduce performance? I want to know before I continue using this!

Post a comment

comment list (0)

  1. No comments so far