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 require_once('admin-header.php');
mp-wp_genesis 26 ?>
mp-wp_genesis 27
mp-wp_genesis 28 <?php if ( ! validate_current_theme() ) : ?>
mp-wp_genesis 29 <div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
mp-wp_genesis 30 <?php elseif ( isset($_GET['activated']) ) : ?>
mp-wp_genesis 31 <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 32 <?php endif; ?>
mp-wp_genesis 33
mp-wp_genesis 34 <?php
mp-wp_genesis 35 $themes = get_themes();
mp-wp_genesis 36 $ct = current_theme_info();
mp-wp_genesis 37
mp-wp_genesis 38 ksort( $themes );
mp-wp_genesis 39 $theme_total = count( $themes );
mp-wp_genesis 40 $per_page = 15;
mp-wp_genesis 41
mp-wp_genesis 42 if ( isset( $_GET['pagenum'] ) )
mp-wp_genesis 43 $page = absint( $_GET['pagenum'] );
mp-wp_genesis 44
mp-wp_genesis 45 if ( empty($page) )
mp-wp_genesis 46 $page = 1;
mp-wp_genesis 47
mp-wp_genesis 48 $start = $offset = ( $page - 1 ) * $per_page;
mp-wp_genesis 49
mp-wp_genesis 50 $page_links = paginate_links( array(
mp-wp_genesis 51 'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav',
mp-wp_genesis 52 'format' => '',
mp-wp_genesis 53 'prev_text' => __('&laquo;'),
mp-wp_genesis 54 'next_text' => __('&raquo;'),
mp-wp_genesis 55 'total' => ceil($theme_total / $per_page),
mp-wp_genesis 56 'current' => $page
mp-wp_genesis 57 ));
mp-wp_genesis 58
mp-wp_genesis 59 $themes = array_slice( $themes, $start, $per_page );
mp-wp_genesis 60
mp-wp_genesis 61 ?>
mp-wp_genesis 62
mp-wp_genesis 63 <div class="wrap">
mp-wp_genesis 64 <?php screen_icon(); ?>
mp-wp_genesis 65 <h2><?php echo wp_specialchars( $title ); ?></h2>
mp-wp_genesis 66
mp-wp_genesis 67 <h3><?php _e('Current Theme'); ?></h3>
mp-wp_genesis 68 <div id="current-theme">
mp-wp_genesis 69 <?php if ( $ct->screenshot ) : ?>
mp-wp_genesis 70 <img src="<?php echo WP_CONTENT_URL . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
mp-wp_genesis 71 <?php endif; ?>
mp-wp_genesis 72 <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 73 <p class="description"><?php echo $ct->description; ?></p>
mp-wp_genesis 74 <?php if ($ct->parent_theme) { ?>
mp-wp_genesis 75 <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 76 <?php } else { ?>
mp-wp_genesis 77 <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 78 <?php } ?>
mp-wp_genesis 79 <?php if ( $ct->tags ) : ?>
mp-wp_genesis 80 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p>
mp-wp_genesis 81 <?php endif; ?>
mp-wp_genesis 82
mp-wp_genesis 83 </div>
mp-wp_genesis 84 <div class="clear"></div>
mp-wp_genesis 85 <h3><?php _e('Available Themes'); ?></h3>
mp-wp_genesis 86 <div class="clear"></div>
mp-wp_genesis 87
mp-wp_genesis 88 <?php if ( $page_links ) : ?>
mp-wp_genesis 89 <div class="tablenav">
mp-wp_genesis 90 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
mp-wp_genesis 91 number_format_i18n( $start + 1 ),
mp-wp_genesis 92 number_format_i18n( min( $page * $per_page, $theme_total ) ),
mp-wp_genesis 93 number_format_i18n( $theme_total ),
mp-wp_genesis 94 $page_links
mp-wp_genesis 95 ); echo $page_links_text; ?></div>
mp-wp_genesis 96 </div>
mp-wp_genesis 97 <?php endif; ?>
mp-wp_genesis 98
mp-wp_genesis 99 <?php if ( 1 < $theme_total ) { ?>
mp-wp_genesis 100 <table id="availablethemes" cellspacing="0" cellpadding="0">
mp-wp_genesis 101 <?php
mp-wp_genesis 102 $style = '';
mp-wp_genesis 103
mp-wp_genesis 104 $theme_names = array_keys($themes);
mp-wp_genesis 105 natcasesort($theme_names);
mp-wp_genesis 106
mp-wp_genesis 107 $rows = ceil(count($theme_names) / 3);
mp-wp_genesis 108 for ( $row = 1; $row <= $rows; $row++ )
mp-wp_genesis 109 for ( $col = 1; $col <= 3; $col++ )
mp-wp_genesis 110 $table[$row][$col] = array_shift($theme_names);
mp-wp_genesis 111
mp-wp_genesis 112 foreach ( $table as $row => $cols ) {
mp-wp_genesis 113 ?>
mp-wp_genesis 114 <tr>
mp-wp_genesis 115 <?php
mp-wp_genesis 116 foreach ( $cols as $col => $theme_name ) {
mp-wp_genesis 117 $class = array('available-theme');
mp-wp_genesis 118 if ( $row == 1 ) $class[] = 'top';
mp-wp_genesis 119 if ( $col == 1 ) $class[] = 'left';
mp-wp_genesis 120 if ( $row == $rows ) $class[] = 'bottom';
mp-wp_genesis 121 if ( $col == 3 ) $class[] = 'right';
mp-wp_genesis 122 ?>
mp-wp_genesis 123 <td class="<?php echo join(' ', $class); ?>">
mp-wp_genesis 124 <?php if ( !empty($theme_name) ) :
mp-wp_genesis 125 $template = $themes[$theme_name]['Template'];
mp-wp_genesis 126 $stylesheet = $themes[$theme_name]['Stylesheet'];
mp-wp_genesis 127 $title = $themes[$theme_name]['Title'];
mp-wp_genesis 128 $version = $themes[$theme_name]['Version'];
mp-wp_genesis 129 $description = $themes[$theme_name]['Description'];
mp-wp_genesis 130 $author = $themes[$theme_name]['Author'];
mp-wp_genesis 131 $screenshot = $themes[$theme_name]['Screenshot'];
mp-wp_genesis 132 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
mp-wp_genesis 133 $preview_link = clean_url( get_option('home') . '/');
mp-wp_genesis 134 $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 135 $preview_text = attribute_escape( sprintf( __('Preview of "%s"'), $title ) );
mp-wp_genesis 136 $tags = $themes[$theme_name]['Tags'];
mp-wp_genesis 137 $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=".urlencode($template)."&amp;stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template);
mp-wp_genesis 138 $activate_text = attribute_escape( sprintf( __('Activate "%s"'), $title ) );
mp-wp_genesis 139 ?>
mp-wp_remove-all-... 140 <a href="<?php echo $activate_link; ?>" class="screenshot">
mp-wp_genesis 141 <?php if ( $screenshot ) : ?>
mp-wp_genesis 142 <img src="<?php echo WP_CONTENT_URL . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
mp-wp_genesis 143 <?php endif; ?>
mp-wp_genesis 144 </a>
mp-wp_remove-all-... 145 <h3><a href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>
mp-wp_genesis 146 <p><?php echo $description; ?></p>
mp-wp_genesis 147 <?php if ( $tags ) : ?>
mp-wp_genesis 148 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p>
mp-wp_genesis 149 <?php endif; ?>
mp-wp_genesis 150 <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 151 <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 152 <?php endif; // end if not empty theme_name ?>
mp-wp_genesis 153 </td>
mp-wp_genesis 154 <?php } // end foreach $cols ?>
mp-wp_genesis 155 </tr>
mp-wp_genesis 156 <?php } // end foreach $table ?>
mp-wp_genesis 157 </table>
mp-wp_genesis 158 <?php } ?>
mp-wp_genesis 159
mp-wp_genesis 160 <br class="clear" />
mp-wp_genesis 161
mp-wp_genesis 162 <?php if ( $page_links ) : ?>
mp-wp_genesis 163 <div class="tablenav">
mp-wp_genesis 164 <?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?>
mp-wp_genesis 165 <br class="clear" />
mp-wp_genesis 166 </div>
mp-wp_genesis 167 <?php endif; ?>
mp-wp_genesis 168
mp-wp_genesis 169 <br class="clear" />
mp-wp_genesis 170
mp-wp_genesis 171 <?php
mp-wp_genesis 172 // List broken themes, if any.
mp-wp_genesis 173 $broken_themes = get_broken_themes();
mp-wp_genesis 174 if ( count($broken_themes) ) {
mp-wp_genesis 175 ?>
mp-wp_genesis 176
mp-wp_genesis 177 <h2><?php _e('Broken Themes'); ?></h2>
mp-wp_genesis 178 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
mp-wp_genesis 179
mp-wp_genesis 180 <table width="100%" cellpadding="3" cellspacing="3">
mp-wp_genesis 181 <tr>
mp-wp_genesis 182 <th><?php _e('Name'); ?></th>
mp-wp_genesis 183 <th><?php _e('Description'); ?></th>
mp-wp_genesis 184 </tr>
mp-wp_genesis 185 <?php
mp-wp_genesis 186 $theme = '';
mp-wp_genesis 187
mp-wp_genesis 188 $theme_names = array_keys($broken_themes);
mp-wp_genesis 189 natcasesort($theme_names);
mp-wp_genesis 190
mp-wp_genesis 191 foreach ($theme_names as $theme_name) {
mp-wp_genesis 192 $title = $broken_themes[$theme_name]['Title'];
mp-wp_genesis 193 $description = $broken_themes[$theme_name]['Description'];
mp-wp_genesis 194
mp-wp_genesis 195 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"';
mp-wp_genesis 196 echo "
mp-wp_genesis 197 <tr $theme>
mp-wp_genesis 198 <td>$title</td>
mp-wp_genesis 199 <td>$description</td>
mp-wp_genesis 200 </tr>";
mp-wp_genesis 201 }
mp-wp_genesis 202 ?>
mp-wp_genesis 203 </table>
mp-wp_genesis 204 <?php
mp-wp_genesis 205 }
mp-wp_genesis 206 ?>
mp-wp_genesis 207
mp-wp_genesis 208 </div>
mp-wp_genesis 209
mp-wp_genesis 210 <?php require('admin-footer.php'); ?>