- Timestamp:
- 05/20/2020 06:47:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php
r47808 r47835 24 24 25 25 /** 26 * Whether to show the auto-updates UI. 27 * 28 * @since 5.5.0 29 * 30 * @var bool True if auto-updates UI is to be shown, false otherwise. 31 */ 32 protected $show_autoupdates = true; 33 34 /** 26 35 * Constructor. 27 36 * … … 46 55 47 56 $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; 48 if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ), true ) ) {57 if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) { 49 58 $status = 'all'; 50 59 } … … 57 66 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 58 67 } 68 69 $this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'theme' ) && 70 ! $this->is_site_themes && current_user_can( 'update_themes' ); 59 71 } 60 72 … … 108 120 ); 109 121 122 if ( $this->show_autoupdates ) { 123 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 124 125 $themes['auto-update-enabled'] = array(); 126 $themes['auto-update-disabled'] = array(); 127 } 128 110 129 if ( $this->is_site_themes ) { 111 130 $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); … … 132 151 $filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; 133 152 $themes[ $filter ][ $key ] = $themes['all'][ $key ]; 153 154 if ( $this->show_autoupdates ) { 155 if ( in_array( $key, $auto_updates, true ) ) { 156 $themes['auto-update-enabled'][ $key ] = $themes['all'][ $key ]; 157 } else { 158 $themes['auto-update-disabled'][ $key ] = $themes['all'][ $key ]; 159 } 160 } 134 161 } 135 162 … … 258 285 */ 259 286 public function get_columns() { 260 returnarray(287 $columns = array( 261 288 'cb' => '<input type="checkbox" />', 262 289 'name' => __( 'Theme' ), 263 290 'description' => __( 'Description' ), 264 291 ); 292 293 if ( $this->show_autoupdates ) { 294 $columns['auto-updates'] = __( 'Automatic Updates' ); 295 } 296 297 return $columns; 265 298 } 266 299 … … 345 378 ); 346 379 break; 380 case 'auto-update-enabled': 381 /* translators: %s: Number of themes. */ 382 $text = _n( 383 'Auto-updates Enabled <span class="count">(%s)</span>', 384 'Auto-updates Enabled <span class="count">(%s)</span>', 385 $count 386 ); 387 break; 388 case 'auto-update-disabled': 389 /* translators: %s: Number of themes. */ 390 $text = _n( 391 'Auto-updates Disabled <span class="count">(%s)</span>', 392 'Auto-updates Disabled <span class="count">(%s)</span>', 393 $count 394 ); 395 break; 347 396 } 348 397 … … 389 438 } 390 439 } 440 441 if ( $this->show_autoupdates ) { 442 if ( 'auto-update-enabled' !== $status ) { 443 $actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' ); 444 } 445 446 if ( 'auto-update-disabled' !== $status ) { 447 $actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' ); 448 } 449 } 450 391 451 return $actions; 392 452 } … … 641 701 642 702 /** 703 * Handles the auto-updates column output. 704 * 705 * @since 5.5.0 706 * 707 * @global string $status 708 * @global int $page 709 * 710 * @param WP_Theme $theme The current WP_Theme object. 711 */ 712 public function column_autoupdates( $theme ) { 713 global $status, $page; 714 715 static $auto_updates, $available_updates; 716 717 if ( ! $auto_updates ) { 718 $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); 719 } 720 if ( ! $available_updates ) { 721 $available_updates = get_site_transient( 'update_themes' ); 722 } 723 724 $stylesheet = $theme->get_stylesheet(); 725 726 if ( in_array( $stylesheet, $auto_updates, true ) ) { 727 $text = __( 'Disable auto-updates' ); 728 $action = 'disable'; 729 $time_class = ''; 730 } else { 731 $text = __( 'Enable auto-updates' ); 732 $action = 'enable'; 733 $time_class = ' hidden'; 734 } 735 736 $query_args = array( 737 'action' => "{$action}-auto-update", 738 'theme' => $stylesheet, 739 'paged' => $page, 740 'theme_status' => $status, 741 ); 742 743 $url = add_query_arg( $query_args, 'themes.php' ); 744 745 printf( 746 '<a href="%s" class="toggle-auto-update" data-wp-action="%s">', 747 wp_nonce_url( $url, 'updates' ), 748 $action 749 ); 750 751 echo '<span class="dashicons dashicons-update spin hidden"></span>'; 752 echo '<span class="label">' . $text . '</span>'; 753 echo '</a>'; 754 755 $available_updates = get_site_transient( 'update_themes' ); 756 if ( isset( $available_updates->response[ $stylesheet ] ) ) { 757 printf( 758 '<div class="auto-update-time%s">%s</div>', 759 $time_class, 760 wp_get_auto_update_message() 761 ); 762 } 763 echo '<div class="auto-updates-error inline notice error hidden"><p></p></div>'; 764 } 765 766 /** 643 767 * Handles default column output. 644 768 * … … 722 846 break; 723 847 848 case 'auto-updates': 849 echo "<td class='column-auto-updates{$extra_classes}'>"; 850 851 $this->column_autoupdates( $item ); 852 853 echo '</td>'; 854 break; 724 855 default: 725 856 echo "<td class='$column_name column-$column_name{$extra_classes}'>";
Note: See TracChangeset
for help on using the changeset viewer.