| [ Root ] [ Search ] [ Index ] |
PHP Cross Reference of WordPress 3.0Provided by Yoast |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Themes administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once ('./admin.php'); 11 12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') ) 13 wp_die( __( 'Cheatin’ uh?' ) ); 14 15 if ( current_user_can('switch_themes') && isset($_GET['action']) ) { 16 if ( 'activate' == $_GET['action'] ) { 17 check_admin_referer('switch-theme_' . $_GET['template']); 18 switch_theme($_GET['template'], $_GET['stylesheet']); 19 wp_redirect('themes.php?activated=true'); 20 exit; 21 } else if ( 'delete' == $_GET['action'] ) { 22 check_admin_referer('delete-theme_' . $_GET['template']); 23 if ( !current_user_can('delete_themes') ) 24 wp_die( __( 'Cheatin’ uh?' ) ); 25 delete_theme($_GET['template']); 26 wp_redirect('themes.php?deleted=true'); 27 exit; 28 } 29 } 30 31 $title = __('Manage Themes'); 32 $parent_file = 'themes.php'; 33 34 if ( current_user_can( 'switch_themes' ) ) : 35 36 $help = '<p>' . __('Aside from the default theme included with your WordPress installation, themes are designed and developed by third parties.') . '</p>'; 37 $help .= '<p>' . __('You can see your active theme at the top of the screen. Below are the other themes you have installed that are not currently in use. You can see what your site would look like with one of these themes by clicking the Preview link. To change themes, click the Activate link.') . '</p>'; 38 if ( current_user_can('install_themes') ) 39 $help .= '<p>' . sprintf(__('If you would like to see more themes to choose from, click on the “Install Themes” 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 licensed under the GNU General Public License, version 2, just like WordPress. Oh, and they’re free!'), 'http://wordpress.org/extend/themes/') . '</p>'; 40 41 $help .= '<p><strong>' . __('For more information:') . '</strong></p>'; 42 $help .= '<p>' . __('<a href="http://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>') . '</p>'; 43 $help .= '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'; 44 add_contextual_help($current_screen, $help); 45 46 add_thickbox(); 47 wp_enqueue_script( 'theme-preview' ); 48 49 endif; 50 51 require_once ('./admin-header.php'); 52 if ( is_multisite() && current_user_can('edit_themes') ) { 53 ?><div id="message0" class="updated"><p><?php printf( __('Administrator: new themes must be activated in the <a href="%s">Network Themes</a> screen before they appear here.'), admin_url( 'ms-themes.php') ); ?></p></div><?php 54 } 55 ?> 56 57 <?php if ( ! validate_current_theme() ) : ?> 58 <div id="message1" class="updated"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div> 59 <?php elseif ( isset($_GET['activated']) ) : 60 if ( isset($wp_registered_sidebars) && count( (array) $wp_registered_sidebars ) && current_user_can('edit_theme_options') ) { ?> 61 <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 62 } else { ?> 63 <div id="message2" class="updated"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php 64 } 65 elseif ( isset($_GET['deleted']) ) : ?> 66 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div> 67 <?php endif; ?> 68 <?php 69 $themes = get_allowed_themes(); 70 $ct = current_theme_info(); 71 unset($themes[$ct->name]); 72 73 uksort( $themes, "strnatcasecmp" ); 74 $theme_total = count( $themes ); 75 $per_page = 15; 76 77 if ( isset( $_GET['pagenum'] ) ) 78 $page = absint( $_GET['pagenum'] ); 79 80 if ( empty($page) ) 81 $page = 1; 82 83 $start = $offset = ( $page - 1 ) * $per_page; 84 85 $page_links = paginate_links( array( 86 'base' => add_query_arg( 'pagenum', '%#%' ) . '#themenav', 87 'format' => '', 88 'prev_text' => __('«'), 89 'next_text' => __('»'), 90 'total' => ceil($theme_total / $per_page), 91 'current' => $page 92 )); 93 94 $themes = array_slice( $themes, $start, $per_page ); 95 ?> 96 97 <div class="wrap"> 98 <?php screen_icon(); ?> 99 <h2><a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a><?php if ( current_user_can('install_themes') ) { ?><a href="theme-install.php" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a><?php } ?></h2> 100 101 <h3><?php _e('Current Theme'); ?></h3> 102 <div id="current-theme"> 103 <?php if ( $ct->screenshot ) : ?> 104 <img src="<?php echo $ct->theme_root_uri . '/' . $ct->stylesheet . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" /> 105 <?php endif; ?> 106 <h4><?php 107 /* translators: 1: theme title, 2: theme version, 3: theme author */ 108 printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4> 109 <p class="theme-description"><?php echo $ct->description; ?></p> 110 <?php if ( current_user_can('edit_themes') && $ct->parent_theme ) { ?> 111 <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, str_replace( WP_CONTENT_DIR, '', $ct->template_dir ), str_replace( WP_CONTENT_DIR, '', $ct->stylesheet_dir ), $ct->title, $ct->parent_theme); ?></p> 112 <?php } else { ?> 113 <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $ct->title, str_replace( WP_CONTENT_DIR, '', $ct->template_dir ), str_replace( WP_CONTENT_DIR, '', $ct->stylesheet_dir ) ); ?></p> 114 <?php } ?> 115 <?php if ( $ct->tags ) : ?> 116 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p> 117 <?php endif; ?> 118 <?php theme_update_available($ct); ?> 119 120 </div> 121 122 <div class="clear"></div> 123 <?php 124 if ( ! current_user_can( 'switch_themes' ) ) { 125 echo '</div>'; 126 require ( './admin-footer.php' ); 127 exit; 128 } 129 ?> 130 <h3><?php _e('Available Themes'); ?></h3> 131 <div class="clear"></div> 132 133 <?php if ( $theme_total ) { ?> 134 135 <?php if ( $page_links ) : ?> 136 <div class="tablenav"> 137 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 138 number_format_i18n( $start + 1 ), 139 number_format_i18n( min( $page * $per_page, $theme_total ) ), 140 number_format_i18n( $theme_total ), 141 $page_links 142 ); echo $page_links_text; ?></div> 143 </div> 144 <?php endif; ?> 145 146 <table id="availablethemes" cellspacing="0" cellpadding="0"> 147 <?php 148 $style = ''; 149 150 $theme_names = array_keys($themes); 151 natcasesort($theme_names); 152 153 $table = array(); 154 $rows = ceil(count($theme_names) / 3); 155 for ( $row = 1; $row <= $rows; $row++ ) 156 for ( $col = 1; $col <= 3; $col++ ) 157 $table[$row][$col] = array_shift($theme_names); 158 159 foreach ( $table as $row => $cols ) { 160 ?> 161 <tr> 162 <?php 163 foreach ( $cols as $col => $theme_name ) { 164 $class = array('available-theme'); 165 if ( $row == 1 ) $class[] = 'top'; 166 if ( $col == 1 ) $class[] = 'left'; 167 if ( $row == $rows ) $class[] = 'bottom'; 168 if ( $col == 3 ) $class[] = 'right'; 169 ?> 170 <td class="<?php echo join(' ', $class); ?>"> 171 <?php if ( !empty($theme_name) ) : 172 $template = $themes[$theme_name]['Template']; 173 $stylesheet = $themes[$theme_name]['Stylesheet']; 174 $title = $themes[$theme_name]['Title']; 175 $version = $themes[$theme_name]['Version']; 176 $description = $themes[$theme_name]['Description']; 177 $author = $themes[$theme_name]['Author']; 178 $screenshot = $themes[$theme_name]['Screenshot']; 179 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; 180 $template_dir = $themes[$theme_name]['Template Dir']; 181 $parent_theme = $themes[$theme_name]['Parent Theme']; 182 $theme_root = $themes[$theme_name]['Theme Root']; 183 $theme_root_uri = $themes[$theme_name]['Theme Root URI']; 184 $preview_link = esc_url(get_option('home') . '/'); 185 if ( is_ssl() ) 186 $preview_link = str_replace( 'http://', 'https://', $preview_link ); 187 $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), $preview_link ) ); 188 $preview_text = esc_attr( sprintf( __('Preview of “%s”'), $title ) ); 189 $tags = $themes[$theme_name]['Tags']; 190 $thickbox_class = 'thickbox thickbox-preview'; 191 $activate_link = wp_nonce_url("themes.php?action=activate&template=".urlencode($template)."&stylesheet=".urlencode($stylesheet), 'switch-theme_' . $template); 192 $activate_text = esc_attr( sprintf( __('Activate “%s”'), $title ) ); 193 $actions = array(); 194 $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' . $activate_text . '">' . __('Activate') . '</a>'; 195 $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr(sprintf(__('Preview “%s”'), $theme_name)) . '">' . __('Preview') . '</a>'; 196 if ( current_user_can('delete_themes') ) 197 $actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url("themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet) . '" onclick="' . "return confirm('" . esc_js(sprintf( __("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $theme_name )) . "');" . '">' . __('Delete') . '</a>'; 198 $actions = apply_filters('theme_action_links', $actions, $themes[$theme_name]); 199 200 $actions = implode ( ' | ', $actions ); 201 ?> 202 <a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot"> 203 <?php if ( $screenshot ) : ?> 204 <img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" /> 205 <?php endif; ?> 206 </a> 207 <h3><?php 208 /* translators: 1: theme title, 2: theme version, 3: theme author */ 209 printf(__('%1$s %2$s by %3$s'), $title, $version, $author) ; ?></h3> 210 <p class="description"><?php echo $description; ?></p> 211 <span class='action-links'><?php echo $actions ?></span> 212 <?php if ( current_user_can('edit_themes') && $parent_theme ) { 213 /* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?> 214 <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.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ), $title, $parent_theme); ?></p> 215 <?php } else { ?> 216 <p><?php printf(__('All of this theme’s files are located in <code>%2$s</code>.'), $title, str_replace( WP_CONTENT_DIR, '', $template_dir ), str_replace( WP_CONTENT_DIR, '', $stylesheet_dir ) ); ?></p> 217 <?php } ?> 218 <?php if ( $tags ) : ?> 219 <p><?php _e('Tags:'); ?> <?php echo join(', ', $tags); ?></p> 220 <?php endif; ?> 221 <?php theme_update_available( $themes[$theme_name] ); ?> 222 <?php endif; // end if not empty theme_name ?> 223 </td> 224 <?php } // end foreach $cols ?> 225 </tr> 226 <?php } // end foreach $table ?> 227 </table> 228 <?php } else { ?> 229 <p><?php 230 if ( current_user_can('install_themes') ) 231 printf(__('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress.org Theme Directory at any time: just click on the <em><a href="%s">Install Themes</a></em> tab above.'), 'theme-install.php'); 232 else 233 printf(__('Only the current theme is available to you. Contact the %s administrator for information about accessing additional themes.'), get_site_option('site_name')); 234 ?></p> 235 <?php } // end if $theme_total?> 236 <br class="clear" /> 237 238 <?php if ( $page_links ) : ?> 239 <div class="tablenav"> 240 <?php echo "<div class='tablenav-pages'>$page_links_text</div>"; ?> 241 <br class="clear" /> 242 </div> 243 <?php endif; ?> 244 245 <br class="clear" /> 246 247 <?php 248 // List broken themes, if any. 249 $broken_themes = get_broken_themes(); 250 if ( current_user_can('edit_themes') && count( $broken_themes ) ) { 251 ?> 252 253 <h2><?php _e('Broken Themes'); ?> <?php if ( is_multisite() ) _e( '(Site admin only)' ); ?></h2> 254 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> 255 256 <table id="broken-themes"> 257 <tr> 258 <th><?php _e('Name'); ?></th> 259 <th><?php _e('Description'); ?></th> 260 </tr> 261 <?php 262 $theme = ''; 263 264 $theme_names = array_keys($broken_themes); 265 natcasesort($theme_names); 266 267 foreach ($theme_names as $theme_name) { 268 $title = $broken_themes[$theme_name]['Title']; 269 $description = $broken_themes[$theme_name]['Description']; 270 271 $theme = ('class="alternate"' == $theme) ? '' : 'class="alternate"'; 272 echo " 273 <tr $theme> 274 <td>$title</td> 275 <td>$description</td> 276 </tr>"; 277 } 278 ?> 279 </table> 280 <?php 281 } 282 ?> 283 </div> 284 285 <?php require ('./admin-footer.php'); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Oct 14 05:11:12 2010 | Cross-referenced by PHPXref 0.7 |