/**
		 * Metabox to show the restore options
		 *
		 * @since 1.0.2
		 *
		 * @param string $title - Title to be displayed in header of metabox
		 * @param array  $item 	- The current viewed item
		 * @return none
		 */

		function snapshot_metabox_restore_options($title, $item) {
			?>
			<div class="postbox">
				<h3 class="hndle"><span><?php echo $title; ?></span></h3>
				<div class="inside">

					<table class="form-table snapshot-restore-options">
					<tr class="">
						<th scope="row">
							<label><?php _e('Plugins', SNAPSHOT_I18N_DOMAIN); ?></label>
						</th>
						<td>
							<input type="checkbox" id="snapshot-restore-option-plugins" name="restore-option-plugins" value="yes" /> <label
									 for="snapshot-restore-option-plugins"><?php _e('Turn off all plugins', SNAPSHOT_I18N_DOMAIN); ?></label>
						</td>
					</tr>
					<tr>
						<th scope="row">
							<label><?php _e('Set a theme to active', SNAPSHOT_I18N_DOMAIN); ?></label>
						</th>
						<td>
							<?php
								if (isset($item['blog-id'])) {
									$current_theme = snapshot_utility_get_current_theme($item['blog-id']);
								} else {
									$current_theme = snapshot_utility_get_current_theme();
								}
								//echo "current_theme=[". $current_theme ."]<br />";

								if (isset($item['blog-id'])) {
									$themes = snapshot_utility_get_blog_active_themes($item['blog-id']);
								} else {
									$themes = snapshot_utility_get_blog_active_themes();
								}

								if ($themes) {
									//echo "themes<pre>"; print_r($themes); echo "</pre>";

									?><ul><?php
									foreach($themes as $theme_key => $theme_name) {

										?>
										<li><input type="radio" id="snapshot-restore-option-theme-<?php echo $theme_key; ?>"
										<?php
											if ($theme_name == $current_theme) { echo ' checked="checked" '; }
											?> name="restore-option-theme" value="<?php echo $theme_key; ?>" />
											<label for="snapshot-restore-option-theme-<?php echo $theme_key; ?>">
												<?php if ($theme_name == $current_theme) { echo '<strong>'; } ?>
												<?php echo $theme_name ?>
												<?php if ($theme_name == $current_theme) { echo '</strong> (current active theme)'; } ?>
											</label>
										</li>
										<?php
									}
									?></ul><?php
								}
							?>
						</td>
					</tr>
					</table>
				</div>
			</div>
			<?php
		}
Example #2
0
 /**
  * AJAX callback function from the snapshot restore form. This is the third
  * step of the restore. This step will performs the cleanup of the unzipped
  * archive and writes an entry to the activity log about the restore.
  *
  * @since 1.0.2
  * @see
  *
  * @param none
  * @return JSON formatted array status.
  */
 function snapshot_ajax_restore_finish($item)
 {
     $this->snapshot_ajax_restore_rename_restored_tables($item);
     if (is_multisite()) {
         $this->snapshot_ajax_restore_convert_db_global_tables($item);
     }
     if (isset($_POST['snapshot_restore_theme'])) {
         $snapshot_restore_theme = esc_attr($_REQUEST['snapshot_restore_theme']);
         if ($snapshot_restore_theme) {
             $themes = snapshot_utility_get_blog_active_themes($item['blog-id']);
             if ($themes && isset($themes[$snapshot_restore_theme])) {
                 if (is_multisite()) {
                     delete_blog_option($item['blog-id'], 'current_theme');
                     add_blog_option($item['blog-id'], 'current_theme', $themes[$snapshot_restore_theme]);
                 } else {
                     delete_option('current_theme');
                     add_option('current_theme', $themes[$snapshot_restore_theme]);
                 }
             }
         }
     }
     if (isset($_REQUEST['snapshot_restore_plugin']) && esc_attr($_REQUEST['snapshot_restore_plugin']) == "yes") {
         $_plugin_file = basename(dirname(__FILE__)) . "/" . basename(__FILE__);
         $_plugins = array($_plugin_file);
         if (is_multisite()) {
             delete_blog_option($item['blog-id'], 'active_plugins');
             add_blog_option($item['blog-id'], 'active_plugins', $_plugins);
         } else {
             delete_option('active_plugins');
             add_option('active_plugins', $_plugins);
         }
     }
     // Cleanup any files from restore in case any files were left
     if ($dh = opendir($this->_session->data['restoreFolder'])) {
         while (($file = readdir($dh)) !== false) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             snapshot_utility_recursive_rmdir($this->_session->data['restoreFolder'] . $file);
         }
         closedir($dh);
     }
     flush_rewrite_rules();
     $error_status = array();
     $error_status['errorStatus'] = false;
     $error_status['errorText'] = "";
     $error_status['responseText'] = "<p>" . __("SUCCESS: Snapshot Restore complete! ", SNAPSHOT_I18N_DOMAIN) . "</p>";
     return $error_status;
 }