add code in functions.php will slow down the Execution speed?

admin2025-06-02  1

I put these code in functions.php to custom what I need.

before I add these code,the back_end`s ttfb is 746ms.

after adding,the ttfb is 3.6s !!!

speed becomes slow obviously!

Is there any way to optimize ?

**//back_end footer text**
add_filter('admin_footer_text', 'left_admin_footer_text');
function left_admin_footer_text($text) {
        //left text
        $text = '';
        return $text;}
add_filter('update_footer', 'right_admin_footer_text', 11);
function right_admin_footer_text($text) {
        //right text
        $text = "Power by Ateam";
        return $text;}

//Logo`s URL
function my_loginURL() {
    return '#';
}
add_filter('login_headerurl', 'my_loginURL');

//login page logo text
function my_loginURLtext() {
    return 'Powered by Ateam';
}
add_filter('login_headertitle', 'my_loginURLtext');

//hide the back_end logo
function annointed_admin_bar_remove() {
        global $wp_admin_bar;
        /* Remove their stuff */
        $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);

//hide the hlep tabs
add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
$screen->remove_help_tabs();
return $old_help;
}

//stop the update notice (Core)
remove_action ('load-update-core.php', 'wp_update_themes');
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

//stop the update notice(Plugins)
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );

//stop the update notice (Themes)
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );

//stop the update (theme)
add_filter( 'auto_update_theme', '__return_false' );

//stop the update (plugins)
add_filter( 'auto_update_plugin', '__return_false' );

//stop the back_ends notices
function pr_disable_admin_notices() {
    global $wp_filter;
      if ( is_user_admin() ) {
        if ( isset( $wp_filter['user_admin_notices'] ) ) {
                unset( $wp_filter['user_admin_notices'] );
        }
      } elseif ( isset( $wp_filter['admin_notices'] ) ) {
            unset( $wp_filter['admin_notices'] );
      }
      if ( isset( $wp_filter['all_admin_notices'] ) ) {
            unset( $wp_filter['all_admin_notices'] );
      }
  }
add_action( 'admin_print_scripts', 'pr_disable_admin_notices' );

I put these code in functions.php to custom what I need.

before I add these code,the back_end`s ttfb is 746ms.

after adding,the ttfb is 3.6s !!!

speed becomes slow obviously!

Is there any way to optimize ?

**//back_end footer text**
add_filter('admin_footer_text', 'left_admin_footer_text');
function left_admin_footer_text($text) {
        //left text
        $text = '';
        return $text;}
add_filter('update_footer', 'right_admin_footer_text', 11);
function right_admin_footer_text($text) {
        //right text
        $text = "Power by Ateam";
        return $text;}

//Logo`s URL
function my_loginURL() {
    return '#';
}
add_filter('login_headerurl', 'my_loginURL');

//login page logo text
function my_loginURLtext() {
    return 'Powered by Ateam';
}
add_filter('login_headertitle', 'my_loginURLtext');

//hide the back_end logo
function annointed_admin_bar_remove() {
        global $wp_admin_bar;
        /* Remove their stuff */
        $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'annointed_admin_bar_remove', 0);

//hide the hlep tabs
add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
$screen->remove_help_tabs();
return $old_help;
}

//stop the update notice (Core)
remove_action ('load-update-core.php', 'wp_update_themes');
add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );

//stop the update notice(Plugins)
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );

//stop the update notice (Themes)
remove_action( 'load-update-core.php', 'wp_update_themes' );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );

//stop the update (theme)
add_filter( 'auto_update_theme', '__return_false' );

//stop the update (plugins)
add_filter( 'auto_update_plugin', '__return_false' );

//stop the back_ends notices
function pr_disable_admin_notices() {
    global $wp_filter;
      if ( is_user_admin() ) {
        if ( isset( $wp_filter['user_admin_notices'] ) ) {
                unset( $wp_filter['user_admin_notices'] );
        }
      } elseif ( isset( $wp_filter['admin_notices'] ) ) {
            unset( $wp_filter['admin_notices'] );
      }
      if ( isset( $wp_filter['all_admin_notices'] ) ) {
            unset( $wp_filter['all_admin_notices'] );
      }
  }
add_action( 'admin_print_scripts', 'pr_disable_admin_notices' );
Share Improve this question asked Mar 8, 2019 at 3:11 cindycindy 1059 bronze badges 2
  • 1 Wow, you really want to disable all the updates? It isn’t the best idea from security point of view... (and no, I don’t see in this part of code anything that will slow down the site) – Krzysiek Dróżdż Commented Mar 8, 2019 at 6:17
  • I found something. Answer below. – MikeNGarrett Commented Mar 8, 2019 at 21:36
Add a comment  | 

1 Answer 1

Reset to default 1

There's one thing here you shouldn't do:

add_filter( 'pre_site_transient_update_core', create_function( '$a', "return null;" ) );
add_filter( 'pre_set_site_transient_update_plugins', create_function( '$a', "return null;" ) );
add_filter( 'pre_site_transient_update_themes', create_function( '$a', "return null;" ) );

In my testing, this slowed down the admin side of the site significantly on a fresh local install. This is because if the the transients update_core, update_plugins, and update_themes are not found, they go back to object cache for an answer. If you're not using object cache which isn't setup by default, the request goes all the way back to the database.

I did some rough benchmarking on a fresh install. A typical admin request calls one of these transients up to 17 times in a single request. When you're logged in and looking at the front-facing site it can be up to 5. That adds up.

Fortunately, Jason Jalbuena has found a better way:

function remove_core_updates () {
    global $wp_version;
    return(object) array(
        'last_checked'=> time(),
        'version_checked'=> $wp_version,
        'updates' => array()
    );
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');

Source: https://jasonjalbuena/disable-wordpress-update-notifications/

This works because it does not remove the transient, it only replaces it with values that trick WordPress into thinking the check has happened and nothing needs to be updated.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748827968a314057.html

最新回复(0)