Пример #1
0
if (!is_multisite() && current_user_can('install_themes')) {
    ?>
		<a href="<?php 
    echo admin_url('theme-install.php');
    ?>
" class="hide-if-no-js add-new-h2"><?php 
    echo esc_html_x('Add New', 'Add new theme');
    ?>
</a>
	<?php 
}
?>
	</h2>
<?php 
//k(!validate_current_theme());
if (!validate_current_theme() || isset($_GET['broken'])) {
    ?>
<div id="message1" class="updated notice is-dismissible"><p><?php 
    _e('The active theme is broken. Reverting to the default theme.');
    ?>
</p></div>
<?php 
} elseif (isset($_GET['activated'])) {
    if (isset($_GET['previewed'])) {
        ?>
		<div id="message2" class="updated notice is-dismissible"><p><?php 
        printf(__('Settings saved and theme activated. <a href="%s">Visit site</a>'), home_url('/'));
        ?>
</p></div>
		<?php 
    } else {
Пример #2
0
            $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
        } else {
            $help_install = '<p>' . sprintf(__('If you would like to see more themes to choose from, click on the &#8220;Install Themes&#8221; tab and you will be able to browse or search for additional themes from the <a href="%s" target="_blank">WordPress.org Theme Directory</a>. Themes in the WordPress.org Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!'), 'http://wordpress.org/extend/themes/') . '</p>';
        }
        get_current_screen()->add_help_tab(array('id' => 'adding-themes', 'title' => __('Adding Themes'), 'content' => $help_install));
    }
    get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>' . '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
    add_thickbox();
    wp_enqueue_script('theme-preview');
    wp_enqueue_script('theme');
}
require_once './admin-header.php';
?>

