本文整理汇总了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));
}