Changes in trunk/wp-admin/themes.php [15135:17364]
- File:
-
- 1 edited
-
trunk/wp-admin/themes.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/themes.php
r15135 r17364 13 13 wp_die( __( 'Cheatin’ uh?' ) ); 14 14 15 if ( current_user_can('switch_themes') && isset($_GET['action']) ) { 15 $wp_list_table = _get_list_table('WP_Themes_List_Table'); 16 17 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { 16 18 if ( 'activate' == $_GET['action'] ) { 17 19 check_admin_referer('switch-theme_' . $_GET['template']); 18 20 switch_theme($_GET['template'], $_GET['stylesheet']); 19 wp_redirect( 'themes.php?activated=true');21 wp_redirect( admin_url('themes.php?activated=true') ); 20 22 exit; 21 } else if ( 'delete' == $_GET['action'] ) {23 } elseif ( 'delete' == $_GET['action'] ) { 22 24 check_admin_referer('delete-theme_' . $_GET['template']); 23 25 if ( !current_user_can('delete_themes') ) 24 26 wp_die( __( 'Cheatin’ uh?' ) ); 25 27 delete_theme($_GET['template']); 26 wp_redirect( 'themes.php?deleted=true');28 wp_redirect( admin_url('themes.php?deleted=true') ); 27 29 exit; 28 30 } 29 31 } 32 33 $wp_list_table->prepare_items(); 30 34 31 35 $title = __('Manage Themes'); … … 46 50 add_thickbox(); 47 51 wp_enqueue_script( 'theme-preview' ); 52 wp_enqueue_script( 'theme' ); 53 wp_enqueue_style( 'theme-install' ); 48 54 49 55 endif; 50 56 51 57 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><?php54 }55 58 ?> 56 59 … … 66 69 <div id="message3" class="updated"><p><?php _e('Theme deleted.') ?></p></div> 67 70 <?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> 71 72 <div class="wrap"><?php 73 screen_icon(); 74 if ( !is_multisite() ) : ?> 75 <h2 class="nav-tab-wrapper"> 76 <a href="themes.php" class="nav-tab nav-tab-active"><?php echo esc_html( $title ); ?></a> 77 <?php if ( current_user_can('install_themes') ) : ?> 78 <a href="<?php echo admin_url( 'theme-install.php'); ?>" class="nav-tab"><?php echo esc_html_x('Install Themes', 'theme'); ?></a> 79 <?php endif; 80 else : ?> 81 <h2> 82 <?php echo esc_html( $title ); ?> 83 <?php endif; ?> 84 </h2> 100 85 101 86 <h3><?php _e('Current Theme'); ?></h3> … … 108 93 printf(__('%1$s %2$s by %3$s'), $ct->title, $ct->version, $ct->author) ; ?></h4> 109 94 <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; ?> 95 <div class="theme-options"> 96 <span><?php _e( 'Options:' )?></span> 97 <?php 98 // Pretend you didn't see this. 99 $options = array(); 100 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { 101 foreach ( (array) $submenu['themes.php'] as $item) { 102 $class = ''; 103 if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] ) 104 continue; 105 // 0 = name, 1 = capability, 2 = file 106 if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) ) $class = ' class="current"'; 107 108 if ( !empty($submenu[$item[2]]) ) { 109 $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index. 110 $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]); 111 if ( file_exists(ABSPATH . PLUGINDIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook)) 112 $options[] = "<a href='admin.php?page={$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 113 else 114 $options[] = "<a href='{$submenu[$item[2]][0][2]}'$class>{$item[0]}</a>"; 115 } else if ( current_user_can($item[1]) ) { 116 if ( file_exists(ABSPATH . 'wp-admin/' . $item[2]) ) { 117 $options[] = "<a href='{$item[2]}'$class>{$item[0]}</a>"; 118 } else { 119 $options[] = "<a href='themes.php?page={$item[2]}'$class>{$item[0]}</a>"; 120 } 121 } 122 } 123 } 124 echo implode ( ' | ', $options ); 125 126 if ( $ct->tags ) : ?> 127 <p><?php _e('Tags:'); ?> <?php echo join(', ', $ct->tags); ?></p> 128 <?php endif; ?> 129 </div> 118 130 <?php theme_update_available($ct); ?> 119 131 120 132 </div> 121 133 122 < div class="clear"></div>134 <br class="clear" /> 123 135 <?php 124 136 if ( ! current_user_can( 'switch_themes' ) ) { … … 128 140 } 129 141 ?> 142 130 143 <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?> 144 145 <?php if ( !empty( $_REQUEST['s'] ) || !empty( $_REQUEST['filter'] ) || $wp_list_table->has_items() ) : ?> 146 147 <form class="search-form filter-form" action="" method="get"> 148 149 <p class="search-box"> 150 <label class="screen-reader-text" for="theme-search-input"><?php _e('Search Themes'); ?>:</label> 151 <input type="text" id="theme-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 152 <?php submit_button( __( 'Search Themes' ), 'button', 'submit', false ); ?> 153 <a id="filter-click" href="?filter=1"><?php _e( 'Feature Filter' ); ?></a> 154 </p> 155 156 <br class="clear"/> 157 158 <div id="filter-box" style="<?php if ( empty($_REQUEST['filter']) ) echo 'display: none;'; ?>"> 159 <?php $feature_list = get_theme_feature_list(); ?> 160 <div class="feature-filter"> 161 <p class="install-help"><?php _e('Theme filters') ?></p> 162 <?php if ( !empty( $_REQUEST['filter'] ) ) : ?> 163 <input type="hidden" name="filter" value="1" /> 164 <?php endif; ?> 165 <?php foreach ( $feature_list as $feature_name => $features ) : 166 $feature_name = esc_html( $feature_name ); ?> 167 168 <div class="feature-container"> 169 <div class="feature-name"><?php echo $feature_name ?></div> 170 171 <ol class="feature-group"> 172 <?php foreach ( $features as $key => $feature ) : 173 $feature_name = $feature; 174 $feature_name = esc_html( $feature_name ); 175 $feature = esc_attr( $feature ); 176 ?> 177 <li> 178 <input type="checkbox" name="features[]" id="feature-id-<?php echo $key; ?>" value="<?php echo $key; ?>" <?php checked( in_array( $key, $wp_list_table->features ) ); ?>/> 179 <label for="feature-id-<?php echo $key; ?>"><?php echo $feature_name; ?></label> 180 </li> 181 <?php endforeach; ?> 182 </ol> 183 </div> 184 <?php endforeach; ?> 185 186 <div class="feature-container"> 187 <?php submit_button( __( 'Apply Filters' ), 'button-secondary submitter', 'submit', false, array( 'style' => 'margin-left: 120px' ) ); ?> 188 189 <small><a id="mini-filter-click" href="<?php echo esc_url( remove_query_arg( array('filter', 'features', 'submit') ) ); ?>"><?php _e( 'Close filters' )?></a></small> 190 </div> 191 <br/> 192 </div> 193 <br class="clear"/> 194 </div> 195 236 196 <br class="clear" /> 237 197 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 198 <?php endif; ?> 199 200 <?php $wp_list_table->display(); ?> 201 202 </form> 245 203 <br class="clear" /> 246 204 … … 251 209 ?> 252 210 253 <h 2><?php _e('Broken Themes'); ?> <?php if ( is_multisite() ) _e( '(Site admin only)' ); ?></h2>211 <h3><?php _e('Broken Themes'); ?></h3> 254 212 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p> 255 213
Note: See TracChangeset
for help on using the changeset viewer.