<?php 
if (!validate_current_theme()) {
    ?>
<div id="message1" class="updated"><p><?php 
    _e('The active theme is broken. Reverting to the default theme.');
    ?>
</p></div>
<?php 
} elseif (isset($_GET['activated'])) {
    if (isset($wp_registered_sidebars) && count((array) $wp_registered_sidebars) && current_user_can('edit_theme_options')) {
        ?>
<div id="message2" class="updated"><p><?php 
        printf(__('New theme activated. This theme supports widgets, please visit the <a href="%s">widgets settings</a> screen to configure them.'), admin_url('widgets.php'));
        ?>
</p></div><?php 
    } else {
        ?>
Пример #3
0
 /**
  * Callback to validate a theme once it is loaded
  *
  * @since 3.4.0
  */
 public function after_setup_theme()
 {
     $doing_ajax_or_is_customized = $this->doing_ajax() || isset($_SERVER['customized']);
     if (!$doing_ajax_or_is_customized && !validate_current_theme()) {
         wp_redirect('themes.php?broken=true');
         exit;
     }
 }
 /**
  * Callback to validate a theme once it is loaded
  *
  * @since 3.4.0
  */
 public function after_setup_theme()
 {
     if (!$this->doing_ajax() && !validate_current_theme()) {
         wp_redirect('themes.php?broken=true');
         exit;
     }
 }
Пример #5
0
 /**
  * @expectedDeprecated get_themes
  * @expectedDeprecated get_current_theme
  */
 function test_switch_theme()
 {
     $themes = get_themes();
     // Switch to each theme in sequence.
     // Do it twice to make sure we switch to the first theme, even if it's our starting theme.
     // Do it a third time to ensure switch_theme() works with one argument.
     for ($i = 0; $i < 3; $i++) {
         foreach ($themes as $name => $theme) {
             // switch to this theme
             if ($i === 2) {
                 switch_theme($theme['Template'], $theme['Stylesheet']);
             } else {
                 switch_theme($theme['Stylesheet']);
             }
             $this->assertEquals($name, get_current_theme());
             // make sure the various get_* functions return the correct values
             $this->assertEquals($theme['Template'], get_template());
             $this->assertEquals($theme['Stylesheet'], get_stylesheet());
             $root_fs = get_theme_root();
             $this->assertTrue(is_dir($root_fs));
             $root_uri = get_theme_root_uri();
             $this->assertTrue(!empty($root_uri));
             $this->assertEquals($root_fs . '/' . get_stylesheet(), get_stylesheet_directory());
             $this->assertEquals($root_uri . '/' . get_stylesheet(), get_stylesheet_directory_uri());
             $this->assertEquals($root_uri . '/' . get_stylesheet() . '/style.css', get_stylesheet_uri());
             #				$this->assertEquals($root_uri . '/' . get_stylesheet(), get_locale_stylesheet_uri());
             $this->assertEquals($root_fs . '/' . get_template(), get_template_directory());
             $this->assertEquals($root_uri . '/' . get_template(), get_template_directory_uri());
             //get_query_template
             // template file that doesn't exist
             $this->assertEquals('', get_query_template(rand_str()));
             // template files that do exist
             //foreach ($theme['Template Files'] as $path) {
             //$file = basename($path, '.php');
             // FIXME: untestable because get_query_template uses TEMPLATEPATH
             //$this->assertEquals('', get_query_template($file));
             //}
             // these are kind of tautologies but at least exercise the code
             $this->assertEquals(get_404_template(), get_query_template('404'));
             $this->assertEquals(get_archive_template(), get_query_template('archive'));
             $this->assertEquals(get_author_template(), get_query_template('author'));
             $this->assertEquals(get_category_template(), get_query_template('category'));
             $this->assertEquals(get_date_template(), get_query_template('date'));
             $this->assertEquals(get_home_template(), get_query_template('home', array('home.php', 'index.php')));
             $this->assertEquals(get_page_template(), get_query_template('page'));
             $this->assertEquals(get_paged_template(), get_query_template('paged'));
             $this->assertEquals(get_search_template(), get_query_template('search'));
             $this->assertEquals(get_single_template(), get_query_template('single'));
             $this->assertEquals(get_attachment_template(), get_query_template('attachment'));
             // this one doesn't behave like the others
             if (get_query_template('comments-popup')) {
                 $this->assertEquals(get_comments_popup_template(), get_query_template('comments-popup'));
             } else {
                 $this->assertEquals(get_comments_popup_template(), ABSPATH . 'wp-includes/theme-compat/comments-popup.php');
             }
             $this->assertEquals(get_tag_template(), get_query_template('tag'));
             // nb: this probably doesn't run because WP_INSTALLING is defined
             $this->assertTrue(validate_current_theme());
         }
     }
 }
Пример #6
0
 private function restore_backup($timestamp, $continuation_data = null)
 {
     @set_time_limit(UPDRAFTPLUS_SET_TIME_LIMIT);
     global $wp_filesystem, $updraftplus;
     $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
     if (!isset($backup_history[$timestamp]) || !is_array($backup_history[$timestamp])) {
         echo '<p>' . __('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus') . " {$timestamp}</p><br/>";
         return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
     }
     // request_filesystem_credentials passes on fields just via hidden name/value pairs.
     // Build array of parameters to be passed via this
     $extra_fields = array();
     if (isset($_POST['updraft_restore']) && is_array($_POST['updraft_restore'])) {
         foreach ($_POST['updraft_restore'] as $entity) {
             $_POST['updraft_restore_' . $entity] = 1;
             $extra_fields[] = 'updraft_restore_' . $entity;
         }
     }
     if (is_array($continuation_data)) {
         foreach ($continuation_data['second_loop_entities'] as $type => $files) {
             $_POST['updraft_restore_' . $type] = 1;
             if (!in_array('updraft_restore_' . $type, $extra_fields)) {
                 $extra_fields[] = 'updraft_restore_' . $type;
             }
         }
         if (!empty($continuation_data['restore_options'])) {
             $restore_options = $continuation_data['restore_options'];
         }
     }
     // Now make sure that updraft_restorer_ option fields get passed along to request_filesystem_credentials
     foreach ($_POST as $key => $value) {
         if (0 === strpos($key, 'updraft_restorer_')) {
             $extra_fields[] = $key;
         }
     }
     $credentials = request_filesystem_credentials(UpdraftPlus_Options::admin_page() . "?page=updraftplus&action=updraft_restore&backup_timestamp={$timestamp}", '', false, false, $extra_fields);
     WP_Filesystem($credentials);
     if ($wp_filesystem->errors->get_error_code()) {
         echo '<p><em><a href="https://updraftplus.com/faqs/asked-ftp-details-upon-restorationmigration-updates/">' . __('Why am I seeing this?', 'updraftplus') . '</a></em></p>';
         foreach ($wp_filesystem->errors->get_error_messages() as $message) {
             show_message($message);
         }
         exit;
     }
     // If we make it this far then WP_Filesystem has been instantiated and is functional
     # Set up logging
     $updraftplus->backup_time_nonce();
     $updraftplus->jobdata_set('job_type', 'restore');
     $updraftplus->jobdata_set('job_time_ms', $updraftplus->job_time_ms);
     $updraftplus->logfile_open($updraftplus->nonce);
     # Provide download link for the log file
     # TODO: Automatic purging of old log files
     # TODO: Provide option to auto-email the log file
     echo '<h1>' . __('UpdraftPlus Restoration: Progress', 'updraftplus') . '</h1><div id="updraft-restore-progress">';
     $this->show_admin_warning('<a target="_blank" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce=' . htmlspecialchars($updraftplus->nonce) . '">' . __('Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus') . '</a>');
     $updraft_dir = trailingslashit($updraftplus->backups_dir_location());
     $foreign_known = apply_filters('updraftplus_accept_archivename', array());
     $service = isset($backup_history[$timestamp]['service']) ? $backup_history[$timestamp]['service'] : false;
     if (!is_array($service)) {
         $service = array($service);
     }
     // Now, need to turn any updraft_restore_<entity> fields (that came from a potential WP_Filesystem form) back into parts of the _POST array (which we want to use)
     if (empty($_POST['updraft_restore']) || !is_array($_POST['updraft_restore'])) {
         $_POST['updraft_restore'] = array();
     }
     $backup_set = $backup_history[$timestamp];
     $entities_to_restore = array();
     foreach ($_POST['updraft_restore'] as $entity) {
         if (empty($backup_set['meta_foreign'])) {
             $entities_to_restore[$entity] = $entity;
         } else {
             if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]) && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
                 $entities_to_restore[$entity] = 'db';
             } else {
                 $entities_to_restore[$entity] = 'wpcore';
             }
         }
     }
     foreach ($_POST as $key => $value) {
         if (0 === strpos($key, 'updraft_restore_')) {
             $nkey = substr($key, 16);
             if (!isset($entities_to_restore[$nkey])) {
                 $_POST['updraft_restore'][] = $nkey;
                 if (empty($backup_set['meta_foreign'])) {
                     $entities_to_restore[$nkey] = $nkey;
                 } else {
                     if ('db' == $entity && !empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
                         $entities_to_restore[$nkey] = 'db';
                     } else {
                         $entities_to_restore[$nkey] = 'wpcore';
                     }
                 }
             }
         }
     }
     if (0 == count($_POST['updraft_restore'])) {
         echo '<p>' . __('ABORT: Could not find the information on which entities to restore.', 'updraftplus') . '</p>';
         echo '<p>' . __('If making a request for support, please include this information:', 'updraftplus') . ' ' . count($_POST) . ' : ' . htmlspecialchars(serialize($_POST)) . '</p>';
         return new WP_Error('missing_info', 'Backup information not found');
     }
     $this->entities_to_restore = $entities_to_restore;
     set_error_handler(array($updraftplus, 'php_error'), E_ALL & ~E_STRICT);
     /*
     $_POST['updraft_restore'] is typically something like: array( 0=>'db', 1=>'plugins', 2=>'themes'), etc.
     i.e. array ( 'db', 'plugins', themes')
     */
     if (empty($restore_options)) {
         // Gather the restore optons into one place - code after here should read the options, and not the HTTP layer
         $restore_options = array();
         if (!empty($_POST['updraft_restorer_restore_options'])) {
             parse_str($_POST['updraft_restorer_restore_options'], $restore_options);
         }
         $restore_options['updraft_restorer_replacesiteurl'] = empty($_POST['updraft_restorer_replacesiteurl']) ? false : true;
         $restore_options['updraft_encryptionphrase'] = empty($_POST['updraft_encryptionphrase']) ? '' : (string) $_POST['updraft_encryptionphrase'];
         $restore_options['updraft_restorer_wpcore_includewpconfig'] = empty($_POST['updraft_restorer_wpcore_includewpconfig']) ? false : true;
         $updraftplus->jobdata_set('restore_options', $restore_options);
     }
     // Restore in the most helpful order
     uksort($backup_set, array($this, 'sort_restoration_entities'));
     // Now log
     $copy_restore_options = $restore_options;
     if (!empty($copy_restore_options['updraft_encryptionphrase'])) {
         $copy_restore_options['updraft_encryptionphrase'] = '***';
     }
     $updraftplus->log("Restore job started. Entities to restore: " . implode(', ', array_flip($entities_to_restore)) . '. Restore options: ' . json_encode($copy_restore_options));
     $backup_set['timestamp'] = $timestamp;
     $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
     // Allow add-ons to adjust the restore directory (but only in the case of restore - otherwise, they could just use the filter built into UpdraftPlus::get_backupable_file_entities)
     $backupable_entities = apply_filters('updraft_backupable_file_entities_on_restore', $backupable_entities, $restore_options, $backup_set);
     // We use a single object for each entity, because we want to store information about the backup set
     require_once UPDRAFTPLUS_DIR . '/restorer.php';
     global $updraftplus_restorer;
     $updraftplus_restorer = new Updraft_Restorer(new Updraft_Restorer_Skin(), $backup_set, false, $restore_options);
     $second_loop = array();
     echo "<h2>" . __('Final checks', 'updraftplus') . '</h2>';
     if (empty($backup_set['meta_foreign'])) {
         $entities_to_download = $entities_to_restore;
     } else {
         if (!empty($foreign_known[$backup_set['meta_foreign']]['separatedb'])) {
             $entities_to_download = array();
             if (in_array('db', $entities_to_restore)) {
                 $entities_to_download['db'] = 1;
             }
             if (count($entities_to_restore) > 1 || !in_array('db', $entities_to_restore)) {
                 $entities_to_download['wpcore'] = 1;
             }
         } else {
             $entities_to_download = array('wpcore' => 1);
         }
     }
     // First loop: make sure that files are present + readable; and populate array for second loop
     foreach ($backup_set as $type => $files) {
         // All restorable entities must be given explicitly, as we can store other arbitrary data in the history array
         if (!isset($backupable_entities[$type]) && 'db' != $type) {
             continue;
         }
         if (isset($backupable_entities[$type]['restorable']) && $backupable_entities[$type]['restorable'] == false) {
             continue;
         }
         if (!isset($entities_to_download[$type])) {
             continue;
         }
         if ('wpcore' == $type && is_multisite() && 0 === $updraftplus_restorer->ud_backup_is_multisite) {
             echo "<p>{$type}: <strong>";
             echo __('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus');
             #TODO
             #$updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.');
             echo "</strong></p>";
             continue;
         }
         if (is_string($files)) {
             $files = array($files);
         }
         foreach ($files as $ind => $file) {
             $fullpath = $updraft_dir . $file;
             echo sprintf(__("Looking for %s archive: file name: %s", 'updraftplus'), $type, htmlspecialchars($file)) . "<br>";
             if (is_array($continuation_data) && isset($continuation_data['second_loop_entities'][$type]) && !in_array($file, $continuation_data['second_loop_entities'][$type])) {
                 echo __('Skipping: this archive was already restored.', 'updraftplus') . "<br>";
                 // Set the marker so that the existing directory isn't moved out of the way
                 $updraftplus_restorer->been_restored[$type] = true;
                 continue;
             }
             add_action('http_request_args', array($updraftplus, 'modify_http_options'));
             foreach ($service as $serv) {
                 if (!is_readable($fullpath)) {
                     $sd = empty($updraftplus->backup_methods[$serv]) ? $serv : $updraftplus->backup_methods[$serv];
                     echo __("File is not locally present - needs retrieving from remote storage", 'updraftplus') . " ({$sd})";
                     $this->download_file($file, $serv);
                     echo ": ";
                     if (!is_readable($fullpath)) {
                         echo __("Error", 'updraftplus');
                     } else {
                         echo __("OK", 'updraftplus');
                     }
                     echo '<br>';
                 }
             }
             remove_action('http_request_args', array($updraftplus, 'modify_http_options'));
             $index = $ind == 0 ? '' : $ind;
             // If a file size is stored in the backup data, then verify correctness of the local file
             if (isset($backup_history[$timestamp][$type . $index . '-size'])) {
                 $fs = $backup_history[$timestamp][$type . $index . '-size'];
                 echo __("Archive is expected to be size:", 'updraftplus') . " " . round($fs / 1024, 1) . " KB: ";
                 $as = @filesize($fullpath);
                 if ($as == $fs) {
                     echo __('OK', 'updraftplus') . '<br>';
                 } else {
                     echo "<strong>" . __('Error:', 'updraftplus') . "</strong> " . __('file is size:', 'updraftplus') . " " . round($as / 1024) . " ({$fs}, {$as})<br>";
                 }
             } else {
                 echo __("The backup records do not contain information about the proper size of this file.", 'updraftplus') . "<br>";
             }
             if (!is_readable($fullpath)) {
                 echo __('Could not find one of the files for restoration', 'updraftplus') . " ({$file})<br>";
                 $updraftplus->log("{$file}: " . __('Could not find one of the files for restoration', 'updraftplus'), 'error');
                 echo '</div>';
                 restore_error_handler();
                 return false;
             }
         }
         if (empty($updraftplus_restorer->ud_foreign)) {
             $types = array($type);
         } else {
             if ('db' != $type || empty($foreign_known[$updraftplus_restorer->ud_foreign]['separatedb'])) {
                 $types = array('wpcore');
             } else {
                 $types = array('db');
             }
         }
         foreach ($types as $check_type) {
             $info = isset($backupable_entities[$check_type]) ? $backupable_entities[$check_type] : array();
             $val = $updraftplus_restorer->pre_restore_backup($files, $check_type, $info, $continuation_data);
             if (is_wp_error($val)) {
                 $updraftplus->log_wp_error($val);
                 foreach ($val->get_error_messages() as $msg) {
                     echo '<strong>' . __('Error:', 'updraftplus') . '</strong> ' . htmlspecialchars($msg) . '<br>';
                 }
                 foreach ($val->get_error_codes() as $code) {
                     if ('already_exists' == $code) {
                         $this->print_delete_old_dirs_form(false);
                     }
                 }
                 echo '</div>';
                 //close the updraft_restore_progress div even if we error
                 restore_error_handler();
                 return $val;
             } elseif (false === $val) {
                 echo '</div>';
                 //close the updraft_restore_progress div even if we error
                 restore_error_handler();
                 return false;
             }
         }
         foreach ($entities_to_restore as $entity => $via) {
             if ($via == $type) {
                 if ('wpcore' == $via && 'db' == $entity && count($files) > 1) {
                     $second_loop[$entity] = apply_filters('updraftplus_select_wpcore_file_with_db', $files, $updraftplus_restorer->ud_foreign);
                 } else {
                     $second_loop[$entity] = $files;
                 }
             }
         }
     }
     $updraftplus_restorer->delete = UpdraftPlus_Options::get_updraft_option('updraft_delete_local') ? true : false;
     if ('none' === $service || 'email' === $service || empty($service) || is_array($service) && 1 == count($service) && (in_array('none', $service) || in_array('', $service) || in_array('email', $service)) || !empty($updraftplus_restorer->ud_foreign)) {
         if ($updraftplus_restorer->delete) {
             $updraftplus->log_e('Will not delete any archives after unpacking them, because there was no cloud storage for this backup');
         }
         $updraftplus_restorer->delete = false;
     }
     if (!empty($updraftplus_restorer->ud_foreign)) {
         $updraftplus->log("Foreign backup; created by: " . $updraftplus_restorer->ud_foreign);
     }
     // Second loop: now actually do the restoration
     uksort($second_loop, array($this, 'sort_restoration_entities'));
     // If continuing, then prune those already done
     if (is_array($continuation_data)) {
         foreach ($second_loop as $type => $files) {
             if (isset($continuation_data['second_loop_entities'][$type])) {
                 $second_loop[$type] = $continuation_data['second_loop_entities'][$type];
             }
         }
     }
     $updraftplus->jobdata_set('second_loop_entities', $second_loop);
     $updraftplus->jobdata_set('backup_timestamp', $timestamp);
     // use a site option, as otherwise on multisite when all the array of options is updated via UpdraftPlus_Options::update_site_option(), it will over-write any restored UD options from the backup
     update_site_option('updraft_restore_in_progress', $updraftplus->nonce);
     foreach ($second_loop as $type => $files) {
         # Types: uploads, themes, plugins, others, db
         $info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
         echo 'db' == $type ? "<h2>" . __('Database', 'updraftplus') . "</h2>" : "<h2>" . $info['description'] . "</h2>";
         $updraftplus->log("Entity: " . $type);
         if (is_string($files)) {
             $files = array($files);
         }
         foreach ($files as $fkey => $file) {
             $last_one = 1 == count($second_loop) && 1 == count($files);
             $val = $updraftplus_restorer->restore_backup($file, $type, $info, $last_one);
             if (is_wp_error($val)) {
                 $codes = $val->get_error_codes();
                 if (is_array($codes) && in_array('not_found', $codes) && !empty($updraftplus_restorer->ud_foreign) && apply_filters('updraftplus_foreign_allow_missing_entity', false, $type, $updraftplus_restorer->ud_foreign)) {
                     $updraftplus->log("Entity to move not found in this zip - but this is possible with this foreign backup type");
                 } else {
                     $updraftplus->log_e($val);
                     foreach ($val->get_error_messages() as $msg) {
                         echo '<strong>' . __('Error message', 'updraftplus') . ':</strong> ' . htmlspecialchars($msg) . '<br>';
                     }
                     $codes = $val->get_error_codes();
                     if (is_array($codes)) {
                         foreach ($codes as $code) {
                             $data = $val->get_error_data($code);
                             if (!empty($data)) {
                                 $pdata = is_string($data) ? $data : serialize($data);
                                 echo '<strong>' . __('Error data:', 'updraftplus') . '</strong> ' . htmlspecialchars($pdata) . '<br>';
                                 if (false !== strpos($pdata, 'PCLZIP_ERR_BAD_FORMAT (-10)')) {
                                     echo '<a href="https://updraftplus.com/faqs/error-message-pclzip_err_bad_format-10-invalid-archive-structure-mean/"><strong>' . __('Please consult this FAQ for help on what to do about it.', 'updraftplus') . '</strong></a><br>';
                                 }
                             }
                         }
                     }
                     echo '</div>';
                     //close the updraft_restore_progress div even if we error
                     restore_error_handler();
                     return $val;
                 }
             } elseif (false === $val) {
                 echo '</div>';
                 //close the updraft_restore_progress div even if we error
                 restore_error_handler();
                 return false;
             }
             unset($files[$fkey]);
             $second_loop[$type] = $files;
             $updraftplus->jobdata_set('second_loop_entities', $second_loop);
             $updraftplus->jobdata_set('backup_timestamp', $timestamp);
             do_action('updraft_restored_archive', $file, $type, $val, $fkey, $timestamp);
         }
         unset($second_loop[$type]);
         update_site_option('updraft_restore_in_progress', $updraftplus->nonce);
         $updraftplus->jobdata_set('second_loop_entities', $second_loop);
         $updraftplus->jobdata_set('backup_timestamp', $timestamp);
     }
     // All done - remove
     delete_site_option('updraft_restore_in_progress');
     foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
         add_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt));
     }
     # Clear any cached pages after the restore
     $updraftplus_restorer->clear_cache();
     if (!function_exists('validate_current_theme')) {
         require_once ABSPATH . WPINC . '/themes';
     }
     # Have seen a case where the current theme in the DB began with a capital, but not on disk - and this breaks migrating from Windows to a case-sensitive system
     $template = get_option('template');
     if (!empty($template) && $template != WP_DEFAULT_THEME && $template != strtolower($template)) {
         $theme_root = get_theme_root($template);
         $theme_root2 = get_theme_root(strtolower($template));
         if (!file_exists("{$theme_root}/{$template}/style.css") && file_exists("{$theme_root}/" . strtolower($template) . "/style.css")) {
             $updraftplus->log_e("Theme directory (%s) not found, but lower-case version exists; updating database option accordingly", $template);
             update_option('template', strtolower($template));
         }
     }
     if (!validate_current_theme()) {
         echo '<strong>';
         $updraftplus->log_e("The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme");
         echo '</strong>';
     }
     echo '</div>';
     //close the updraft_restore_progress div
     restore_error_handler();
     return true;
 }
