302 |
387 |
303 // Pre-order. |
388 // Pre-order. |
304 $actions = array( |
389 $actions = array( |
305 'enable' => '', |
390 'enable' => '', |
306 'disable' => '', |
391 'disable' => '', |
307 'edit' => '', |
|
308 'delete' => '' |
392 'delete' => '' |
309 ); |
393 ); |
310 |
394 |
311 $stylesheet = $theme->get_stylesheet(); |
395 $stylesheet = $theme->get_stylesheet(); |
312 $theme_key = urlencode( $stylesheet ); |
396 $theme_key = urlencode( $stylesheet ); |
313 |
397 |
314 if ( ! $allowed ) { |
398 if ( ! $allowed ) { |
315 if ( ! $theme->errors() ) |
399 if ( ! $theme->errors() ) { |
316 $actions['enable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=enable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'enable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Enable this theme') . '" class="edit">' . ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) . '</a>'; |
400 $url = add_query_arg( array( |
|
401 'action' => 'enable', |
|
402 'theme' => $theme_key, |
|
403 'paged' => $page, |
|
404 's' => $s, |
|
405 ), $url ); |
|
406 |
|
407 if ( $this->is_site_themes ) { |
|
408 /* translators: %s: theme name */ |
|
409 $aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) ); |
|
410 } else { |
|
411 /* translators: %s: theme name */ |
|
412 $aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) ); |
|
413 } |
|
414 |
|
415 $actions['enable'] = sprintf( '<a href="%s" class="edit" aria-label="%s">%s</a>', |
|
416 esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ), |
|
417 esc_attr( $aria_label ), |
|
418 ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) |
|
419 ); |
|
420 } |
317 } else { |
421 } else { |
318 $actions['disable'] = '<a href="' . esc_url( wp_nonce_url($url . 'action=disable&theme=' . $theme_key . '&paged=' . $page . '&s=' . $s, 'disable-theme_' . $stylesheet ) ) . '" title="' . esc_attr__('Disable this theme') . '">' . ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) . '</a>'; |
422 $url = add_query_arg( array( |
319 } |
423 'action' => 'disable', |
320 |
424 'theme' => $theme_key, |
321 if ( current_user_can('edit_themes') ) |
425 'paged' => $page, |
322 $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>'; |
426 's' => $s, |
323 |
427 ), $url ); |
324 if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) |
428 |
325 $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>'; |
429 if ( $this->is_site_themes ) { |
326 |
430 /* translators: %s: theme name */ |
|
431 $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); |
|
432 } else { |
|
433 /* translators: %s: theme name */ |
|
434 $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); |
|
435 } |
|
436 |
|
437 $actions['disable'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', |
|
438 esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), |
|
439 esc_attr( $aria_label ), |
|
440 ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) |
|
441 ); |
|
442 } |
|
443 |
|
444 if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) { |
|
445 $url = add_query_arg( array( |
|
446 'action' => 'delete-selected', |
|
447 'checked[]' => $theme_key, |
|
448 'theme_status' => $context, |
|
449 'paged' => $page, |
|
450 's' => $s, |
|
451 ), 'themes.php' ); |
|
452 |
|
453 /* translators: %s: theme name */ |
|
454 $aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) ); |
|
455 |
|
456 $actions['delete'] = sprintf( '<a href="%s" class="delete" aria-label="%s">%s</a>', |
|
457 esc_url( wp_nonce_url( $url, 'bulk-themes' ) ), |
|
458 esc_attr( $aria_label ), |
|
459 __( 'Delete' ) |
|
460 ); |
|
461 } |
327 /** |
462 /** |
328 * Filter the action links displayed for each theme in the Multisite |
463 * Filters the action links displayed for each theme in the Multisite |
329 * themes list table. |
464 * themes list table. |
330 * |
465 * |
331 * The action links displayed are determined by the theme's status, and |
466 * The action links displayed are determined by the theme's status, and |
332 * which Multisite themes list table is being displayed - the Network |
467 * which Multisite themes list table is being displayed - the Network |
333 * themes list table (themes.php), which displays all installed themes, |
468 * themes list table (themes.php), which displays all installed themes, |
334 * or the Site themes list table (site-themes.php), which displays the |
469 * or the Site themes list table (site-themes.php), which displays the |
335 * non-network enabled themes when editing a site in the Network admin. |
470 * non-network enabled themes when editing a site in the Network admin. |
336 * |
471 * |
337 * The default action links for the Network themes list table include |
472 * The default action links for the Network themes list table include |
338 * 'Network Enable', 'Network Disable', 'Edit', and 'Delete'. |
473 * 'Network Enable', 'Network Disable', and 'Delete'. |
339 * |
474 * |
340 * The default action links for the Site themes list table include |
475 * The default action links for the Site themes list table include |
341 * 'Enable', 'Disable', and 'Edit'. |
476 * 'Enable', and 'Disable'. |
342 * |
477 * |
343 * @since 2.8.0 |
478 * @since 2.8.0 |
344 * |
479 * |
345 * @param array $actions An array of action links. |
480 * @param array $actions An array of action links. |
346 * @param WP_Theme $theme The current WP_Theme object. |
481 * @param WP_Theme $theme The current WP_Theme object. |
347 * @param string $context Status of the theme. |
482 * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
348 */ |
483 */ |
349 $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
484 $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
350 |
485 |
351 /** |
486 /** |
352 * Filter the action links of a specific theme in the Multisite themes |
487 * Filters the action links of a specific theme in the Multisite themes |
353 * list table. |
488 * list table. |
354 * |
489 * |
355 * The dynamic portion of the hook name, `$stylesheet`, refers to the |
490 * The dynamic portion of the hook name, `$stylesheet`, refers to the |
356 * directory name of the theme, which in most cases is synonymous |
491 * directory name of the theme, which in most cases is synonymous |
357 * with the template name. |
492 * with the template name. |
358 * |
493 * |
359 * @since 3.1.0 |
494 * @since 3.1.0 |
360 * |
495 * |
361 * @param array $actions An array of action links. |
496 * @param array $actions An array of action links. |
362 * @param WP_Theme $theme The current WP_Theme object. |
497 * @param WP_Theme $theme The current WP_Theme object. |
363 * @param string $context Status of the theme. |
498 * @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
364 */ |
499 */ |
365 $actions = apply_filters( "theme_action_links_$stylesheet", $actions, $theme, $context ); |
500 $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context ); |
|
501 |
|
502 echo $this->row_actions( $actions, true ); |
|
503 } |
|
504 |
|
505 /** |
|
506 * Handles the description column output. |
|
507 * |
|
508 * @since 4.3.0 |
|
509 * |
|
510 * @global string $status |
|
511 * @global array $totals |
|
512 * |
|
513 * @param WP_Theme $theme The current WP_Theme object. |
|
514 */ |
|
515 public function column_description( $theme ) { |
|
516 global $status, $totals; |
|
517 if ( $theme->errors() ) { |
|
518 $pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : ''; |
|
519 echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>'; |
|
520 } |
|
521 |
|
522 if ( $this->is_site_themes ) { |
|
523 $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
524 } else { |
|
525 $allowed = $theme->is_allowed( 'network' ); |
|
526 } |
366 |
527 |
367 $class = ! $allowed ? 'inactive' : 'active'; |
528 $class = ! $allowed ? 'inactive' : 'active'; |
368 $checkbox_id = "checkbox_" . md5( $theme->get('Name') ); |
|
369 $checkbox = "<input type='checkbox' name='checked[]' value='" . esc_attr( $stylesheet ) . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $theme->display('Name') . "</label>"; |
|
370 |
|
371 $id = sanitize_html_class( $theme->get_stylesheet() ); |
|
372 |
|
373 if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) |
529 if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) |
374 $class .= ' update'; |
530 $class .= ' update'; |
375 |
531 |
376 echo "<tr id='$id' class='$class'>"; |
532 echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
377 |
533 <div class='$class second theme-version-author-uri'>"; |
378 list( $columns, $hidden ) = $this->get_column_info(); |
534 |
|
535 $stylesheet = $theme->get_stylesheet(); |
|
536 $theme_meta = array(); |
|
537 |
|
538 if ( $theme->get('Version') ) { |
|
539 $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') ); |
|
540 } |
|
541 $theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') ); |
|
542 |
|
543 if ( $theme->get('ThemeURI') ) { |
|
544 /* translators: %s: theme name */ |
|
545 $aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) ); |
|
546 |
|
547 $theme_meta[] = sprintf( '<a href="%s" aria-label="%s">%s</a>', |
|
548 $theme->display( 'ThemeURI' ), |
|
549 esc_attr( $aria_label ), |
|
550 __( 'Visit Theme Site' ) |
|
551 ); |
|
552 } |
|
553 /** |
|
554 * Filters the array of row meta for each theme in the Multisite themes |
|
555 * list table. |
|
556 * |
|
557 * @since 3.1.0 |
|
558 * |
|
559 * @param array $theme_meta An array of the theme's metadata, |
|
560 * including the version, author, and |
|
561 * theme URI. |
|
562 * @param string $stylesheet Directory name of the theme. |
|
563 * @param WP_Theme $theme WP_Theme object. |
|
564 * @param string $status Status of the theme. |
|
565 */ |
|
566 $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
|
567 echo implode( ' | ', $theme_meta ); |
|
568 |
|
569 echo '</div>'; |
|
570 } |
|
571 |
|
572 /** |
|
573 * Handles default column output. |
|
574 * |
|
575 * @since 4.3.0 |
|
576 * |
|
577 * @param WP_Theme $theme The current WP_Theme object. |
|
578 * @param string $column_name The current column name. |
|
579 */ |
|
580 public function column_default( $theme, $column_name ) { |
|
581 $stylesheet = $theme->get_stylesheet(); |
|
582 |
|
583 /** |
|
584 * Fires inside each custom column of the Multisite themes list table. |
|
585 * |
|
586 * @since 3.1.0 |
|
587 * |
|
588 * @param string $column_name Name of the column. |
|
589 * @param string $stylesheet Directory name of the theme. |
|
590 * @param WP_Theme $theme Current WP_Theme object. |
|
591 */ |
|
592 do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); |
|
593 } |
|
594 |
|
595 /** |
|
596 * Handles the output for a single table row. |
|
597 * |
|
598 * @since 4.3.0 |
|
599 * |
|
600 * @param WP_Theme $item The current WP_Theme object. |
|
601 */ |
|
602 public function single_row_columns( $item ) { |
|
603 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
379 |
604 |
380 foreach ( $columns as $column_name => $column_display_name ) { |
605 foreach ( $columns as $column_name => $column_display_name ) { |
381 $style = ''; |
606 $extra_classes = ''; |
382 if ( in_array( $column_name, $hidden ) ) |
607 if ( in_array( $column_name, $hidden ) ) { |
383 $style = ' style="display:none;"'; |
608 $extra_classes .= ' hidden'; |
|
609 } |
384 |
610 |
385 switch ( $column_name ) { |
611 switch ( $column_name ) { |
386 case 'cb': |
612 case 'cb': |
387 echo "<th scope='row' class='check-column'>$checkbox</th>"; |
613 echo '<th scope="row" class="check-column">'; |
388 break; |
614 |
|
615 $this->column_cb( $item ); |
|
616 |
|
617 echo '</th>'; |
|
618 break; |
|
619 |
389 case 'name': |
620 case 'name': |
390 echo "<td class='theme-title'$style><strong>" . $theme->display('Name') . "</strong>"; |
621 |
391 echo $this->row_actions( $actions, true ); |
622 $active_theme_label = ''; |
|
623 |
|
624 /* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */ |
|
625 if ( ! empty( $this->site_id ) ) { |
|
626 $stylesheet = get_blog_option( $this->site_id, 'stylesheet' ); |
|
627 $template = get_blog_option( $this->site_id, 'template' ); |
|
628 |
|
629 /* Add a label for the active template */ |
|
630 if ( $item->get_template() === $template ) { |
|
631 $active_theme_label = ' — ' . __( 'Active Theme' ); |
|
632 } |
|
633 |
|
634 /* In case this is a child theme, label it properly */ |
|
635 if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet) { |
|
636 $active_theme_label = ' — ' . __( 'Active Child Theme' ); |
|
637 } |
|
638 } |
|
639 |
|
640 echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display( 'Name' ) . $active_theme_label . '</strong>'; |
|
641 |
|
642 $this->column_name( $item ); |
|
643 |
392 echo "</td>"; |
644 echo "</td>"; |
393 break; |
645 break; |
|
646 |
394 case 'description': |
647 case 'description': |
395 echo "<td class='column-description desc'$style>"; |
648 echo "<td class='column-description desc{$extra_classes}'>"; |
396 if ( $theme->errors() ) { |
649 |
397 $pre = $status == 'broken' ? __( 'Broken Theme:' ) . ' ' : ''; |
650 $this->column_description( $item ); |
398 echo '<p><strong class="attention">' . $pre . $theme->errors()->get_error_message() . '</strong></p>'; |
651 |
399 } |
652 echo '</td>'; |
400 echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
|
401 <div class='$class second theme-version-author-uri'>"; |
|
402 |
|
403 $theme_meta = array(); |
|
404 |
|
405 if ( $theme->get('Version') ) |
|
406 $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display('Version') ); |
|
407 |
|
408 $theme_meta[] = sprintf( __( 'By %s' ), $theme->display('Author') ); |
|
409 |
|
410 if ( $theme->get('ThemeURI') ) |
|
411 $theme_meta[] = '<a href="' . $theme->display('ThemeURI') . '" title="' . esc_attr__( 'Visit theme homepage' ) . '">' . __( 'Visit Theme Site' ) . '</a>'; |
|
412 |
|
413 /** |
|
414 * Filter the array of row meta for each theme in the Multisite themes |
|
415 * list table. |
|
416 * |
|
417 * @since 3.1.0 |
|
418 * |
|
419 * @param array $theme_meta An array of the theme's metadata, |
|
420 * including the version, author, and |
|
421 * theme URI. |
|
422 * @param string $stylesheet Directory name of the theme. |
|
423 * @param WP_Theme $theme WP_Theme object. |
|
424 * @param string $status Status of the theme. |
|
425 */ |
|
426 $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
|
427 echo implode( ' | ', $theme_meta ); |
|
428 |
|
429 echo "</div></td>"; |
|
430 break; |
653 break; |
431 |
654 |
432 default: |
655 default: |
433 echo "<td class='$column_name column-$column_name'$style>"; |
656 echo "<td class='$column_name column-$column_name{$extra_classes}'>"; |
434 |
657 |
435 /** |
658 $this->column_default( $item, $column_name ); |
436 * Fires inside each custom column of the Multisite themes list table. |
659 |
437 * |
|
438 * @since 3.1.0 |
|
439 * |
|
440 * @param string $column_name Name of the column. |
|
441 * @param string $stylesheet Directory name of the theme. |
|
442 * @param WP_Theme $theme Current WP_Theme object. |
|
443 */ |
|
444 do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); |
|
445 echo "</td>"; |
660 echo "</td>"; |
446 } |
661 break; |
447 } |
662 } |
|
663 } |
|
664 } |
|
665 |
|
666 /** |
|
667 * @global string $status |
|
668 * @global array $totals |
|
669 * |
|
670 * @param WP_Theme $theme |
|
671 */ |
|
672 public function single_row( $theme ) { |
|
673 global $status, $totals; |
|
674 |
|
675 if ( $this->is_site_themes ) { |
|
676 $allowed = $theme->is_allowed( 'site', $this->site_id ); |
|
677 } else { |
|
678 $allowed = $theme->is_allowed( 'network' ); |
|
679 } |
|
680 |
|
681 $stylesheet = $theme->get_stylesheet(); |
|
682 |
|
683 $class = ! $allowed ? 'inactive' : 'active'; |
|
684 if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
|
685 $class .= ' update'; |
|
686 } |
|
687 |
|
688 printf( '<tr class="%s" data-slug="%s">', |
|
689 esc_attr( $class ), |
|
690 esc_attr( $stylesheet ) |
|
691 ); |
|
692 |
|
693 $this->single_row_columns( $theme ); |
448 |
694 |
449 echo "</tr>"; |
695 echo "</tr>"; |
450 |
696 |
451 if ( $this->is_site_themes ) |
697 if ( $this->is_site_themes ) |
452 remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
698 remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |