Skip to content

Commit

Permalink
Add config to enable or disable updates
Browse files Browse the repository at this point in the history
Thanks to @rippedspine
  • Loading branch information
vinkla committed Apr 10, 2015
1 parent 5d8e74a commit 8c1ba6e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 35 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
APP_ENV=local

WP_DEBUG=false

THEME_SLUG=boilerplate
Expand Down
11 changes: 11 additions & 0 deletions wp-content/themes/boilerplate/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,15 @@

'disallow_file_edit' => true,

/*
|--------------------------------------------------------------------------
| WordPress Updates
|--------------------------------------------------------------------------
|
| Enable or disable WordPress core, plugins and themes updates.
|
*/

'updates' => false,

];
74 changes: 39 additions & 35 deletions wp-content/themes/boilerplate/library/modules/updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,45 @@
* file that was distributed with this source code.
*/

/**
* Remove option to update themes.
*/
remove_action('load-update-core.php', 'wp_update_themes');
wp_clear_scheduled_hook('wp_update_themes');
if (config('app.updates', false)) {

/**
* Prevent from seeing core updates.
*/
wp_clear_scheduled_hook('wp_version_check');
remove_action('wp_maybe_auto_update', 'wp_maybe_auto_update');
remove_action('admin_init', 'wp_maybe_auto_update');
remove_action('admin_init', 'wp_auto_update_core');
wp_clear_scheduled_hook('wp_maybe_auto_update');
/**
* Remove option to update themes.
*/
remove_action('load-update-core.php', 'wp_update_themes');
wp_clear_scheduled_hook('wp_update_themes');

/**
* Removes plugin update notification.
*/
remove_action('load-update-core.php', 'wp_update_plugins');
wp_clear_scheduled_hook('wp_update_plugins');
/**
* Prevent from seeing core updates.
*/
wp_clear_scheduled_hook('wp_version_check');
remove_action('wp_maybe_auto_update', 'wp_maybe_auto_update');
remove_action('admin_init', 'wp_maybe_auto_update');
remove_action('admin_init', 'wp_auto_update_core');
wp_clear_scheduled_hook('wp_maybe_auto_update');

/**
* Disable all automatic updates.
*/
add_filter('auto_update_translation', '__return_false');
add_filter('automatic_updater_disabled', '__return_true');
add_filter('allow_minor_auto_core_updates', '__return_false');
add_filter('allow_major_auto_core_updates', '__return_false');
add_filter('allow_dev_auto_core_updates', '__return_false');
add_filter('auto_update_core', '__return_false');
add_filter('wp_auto_update_core', '__return_false');
add_filter('auto_core_update_send_email', '__return_false');
add_filter('send_core_update_notification_email', '__return_false');
add_filter('auto_update_plugin', '__return_false');
add_filter('auto_update_theme', '__return_false');
add_filter('automatic_updates_send_debug_email', '__return_false');
add_filter('automatic_updates_is_vcs_checkout', '__return_true');
add_filter('pre_site_transient_update_plugins', '__return_null');
/**
* Removes plugin update notification.
*/
remove_action('load-update-core.php', 'wp_update_plugins');
wp_clear_scheduled_hook('wp_update_plugins');

/**
* Disable all automatic updates.
*/
add_filter('auto_update_translation', '__return_false');
add_filter('automatic_updater_disabled', '__return_true');
add_filter('allow_minor_auto_core_updates', '__return_false');
add_filter('allow_major_auto_core_updates', '__return_false');
add_filter('allow_dev_auto_core_updates', '__return_false');
add_filter('auto_update_core', '__return_false');
add_filter('wp_auto_update_core', '__return_false');
add_filter('auto_core_update_send_email', '__return_false');
add_filter('send_core_update_notification_email', '__return_false');
add_filter('auto_update_plugin', '__return_false');
add_filter('auto_update_theme', '__return_false');
add_filter('automatic_updates_send_debug_email', '__return_false');
add_filter('automatic_updates_is_vcs_checkout', '__return_true');
add_filter('pre_site_transient_update_plugins', '__return_null');

}

0 comments on commit 8c1ba6e

Please sign in to comment.