Пример #7
0
	  if (isset($_GET['stylesheet'])) {
	    update_option('stylesheet', $_GET['stylesheet']);
	  }

		do_action('switch_theme', get_current_theme());

	  header('Location: themes.php?activated=true');
	}
 }

$title = __('Manage Themes');
$parent_file = 'themes.php';
require_once('admin-header.php');
?>
<?php if ( ! validate_current_theme() ) : ?>
<div class="updated"><p><?php _e('The active theme is broken.  Reverting to the default theme.'); ?></p></div>
<?php elseif ( isset($activated) ) : ?>
<div class="updated"><p><?php _e('New theme activated'); ?></p></div>
<?php endif; ?>

<?php
$themes = get_themes();
$current_theme = get_current_theme();
$current_title = $themes[$current_theme]['Title'];
$current_version = $themes[$current_theme]['Version'];
$current_parent_theme = $themes[$current_theme]['Parent Theme'];
$current_template_dir = $themes[$current_theme]['Template Dir'];
$current_stylesheet_dir = $themes[$current_theme]['Stylesheet Dir'];
$current_template = $themes[$current_theme]['Template'];
$current_stylesheet = $themes[$current_theme]['Stylesheet'];
}

// Escape with wpdb.
$_GET    = add_magic_quotes($_GET   );
$_POST   = add_magic_quotes($_POST  );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);

