Monday, June 29, 2015

Disable Update Notification in Wordpress Without Plugin


WordPress provide auto update functionality for update all sources and plugin with the latest updated from it's admin panel which is called `wp-admin`. After some specific time or event update function of Wordpress finds the latest version of exiting resources from the internet and also provide direct download and install to current resource functionality.
This is very nice functionality for use latest version and updated functions and supports of Wordpress. But Sometimes when you make some customize of Wordpress functionality by modification of files than when you upgrade than previous updated files removed and replace it to a new file and again make changes to new file according to theme or customization so that time must stop upgrade the latest version of Wordpress resource.
When an update available than in admin panel display notification for update version so you must remove that notification for stop update.
In Wordpress there are three types of  update.

1) Wordpress Core Update 

This update is for change Wordpress version to latest version and update all Wordpress core functionality and files which are in `wp-include` and `wp-admin` folder.Wordpress core update notification display at the header of the admin panel. so remove that notification by two ways.
  • Edit File
    For stop Wordpress core notification just set Wordpress version to latest version.Wordpress define it's version as global variable as `$wp_version` in wp-include/version.php file.So just change new version in that variable.For these changes must check Mysql and PHP version and comparability.
  • Modifying Core Functions
    Wordpress check latest version according to last checked time so changed that time to latest time.for that add below function in theme `function.php` file
    
    function remove_core_updates(){
     global $wp_version;
     return(object) array('last_checked'=> time(),'version_checked'=> $wp_version);
    }
    add_filter('pre_site_transient_update_core','remove_core_updates');
    

2) Wordpress Plugin Update

Wordpress plugin update notification display in `Update` and `Plugins` menu so remove that notification as below.
  • Edit File
    For stop Wordpress plugin update notification just change the version to latest version in the plugin main file where define plugin name and description.
  • Modifying Core Functions
    Add below function in theme `function.php` file or plugin file.
    
    function remove_plugin_updates(){
     global $wp_version;
     return(object) array('last_checked'=> time(),'version_checked'=> $wp_version);
    }
    add_filter('pre_site_transient_update_plugins','remove_plugin_updates');
    
    or use below code for any specify plugin
    
    function stop_plugin_updates( $value ) {
        unset( $value->response['akismet/akismet.php'] ); //Plugin file name
        return $value;
    }
    add_filter( 'site_transient_update_plugins', 'stop_plugin_updates' );
    

3) Wordpress Theme Update 

Wordpress theme update notification display in `Update` and `Appearance` menu so remove that notification as below.
  • Edit File
    For stop Wordpress them update notification just change the version to the latest version of theme `style.css` file where theme name and description define.
  • Modifying Core Functions
    Add below function in theme `function.php` file.
    
    function remove_plugin_updates(){
     global $wp_version;
     return(object) array('last_checked'=> time(),'version_checked'=> $wp_version);
    }
    add_filter('pre_site_transient_update_themes','remove_theme_updates');
    
Here when you changes in a file for remove update notification than every time you make changes in the file whenever a new update available. So it's better to add new functions for stop update notification. Here single function use for stop all Wordpress notifications as below.

function remove_all_updates(){
 global $wp_version;
 return(object) array('last_checked'=> time(),'version_checked'=> $wp_version);
}
add_filter('pre_site_transient_update_core','remove_all_updates'); // Core update
add_filter('pre_site_transient_update_plugins','remove_all_updates'); //Plugin update
add_filter('pre_site_transient_update_themes','remove_all_updates'); //Theme update

No comments :

Post a Comment