notices
5 years ago
admin-bar.php
7 years ago
admin-tab-advanced.php
7 years ago
admin-tab-logs.php
5 years ago
admin-tab-main.php
7 years ago
admin-tab-plugins.php
5 years ago
admin-tab-themes.php
5 years ago
advanced-premium-preview.php
7 years ago
advanced-premium.php
5 years ago
exclude-users.php
5 years ago
force-updates.php
5 years ago
reset-options.php
5 years ago
force-updates.php
71 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) die('No direct access.'); |
| 3 | echo '<div class="eum-advanced-settings-container force-updates">'; |
| 4 | |
| 5 | // Check for wp-config constants that disable force updates |
| 6 | if (defined('AUTOMATIC_UPDATER_DISABLED') && true == AUTOMATIC_UPDATER_DISABLED) { |
| 7 | printf('<div class="mpsum-error mpsum-bold">%s</div>', esc_html__('Automatic updates are disabled. Please check your wp-config.php file for AUTOMATIC_UPDATER_DISABLED and remove the line.')); |
| 8 | } |
| 9 | if (defined('WP_AUTO_UPDATE_CORE') && false == WP_AUTO_UPDATE_CORE) { |
| 10 | printf('<div class="mpsum-error mpsum-bold">%s</div>', esc_html__('Automatic updates for Core are disabled. Please check your wp-config.php file for WP_AUTO_UPDATE_CORE and remove the line.')); |
| 11 | } |
| 12 | |
| 13 | // Check for options that also disable force updates |
| 14 | $options = MPSUM_Updates_Manager::get_options('core'); |
| 15 | |
| 16 | // Show a notice if all updates are disabled |
| 17 | if (isset($options['all_updates']) && 'off' == $options['all_updates']) { |
| 18 | printf('<div class="mpsum-error mpsum-bold">%s</div>', esc_html__('All updates are disabled. Please re-enable all updates for force updates to work.')); |
| 19 | } |
| 20 | |
| 21 | // Show a notice if automatic updates are off |
| 22 | if (!MPSUM_Utils::get_instance()->is_automatic_updates_enabled()) { |
| 23 | printf('<div class="mpsum-error mpsum-bold">%s</div>', esc_html__('Automatic updates are off, so Force updates will not work.')); |
| 24 | } |
| 25 | |
| 26 | // Show a warning if delay updates is above zero |
| 27 | if (isset($options['delay_updates']) && $options['delay_updates'] > 0) { |
| 28 | printf('<div class="mpsum-notice mpsum-bold">%s</div>', esc_html__('Delayed updates are on, so some assets may not be updated automatically.')); |
| 29 | } |
| 30 | |
| 31 | // Begin output |
| 32 | printf('<h3>%s</h3>', esc_html__('Force automatic updates', 'stops-core-theme-and-plugin-updates')); |
| 33 | printf('<div class="mpsum-notice mpsum-regular">%s</div>', esc_html__('Force updates will request automatic updates of your plugins, core, themes, and translations immediately. This is useful for debugging and checking that automatic updates are working as intended. By default, WordPress checks for updates every 12 hours. Running force updates will, if successful, cause updates to happen immediately.', 'stops-core-theme-and-plugin-updates')); |
| 34 | $utils = MPSUM_Utils::get_instance(); |
| 35 | $updraftplus = $utils->is_installed('updraftplus'); |
| 36 | if (true === $updraftplus['installed'] && true === $updraftplus['active']) { |
| 37 | global $updraftplus_admin; |
| 38 | if (is_a($updraftplus_admin, 'UpdraftPlus_Admin') && is_callable(array($updraftplus_admin, 'add_backup_scaffolding'))) { |
| 39 | printf('<label><input type="checkbox" name="backup_force_updates" id="backup_force_updates" value="1" />%s</label>', __('Take a backup first (with UpdraftPlus)', 'stops-core-theme-and-plugin-updates')); |
| 40 | $updraftplus_admin->add_backup_scaffolding(__('Take a backup before update', 'stops-core-theme-and-plugin-updates'), array($updraftplus_admin, 'backupnow_modal_contents')); |
| 41 | } |
| 42 | } else { |
| 43 | if (true === $updraftplus['installed'] && false === $updraftplus['active']) { |
| 44 | $can_activate = is_multisite() ? current_user_can('manage_network_plugins') : current_user_can('activate_plugins'); |
| 45 | if ($can_activate) { |
| 46 | $activate_link = is_multisite() ? network_admin_url('plugins.php?action=activate&plugin='.$updraftplus['name']) : self_admin_url('plugins.php?action=activate&plugin='.$updraftplus['name']); |
| 47 | $url = esc_url(wp_nonce_url( |
| 48 | $activate_link, |
| 49 | 'activate-plugin_'.$updraftplus['name'] |
| 50 | )); |
| 51 | $url_text = __('Follow this link to activate it.', 'stops-core-theme-and-plugin-updates'); |
| 52 | $anchor = "<a href=\"{$url}\">{$url_text}</a>"; |
| 53 | } |
| 54 | $required_plugin = __('Take a backup with UpdraftPlus before updating.', 'stops-core-theme-and-plugin-updates'); |
| 55 | printf('<p id="eum-auto-backup-description">%s %s</p>', $required_plugin, $anchor); |
| 56 | } else { |
| 57 | if (current_user_can('install_plugins')) { |
| 58 | $url = esc_url(wp_nonce_url( |
| 59 | is_multisite() ? network_admin_url('update.php?action=install-plugin&plugin=updraftcentral') : self_admin_url('update.php?action=install-plugin&plugin=updraftplus'), |
| 60 | 'install-plugin_updraftplus' |
| 61 | )); |
| 62 | $url_text = __('Follow this link to install it.', 'stops-core-theme-and-plugin-updates'); |
| 63 | $anchor = "<a href=\"{$url}\">{$url_text}</a>"; |
| 64 | $required_plugin = __('You can take backups using UpdraftPlus before updating.', 'stops-core-theme-and-plugin-updates'); |
| 65 | printf('<p id="eum-auto-backup-description">%s %s</p>', $required_plugin, $anchor); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | printf('<p class="submit"><input type="submit" name="submit" id="force-updates" class="button button-primary" value="%s"></p>', esc_attr__('Force updates', 'stops-core-theme-and-plugin-updates')); |
| 70 | echo '</div>'; |
| 71 |