do_action('sanitize_comment_cookies');

$wp_the_query =& new WP_Query();
$wp_query     =& $wp_the_query;
$wp_rewrite   =& new WP_Rewrite();
$wp           =& new WP();

validate_current_theme();
define('TEMPLATEPATH', get_template_directory());
define('STYLESHEETPATH', get_stylesheet_directory());

// Load the default text localization domain.
load_default_textdomain();

$locale = get_locale();
$locale_file = ABSPATH . LANGDIR . "/$locale.php";
if ( is_readable($locale_file) )
	require_once($locale_file);

// Pull in locale data after loading text domain.
require_once(ABSPATH . WPINC . '/locale.php');

$wp_locale =& new WP_Locale();
Пример #9
0
 function restore_backup($timestamp)
 {
     @set_time_limit(900);
     global $wp_filesystem, $updraftplus;
     $backup_history = UpdraftPlus_Options::get_updraft_option('updraft_backup_history');
     if (!is_array($backup_history[$timestamp])) {
         echo '<p>' . __('This backup does not exist in the backup history - restoration aborted. Timestamp:', 'updraftplus') . " {$timestamp}</p><br/>";
         return new WP_Error('does_not_exist', __('Backup does not exist in the backup history', 'updraftplus'));
     }
     // request_filesystem_credentials passes on fields just via hidden name/value pairs.
     // Build array of parameters to be passed via this
     $extra_fields = array();
     if (isset($_POST['updraft_restore']) && is_array($_POST['updraft_restore'])) {
         foreach ($_POST['updraft_restore'] as $entity) {
             $_POST['updraft_restore_' . $entity] = 1;
             $extra_fields[] = 'updraft_restore_' . $entity;
         }
     }
     // Now make sure that updraft_restorer_ option fields get passed along to request_filesystem_credentials
     foreach ($_POST as $key => $value) {
         if (0 === strpos($key, 'updraft_restorer_')) {
             $extra_fields[] = $key;
         }
     }
     $credentials = request_filesystem_credentials(UpdraftPlus_Options::admin_page() . "?page=updraftplus&action=updraft_restore&backup_timestamp={$timestamp}", '', false, false, $extra_fields);
     WP_Filesystem($credentials);
     if ($wp_filesystem->errors->get_error_code()) {
         foreach ($wp_filesystem->errors->get_error_messages() as $message) {
             show_message($message);
         }
         exit;
     }
     # Set up logging
     $updraftplus->backup_time_nonce();
     $updraftplus->jobdata_set('job_type', 'restore');
     $updraftplus->jobdata_set('job_time_ms', $updraftplus->job_time_ms);
     $updraftplus->logfile_open($updraftplus->nonce);
     # Provide download link for the log file
     #echo '<p><a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce='.htmlspecialchars($updraftplus->nonce).'">'.__('Follow this link to download the log file for this restoration.', 'updraftplus').'</a></p>';
     # TODO: Automatic purging of old log files
     # TODO: Provide option to auto-email the log file
     //if we make it this far then WP_Filesystem has been instantiated and is functional (tested with ftpext, what about suPHP and other situations where direct may work?)
     echo '<h1>' . __('UpdraftPlus Restoration: Progress', 'updraftplus') . '</h1><div id="updraft-restore-progress">';
     $this->show_admin_warning('<a target="_new" href="?action=downloadlog&page=updraftplus&updraftplus_backup_nonce=' . htmlspecialchars($updraftplus->nonce) . '">' . __('Follow this link to download the log file for this restoration (needed for any support requests).', 'updraftplus') . '</a>');
     $updraft_dir = trailingslashit($updraftplus->backups_dir_location());
     $service = isset($backup_history[$timestamp]['service']) ? $backup_history[$timestamp]['service'] : false;
     if (!is_array($service)) {
         $service = array($service);
     }
     // Now, need to turn any updraft_restore_<entity> fields (that came from a potential WP_Filesystem form) back into parts of the _POST array (which we want to use)
     if (empty($_POST['updraft_restore']) || !is_array($_POST['updraft_restore'])) {
         $_POST['updraft_restore'] = array();
     }
     $entities_to_restore = array_flip($_POST['updraft_restore']);
     $entities_log = '';
     foreach ($_POST as $key => $value) {
         if (strpos($key, 'updraft_restore_') === 0) {
             $nkey = substr($key, 16);
             if (!isset($entities_to_restore[$nkey])) {
                 $_POST['updraft_restore'][] = $nkey;
                 $entities_to_restore[$nkey] = 1;
                 $entities_log .= '' == $entities_log ? $nkey : ",{$nkey}";
             }
         }
     }
     $updraftplus->log("Restore job started. Entities to restore: {$entities_log}");
     if (0 == count($_POST['updraft_restore'])) {
         echo '<p>' . __('ABORT: Could not find the information on which entities to restore.', 'updraftplus') . '</p>';
         echo '<p>' . __('If making a request for support, please include this information:', 'updraftplus') . ' ' . count($_POST) . ' : ' . htmlspecialchars(serialize($_POST)) . '</p>';
         return new WP_Error('missing_info', 'Backup information not found');
     }
     set_error_handler(array($updraftplus, 'php_error'), E_ALL & ~E_STRICT);
     /*
     $_POST['updraft_restore'] is typically something like: array( 0=>'db', 1=>'plugins', 2=>'themes'), etc.
     i.e. array ( 'db', 'plugins', themes')
     */
     $backupable_entities = $updraftplus->get_backupable_file_entities(true, true);
     $backup_set = $backup_history[$timestamp];
     uksort($backup_set, array($this, 'sort_restoration_entities'));
     // We use a single object for each entity, because we want to store information about the backup set
     require_once UPDRAFTPLUS_DIR . '/restorer.php';
     global $updraftplus_restorer;
     $updraftplus_restorer = new Updraft_Restorer(new Updraft_Restorer_Skin());
     $second_loop = array();
     echo "<h2>" . __('Final checks', 'updraftplus') . '</h2>';
     // First loop: make sure that files are present + readable; and populate array for second loop
     foreach ($backup_set as $type => $files) {
         // All restorable entities must be given explicitly, as we can store other arbitrary data in the history array
         if (!isset($backupable_entities[$type]) && 'db' != $type) {
             continue;
         }
         if (isset($backupable_entities[$type]['restorable']) && $backupable_entities[$type]['restorable'] == false) {
             continue;
         }
         if (!isset($entities_to_restore[$type])) {
             continue;
         }
         if ($type == 'wpcore' && is_multisite() && 0 === $updraftplus_restorer->ud_backup_is_multisite) {
             echo "<p>{$type}: <strong>";
             echo __('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.', 'updraftplus');
             #TODO
             #$updraftplus->log_e('Skipping restoration of WordPress core when importing a single site into a multisite installation. If you had anything necessary in your WordPress directory then you will need to re-add it manually from the zip file.');
             echo "</strong></p>";
             continue;
         }
         if (is_string($files)) {
             $files = array($files);
         }
         foreach ($files as $ind => $file) {
             $fullpath = $updraft_dir . $file;
             echo sprintf(__("Looking for %s archive: file name: %s", 'updraftplus'), $type, htmlspecialchars($file)) . "<br>";
             foreach ($service as $serv) {
                 if (!is_readable($fullpath)) {
                     $sd = empty($updraftplus->backup_methods[$serv]) ? $serv : $updraftplus->backup_methods[$serv];
                     echo __("File is not locally present - needs retrieving from remote storage", 'updraftplus') . " ({$sd})";
                     $this->download_file($file, $serv);
                     echo ": ";
                     if (!is_readable($fullpath)) {
                         echo __("Error", 'updraftplus');
                     } else {
                         echo __("OK", 'updraftplus');
                     }
                     echo '<br>';
                 }
             }
             $index = $ind == 0 ? '' : $ind;
             // If a file size is stored in the backup data, then verify correctness of the local file
             if (isset($backup_history[$timestamp][$type . $index . '-size'])) {
                 $fs = $backup_history[$timestamp][$type . $index . '-size'];
                 echo __("Archive is expected to be size:", 'updraftplus') . " " . round($fs / 1024, 1) . " Kb: ";
                 $as = @filesize($fullpath);
                 if ($as == $fs) {
                     echo __('OK', 'updraftplus') . '<br>';
                 } else {
                     echo "<strong>" . __('Error:', 'updraftplus') . "</strong> " . __('file is size:', 'updraftplus') . " " . round($as / 1024) . " ({$fs}, {$as})<br>";
                 }
             } else {
                 echo __("The backup records do not contain information about the proper size of this file.", 'updraftplus') . "<br>";
             }
             if (!is_readable($fullpath)) {
                 echo __('Could not find one of the files for restoration', 'updraftplus') . " ({$file})<br>";
                 $updraftplus->log("{$file}: " . __('Could not find one of the files for restoration', 'updraftplus'), 'error');
                 echo '</div>';
                 restore_error_handler();
                 return false;
             }
         }
         $info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
         $val = $updraftplus_restorer->pre_restore_backup($files, $type, $info);
         if (is_wp_error($val)) {
             $updraftplus->log_wp_error($val);
             foreach ($val->get_error_messages() as $msg) {
                 echo '<strong>' . __('Error:', 'updraftplus') . '</strong> ' . htmlspecialchars($msg) . '<br>';
             }
             foreach ($val->get_error_codes() as $code) {
                 if ('already_exists' == $code) {
                     $this->print_delete_old_dirs_form(false);
                 }
             }
             echo '</div>';
             //close the updraft_restore_progress div even if we error
             restore_error_handler();
             return $val;
         } elseif (false === $val) {
             echo '</div>';
             //close the updraft_restore_progress div even if we error
             restore_error_handler();
             return false;
         }
         $second_loop[$type] = $files;
     }
     $updraftplus_restorer->delete = UpdraftPlus_Options::get_updraft_option('updraft_delete_local') ? true : false;
     if ('none' === $service || 'email' === $service || empty($service) || is_array($service) && 1 == count($service) && (in_array('none', $service) || in_array('', $service) || in_array('email', $service))) {
         if ($updraftplus_restorer->delete) {
             $updraftplus->log_e('Will not delete any archives after unpacking them, because there was no cloud storage for this backup');
         }
         $updraftplus_restorer->delete = false;
     }
     // Second loop: now actually do the restoration
     uksort($second_loop, array($this, 'sort_restoration_entities'));
     foreach ($second_loop as $type => $files) {
         # Types: uploads, themes, plugins, others, db
         $info = isset($backupable_entities[$type]) ? $backupable_entities[$type] : array();
         echo 'db' == $type ? "<h2>" . __('Database', 'updraftplus') . "</h2>" : "<h2>" . $info['description'] . "</h2>";
         $updraftplus->log("Entity: " . $type);
         if (is_string($files)) {
             $files = array($files);
         }
         foreach ($files as $file) {
             $val = $updraftplus_restorer->restore_backup($file, $type, $info);
             if (is_wp_error($val)) {
                 $updraftplus->log_e($val);
                 foreach ($val->get_error_messages() as $msg) {
                     echo '<strong>' . __('Error message', 'updraftplus') . ':</strong> ' . htmlspecialchars($msg) . '<br>';
                 }
                 $codes = $val->get_error_codes();
                 if (is_array($codes)) {
                     foreach ($codes as $code) {
                         $data = $val->get_error_data($code);
                         if (!empty($data)) {
                             $pdata = is_string($data) ? $data : serialize($data);
                             echo '<strong>' . __('Error data:', 'updraftplus') . '</strong> ' . htmlspecialchars($pdata) . '<br>';
                         }
                     }
                 }
                 echo '</div>';
                 //close the updraft_restore_progress div even if we error
                 restore_error_handler();
                 return $val;
             } elseif (false === $val) {
                 echo '</div>';
                 //close the updraft_restore_progress div even if we error
                 restore_error_handler();
                 return false;
             }
         }
     }
     foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
         add_filter('pre_option_' . $opt, array($this, 'option_filter_' . $opt));
     }
     if (!function_exists('validate_current_theme')) {
         require_once ABSPATH . 'wp-includes/themes';
     }
     if (!validate_current_theme()) {
         global $updraftplus;
         echo '<strong>';
         $updraftplus->log_e("The current theme was not found; to prevent this stopping the site from loading, your theme has been reverted to the default theme");
         echo '</strong>';
     }
     #foreach (array('template', 'stylesheet', 'template_root', 'stylesheet_root') as $opt) {
     #	remove_filter('pre_option_'.$opt, array($this, 'option_filter_'.$opt));
     #}
     echo '</div>';
     //close the updraft_restore_progress div
     restore_error_handler();
     return true;
 }
