class-activation.php
1 year ago
class-admin-menu-organizer.php
1 year ago
class-auto-publish-posts-with-missed-schedule.php
1 year ago
class-avif-upload.php
1 year ago
class-captcha-protection.php
1 year ago
class-change-login-url.php
1 year ago
class-cleanup-admin-bar.php
1 year ago
class-common-methods.php
1 year ago
class-content-duplication.php
1 year ago
class-content-order.php
1 year ago
class-custom-admin-footer-text.php
1 year ago
class-custom-body-class.php
1 year ago
class-custom-css.php
1 year ago
class-custom-nav-menu-items-in-new-tab.php
1 year ago
class-deactivation.php
1 year ago
class-disable-comments.php
1 year ago
class-disable-dashboard-widgets.php
1 year ago
class-disable-feeds.php
1 year ago
class-disable-gutenberg.php
1 year ago
class-disable-rest-api.php
1 year ago
class-disable-smaller-components.php
1 year ago
class-disable-updates.php
1 year ago
class-disable-xml-rpc.php
1 year ago
class-display-system-summary.php
1 year ago
class-email-address-obfuscator.php
1 year ago
class-email-delivery.php
1 year ago
class-enhance-list-tables.php
1 year ago
class-external-permalinks.php
1 year ago
class-heartbeat-control.php
1 year ago
class-hide-admin-bar.php
1 year ago
class-hide-admin-notices.php
1 year ago
class-image-sizes-panel.php
1 year ago
class-image-upload-control.php
1 year ago
class-insert-head-body-footer-code.php
1 year ago
class-last-login-column.php
1 year ago
class-limit-login-attempts.php
1 year ago
class-login-id-type.php
1 year ago
class-login-logout-menu.php
1 year ago
class-maintenance-mode.php
1 year ago
class-manage-ads-appads-txt.php
1 year ago
class-manage-robots-txt.php
1 year ago
class-media-replacement.php
1 year ago
class-multiple-user-roles.php
1 year ago
class-obfuscate-author-slugs.php
1 year ago
class-open-external-links-in-new-tab.php
1 year ago
class-password-protection.php
1 year ago
class-redirect-after-login.php
1 year ago
class-redirect-after-logout.php
1 year ago
class-redirect-fourofour.php
1 year ago
class-registration-date-column.php
1 year ago
class-revisions-control.php
1 year ago
class-search-engines-visibility.php
1 year ago
class-settings-fields-render.php
1 year ago
class-settings-sanitization.php
1 year ago
class-settings-sections-fields.php
1 year ago
class-show-custom-taxonomy-filters.php
1 year ago
class-site-identity-on-login-page.php
1 year ago
class-svg-upload.php
1 year ago
class-various-admin-ui-enhancements.php
1 year ago
class-view-admin-as-role.php
1 year ago
class-wider-admin-menu.php
1 year ago
class-wp-config-transformer.php
1 year ago
class-disable-updates.php
103 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | /** |
| 6 | * Class for Disable Updates module |
| 7 | * |
| 8 | * @since 6.9.5 |
| 9 | */ |
| 10 | class Disable_Updates { |
| 11 | |
| 12 | /** |
| 13 | * Disable updates and related functionalities |
| 14 | * |
| 15 | * @since 4.0.0 |
| 16 | */ |
| 17 | public function disable_update_notices_version_checks() { |
| 18 | |
| 19 | // Remove nags |
| 20 | remove_action( 'admin_notices', 'update_nag', 3 ); |
| 21 | remove_action( 'admin_notices', 'maintenance_nag' ); |
| 22 | |
| 23 | // Disable WP version check |
| 24 | remove_action( 'wp_version_check', 'wp_version_check' ); |
| 25 | remove_action( 'admin_init', 'wp_version_check' ); |
| 26 | wp_clear_scheduled_hook( 'wp_version_check' ); |
| 27 | |
| 28 | add_filter( 'pre_option_update_core', '__return_null' ); |
| 29 | |
| 30 | // Disable theme version checks |
| 31 | remove_action( 'wp_update_themes', 'wp_update_themes' ); |
| 32 | remove_action( 'admin_init', '_maybe_update_themes' ); |
| 33 | wp_clear_scheduled_hook( 'wp_update_themes' ); |
| 34 | |
| 35 | remove_action( 'load-themes.php', 'wp_update_themes' ); |
| 36 | remove_action( 'load-update.php', 'wp_update_themes' ); |
| 37 | remove_action( 'load-update-core.php', 'wp_update_themes' ); |
| 38 | |
| 39 | // Disable plugin version checks |
| 40 | remove_action( 'wp_update_plugins', 'wp_update_plugins' ); |
| 41 | remove_action( 'admin_init', '_maybe_update_plugins' ); |
| 42 | wp_clear_scheduled_hook( 'wp_update_plugins' ); |
| 43 | |
| 44 | remove_action( 'load-plugins.php', 'wp_update_plugins' ); |
| 45 | remove_action( 'load-update.php', 'wp_update_plugins' ); |
| 46 | remove_action( 'load-update-core.php', 'wp_update_plugins' ); |
| 47 | |
| 48 | // Disable auto updates |
| 49 | wp_clear_scheduled_hook( 'wp_maybe_auto_update' ); |
| 50 | |
| 51 | remove_action( 'wp_maybe_auto_update', 'wp_maybe_auto_update' ); |
| 52 | remove_action( 'admin_init', 'wp_maybe_auto_update' ); |
| 53 | remove_action( 'admin_init', 'wp_auto_update_core' ); |
| 54 | |
| 55 | // Disable Site Health checks |
| 56 | add_filter( 'site_status_tests', [ $this, 'disable_update_checks_in_site_health' ] ); |
| 57 | |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Override version check info stored in transients named update_core, update_plugins, update_themes. |
| 62 | * |
| 63 | * @since 4.0.0 |
| 64 | */ |
| 65 | public function override_version_check_info() { |
| 66 | |
| 67 | include( ABSPATH . WPINC . '/version.php' ); // get $wp_version from here |
| 68 | |
| 69 | $current = (object)array(); // create empty object |
| 70 | $current->updates = array(); |
| 71 | $current->response = array(); |
| 72 | $current->version_checked = $wp_version; |
| 73 | $current->last_checked = time(); |
| 74 | |
| 75 | return $current; |
| 76 | |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Disable Background Updates and Auto-Updates tests in Site Health tests |
| 81 | * |
| 82 | * @since 4.0.0 |
| 83 | */ |
| 84 | public function disable_update_checks_in_site_health( $tests ) { |
| 85 | |
| 86 | unset( $tests['async']['background_updates'] ); |
| 87 | unset( $tests['direct']['plugin_theme_auto_updates'] ); |
| 88 | |
| 89 | return $tests; |
| 90 | |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Remove Dashboard >> Updates menu item |
| 95 | * |
| 96 | * @since 4.0.0 |
| 97 | */ |
| 98 | public function remove_updates_menu() { |
| 99 | global $submenu; |
| 100 | remove_submenu_page( 'index.php', 'update-core.php' ); |
| 101 | } |
| 102 | |
| 103 | } |