PluginProbe
Disable Updates for WordPress Core, Plugins and Themes / 1.4.3
Disable Updates for WordPress Core, Plugins and Themes v1.4.3
trunk 1.1 1.1.1 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.9 1.3.0 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3
disable-updates / disable-updates.php

disable-updates.php in Disable Updates for WordPress Core, Plugins and Themes 1.4.3, at disable-updates.php

89 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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.4.3
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
41 return $event;
42
43 }
44 add_action ( 'schedule_event', 'filter_cron_events' );
45
46 // hide all upgrade notices
47 function du_hide_admin_notices () {
48 remove_action ( 'admin_notices', 'update_nag', 3 );
49 }
50 add_action ( 'admin_menu', 'du_hide_admin_notices' );
51
52 // remove the 'Updates' menu item from the admin interface
53 function du_remove_menus () {
54 global $submenu;
55 remove_submenu_page ( 'index.php', 'update-core.php' );
56 }
57 add_action ( 'admin_menu', 'du_remove_menus', 102 );
58
59 // disable core, theme and plugin updates
60 function du_disable_updates () {
61 remove_action ( 'load-update-core.php', 'wp_update_core' );
62 remove_action ( 'load-update-core.php', 'wp_update_themes' );
63 remove_action ( 'load-update-core.php', 'wp_update_plugins' );
64 }
65 add_action ( 'init', 'du_disable_updates', 1 );
66
67 // fake last checked time (using __return_null makes the dashboard slow)
68 function du_last_checked () {
69 global $wp_version;
70 return ( object ) array (
71 'last_checked' => time (),
72 'version_checked' => $wp_version,
73 'updates' => array ()
74 );
75 }
76 add_filter ( 'pre_site_transient_update_core', 'du_last_checked' );
77 add_filter ( 'pre_site_transient_update_plugins', 'du_last_checked' ) ;
78 add_filter ( 'pre_site_transient_update_themes', 'du_last_checked' );
79
80 // disable automatic updates
81 add_filter ( 'automatic_updater_disabled', '__return_true' );
82
83 // disable update health check
84 add_filter ( 'site_status_tests', function ( $tests ) {
85 unset ( $tests['async']['background_updates'] );
86 unset ( $tests['direct']['plugin_theme_auto_updates'] );
87 return $tests;
88 });
89