raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Themes administration panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 if ( isset($_GET['action']) ) {
mp-wp_genesis 13 check_admin_referer('switch-theme_' . $_GET['template']);
mp-wp_genesis 14
mp-wp_genesis 15 if ('activate' == $_GET['action']) {
mp-wp_genesis 16 switch_theme($_GET['template'], $_GET['stylesheet']);
mp-wp_genesis 17 wp_redirect('themes.php?activated=true');
mp-wp_genesis 18 exit;
mp-wp_genesis 19 }
mp-wp_genesis 20 }
mp-wp_genesis 21
mp-wp_genesis 22 $title = __('Manage Themes');
mp-wp_genesis 23 $parent_file = 'themes.php';
mp-wp_genesis 24
mp-wp_genesis 25 add_thickbox();
mp-wp_genesis 26 wp_enqueue_script( 'theme-preview' );
mp-wp_genesis 27
mp-wp_genesis 28 require_once('admin-header.php');
mp-wp_genesis 29 ?>
mp-wp_genesis 30
mp-wp_genesis 31 <?php if ( ! validate_current_theme() ) : ?>
mp-wp_genesis 32 <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
mp-wp_genesis 33 <?php elseif ( isset($_GET['activated']) ) : ?>
mp-wp_genesis 34 <div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">Visit site</a>'), get_bloginfo('url') . '/'); ?></p></div>
mp-wp_genesis 35 <?php endif; ?>
mp-wp_genesis 36
mp-wp_genesis 37 <?php
mp-wp_genesis 38 $themes = get_themes();
mp-wp_genesis 39 $ct = current_theme_info();
mp-wp_genesis 40
mp-wp_genesis 41 ksort( $themes );
mp-wp_genesis 42 $theme_total = count( $themes );
mp-wp_genesis 43 $per_page = 15;
mp-wp_genesis 44
mp-wp_genesis 45 if ( isset( $_GET['pagenum'] ) )
mp-wp_genesis 46 $page = absint( $_GET['pagenum'] );
mp-wp_genesis 47
mp-wp_genesis 48 if ( empty($page) )
mp-wp_genesis 49 $page = 1;
mp-wp_genesis 50
mp-wp_genesis 51 $start = $offset = ( $page - 1 ) * $per_page;
mp-wp_genesis 52
mp-wp_genesis 53 $page_links = paginate_links( array(
mp-wp_genesis 54 'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav',
mp-wp_genesis 55 'format' => '',
mp-wp_genesis 56 'prev_text' => __('&laquo;'),
mp-wp_genesis 57 'next_text' => __('&raquo;'),
mp-wp_genesis 58 'total' => ceil($theme_total / $per_page),
mp-wp_genesis 59 'current' => $page
mp-wp_genesis 60 ));
mp-wp_genesis 61
mp-wp_genesis 62 $themes = array_slice( $themes, $start, $per_page );
mp-wp_genesis 63
mp-wp_genesis 64 /**
mp-wp_genesis 65 * Check if there is an update for a theme available.
mp-wp_genesis 66 *
mp-wp_genesis 67 * Will display link, if there is an update available.
mp-wp_genesis 68 *
mp-wp_genesis 69 * @since 2.7.0
mp-wp_genesis 70 *
mp-wp_genesis 71 * @param object $theme Theme data object.
mp-wp_genesis 72 * @return bool False if no valid info was passed.
mp-wp_genesis 73 */
mp-wp_genesis 74 function theme_update_available( $theme ) {
mp-wp_genesis 75 static $themes_update;
mp-wp_genesis 76 if ( !isset($themes_update) )
mp-wp_genesis 77 $themes_update = get_option('update_themes');
mp-wp_genesis 78
mp-wp_genesis 79 if ( is_object($theme) && isset($theme->stylesheet) )
mp-wp_genesis 80 $stylesheet = $theme->stylesheet;
mp-wp_genesis 81 elseif ( is_array($theme) && isset($theme['Stylesheet']) )
mp-wp_genesis 82 $stylesheet = $theme['Stylesheet'];
mp-wp_genesis 83 else
mp-wp_genesis 84 return false; //No valid info passed.
mp-wp_genesis 85
mp-wp_genesis 86 if ( isset($themes_update->response[ $stylesheet ]) ) {
mp-wp_genesis 87 $update = $themes_update->response[ $stylesheet ];
mp-wp_genesis 88 $details_url = add_query_arg(array('TB_iframe' => 'true', 'width' => 1024, 'height' => 800), $update['url']); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list.
mp-wp_genesis 89 $update_url = wp_nonce_url('update.php?action=upgrade-theme&amp;theme=' . urlencode($stylesheet), 'upgrade-theme_' . $stylesheet);
mp-wp_genesis 90
mp-wp_genesis 91 if ( ! current_user_can('update_themes') )
mp-wp_genesis 92 printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a>.</p>'), $ct->name, $details_url, $update['new_version']);
mp-wp_genesis 93 else if ( empty($update->package) )
mp-wp_genesis 94 printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> <em>automatic upgrade unavailable for this theme</em>.</p>'), $ct->name, $details_url, $update['new_version']);
mp-wp_genesis 95 else
mp-wp_genesis 96 printf( __('<p>There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%1$s">View version %3$s Details</a> or <a href="%4$s">upgrade automatically</a>.</p>'), $ct->name, $details_url, $update['new_version'], $update_url );
mp-wp_genesis 97 }
mp-wp_genesis 98 }
mp-wp_genesis 99
mp-wp_genesis 100 ?>
mp-wp_genesis 101
mp-wp_genesis 102 <div class="wrap">
mp-wp_genesis 103 <?php screen_icon(); ?>
mp-wp_genesis 104 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 105
mp-wp_genesis 106 <h3><?php _e('Current Theme'); ?></h3>
mp-wp_genesis 107 <div id="current-theme">
mp-wp_genesis 108 <?php if ( $ct->screenshot ) : ?>
mp-wp_genesis 109 <img src="<?php echo WP_CONTENT_URL . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
mp-wp_genesis 110 <?php endif; ?>
mp-wp_genesis 111 <h4><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h4>
mp-wp_genesis 112 <p class="description"><?php echo $ct->description; ?></p>
mp-wp_genesis 113 <?php if ($ct->parent_theme) { ?>
mp-wp_genesis 114 <p><?php printf(__('The template files are located in <code>%2$s</code>. The stylesheet files are located in <code>%3$s</code>. <strong>%4$s</strong> uses templates from <strong>%5$s</strong>. Changes made to the templates will affect both themes.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir, $ct->title, $ct->parent_theme); ?></p>
mp-wp_genesis 115 <?php } else { ?>
mp-wp_genesis 116 <p><?php printf(__('All of this theme&#8217;s files are located in <code>%2$s</code>.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir); ?></p>
mp-wp_genesis 117 <?php } ?>
mp-wp_genesis 118 <?php if ( $ct->tags ) : ?>
mp-wp_genesis 119 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
mp-wp_genesis 120 <?php endif; ?>
mp-wp_genesis 121 <?php theme_update_available($ct); ?>
mp-wp_genesis 122
mp-wp_genesis 123 </div>
mp-wp_genesis 124 <div class="clear"></div>
mp-wp_genesis 125 <h3><?php _e('Available Themes'); ?></h3>
mp-wp_genesis 126 <div class="clear"></div>
mp-wp_genesis 127
mp-wp_genesis 128 <?php if ( $page_links ) : ?>
mp-wp_genesis 129 <div class="tablenav">
mp-wp_genesis 130 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
mp-wp_genesis 131 number_format_i18n( $start + 1 ),
mp-wp_genesis 132 number_format_i18n( min( $page * $per_page, $theme_total ) ),
mp-wp_genesis 133 number_format_i18n( $theme_total ),
mp-wp_genesis 134 $page_links
mp-wp_genesis 135 ); echo $page_links_text; ?></div>
mp-wp_genesis 136 </div>
mp-wp_genesis 137 <?php endif; ?>
mp-wp_genesis 138
mp-wp_genesis 139 <?php if ( 1 < $theme_total ) { ?>
mp-wp_genesis 140 <table id="availablethemes" cellspacing="0" cellpadding="0">
mp-wp_genesis 141 <?php
mp-wp_genesis 142 $style = '';
mp-wp_genesis 143
mp-wp_genesis 144 $theme_names = array_keys($themes);
mp-wp_genesis 145 natcasesort($theme_names);
mp-wp_genesis 146
mp-wp_genesis 147 $rows = ceil(count($theme_names) / 3);
mp-wp_genesis 148 for ( $row = 1; $row <= $rows; $row++ )
mp-wp_genesis 149 for ( $col = 1; $col <= 3; $col++ )
mp-wp_genesis 150 $table[$row][$col] = array_shift($theme_names);
mp-wp_genesis 151
mp-wp_genesis 152 foreach ( $table as $row => $cols ) {
mp-wp_genesis 153 ?>
mp-wp_genesis 154 <tr>
mp-wp_genesis 155 <?php
mp-wp_genesis 156 foreach ( $cols as $col => $theme_name ) {
mp-wp_genesis 157 $class = array('available-theme');
mp-wp_genesis 158 if ( $row == 1 ) $class[] = 'top';
mp-wp_genesis 159 if ( $col == 1 ) $class[] = 'left';
mp-wp_genesis 160 if ( $row == $rows ) $class[] = 'bottom';
mp-wp_genesis 161 if ( $col == 3 ) $class[] = 'right';
mp-wp_genesis 162 ?>
mp-wp_genesis 163 <td class="<?php echo join(' ', $class); ?>">
mp-wp_genesis 164 <?php if ( !empty($theme_name) ) :
mp-wp_genesis 165 $template = $themes[$theme_name]['Template'];
mp-wp_genesis 166 $stylesheet = $themes[$theme_name]['Stylesheet'];
mp-wp_genesis 167 $title = $themes[$theme_name]['Title'];
mp-wp_genesis 168 $version = $themes[$theme_name]['Version'];
mp-wp_genesis 169 $description = $themes[$theme_name]['Description'];
mp-wp_genesis 170 $author = $themes[$theme_name]['Author'];
mp-wp_genesis 171 $screenshot = $themes[$theme_name]['Screenshot'];
mp-wp_genesis 172 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
mp-wp_genesis 173 $preview_link = clean_url( get_option('home') . '/');
mp-wp_genesis 174 $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true', 'width' => 600, 'height' => 400 ), $preview_link ) );
mp-wp_genesis 175 $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
mp-wp_genesis 176 $tags = $themes[$theme_name]['Tags'];
mp-wp_genesis 177 $thickbox_class = 'thickbox';
mp-wp_genesis 178 $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=".urlencode($template)."&amp;stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
mp-wp_genesis 179 $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) );
mp-wp_genesis 180 ?>
mp-wp_genesis 181 <a href="<?php echo $activate_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
mp-wp_genesis 182 <?php if ( $screenshot ) : ?>
mp-wp_genesis 183 <img src="<?php echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
mp-wp_genesis 184 <?php endif; ?>
mp-wp_genesis 185 </a>
mp-wp_genesis 186 <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
mp-wp_genesis 187 <p><?php echo $description; ?></p>
mp-wp_genesis 188 <?php if ( $tags ) : ?>
mp-wp_genesis 189 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
mp-wp_genesis 190 <?php endif; ?>
mp-wp_genesis 191 <?php theme_update_available( $themes[$theme_name] ); ?>
mp-wp_genesis 192 <noscript><p class="themeactions"><a href="<?php echo $preview_link; ?>" title="<?php echo $preview_text; ?>"><?php _e('Preview'); ?></a> <a href="<?php echo $activate_link; ?>" title="<?php echo $activate_text; ?>"><?php _e('Activate'); ?></a></p></noscript>
mp-wp_genesis 193 <div style="display:none;"><a class="previewlink" href="<?php echo $preview_link; ?>"><?php echo $preview_text; ?></a> <a class="activatelink" href="<?php echo $activate_link; ?>"><?php echo $activate_text; ?></a></div>
mp-wp_genesis 194 <?php endif; // end if not empty theme_name ?>
mp-wp_genesis 195 </td>
mp-wp_genesis 196 <?php } // end foreach $cols ?>
mp-wp_genesis 197 </tr>
mp-wp_genesis 198 <?php } // end foreach $table ?>
mp-wp_genesis 199 </table>
mp-wp_genesis 200 <?php } ?>
mp-wp_genesis 201
mp-wp_genesis 202 <br class="clear" />
mp-wp_genesis 203
mp-wp_genesis 204 <?php if ( $page_links ) : ?>
mp-wp_genesis 205 <div class="tablenav">
mp-wp_genesis 206 <?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?>
mp-wp_genesis 207 <br class="clear" />
mp-wp_genesis 208 </div>
mp-wp_genesis 209 <?php endif; ?>
mp-wp_genesis 210
mp-wp_genesis 211 <br class="clear" />
mp-wp_genesis 212
mp-wp_genesis 213 <?php
mp-wp_genesis 214 // List broken themes, if any.
mp-wp_genesis 215 $broken_themes = get_broken_themes();
mp-wp_genesis 216 if ( count($broken_themes) ) {
mp-wp_genesis 217 ?>
mp-wp_genesis 218
mp-wp_genesis 219 <h2><?php _e('Broken Themes'); ?></h2>
mp-wp_genesis 220 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
mp-wp_genesis 221
mp-wp_genesis 222 <table width="100%" cellpadding="3" cellspacing="3">
mp-wp_genesis 223 <tr>
mp-wp_genesis 224 <th><?php _e('Name'); ?></th>
mp-wp_genesis 225 <th><?php _e('Description'); ?></th>
mp-wp_genesis 226 </tr>
mp-wp_genesis 227 <?php
mp-wp_genesis 228 $theme = '';
mp-wp_genesis 229
mp-wp_genesis 230 $theme_names = array_keys($broken_themes);
mp-wp_genesis 231 natcasesort($theme_names);
mp-wp_genesis 232
mp-wp_genesis 233 foreach ($theme_names as $theme_name) {
mp-wp_genesis 234 $title = $broken_themes[$theme_name]['Title'];
mp-wp_genesis 235 $description = $broken_themes[$theme_name]['Description'];
mp-wp_genesis 236
mp-wp_genesis 237 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
mp-wp_genesis 238 echo "
mp-wp_genesis 239 <tr $theme>
mp-wp_genesis 240 <td>$title</td>
mp-wp_genesis 241 <td>$description</td>
mp-wp_genesis 242 </tr>";
mp-wp_genesis 243 }
mp-wp_genesis 244 ?>
mp-wp_genesis 245 </table>
mp-wp_genesis 246 <?php
mp-wp_genesis 247 }
mp-wp_genesis 248 ?>
mp-wp_genesis 249
mp-wp_genesis 250 <h2><?php _e('Get More Themes'); ?></h2>
mp-wp_genesis 251 <p><?php _e('You can find additional themes for your site in the <a href="http://wordpress.org/extend/themes/">WordPress theme directory</a>. To install a theme you generally just need to upload the theme folder into your <code>wp-content/themes</code> directory. Once a theme is uploaded, you should see it on this page.'); ?></p>
mp-wp_genesis 252
mp-wp_genesis 253 </div>
mp-wp_genesis 254
mp-wp_genesis 255 <?php require('admin-footer.php'); ?>