| 1 |
<?php |
| 2 |
/* |
| 3 |
|
| 4 |
Plugin Name: Disable Updates |
| 5 |
Plugin URI: https://wordpress.org/plugins/disable-updates/ |
| 6 |
Description: A simple plugin that prevents updating the WordPress core, plugins and themes. |
| 7 |
Version: 1.3.6 |
| 8 |
Author: Johan van der Wijk |
| 9 |
Author URI: https://vanderwijk.com/ |
| 10 |
License: GPL-2.0+ |
| 11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 12 |
Text Domain: disable-updates |
| 13 |
Domain Path: /languages |
| 14 |
|
| 15 |
*/ |
| 16 |
|
| 17 |
// add donation and review links to plugin description |
| 18 |
function du_plugin_links ( $links, $file ) { |
| 19 |
$base = plugin_basename( __FILE__ ); |
| 20 |
if ( $file == $base ) { |
| 21 |
$links[] = '<a href="https://wordpress.org/support/plugin/disable-updates/reviews/#new-post" target="_blank">' . __( 'Review', 'disable-updates' ) . ' <span class="dashicons dashicons-thumbs-up"></span></a> | <a href="https://paypal.me/vanderwijk">' . __( 'Donate', 'disable-updates' ) . ' <span class="dashicons dashicons-money"></span></a>'; |
| 22 |
} |
| 23 |
return $links; |
| 24 |
} |
| 25 |
add_filter ( 'plugin_row_meta', 'du_plugin_links', 10, 2 ); |
| 26 |
|
| 27 |
// remove cron events for core, themes and plugins |
| 28 |
function filter_cron_events ( $event ) { |
| 29 |
|
| 30 |
$ignore = array ( |
| 31 |
'wp_version_check', |
| 32 |
'wp_update_plugins', |
| 33 |
'wp_update_themes', |
| 34 |
'wp_maybe_auto_update', |
| 35 |
); |
| 36 |
|
| 37 |
if ( in_array ( $event -> hook, $ignore ) ) { |
| 38 |
return false; |
| 39 |
} |
| 40 |
return $event; |
| 41 |
} |
| 42 |
add_action ( 'schedule_event', 'filter_cron_events' ); |
| 43 |
|
| 44 |
// hide all upgrade notices |
| 45 |
function du_hide_admin_notices () { |
| 46 |
remove_action ( 'admin_notices', 'update_nag', 3 ); |
| 47 |
} |
| 48 |
add_action ( 'admin_menu', 'du_hide_admin_notices' ); |
| 49 |
|
| 50 |
// remove the 'Updates' menu item from the admin interface |
| 51 |
function du_remove_menus () { |
| 52 |
global $submenu; |
| 53 |
remove_submenu_page ( 'index.php', 'update-core.php' ); |
| 54 |
} |
| 55 |
add_action ( 'admin_menu', 'du_remove_menus', 102 ); |
| 56 |
|
| 57 |
// disable core, theme and plugin updates |
| 58 |
function du_disable_updates () { |
| 59 |
remove_action ( 'load-update-core.php', 'wp_update_core' ); |
| 60 |
remove_action ( 'load-update-core.php', 'wp_update_themes' ); |
| 61 |
remove_action ( 'load-update-core.php', 'wp_update_plugins' ); |
| 62 |
} |
| 63 |
add_action ( 'init', 'du_disable_updates', 1 ); |
| 64 |
|
| 65 |
// fake last checked time (using __return_null makes the dashboard slow) |
| 66 |
function du_last_checked () { |
| 67 |
global $wp_version; |
| 68 |
return ( object ) array ( |
| 69 |
'last_checked' => time (), |
| 70 |
'version_checked' => $wp_version, |
| 71 |
'updates' => array () |
| 72 |
); |
| 73 |
} |
| 74 |
add_filter ( 'pre_site_transient_update_core', 'du_last_checked' ); |
| 75 |
add_filter ( 'pre_site_transient_update_plugins', 'du_last_checked' ) ; |
| 76 |
add_filter ( 'pre_site_transient_update_themes', 'du_last_checked' ); |
| 77 |
|
| 78 |
// disable automatic updates |
| 79 |
add_filter ( 'automatic_updater_disabled', '__return_true' ); |
| 80 |
|
| 81 |
// disable update health check |
| 82 |
add_filter ( 'site_status_tests', function ( $tests ) { |
| 83 |
unset ( $tests['async']['background_updates'] ); |
| 84 |
unset ( $tests['direct']['plugin_theme_auto_updates'] ); |
| 85 |
return $tests; |
| 86 |
}); |