Пример #10
0
function wp_united_display_theme_menu()
{
    global $user_ID, $title, $parent_file, $wp_version;
    $wpuConnSettings = get_settings('wputd_connection');
    if (!validate_current_theme()) {
        ?>
	<div id="message1" class="updated fade"><p><?php 
        _e('The active theme is broken.  Reverting to the default theme.');
        ?>
</p></div>
	<?php 
    } elseif (isset($_GET['activated'])) {
        ?>
	<div id="message2" class="updated fade"><p><?php 
        printf(__('New theme activated. <a href="%s">View your blog &raquo;</a>'), wpu_homelink('wpu-activate-theme') . '/');
        ?>
</p></div>
	<?php 
    }
    $themes = get_themes();
    $theme_names = array_keys($themes);
    $user_theme = 'WordPress Default';
    $user_template = get_usermeta($user_ID, 'WPU_MyTemplate');
    $user_stylesheet = get_usermeta($user_ID, 'WPU_MyStylesheet');
    $site_theme = current_theme_info();
    $user_theme = $site_theme->title;
    // if user hasn't set a theme yet, it is the same as site default
    // get current user theme
    if ($themes) {
        foreach ($theme_names as $theme_name) {
            if ($themes[$theme_name]['Stylesheet'] == $user_stylesheet && $themes[$theme_name]['Template'] == $user_template) {
                $user_theme = $themes[$theme_name]['Name'];
                break;
            }
        }
    }
    $template = $themes[$user_theme]['Template'];
    $stylesheet = $themes[$user_theme]['Stylesheet'];
    $title = $themes[$user_theme]['Title'];
    $version = $themes[$user_theme]['Version'];
    $description = $themes[$user_theme]['Description'];
    $author = $themes[$user_theme]['Author'];
    $screenshot = $themes[$user_theme]['Screenshot'];
    $stylesheet_dir = $themes[$user_theme]['Stylesheet Dir'];
    $tags = $themes[$user_theme]['Tags'];
    if ($wp_version > 2.5) {
        // paginate if necessary
        ksort($themes);
        $theme_total = count($themes);
        $per_page = 15;
        if (isset($_GET['pagenum'])) {
            $page = absint($_GET['pagenum']);
        }
        if (empty($page)) {
            $page = 1;
        }
        $start = $offset = ($page - 1) * $per_page;
        $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%') . '#themenav', 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => ceil($theme_total / $per_page), 'current' => $page));
        $themes = array_slice($themes, $start, $per_page);
        $pageTitle = __('Set Your Blog Theme');
        $parent_file = 'wpu-plugin.php&wputab=themes';
        ?>
		
		<div class="wrap">
			<?php 
        screen_icon();
        ?>
			<h2><?php 
        echo wp_specialchars($pageTitle);
        ?>
</h2>
		<?php 
        /* CURRENT THEME */
        ?>
			<h3><?php 
        _e('Current Theme');
        ?>
</h3>
			<div id="current-theme">
				<?php 
        if ($screenshot) {
            ?>
				<img src="<?php 
            echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot;
            ?>
" alt="<?php 
            _e('Current theme preview');
            ?>
" />
				<?php 
        }
        ?>
				<h4><?php 
        printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $title, $version, $author);
        ?>
</h4>
				<p class="description"><?php 
        echo $description;
        ?>
</p>
				<?php 
        if ($tags) {
            ?>
					<p><?php 
            _e('Tags:');
            ?>
 <?php 
            echo join(', ', $tags);
            ?>
</p>
				<?php 
        }
        ?>
			</div>
			
			<div class="clear"></div>
			<h3><?php 
        _e('Available Themes');
        ?>
</h3>
			<div class="clear"></div>
			
			<?php 
        /* PAGINATION */
        ?>
			<?php 
        if ($page_links) {
            ?>
			<div class="tablenav">
			<div class="tablenav-pages"><?php 
            $page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n($start + 1), number_format_i18n(min($page * $per_page, $theme_total)), number_format_i18n($theme_total), $page_links);
            echo $page_links_text;
            ?>
</div>
			</div>
			<?php 
        }
        ?>
		
		
			<?php 
        /* OTHER THEMES */
        ?>
			
			<?php 
        if (1 < $theme_total) {
            ?>
			<table id="availablethemes" cellspacing="0" cellpadding="0">
			<?php 
            $style = '';
            $theme_names = array_keys($themes);
            natcasesort($theme_names);
            $rows = ceil(count($theme_names) / 3);
            for ($row = 1; $row <= $rows; $row++) {
                for ($col = 1; $col <= 3; $col++) {
                    $table[$row][$col] = array_shift($theme_names);
                }
            }
            foreach ($table as $row => $cols) {
                ?>
			<tr>
			<?php 
                foreach ($cols as $col => $theme_name) {
                    if ($theme_name != $user_theme) {
                        $class = array('available-theme');
                        if ($row == 1) {
                            $class[] = 'top';
                        }
                        if ($col == 1) {
                            $class[] = 'left';
                        }
                        if ($row == $rows) {
                            $class[] = 'bottom';
                        }
                        if ($col == 3) {
                            $class[] = 'right';
                        }
                        ?>
					<td class="<?php 
                        echo join(' ', $class);
                        ?>
">
					<?php 
                        if (!empty($theme_name)) {
                            $template = $themes[$theme_name]['Template'];
                            $stylesheet = $themes[$theme_name]['Stylesheet'];
                            $title = $themes[$theme_name]['Title'];
                            $version = $themes[$theme_name]['Version'];
                            $description = $themes[$theme_name]['Description'];
                            $author = $themes[$theme_name]['Author'];
                            $screenshot = $themes[$theme_name]['Screenshot'];
                            $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
                            $preview_link = clean_url(get_option('home') . '/');
                            $preview_link = htmlspecialchars(add_query_arg(array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400), $preview_link));
                            $preview_text = attribute_escape(sprintf(__('Preview of "%s"'), $title));
                            $tags = $themes[$theme_name]['Tags'];
                            $thickbox_class = 'thickbox';
                            $activate_link = wp_nonce_url('admin.php?page=wpu-plugin.php&amp;wputab=themes&amp;noheader=true&amp;wpu_action=activate&amp;template=' . $template . '&amp;stylesheet=' . $stylesheet, 'wp-united-switch-theme_' . $template);
                            $activate_text = attribute_escape(sprintf(__('Activate "%s"'), $title));
                            ?>
						<?php 
                            if ($screenshot) {
                                ?>
							<a href="<?php 
                                echo $preview_link;
                                ?>
" title="<?php 
                                echo $preview_text;
                                ?>
" class="<?php 
                                echo $thickbox_class;
                                ?>
 screenshot">
								<img src="<?php 
                                echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot;
                                ?>
" alt="" />
							</a>
						<?php 
                            }
                            ?>
						<h3><a class="<?php 
                            echo $thickbox_class;
                            ?>
" href="<?php 
                            echo $activate_link;
                            ?>
"><?php 
                            echo $title;
                            ?>
</a></h3>
						<p><?php 
                            echo $description;
                            ?>
</p>
						<?php 
                            if ($tags) {
                                ?>
							<p><?php 
                                _e('Tags:');
                                ?>
 <?php 
                                echo join(', ', $tags);
                                ?>
</p>
						<?php 
                            }
                            ?>
						<span class="action-links"><a href="<?php 
                            echo $preview_link;
                            ?>
" class="<?php 
                            echo $thickbox_class;
                            ?>
" title="<?php 
                            echo $preview_text;
                            ?>
"><?php 
                            _e('Preview');
                            ?>
</a> <a href="<?php 
                            echo $activate_link;
                            ?>
" title="<?php 
                            echo $activate_text;
                            ?>
"><?php 
                            _e('Activate');
                            ?>
</a></span>
	
					<?php 
                        }
                    }
                    ?>
				</td>
			<?php 
                }
                // end foreach $cols
                ?>
			</tr>
			<?php 
            }
            // end foreach $table
            ?>
			</table>
		<?php 
        }
        ?>

		<br class="clear" />

		<?php 
        if ($page_links) {
            ?>
			<div class="tablenav">
			<?php 
            echo "<div class='tablenav-pages'>{$page_links_text}</div>";
            ?>
			<br class="clear" />
			</div>
		<?php 
        }
        ?>
		<br class="clear" />
	</div>
			
			
