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' => __('«'),
mp-wp_genesis 57 'next_text' => __('»'),
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
mp-wp_genesis 66 <div class="wrap">
mp-wp_genesis 67 <?php screen_icon(); ?>
mp-wp_genesis 68 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 69
mp-wp_genesis 70 <h3><?php _e('Current Theme'); ?></h3>
mp-wp_genesis 71 <div id="current-theme">
mp-wp_genesis 72 <?php if ( $ct->screenshot ) : ?>
mp-wp_genesis 73 <img src="<?php echo WP_CONTENT_URL . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
mp-wp_genesis 74 <?php endif; ?>
mp-wp_genesis 75 <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 76 <p class="description"><?php echo $ct->description; ?></p>
mp-wp_genesis 77 <?php if ($ct->parent_theme) { ?>
mp-wp_genesis 78 <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 79 <?php } else { ?>
mp-wp_genesis 80 <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $ct->title, $ct->template_dir, $ct->stylesheet_dir); ?></p>
mp-wp_genesis 81 <?php } ?>
mp-wp_genesis 82 <?php if ( $ct->tags ) : ?>
mp-wp_genesis 83 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
mp-wp_genesis 84 <?php endif; ?>
mp-wp_genesis 85
mp-wp_genesis 86 </div>
mp-wp_genesis 87 <div class="clear"></div>
mp-wp_genesis 88 <h3><?php _e('Available Themes'); ?></h3>
mp-wp_genesis 89 <div class="clear"></div>
mp-wp_genesis 90
mp-wp_genesis 91 <?php if ( $page_links ) : ?>
mp-wp_genesis 92 <div class="tablenav">
mp-wp_genesis 93 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
mp-wp_genesis 94 number_format_i18n( $start + 1 ),
mp-wp_genesis 95 number_format_i18n( min( $page * $per_page, $theme_total ) ),
mp-wp_genesis 96 number_format_i18n( $theme_total ),
mp-wp_genesis 97 $page_links
mp-wp_genesis 98 ); echo $page_links_text; ?></div>
mp-wp_genesis 99 </div>
mp-wp_genesis 100 <?php endif; ?>
mp-wp_genesis 101
mp-wp_genesis 102 <?php if ( 1 < $theme_total ) { ?>
mp-wp_genesis 103 <table id="availablethemes" cellspacing="0" cellpadding="0">
mp-wp_genesis 104 <?php
mp-wp_genesis 105 $style = '';
mp-wp_genesis 106
mp-wp_genesis 107 $theme_names = array_keys($themes);
mp-wp_genesis 108 natcasesort($theme_names);
mp-wp_genesis 109
mp-wp_genesis 110 $rows = ceil(count($theme_names) / 3);
mp-wp_genesis 111 for ( $row = 1; $row <= $rows; $row++ )
mp-wp_genesis 112 for ( $col = 1; $col <= 3; $col++ )
mp-wp_genesis 113 $table[$row][$col] = array_shift($theme_names);
mp-wp_genesis 114
mp-wp_genesis 115 foreach ( $table as $row => $cols ) {
mp-wp_genesis 116 ?>
mp-wp_genesis 117 <tr>
mp-wp_genesis 118 <?php
mp-wp_genesis 119 foreach ( $cols as $col => $theme_name ) {
mp-wp_genesis 120 $class = array('available-theme');
mp-wp_genesis 121 if ( $row == 1 ) $class[] = 'top';
mp-wp_genesis 122 if ( $col == 1 ) $class[] = 'left';
mp-wp_genesis 123 if ( $row == $rows ) $class[] = 'bottom';
mp-wp_genesis 124 if ( $col == 3 ) $class[] = 'right';
mp-wp_genesis 125 ?>
mp-wp_genesis 126 <td class="<?php echo join(' ', $class); ?>">
mp-wp_genesis 127 <?php if ( !empty($theme_name) ) :
mp-wp_genesis 128 $template = $themes[$theme_name]['Template'];
mp-wp_genesis 129 $stylesheet = $themes[$theme_name]['Stylesheet'];
mp-wp_genesis 130 $title = $themes[$theme_name]['Title'];
mp-wp_genesis 131 $version = $themes[$theme_name]['Version'];
mp-wp_genesis 132 $description = $themes[$theme_name]['Description'];
mp-wp_genesis 133 $author = $themes[$theme_name]['Author'];
mp-wp_genesis 134 $screenshot = $themes[$theme_name]['Screenshot'];
mp-wp_genesis 135 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
mp-wp_genesis 136 $preview_link = clean_url( get_option('home') . '/');
mp-wp_genesis 137 $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 138 $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
mp-wp_genesis 139 $tags = $themes[$theme_name]['Tags'];
mp-wp_genesis 140 $thickbox_class = 'thickbox';
mp-wp_genesis 141 $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
mp-wp_genesis 142 $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) );
mp-wp_genesis 143 ?>
mp-wp_genesis 144 <a href="<?php echo $activate_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
mp-wp_genesis 145 <?php if ( $screenshot ) : ?>
mp-wp_genesis 146 <img src="<?php echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
mp-wp_genesis 147 <?php endif; ?>
mp-wp_genesis 148 </a>
mp-wp_genesis 149 <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
mp-wp_genesis 150 <p><?php echo $description; ?></p>
mp-wp_genesis 151 <?php if ( $tags ) : ?>
mp-wp_genesis 152 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
mp-wp_genesis 153 <?php endif; ?>
mp-wp_genesis 154 <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 155 <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 156 <?php endif; // end if not empty theme_name ?>
mp-wp_genesis 157 </td>
mp-wp_genesis 158 <?php } // end foreach $cols ?>
mp-wp_genesis 159 </tr>
mp-wp_genesis 160 <?php } // end foreach $table ?>
mp-wp_genesis 161 </table>
mp-wp_genesis 162 <?php } ?>
mp-wp_genesis 163
mp-wp_genesis 164 <br class="clear" />
mp-wp_genesis 165
mp-wp_genesis 166 <?php if ( $page_links ) : ?>
mp-wp_genesis 167 <div class="tablenav">
mp-wp_genesis 168 <?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?>
mp-wp_genesis 169 <br class="clear" />
mp-wp_genesis 170 </div>
mp-wp_genesis 171 <?php endif; ?>
mp-wp_genesis 172
mp-wp_genesis 173 <br class="clear" />
mp-wp_genesis 174
mp-wp_genesis 175 <?php
mp-wp_genesis 176 // List broken themes, if any.
mp-wp_genesis 177 $broken_themes = get_broken_themes();
mp-wp_genesis 178 if ( count($broken_themes) ) {
mp-wp_genesis 179 ?>
mp-wp_genesis 180
mp-wp_genesis 181 <h2><?php _e('Broken Themes'); ?></h2>
mp-wp_genesis 182 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
mp-wp_genesis 183
mp-wp_genesis 184 <table width="100%" cellpadding="3" cellspacing="3">
mp-wp_genesis 185 <tr>
mp-wp_genesis 186 <th><?php _e('Name'); ?></th>
mp-wp_genesis 187 <th><?php _e('Description'); ?></th>
mp-wp_genesis 188 </tr>
mp-wp_genesis 189 <?php
mp-wp_genesis 190 $theme = '';
mp-wp_genesis 191
mp-wp_genesis 192 $theme_names = array_keys($broken_themes);
mp-wp_genesis 193 natcasesort($theme_names);
mp-wp_genesis 194
mp-wp_genesis 195 foreach ($theme_names as $theme_name) {
mp-wp_genesis 196 $title = $broken_themes[$theme_name]['Title'];
mp-wp_genesis 197 $description = $broken_themes[$theme_name]['Description'];
mp-wp_genesis 198
mp-wp_genesis 199 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
mp-wp_genesis 200 echo "
mp-wp_genesis 201 <tr $theme>
mp-wp_genesis 202 <td>$title</td>
mp-wp_genesis 203 <td>$description</td>
mp-wp_genesis 204 </tr>";
mp-wp_genesis 205 }
mp-wp_genesis 206 ?>
mp-wp_genesis 207 </table>
mp-wp_genesis 208 <?php
mp-wp_genesis 209 }
mp-wp_genesis 210 ?>
mp-wp_genesis 211
mp-wp_genesis 212 <h2><?php _e('Get More Themes'); ?></h2>
mp-wp_genesis 213 <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 214
mp-wp_genesis 215 </div>
mp-wp_genesis 216
mp-wp_genesis 217 <?php require('admin-footer.php'); ?>