- Timestamp:
- 02/28/2012 09:24:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-ms-themes-list-table.php
r20022 r20029 51 51 52 52 function prepare_items() { 53 global $status, $t hemes, $totals, $page, $orderby, $order, $s;53 global $status, $totals, $page, $orderby, $order, $s; 54 54 55 55 wp_reset_vars( array( 'orderby', 'order', 's' ) ); 56 56 57 57 $themes = array( 58 'all' => apply_filters( 'all_themes', get_themes() ),58 'all' => apply_filters( 'all_themes', wp_get_themes() ), 59 59 'search' => array(), 60 60 'enabled' => array(), … … 63 63 ); 64 64 65 $site_allowed_themes = get_site_allowed_themes(); 66 if ( !$this->is_site_themes ) { 67 $allowed_themes = $site_allowed_themes; 65 if ( $this->is_site_themes ) { 66 $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); 67 $allowed_where = 'site'; 68 } else { 68 69 $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); 69 } else { 70 $allowed_themes = wpmu_get_blog_allowedthemes( $this->site_id ); 71 $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); 72 } 73 74 $current = get_site_transient( 'update_themes' ); 70 $allowed_where = 'network'; 71 } 72 73 $current = current_user_can( 'update_themes' ) && ! $this->is_site_themes && get_site_transient( 'update_themes' ); 75 74 76 75 foreach ( (array) $themes['all'] as $key => $theme ) { 77 $theme_key = $theme['Stylesheet']; 78 79 if ( isset( $allowed_themes [ $theme_key ] ) ) { 80 $themes['all'][$key]['enabled'] = true; 81 $themes['enabled'][$key] = $themes['all'][$key]; 82 } 83 else { 84 $themes['all'][$key]['enabled'] = false; 85 $themes['disabled'][$key] = $themes['all'][$key]; 86 } 87 if ( isset( $current->response[ $theme['Template'] ] ) ) 88 $themes['upgrade'][$key] = $themes['all'][$key]; 89 90 if ( $this->is_site_themes && isset( $site_allowed_themes[$theme_key] ) ) { 91 unset( $themes['all'][$key] ); 92 unset( $themes['enabled'][$key] ); 93 unset( $themes['disabled'][$key] ); 94 } 95 } 96 97 if ( !current_user_can( 'update_themes' ) || $this->is_site_themes ) 98 $themes['upgrade'] = array(); 76 if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { 77 unset( $themes['all'][ $key ] ); 78 continue; 79 } 80 81 $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; 82 $themes[ $filter ][ $key ] = $themes['all'][ $key ]; 83 84 if ( $current && isset( $current->response[ $key ] ) ) 85 $themes['upgrade'][ $key ] = $themes['all'][ $key ]; 86 } 99 87 100 88 if ( $s ) { … … 111 99 112 100 $this->items = $themes[ $status ]; 101 WP_Theme::sort_by_name( $this->items ); 102 103 $this->has_items = ! empty( $themes['all'] ); 113 104 $total_this_page = $totals[ $status ]; 114 105 … … 117 108 $order = strtoupper( $order ); 118 109 119 uasort( $this->items, array( &$this, '_order_callback' ) ); 110 if ( $orderby == 'Name' ) { 111 if ( 'ASC' == $order ) 112 $this->items = array_reverse( $this->items ); 113 } else { 114 uasort( $this->items, array( &$this, '_order_callback' ) ); 115 } 120 116 } 121 117 … … 123 119 124 120 if ( $total_this_page > $themes_per_page ) 125 $this->items = array_slice( $this->items, $start, $themes_per_page );121 $this->items = array_slice( $this->items, $start, $themes_per_page, true ); 126 122 127 123 $this->set_pagination_args( array( … … 136 132 $term = stripslashes( $_REQUEST['s'] ); 137 133 138 $search_fields = array( 'Name', 'Title', 'Description', 'Author', 'Author Name', 'Author URI', 'Template', 'Stylesheet' );139 foreach ( $search_fields as $field )140 if ( stripos( $theme[ $field ], $term ) !== false)134 foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { 135 // Don't mark up; Do translate. 136 if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) 141 137 return true; 138 } 139 140 if ( false !== stripos( $theme->get_stylesheet(), $term ) ) 141 return true; 142 143 if ( false !== stripos( $theme->get_template(), $term ) ) 144 return true; 142 145 143 146 return false; 144 147 } 145 148 149 // Not used by any core columns. 146 150 function _order_callback( $theme_a, $theme_b ) { 147 151 global $orderby, $order; 148 152 149 $a = $theme_a[ $orderby];150 $b = $theme_b[ $orderby];153 $a = $theme_a[ $orderby ]; 154 $b = $theme_b[ $orderby ]; 151 155 152 156 if ( $a == $b ) … … 160 164 161 165 function no_items() { 162 global $themes; 163 164 if ( !empty( $themes['all'] ) ) 166 if ( ! $$this->has_items ) 165 167 _e( 'No themes found.' ); 166 168 else … … 260 262 $context = $status; 261 263 262 if ( $this->is_site_themes ) 264 if ( $this->is_site_themes ) { 263 265 $url = "site-themes.php?id={$this->site_id}&"; 264 else 266 $allowed = $theme->is_allowed( 'site', $this->site_id ); 267 } else { 265 268 $url = 'themes.php?'; 269 $allowed = $theme->is_allowed( 'network' ); 270 } 266 271 267 272 // preorder … … 273 278 ); 274 279 275 $theme_key = $theme ['Stylesheet'];276 277 if ( empty( $theme['enabled'] ))280 $theme_key = $theme->get_stylesheet(); 281 282 if ( ! $allowed ) 278 283 $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $theme_key) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>'; 279 284 else … … 281 286 282 287 if ( current_user_can('edit_themes') ) 283 $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . urlencode( $theme['Name'] )) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>';284 285 if ( empty( $theme['enabled'] )&& current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) )288 $actions['edit'] = '<a href="' . esc_url('theme-editor.php?theme=' . $theme_key ) . '" title="' . esc_attr__('Open this theme in the Theme Editor') . '" class="edit">' . __('Edit') . '</a>'; 289 290 if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $theme_key != get_option( 'stylesheet' ) && $theme_key != get_option( 'template' ) ) 286 291 $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( 'themes.php?action=delete-selected&checked[]=' . $theme_key . '&theme_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-themes' ) ) . '" title="' . esc_attr__( 'Delete this theme' ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 287 292 … … 289 294 $actions = apply_filters( "theme_action_links_$theme_key", $actions, $theme_key, $theme, $context ); 290 295 291 $class = empty( $theme['enabled'] ) ? 'inactive' : 'active'; 292 $checkbox_id = "checkbox_" . md5($theme['Name']); 293 $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme['Name'] . "</label>"; 294 295 $description = '<p>' . $theme['Description'] . '</p>'; 296 $theme_name = $theme['Name']; 297 298 $id = sanitize_title( $theme_name ); 296 $class = ! $allowed ? 'inactive' : 'active'; 297 $checkbox_id = "checkbox_" . md5( $theme->get('Name') ); 298 $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $theme_key ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>"; 299 300 $description = '<p>' . $theme->display( 'Description' ) . '</p>'; 301 302 $id = sanitize_html_class( $theme->get_stylesheet() ); 299 303 300 304 echo "<tr id='$id' class='$class'>"; … … 312 316 break; 313 317 case 'name': 314 echo "<td class='theme-title'$style><strong> $theme_name</strong>";318 echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>"; 315 319 echo $this->row_actions( $actions, true ); 316 320 echo "</td>"; … … 318 322 case 'description': 319 323 echo "<td class='column-description desc'$style> 320 <div class='theme-description'> $description</div>324 <div class='theme-description'>" . $theme->display( 'Description' ) . "</div> 321 325 <div class='$class second theme-version-author-uri'>"; 322 326 323 327 $theme_meta = array(); 324 328 325 if ( !empty( $theme['Version']) )326 $theme_meta[] = sprintf( __( 'Version %s' ), $theme ['Version']);327 328 if ( !empty( $theme['Author']) )329 $theme_meta[] = sprintf( __( 'By %s' ), $theme ['Author']);330 331 if ( !empty( $theme['Theme URI']) )332 $theme_meta[] = '<a href="' . $theme ['Theme URI']. '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>';329 if ( $theme->get('Version') ) 330 $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') ); 331 332 if ( $theme->get('Author') ) 333 $theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') ); 334 335 if ( $theme->get('ThemeURI') ) 336 $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>'; 333 337 334 338 $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $theme_key, $theme, $status );
Note: See TracChangeset
for help on using the changeset viewer.