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_Plugins.php
109 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Disables all WordPress plugin updates. |
| 4 | * |
| 5 | * Disables all WordPress plugin updates. |
| 6 | * |
| 7 | * @package WordPress |
| 8 | * @since 5.0.0 |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * Disable plugin updates |
| 13 | * Credit - From https://wordpress.org/plugins/disable-wordpress-updates/ |
| 14 | */ |
| 15 | class MPSUM_Disable_Updates_Plugins { |
| 16 | |
| 17 | /** |
| 18 | * Constructor |
| 19 | */ |
| 20 | public function __construct() { |
| 21 | add_action('admin_init', array($this, 'admin_init')); |
| 22 | |
| 23 | /* |
| 24 | * Disable Plugin Updates |
| 25 | * 2.8 to 3.0 |
| 26 | */ |
| 27 | add_action('pre_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 28 | |
| 29 | /* |
| 30 | * 3.0 |
| 31 | */ |
| 32 | add_filter('pre_site_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 33 | |
| 34 | /* |
| 35 | * Disable All Automatic Updates (3.7+) |
| 36 | */ |
| 37 | add_filter('auto_update_plugin', '__return_false'); |
| 38 | |
| 39 | } //end constructor |
| 40 | |
| 41 | /** |
| 42 | * Initialize and load the plugin stuff |
| 43 | * |
| 44 | * @since 1.3 |
| 45 | * @author scripts@schloebe.de |
| 46 | */ |
| 47 | function admin_init() { |
| 48 | /* |
| 49 | * Disable Plugin Updates |
| 50 | * 2.8 to 3.0 |
| 51 | */ |
| 52 | remove_action('load-plugins.php', 'wp_update_plugins'); |
| 53 | remove_action('load-update.php', 'wp_update_plugins'); |
| 54 | remove_action('admin_init', '_maybe_update_plugins'); |
| 55 | remove_action('wp_update_plugins', 'wp_update_plugins'); |
| 56 | wp_clear_scheduled_hook('wp_update_plugins'); |
| 57 | |
| 58 | /* |
| 59 | * 3.0 |
| 60 | */ |
| 61 | remove_action('load-update-core.php', 'wp_update_plugins'); |
| 62 | wp_clear_scheduled_hook('wp_update_plugins'); |
| 63 | |
| 64 | add_action('upgrader_process_complete', array($this, 'maybe_clear_transient'), 10, 2); |
| 65 | |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Fires when the auto updater is complete |
| 70 | * |
| 71 | * @param WP_Upgrader $wp_upgrader WP Upgrder Instance |
| 72 | * @param array $update_type Type of upgrade it's doing |
| 73 | */ |
| 74 | public function maybe_clear_transient($wp_upgrader, $update_type) { |
| 75 | if (isset($update_type['type']) && 'translation' === $update_type['type']) { |
| 76 | delete_site_transient('eum_plugins_checked'); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Last checked core updates |
| 82 | * |
| 83 | * @param string $transient Specify transients |
| 84 | * @param string $key Name of the transient |
| 85 | * @return object |
| 86 | */ |
| 87 | public function last_checked_now($transient, $key) { |
| 88 | $checked = get_site_transient('eum_plugins_checked'); |
| 89 | if ($checked) return $checked; |
| 90 | remove_action('pre_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 91 | remove_filter('pre_site_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 92 | delete_site_transient($key); |
| 93 | wp_update_plugins(); |
| 94 | $option = get_site_transient($key); |
| 95 | include ABSPATH . WPINC . '/version.php'; |
| 96 | $current = new stdClass; |
| 97 | $current->updates = array(); |
| 98 | $current->version_checked = $wp_version; |
| 99 | $current->last_checked = time(); |
| 100 | if (isset($option->translations)) { |
| 101 | $current->translations = $option->translations; |
| 102 | } |
| 103 | add_action('pre_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 104 | add_filter('pre_site_transient_update_plugins', array($this, 'last_checked_now'), 10, 2); |
| 105 | set_site_transient('eum_plugins_checked', $current, 6 * 60 * 60); |
| 106 | return $current; |
| 107 | } |
| 108 | } |
| 109 |