Changeset 20029 for trunk/wp-admin/includes/class-wp-themes-list-table.php
- Timestamp:
- 02/28/2012 09:24:44 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-themes-list-table.php
r20027 r20029 25 25 26 26 function prepare_items() { 27 global $ct; 28 29 $ct = current_theme_info(); 30 31 $themes = get_allowed_themes(); 27 $themes = wp_get_themes( array( 'allowed' => true ) ); 32 28 33 29 if ( ! empty( $_REQUEST['s'] ) ) { … … 46 42 if ( $this->search || $this->features ) { 47 43 foreach ( $themes as $key => $theme ) { 48 if ( ! $this->search_theme( $theme ) )44 if ( ! $this->search_theme( $theme ) ) 49 45 unset( $themes[ $key ] ); 50 46 } 51 47 } 52 48 53 unset( $themes[ $ct->name] );54 uksort( $themes, "strnatcasecmp");49 unset( $themes[ get_option( 'stylesheet' ) ] ); 50 WP_Theme::sort_by_name( $themes ); 55 51 56 52 $per_page = 999; … … 126 122 function display_rows() { 127 123 $themes = $this->items; 128 $theme_names = array_keys( $themes ); 129 natcasesort( $theme_names ); 130 131 foreach ( $theme_names as $theme_name ) { 132 $class = array( 'available-theme' ); 133 ?> 134 <div class="<?php echo join( ' ', $class ); ?>"> 135 <?php if ( !empty( $theme_name ) ) : 136 $template = $themes[$theme_name]['Template']; 137 $stylesheet = $themes[$theme_name]['Stylesheet']; 138 $title = $themes[$theme_name]['Title']; 139 $version = $themes[$theme_name]['Version']; 140 $description = $themes[$theme_name]['Description']; 141 $author = $themes[$theme_name]['Author']; 142 $screenshot = $themes[$theme_name]['Screenshot']; 143 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; 144 $template_dir = $themes[$theme_name]['Template Dir']; 145 $parent_theme = $themes[$theme_name]['Parent Theme']; 146 $theme_root = $themes[$theme_name]['Theme Root']; 147 $theme_root_uri = $themes[$theme_name]['Theme Root URI']; 148 $preview_link = esc_url( add_query_arg( array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ), home_url( '/' ) ) ); 149 $preview_text = esc_attr( sprintf( __( 'Preview of “%s”' ), $title ) ); 150 $tags = $themes[$theme_name]['Tags']; 151 $thickbox_class = 'thickbox thickbox-preview'; 152 $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $template ); 153 $activate_text = esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ); 154 $actions = array(); 155 $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' . $activate_text . '">' . __( 'Activate' ) . '</a>'; 156 $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $theme_name ) ) . '">' . __( 'Preview' ) . '</a>'; 157 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) 158 $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>'; 159 $actions = apply_filters( 'theme_action_links', $actions, $themes[$theme_name] ); 160 161 $actions = implode ( ' | ', $actions ); 162 ?> 163 <a href="<?php echo $preview_link; ?>" class="<?php echo $thickbox_class; ?> screenshot"> 164 <?php if ( $screenshot ) : ?> 165 <img src="<?php echo $theme_root_uri . '/' . $stylesheet . '/' . $screenshot; ?>" alt="" /> 166 <?php endif; ?> 167 </a> 168 <h3><?php 169 /* translators: 1: theme title, 2: theme version, 3: theme author */ 170 printf( __( '%1$s %2$s by %3$s' ), $title, $version, $author ) ; ?></h3> 171 172 <span class='action-links'><?php echo $actions ?></span> 173 <span class="separator hide-if-no-js">| </span><a href="#" class="theme-detail hide-if-no-js" tabindex='4'><?php _e('Details') ?></a> 174 <div class="themedetaildiv hide-if-js"> 175 <p><?php echo $description; ?></p> 176 <?php if ( current_user_can( 'edit_themes' ) && $parent_theme ) { 177 /* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?> 178 <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> 179 <?php } else { ?> 180 <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> 181 <?php } ?> 182 <?php if ( $tags ) : ?> 183 <p><?php _e( 'Tags:' ); ?> <?php echo join( ', ', $tags ); ?></p> 184 <?php endif; ?> 185 <?php endif; // end if not empty theme_name ?> 186 </div> 187 <?php theme_update_available( $themes[$theme_name] ); ?> 188 </div> 189 <?php } // end foreach $theme_names 124 125 foreach ( $themes as $theme ) { 126 echo '<div class="available-theme">'; 127 128 $template = $theme->get_template(); 129 $stylesheet = $theme->get_stylesheet(); 130 131 $title = $theme->display('Name'); 132 $version = $theme->display('Version'); 133 $author = $theme->display('Author'); 134 135 $activate_link = wp_nonce_url( "themes.php?action=activate&template=" . urlencode( $template ) . "&stylesheet=" . urlencode( $stylesheet ), 'switch-theme_' . $template ); 136 $preview_link = esc_url( add_query_arg( 137 array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ), 138 home_url( '/' ) ) ); 139 140 $actions = array(); 141 $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' 142 . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; 143 $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="' 144 . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>'; 145 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) 146 $actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet ) 147 . '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ) 148 . "' );" . '">' . __( 'Delete' ) . '</a>'; 149 150 $actions = apply_filters( 'theme_action_links', $actions, $theme ); 151 152 $actions = implode ( ' | ', $actions ); 153 ?> 154 <a href="<?php echo $preview_link; ?>" class="thickbox thickbox-preview screenshot"> 155 <?php if ( $theme->get_screenshot() ) : ?> 156 <img src="<?php echo esc_url( $theme->get_screenshot( 'absolute' ) ); ?>" alt="" /> 157 <?php endif; ?> 158 </a> 159 <h3><?php 160 /* translators: 1: theme title, 2: theme version, 3: theme author */ 161 printf( __( '%1$s %2$s by %3$s' ), $title, $version, $author ) ; ?></h3> 162 163 <span class='action-links'><?php echo $actions ?></span> 164 <span class="separator hide-if-no-js">| </span><a href="#" class="theme-detail hide-if-no-js" tabindex='4'><?php _e('Details') ?></a> 165 <div class="themedetaildiv hide-if-js"> 166 <p><?php echo $theme->display('Description'); ?></p> 167 <?php if ( current_user_can( 'edit_themes' ) && $theme->parent() ) : 168 /* translators: 1: theme title, 2: template dir, 3: stylesheet_dir, 4: theme title, 5: parent_theme */ ?> 169 <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.' ), 170 $title, str_replace( WP_CONTENT_DIR, '', $theme->get_template_directory() ), str_replace( WP_CONTENT_DIR, '', $theme->get_stylesheet_directory() ), $title, $theme->parent()->display('Name') ); ?></p> 171 <?php else : 172 /* translators: 1: theme title, 2: template dir, 3: stylesheet_dir */ ?> 173 <p><?php printf( __( 'All of this theme’s files are located in <code>%2$s</code>.' ), 174 $title, str_replace( WP_CONTENT_DIR, '', $theme->get_template_directory() ), str_replace( WP_CONTENT_DIR, '', $theme->get_stylesheet_directory() ) ); ?></p> 175 <?php endif; ?> 176 <?php 177 if ( $theme->get('Tags') ) 178 printf( '<p>' . __( 'Tags: %s.' ) . '</p>', $theme->display('Tags') ); 179 ?> 180 </div> 181 <?php theme_update_available( $theme ); ?> 182 </div> 183 <?php 184 } 190 185 } 191 186 … … 194 189 if ( $this->features ) { 195 190 foreach ( $this->features as $word ) { 196 if ( ! in_array( $word, $theme ['Tags']) )191 if ( ! in_array( $word, $theme->get('Tags') ) ) 197 192 return false; 198 193 } … … 202 197 if ( $this->search ) { 203 198 foreach ( $this->search as $word ) { 204 if ( in_array( $word, $theme ['Tags']) )199 if ( in_array( $word, $theme->get('Tags') ) ) 205 200 continue; 206 } 207 208 foreach ( array( 'Name', 'Title', 'Description', 'Author', 'Template', 'Stylesheet' ) as $header ) { 209 if ( false !== stripos( $theme[ $header ], $word ) ) 210 continue 2; 211 } 212 213 return false; 201 202 foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { 203 // Don't mark up; Do translate. 204 if ( false !== stripos( $theme->display( $header, false, true ), $word ) ) 205 continue 2; 206 } 207 208 if ( false !== stripos( $theme->get_stylesheet(), $word ) ) 209 continue; 210 211 if ( false !== stripos( $theme->get_template(), $word ) ) 212 continue; 213 214 return false; 215 } 214 216 } 215 217
Note: See TracChangeset
for help on using the changeset viewer.