<?php 
    } else {
        // old WordPress (temporary -- to remove in WP-United v0.8)
        ?>
		<div class="wrap">
		<h2><?php 
        _e('Your Current Theme');
        ?>
</h2>
		<div id="currenttheme" style="margin-bottom: 190px;" >
		<?php 
        if ($screenshot) {
            ?>
		<img src="<?php 
            echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot;
            ?>
" alt="<?php 
            _e('Current theme preview');
            ?>
" />
		<?php 
        }
        ?>
		<h3><?php 
        printf(__('%1$s %2$s by %3$s'), $title, $version, $author);
        ?>
</h3>
		<p><?php 
        echo $description;
        ?>
</p>

		</div>

		<h2><?php 
        _e('Available Themes');
        ?>
</h2>
		<?php 
        if (1 < count($themes)) {
            ?>

		<?php 
            $style = '';
            $theme_names = array_keys($themes);
            natcasesort($theme_names);
            foreach ($theme_names as $theme_name) {
                if ($theme_name == $user_theme) {
                    continue;
                }
                $template = $themes[$theme_name]['Template'];
                $stylesheet = $themes[$theme_name]['Stylesheet'];
                $title = $themes[$theme_name]['Title'];
                $version = $themes[$theme_name]['Version'];
                $description = $themes[$theme_name]['Description'];
                $author = $themes[$theme_name]['Author'];
                $screenshot = $themes[$theme_name]['Screenshot'];
                $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
                $activate_link = wp_nonce_url('admin.php?page=' . $wpuConnSettings['full_path_to_plugin'] . '&amp;noheader=true&amp;wpu_action=activate&amp;template=' . $template . '&amp;stylesheet=' . $stylesheet, 'wp-united-switch-theme_' . $template);
                ?>
		<div class="available-theme">
		<h3><a href="<?php 
                echo $activate_link;
                ?>
"><?php 
                echo "{$title} {$version}";
                ?>
</a></h3>

		<a href="<?php 
                echo $activate_link;
                ?>
" class="screenshot">
		<?php 
                if ($screenshot) {
                    ?>
		<img src="<?php 
                    echo get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot;
                    ?>
" alt="" />
		<?php 
                }
                ?>
		</a>

		<p><?php 
                echo $description;
                ?>
</p>
		</div>
		<?php 
            }
            // end foreach theme_names
            ?>

		<?php 
        }
        ?>

	

		<h2><?php 
        _e('Want More Themes?');
        ?>
</h2>
		<p><?php 
        _e('If you have found another WordPress theme that you would like to use, please inform an administrator.');
        ?>
</p>

		</div>
	<?php 
    }
}