32 * @global int $paged |
32 * @global int $paged |
33 * @global string $type |
33 * @global string $type |
34 * @global array $theme_field_defaults |
34 * @global array $theme_field_defaults |
35 */ |
35 */ |
36 public function prepare_items() { |
36 public function prepare_items() { |
37 include( ABSPATH . 'wp-admin/includes/theme-install.php' ); |
37 require ABSPATH . 'wp-admin/includes/theme-install.php'; |
38 |
38 |
39 global $tabs, $tab, $paged, $type, $theme_field_defaults; |
39 global $tabs, $tab, $paged, $type, $theme_field_defaults; |
40 wp_reset_vars( array( 'tab' ) ); |
40 wp_reset_vars( array( 'tab' ) ); |
41 |
41 |
42 $search_terms = array(); |
42 $search_terms = array(); |
80 * the Install Themes screen. |
80 * the Install Themes screen. |
81 */ |
81 */ |
82 $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); |
82 $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); |
83 |
83 |
84 // If a non-valid menu tab has been selected, And it's not a non-menu action. |
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, true ) ) ) { |
86 $tab = key( $tabs ); |
86 $tab = key( $tabs ); |
87 } |
87 } |
88 |
88 |
89 $args = array( |
89 $args = array( |
90 'page' => $paged, |
90 'page' => $paged, |
135 * tabs. Default tabs are 'dashboard', 'search', 'upload', 'featured', |
135 * tabs. Default tabs are 'dashboard', 'search', 'upload', 'featured', |
136 * 'new', and 'updated'. |
136 * 'new', and 'updated'. |
137 * |
137 * |
138 * @since 3.7.0 |
138 * @since 3.7.0 |
139 * |
139 * |
140 * @param array $args An array of themes API arguments. |
140 * @param array|false $args Theme install API arguments. |
141 */ |
141 */ |
142 $args = apply_filters( "install_themes_table_api_args_{$tab}", $args ); |
142 $args = apply_filters( "install_themes_table_api_args_{$tab}", $args ); |
143 |
143 |
144 if ( ! $args ) { |
144 if ( ! $args ) { |
145 return; |
145 return; |
146 } |
146 } |
147 |
147 |
148 $api = themes_api( 'query_themes', $args ); |
148 $api = themes_api( 'query_themes', $args ); |
149 |
149 |
150 if ( is_wp_error( $api ) ) { |
150 if ( is_wp_error( $api ) ) { |
151 wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); |
151 wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try Again' ) . '</a>' ); |
152 } |
152 } |
153 |
153 |
154 $this->items = $api->themes; |
154 $this->items = $api->themes; |
155 |
155 |
156 $this->set_pagination_args( |
156 $this->set_pagination_args( |
185 |
185 |
186 return $display_tabs; |
186 return $display_tabs; |
187 } |
187 } |
188 |
188 |
189 /** |
189 /** |
|
190 * Displays the theme install table. |
|
191 * |
|
192 * Overrides the parent display() method to provide a different container. |
|
193 * |
|
194 * @since 3.1.0 |
190 */ |
195 */ |
191 public function display() { |
196 public function display() { |
192 wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); |
197 wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); |
193 ?> |
198 ?> |
194 <div class="tablenav top themes"> |
199 <div class="tablenav top themes"> |
239 * @global array $themes_allowedtags |
244 * @global array $themes_allowedtags |
240 * |
245 * |
241 * @param object $theme { |
246 * @param object $theme { |
242 * An object that contains theme data returned by the WordPress.org API. |
247 * An object that contains theme data returned by the WordPress.org API. |
243 * |
248 * |
244 * @type string $name Theme name, e.g. 'Twenty Nineteen'. |
249 * @type string $name Theme name, e.g. 'Twenty Twenty'. |
245 * @type string $slug Theme slug, e.g. 'twentynineteen'. |
250 * @type string $slug Theme slug, e.g. 'twentytwenty'. |
246 * @type string $version Theme version, e.g. '1.1'. |
251 * @type string $version Theme version, e.g. '1.1'. |
247 * @type string $author Theme author username, e.g. 'melchoyce'. |
252 * @type string $author Theme author username, e.g. 'melchoyce'. |
248 * @type string $preview_url Preview URL, e.g. 'http://2019.wordpress.net/'. |
253 * @type string $preview_url Preview URL, e.g. 'https://2020.wordpress.net/'. |
249 * @type string $screenshot_url Screenshot URL, e.g. 'https://wordpress.org/themes/twentynineteen/'. |
254 * @type string $screenshot_url Screenshot URL, e.g. 'https://wordpress.org/themes/twentytwenty/'. |
250 * @type float $rating Rating score. |
255 * @type float $rating Rating score. |
251 * @type int $num_ratings The number of ratings. |
256 * @type int $num_ratings The number of ratings. |
252 * @type string $homepage Theme homepage, e.g. 'https://wordpress.org/themes/twentynineteen/'. |
257 * @type string $homepage Theme homepage, e.g. 'https://wordpress.org/themes/twentytwenty/'. |
253 * @type string $description Theme description. |
258 * @type string $description Theme description. |
254 * @type string $download_link Theme ZIP download URL. |
259 * @type string $download_link Theme ZIP download URL. |
255 * } |
260 * } |
256 */ |
261 */ |
257 public function single_row( $theme ) { |
262 public function single_row( $theme ) { |
262 } |
267 } |
263 |
268 |
264 $name = wp_kses( $theme->name, $themes_allowedtags ); |
269 $name = wp_kses( $theme->name, $themes_allowedtags ); |
265 $author = wp_kses( $theme->author, $themes_allowedtags ); |
270 $author = wp_kses( $theme->author, $themes_allowedtags ); |
266 |
271 |
267 /* translators: %s: theme name */ |
272 /* translators: %s: Theme name. */ |
268 $preview_title = sprintf( __( 'Preview “%s”' ), $name ); |
273 $preview_title = sprintf( __( 'Preview “%s”' ), $name ); |
269 $preview_url = add_query_arg( |
274 $preview_url = add_query_arg( |
270 array( |
275 array( |
271 'tab' => 'theme-information', |
276 'tab' => 'theme-information', |
272 'theme' => $theme->slug, |
277 'theme' => $theme->slug, |
297 switch ( $status ) { |
302 switch ( $status ) { |
298 case 'update_available': |
303 case 'update_available': |
299 $actions[] = sprintf( |
304 $actions[] = sprintf( |
300 '<a class="install-now" href="%s" title="%s">%s</a>', |
305 '<a class="install-now" href="%s" title="%s">%s</a>', |
301 esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ), |
306 esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ), |
302 /* translators: %s: theme version */ |
307 /* translators: %s: Theme version. */ |
303 esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ), |
308 esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ), |
304 __( 'Update' ) |
309 __( 'Update' ) |
305 ); |
310 ); |
306 break; |
311 break; |
307 case 'newer_installed': |
312 case 'newer_installed': |
315 case 'install': |
320 case 'install': |
316 default: |
321 default: |
317 $actions[] = sprintf( |
322 $actions[] = sprintf( |
318 '<a class="install-now" href="%s" title="%s">%s</a>', |
323 '<a class="install-now" href="%s" title="%s">%s</a>', |
319 esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ), |
324 esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ), |
320 /* translators: %s: theme name */ |
325 /* translators: %s: Theme name. */ |
321 esc_attr( sprintf( __( 'Install %s' ), $name ) ), |
326 esc_attr( sprintf( _x( 'Install %s', 'theme' ), $name ) ), |
322 __( 'Install Now' ) |
327 __( 'Install Now' ) |
323 ); |
328 ); |
324 break; |
329 break; |
325 } |
330 } |
326 |
331 |
327 $actions[] = sprintf( |
332 $actions[] = sprintf( |
328 '<a class="install-theme-preview" href="%s" title="%s">%s</a>', |
333 '<a class="install-theme-preview" href="%s" title="%s">%s</a>', |
329 esc_url( $preview_url ), |
334 esc_url( $preview_url ), |
330 /* translators: %s: theme name */ |
335 /* translators: %s: Theme name. */ |
331 esc_attr( sprintf( __( 'Preview %s' ), $name ) ), |
336 esc_attr( sprintf( __( 'Preview %s' ), $name ) ), |
332 __( 'Preview' ) |
337 __( 'Preview' ) |
333 ); |
338 ); |
334 |
339 |
335 /** |
340 /** |
349 </a> |
354 </a> |
350 |
355 |
351 <h3><?php echo $name; ?></h3> |
356 <h3><?php echo $name; ?></h3> |
352 <div class="theme-author"> |
357 <div class="theme-author"> |
353 <?php |
358 <?php |
354 /* translators: %s: theme author */ |
359 /* translators: %s: Theme author. */ |
355 printf( __( 'By %s' ), $author ); |
360 printf( __( 'By %s' ), $author ); |
356 ?> |
361 ?> |
357 </div> |
362 </div> |
358 |
363 |
359 <div class="action-links"> |
364 <div class="action-links"> |
455 switch ( $status ) { |
460 switch ( $status ) { |
456 case 'update_available': |
461 case 'update_available': |
457 printf( |
462 printf( |
458 '<a class="theme-install button button-primary" href="%s" title="%s">%s</a>', |
463 '<a class="theme-install button button-primary" href="%s" title="%s">%s</a>', |
459 esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ), |
464 esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ), |
460 /* translators: %s: theme version */ |
465 /* translators: %s: Theme version. */ |
461 esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ), |
466 esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ), |
462 __( 'Update' ) |
467 __( 'Update' ) |
463 ); |
468 ); |
464 break; |
469 break; |
465 case 'newer_installed': |
470 case 'newer_installed': |
481 } |
486 } |
482 ?> |
487 ?> |
483 <h3 class="theme-name"><?php echo $name; ?></h3> |
488 <h3 class="theme-name"><?php echo $name; ?></h3> |
484 <span class="theme-by"> |
489 <span class="theme-by"> |
485 <?php |
490 <?php |
486 /* translators: %s: theme author */ |
491 /* translators: %s: Theme author. */ |
487 printf( __( 'By %s' ), $author ); |
492 printf( __( 'By %s' ), $author ); |
488 ?> |
493 ?> |
489 </span> |
494 </span> |
490 <?php if ( isset( $theme->screenshot_url ) ) : ?> |
495 <?php if ( isset( $theme->screenshot_url ) ) : ?> |
491 <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="" /> |
496 <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" alt="" /> |