/**
  * 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));
 }