Skip to content

Instantly share code, notes, and snippets.

@doiftrue
Created January 16, 2024 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doiftrue/8b7c67071af07da8317567e491f6bad4 to your computer and use it in GitHub Desktop.
Save doiftrue/8b7c67071af07da8317567e491f6bad4 to your computer and use it in GitHub Desktop.
[wpkama embed] https://wp-kama.com/2345 Disable Aggressive Updates.
<?php
/**
* Disable forced checking for new WP, plugins, and theme versions in the admin panel,
* so that it doesn't slow down when you haven't visited for a long time and then visit...
* All checks will happen unnoticed through cron or when you visit the "Dashboard > Updates" page.
*
* @see https://wp-kama.ru/filecode/wp-includes/update.php
* @author Kama (https://wp-kama.ru)
* @version 1.1
*/
if( is_admin() ){
// disable update checks when entering the admin panel...
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'admin_init', '_maybe_update_themes' );
// disable update checks when entering a special page in the admin panel...
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-themes.php', 'wp_update_themes' );
// leave forced checking when entering the updates page...
//remove_action( 'load-update-core.php', 'wp_update_plugins' );
//remove_action( 'load-update-core.php', 'wp_update_themes' );
// leave forced checking when entering the "Update/Install Plugin" or "Update/Install Theme" page - it doesn't interfere...
//remove_action( 'load-update.php', 'wp_update_plugins' );
//remove_action( 'load-update.php', 'wp_update_themes' );
// don't touch the cron event, it will be used to check for updates - everything is fine here!
//remove_action( 'wp_version_check', 'wp_version_check' );
//remove_action( 'wp_update_plugins', 'wp_update_plugins' );
//remove_action( 'wp_update_themes', 'wp_update_themes' );
/**
* disable the need to update the browser in the console - we always use top browsers!
* this check happens once a week...
* @see https://wp-kama.ru/function/wp_check_browser_version
*/
add_filter( 'pre_site_transient_browser_'. md5( $_SERVER['HTTP_USER_AGENT'] ), '__return_empty_array' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment