- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-theme-install-list-table.php
r41683 r42343 21 21 22 22 /** 23 *24 23 * @return bool 25 24 */ … … 29 28 30 29 /** 31 *32 30 * @global array $tabs 33 31 * @global string $tab … … 42 40 wp_reset_vars( array( 'tab' ) ); 43 41 44 $search_terms = array();42 $search_terms = array(); 45 43 $search_string = ''; 46 if ( ! empty( $_REQUEST['s'] ) ) {44 if ( ! empty( $_REQUEST['s'] ) ) { 47 45 $search_string = strtolower( wp_unslash( $_REQUEST['s'] ) ); 48 $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );49 } 50 51 if ( ! empty( $_REQUEST['features'] ) ) 46 $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) ); 47 } 48 49 if ( ! empty( $_REQUEST['features'] ) ) { 52 50 $this->features = $_REQUEST['features']; 51 } 53 52 54 53 $paged = $this->get_pagenum(); … … 57 56 58 57 // These are the tabs which are shown on the page, 59 $tabs = array();58 $tabs = array(); 60 59 $tabs['dashboard'] = __( 'Search' ); 61 if ( 'search' === $tab ) 62 $tabs['search'] = __( 'Search Results' ); 63 $tabs['upload'] = __( 'Upload' ); 60 if ( 'search' === $tab ) { 61 $tabs['search'] = __( 'Search Results' ); 62 } 63 $tabs['upload'] = __( 'Upload' ); 64 64 $tabs['featured'] = _x( 'Featured', 'themes' ); 65 65 //$tabs['popular'] = _x( 'Popular', 'themes' ); 66 $tabs['new'] 67 $tabs['updated'] 66 $tabs['new'] = _x( 'Latest', 'themes' ); 67 $tabs['updated'] = _x( 'Recently Updated', 'themes' ); 68 68 69 69 $nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item. … … 83 83 84 84 // If a non-valid menu tab has been selected, And it's not a non-menu action. 85 if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) 85 if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) { 86 86 $tab = key( $tabs ); 87 88 $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults ); 87 } 88 89 $args = array( 90 'page' => $paged, 91 'per_page' => $per_page, 92 'fields' => $theme_field_defaults, 93 ); 89 94 90 95 switch ( $tab ) { … … 104 109 105 110 if ( ! empty( $this->features ) ) { 106 $args['tag'] = $this->features;107 $_REQUEST['s'] = implode( ',', $this->features );111 $args['tag'] = $this->features; 112 $_REQUEST['s'] = implode( ',', $this->features ); 108 113 $_REQUEST['type'] = 'tag'; 109 114 } … … 113 118 114 119 case 'featured': 115 // case 'popular':120 // case 'popular': 116 121 case 'new': 117 122 case 'updated': … … 137 142 $args = apply_filters( "install_themes_table_api_args_{$tab}", $args ); 138 143 139 if ( ! $args ) 144 if ( ! $args ) { 140 145 return; 146 } 141 147 142 148 $api = themes_api( 'query_themes', $args ); 143 149 144 if ( is_wp_error( $api ) ) 150 if ( is_wp_error( $api ) ) { 145 151 wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); 152 } 146 153 147 154 $this->items = $api->themes; 148 155 149 $this->set_pagination_args( array( 150 'total_items' => $api->info['results'], 151 'per_page' => $args['per_page'], 152 'infinite_scroll' => true, 153 ) ); 156 $this->set_pagination_args( 157 array( 158 'total_items' => $api->info['results'], 159 'per_page' => $args['per_page'], 160 'infinite_scroll' => true, 161 ) 162 ); 154 163 } 155 164 … … 161 170 162 171 /** 163 *164 172 * @global array $tabs 165 173 * @global string $tab … … 171 179 $display_tabs = array(); 172 180 foreach ( (array) $tabs as $action => $text ) { 173 $current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';174 $href = self_admin_url('theme-install.php?tab=' . $action);175 $display_tabs[ 'theme-install-'.$action] = "<a href='$href'$current_link_attributes>$text</a>";181 $current_link_attributes = ( $action === $tab ) ? ' class="current" aria-current="page"' : ''; 182 $href = self_admin_url( 'theme-install.php?tab=' . $action ); 183 $display_tabs[ 'theme-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>"; 176 184 } 177 185 … … 182 190 */ 183 191 public function display() { 184 wp_nonce_field( "fetch-list-". get_class( $this ), '_ajax_fetch_list_nonce' );192 wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); 185 193 ?> 186 194 <div class="tablenav top themes"> … … 213 221 foreach ( $themes as $theme ) { 214 222 ?> 215 <div class="available-theme installable-theme"><?php 223 <div class="available-theme installable-theme"> 224 <?php 216 225 $this->single_row( $theme ); 217 ?></div> 218 <?php } // end foreach $theme_names 226 ?> 227 </div> 228 <?php 229 } // end foreach $theme_names 219 230 220 231 $this->theme_installer(); … … 247 258 global $themes_allowedtags; 248 259 249 if ( empty( $theme ) ) 260 if ( empty( $theme ) ) { 250 261 return; 251 252 $name = wp_kses( $theme->name, $themes_allowedtags ); 262 } 263 264 $name = wp_kses( $theme->name, $themes_allowedtags ); 253 265 $author = wp_kses( $theme->author, $themes_allowedtags ); 254 266 255 $preview_title = sprintf( __('Preview “%s”'), $name ); 256 $preview_url = add_query_arg( array( 257 'tab' => 'theme-information', 258 'theme' => $theme->slug, 259 ), self_admin_url( 'theme-install.php' ) ); 267 $preview_title = sprintf( __( 'Preview “%s”' ), $name ); 268 $preview_url = add_query_arg( 269 array( 270 'tab' => 'theme-information', 271 'theme' => $theme->slug, 272 ), self_admin_url( 'theme-install.php' ) 273 ); 260 274 261 275 $actions = array(); 262 276 263 $install_url = add_query_arg( array( 264 'action' => 'install-theme', 265 'theme' => $theme->slug, 266 ), self_admin_url( 'update.php' ) ); 267 268 $update_url = add_query_arg( array( 269 'action' => 'upgrade-theme', 270 'theme' => $theme->slug, 271 ), self_admin_url( 'update.php' ) ); 277 $install_url = add_query_arg( 278 array( 279 'action' => 'install-theme', 280 'theme' => $theme->slug, 281 ), self_admin_url( 'update.php' ) 282 ); 283 284 $update_url = add_query_arg( 285 array( 286 'action' => 'upgrade-theme', 287 'theme' => $theme->slug, 288 ), self_admin_url( 'update.php' ) 289 ); 272 290 273 291 $status = $this->_get_theme_status( $theme ); … … 310 328 <div class="action-links"> 311 329 <ul> 312 <?php foreach ( $actions as $action ) : ?>330 <?php foreach ( $actions as $action ) : ?> 313 331 <li><?php echo $action; ?></li> 314 332 <?php endforeach; ?> 315 <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details')?></a></li>333 <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li> 316 334 </ul> 317 335 </div> … … 376 394 global $themes_allowedtags; 377 395 378 if ( empty( $theme ) ) 396 if ( empty( $theme ) ) { 379 397 return; 380 381 $name = wp_kses( $theme->name, $themes_allowedtags ); 398 } 399 400 $name = wp_kses( $theme->name, $themes_allowedtags ); 382 401 $author = wp_kses( $theme->author, $themes_allowedtags ); 383 402 384 $install_url = add_query_arg( array( 385 'action' => 'install-theme', 386 'theme' => $theme->slug, 387 ), self_admin_url( 'update.php' ) ); 388 389 $update_url = add_query_arg( array( 390 'action' => 'upgrade-theme', 391 'theme' => $theme->slug, 392 ), self_admin_url( 'update.php' ) ); 403 $install_url = add_query_arg( 404 array( 405 'action' => 'install-theme', 406 'theme' => $theme->slug, 407 ), self_admin_url( 'update.php' ) 408 ); 409 410 $update_url = add_query_arg( 411 array( 412 'action' => 'upgrade-theme', 413 'theme' => $theme->slug, 414 ), self_admin_url( 'update.php' ) 415 ); 393 416 394 417 $status = $this->_get_theme_status( $theme ); 395 418 396 419 ?> 397 <div class="install-theme-info"><?php 398 switch ( $status ) { 399 case 'update_available': 400 echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; 401 break; 402 case 'newer_installed': 403 case 'latest_installed': 404 echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; 405 break; 406 case 'install': 407 default: 408 echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>'; 409 break; 410 } ?> 420 <div class="install-theme-info"> 421 <?php 422 switch ( $status ) { 423 case 'update_available': 424 echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; 425 break; 426 case 'newer_installed': 427 case 'latest_installed': 428 echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; 429 break; 430 case 'install': 431 default: 432 echo '<a class="theme-install button button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>'; 433 break; 434 } 435 ?> 411 436 <h3 class="theme-name"><?php echo $name; ?></h3> 412 437 <span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span> 413 <?php if ( isset( $theme->screenshot_url ) ) : ?>438 <?php if ( isset( $theme->screenshot_url ) ) : ?> 414 439 <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="" /> 415 440 <?php endif; ?> 416 441 <div class="theme-details"> 417 <?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?> 442 <?php 443 wp_star_rating( 444 array( 445 'rating' => $theme->rating, 446 'type' => 'percent', 447 'number' => $theme->num_ratings, 448 ) 449 ); 450 ?> 418 451 <div class="theme-version"> 419 <strong><?php _e( 'Version:')?> </strong>452 <strong><?php _e( 'Version:' ); ?> </strong> 420 453 <?php echo wp_kses( $theme->version, $themes_allowedtags ); ?> 421 454 </div> … … 457 490 $installed_theme = wp_get_theme( $theme->slug ); 458 491 if ( $installed_theme->exists() ) { 459 if ( version_compare( $installed_theme->get( 'Version'), $theme->version, '=' ) )492 if ( version_compare( $installed_theme->get( 'Version' ), $theme->version, '=' ) ) { 460 493 $status = 'latest_installed'; 461 elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) )494 } elseif ( version_compare( $installed_theme->get( 'Version' ), $theme->version, '>' ) ) { 462 495 $status = 'newer_installed'; 463 else496 } else { 464 497 $status = 'update_available'; 498 } 465 499 } 466 500
Note: See TracChangeset
for help on using the changeset viewer.