MPSUM_Admin.php
7 years ago
MPSUM_Admin_Advanced.php
7 years ago
MPSUM_Admin_Advanced_Preview.php
7 years ago
MPSUM_Admin_Ajax.php
7 years ago
MPSUM_Admin_Bar.php
7 years ago
MPSUM_Admin_Core.php
7 years ago
MPSUM_Admin_Dashboard.php
7 years ago
MPSUM_Admin_Help.php
7 years ago
MPSUM_Admin_Logs.php
7 years ago
MPSUM_Admin_Plugins.php
7 years ago
MPSUM_Admin_Screen_Options.php
7 years ago
MPSUM_Admin_Themes.php
7 years ago
MPSUM_Advanced_Premium.php
7 years ago
MPSUM_Check_Plugin_Install_Status.php
7 years ago
MPSUM_Check_Theme_Install_Status.php
7 years ago
MPSUM_Commands.php
7 years ago
MPSUM_Disable_Updates.php
7 years ago
MPSUM_Disable_Updates_All.php
7 years ago
MPSUM_Disable_Updates_Plugins.php
7 years ago
MPSUM_Disable_Updates_Themes.php
7 years ago
MPSUM_Disable_Updates_Translations.php
7 years ago
MPSUM_Disable_Updates_WordPress.php
7 years ago
MPSUM_Exclude_Users.php
7 years ago
MPSUM_Force_Updates.php
7 years ago
MPSUM_List_Table.php
7 years ago
MPSUM_Logs.php
7 years ago
MPSUM_Logs_List_Table.php
7 years ago
MPSUM_Plugins_List_Table.php
7 years ago
MPSUM_Reset_Options.php
7 years ago
MPSUM_Themes_List_Table.php
7 years ago
MPSUM_UpdraftCentral.php
7 years ago
MPSUM_UpdraftCentral_EUM_Commands.php
7 years ago
MPSUM_Utils.php
7 years ago
easy-updates-manager-notices.php
7 years ago
updraft-notices.php
7 years ago
MPSUM_Disable_Updates_WordPress.php
126 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Disables all core WordPress updates. |
| 4 | * |
| 5 | * @package WordPress |
| 6 | * @since 5.0.0 |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Disable WordPress core updates |
| 11 | * Credit - From https://wordpress.org/plugins/disable-wordpress-updates/ |
| 12 | */ |
| 13 | class MPSUM_Disable_Updates_WordPress { |
| 14 | /** |
| 15 | * Constructor |
| 16 | */ |
| 17 | public function __construct() { |
| 18 | add_action('admin_init', array($this, 'admin_init')); |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | * Disable Core Updates |
| 23 | * 2.8 to 3.0 |
| 24 | */ |
| 25 | add_filter('pre_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 26 | |
| 27 | /* |
| 28 | * 3.0 |
| 29 | */ |
| 30 | add_filter('pre_site_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | * Disable All Automatic Updates |
| 35 | * 3.7+ |
| 36 | * |
| 37 | * @author sLa NGjI's @ slangji.wordpress.com |
| 38 | */ |
| 39 | add_filter('automatic_updater_disabled', '__return_true'); |
| 40 | add_filter('allow_minor_auto_core_updates', '__return_false'); |
| 41 | add_filter('allow_major_auto_core_updates', '__return_false'); |
| 42 | add_filter('allow_dev_auto_core_updates', '__return_false'); |
| 43 | add_filter('auto_update_core', '__return_false'); |
| 44 | add_filter('wp_auto_update_core', '__return_false'); |
| 45 | add_filter('auto_core_update_send_email', '__return_false'); |
| 46 | add_filter('send_core_update_notification_email', '__return_false'); |
| 47 | add_filter('automatic_updates_send_debug_email', '__return_false'); |
| 48 | add_filter('automatic_updates_is_vcs_checkout', '__return_true'); |
| 49 | |
| 50 | } //end constructor |
| 51 | |
| 52 | /** |
| 53 | * Initialize and load the plugin stuff |
| 54 | * |
| 55 | * @since 1.3 |
| 56 | * @author scripts@schloebe.de |
| 57 | */ |
| 58 | function admin_init() { |
| 59 | /* |
| 60 | * Disable Core Updates |
| 61 | * 2.8 to 3.0 |
| 62 | */ |
| 63 | remove_action('wp_version_check', 'wp_version_check'); |
| 64 | remove_action('admin_init', '_maybe_update_core'); |
| 65 | wp_clear_scheduled_hook('wp_version_check'); |
| 66 | |
| 67 | |
| 68 | /* |
| 69 | * 3.0 |
| 70 | */ |
| 71 | wp_clear_scheduled_hook('wp_version_check'); |
| 72 | |
| 73 | |
| 74 | /* |
| 75 | * 3.7+ |
| 76 | */ |
| 77 | remove_action('wp_maybe_auto_update', 'wp_maybe_auto_update'); |
| 78 | remove_action('admin_init', 'wp_maybe_auto_update'); |
| 79 | remove_action('admin_init', 'wp_auto_update_core'); |
| 80 | wp_clear_scheduled_hook('wp_maybe_auto_update'); |
| 81 | |
| 82 | add_action('upgrader_process_complete', array($this, 'maybe_clear_transient'), 10, 2); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Fires when the auto updater is complete |
| 87 | * |
| 88 | * @param WP_Upgrader $wp_upgrader WP Upgrder Instance |
| 89 | * @param array $update_type Type of upgrade it's doing |
| 90 | */ |
| 91 | public function maybe_clear_transient($wp_upgrader, $update_type) { |
| 92 | if (isset($update_type['type']) && 'translation' === $update_type['type']) { |
| 93 | delete_site_transient('eum_core_checked'); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Last checked core updates |
| 99 | * |
| 100 | * @param string $transient Specify transients |
| 101 | * @param string $key Name of the transient |
| 102 | * @return object |
| 103 | */ |
| 104 | public function last_checked_now($transient, $key) { |
| 105 | $checked = get_site_transient('eum_core_checked'); |
| 106 | if ($checked) return $checked; |
| 107 | remove_action('pre_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 108 | remove_filter('pre_site_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 109 | delete_site_transient($key); |
| 110 | wp_version_check(); |
| 111 | $option = get_site_transient($key); |
| 112 | include ABSPATH . WPINC . '/version.php'; |
| 113 | $current = new stdClass; |
| 114 | $current->updates = array(); |
| 115 | $current->version_checked = $wp_version; |
| 116 | $current->last_checked = time(); |
| 117 | if (isset($option->translations)) { |
| 118 | $current->translations = $option->translations; |
| 119 | } |
| 120 | add_action('pre_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 121 | add_filter('pre_site_transient_update_core', array($this, 'last_checked_now'), 10, 2); |
| 122 | set_site_transient('eum_core_checked', $current, 6 * 60 * 60); |
| 123 | return $current; |
| 124 | } |
| 125 | } |
| 126 |