本文整理匯總了PHP中Theme_Upgrader::maintenance_mode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Theme_Upgrader::maintenance_mode方法的具體用法?PHP Theme_Upgrader::maintenance_mode怎麽用?PHP Theme_Upgrader::maintenance_mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Theme_Upgrader
的用法示例。
在下文中一共展示了Theme_Upgrader::maintenance_mode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: do_theme_update
/**
* Process automatic theme update
*
* @since 1.0.0
*/
public function do_theme_update()
{
if (!isset($_REQUEST['nonce'])) {
die;
}
if (!wp_verify_nonce(esc_attr($_REQUEST['nonce']), 'monstroid-dashboard')) {
die;
}
if (!current_user_can('update_themes')) {
die;
}
monstroid_dashboard()->filesystem->add_creds();
$backup_link = $this->try_make_backup();
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once monstroid_dashboard()->plugin_dir('admin/includes/class-monstroid-dashboard-upgrader-skin.php');
$title = __('Update Monstroid theme', 'monstroid-dashboard');
$theme = 'monstroid';
$upgrader = new Theme_Upgrader(new Monstroid_Dashboard_Upgrader_Skin(compact('title', 'theme')));
ini_set('max_execution_time', -1);
set_time_limit(0);
$update = $upgrader->upgrade($theme);
$log = $upgrader->skin->get_install_log();
$success = __('Great news! Monstroid Dashboard successfully updated your theme to the latest available version', 'monstroid-dashboard');
if (true == $update) {
$this->clear_update_data();
wp_send_json_success(array('message' => $success, 'newVersion' => $this->get_update_data('new_version'), 'updateLog' => $log));
}
$upgrader->maintenance_mode(false);
if (is_wp_error($update)) {
wp_send_json_error(array('message' => sprintf(__('Update failed. %s', 'monstroid-dashboard'), $update->get_error_message()), 'updateLog' => $log));
}
if (!$update) {
wp_send_json_error(array('message' => __('Update failed. <a href="#" class="show-update-log">Show update log</a>', 'monstroid-dashboard'), 'updateLog' => $log));
}
wp_send_json_error(array('message' => __('Unknown error, please try again later or contact our support', 'monstroid-dashboard'), 'updateLog' => $log));
}