- 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-plugins-list-table.php
r47808 r47835 17 17 */ 18 18 class WP_Plugins_List_Table extends WP_List_Table { 19 /** 20 * Whether to show the auto-updates UI. 21 * 22 * @since 5.5.0 23 * 24 * @var bool True if auto-updates UI is to be shown, false otherwise. 25 */ 26 protected $show_autoupdates = true; 19 27 20 28 /** … … 40 48 ); 41 49 42 $status_whitelist = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' );50 $status_whitelist = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' ); 43 51 44 52 $status = 'all'; … … 52 60 53 61 $page = $this->get_pagenum(); 62 63 $this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'plugin' ) && 64 current_user_can( 'update_plugins' ) && 65 ( ! is_multisite() || $this->screen->in_admin( 'network' ) ); 54 66 } 55 67 … … 104 116 'paused' => array(), 105 117 ); 118 if ( $this->show_autoupdates ) { 119 $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); 120 121 $plugins['auto-update-enabled'] = array(); 122 $plugins['auto-update-disabled'] = array(); 123 } 106 124 107 125 $screen = $this->screen; … … 234 252 $plugins['inactive'][ $plugin_file ] = $plugin_data; 235 253 } 254 255 if ( $this->show_autoupdates ) { 256 if ( in_array( $plugin_file, $auto_updates, true ) ) { 257 $plugins['auto-update-enabled'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; 258 } else { 259 $plugins['auto-update-disabled'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; 260 } 261 } 236 262 } 237 263 … … 400 426 global $status; 401 427 402 returnarray(428 $columns = array( 403 429 'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '<input type="checkbox" />' : '', 404 430 'name' => __( 'Plugin' ), 405 431 'description' => __( 'Description' ), 406 432 ); 433 434 if ( $this->show_autoupdates ) { 435 $columns['auto-updates'] = __( 'Automatic Updates' ); 436 } 437 438 return $columns; 407 439 } 408 440 … … 494 526 ); 495 527 break; 528 case 'auto-update-enabled': 529 /* translators: %s: Number of plugins. */ 530 $text = _n( 531 'Auto-updates Enabled <span class="count">(%s)</span>', 532 'Auto-updates Enabled <span class="count">(%s)</span>', 533 $count 534 ); 535 break; 536 case 'auto-update-disabled': 537 /* translators: %s: Number of plugins. */ 538 $text = _n( 539 'Auto-updates Disabled <span class="count">(%s)</span>', 540 'Auto-updates Disabled <span class="count">(%s)</span>', 541 $count 542 ); 543 break; 496 544 } 497 545 … … 533 581 if ( current_user_can( 'delete_plugins' ) && ( 'active' !== $status ) ) { 534 582 $actions['delete-selected'] = __( 'Delete' ); 583 } 584 585 if ( $this->show_autoupdates ) { 586 if ( 'auto-update-enabled' !== $status ) { 587 $actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' ); 588 } 589 if ( 'auto-update-disabled' !== $status ) { 590 $actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' ); 591 } 535 592 } 536 593 } … … 882 939 883 940 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); 941 942 $auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); 943 $available_updates = get_site_transient( 'update_plugins' ); 884 944 885 945 foreach ( $columns as $column_name => $column_display_name ) { … … 975 1035 echo '</td>'; 976 1036 break; 1037 case 'auto-updates': 1038 if ( ! $this->show_autoupdates ) { 1039 break; 1040 } 1041 1042 echo "<td class='column-auto-updates{$extra_classes}'>"; 1043 1044 if ( in_array( $plugin_file, $auto_updates, true ) ) { 1045 $text = __( 'Disable auto-updates' ); 1046 $action = 'disable'; 1047 $time_class = ''; 1048 } else { 1049 $text = __( 'Enable auto-updates' ); 1050 $action = 'enable'; 1051 $time_class = ' hidden'; 1052 } 1053 1054 $query_args = array( 1055 'action' => "{$action}-auto-update", 1056 'plugin' => $plugin_file, 1057 'paged' => $page, 1058 'plugin_status' => $status, 1059 ); 1060 1061 $url = add_query_arg( $query_args, 'plugins.php' ); 1062 1063 printf( 1064 '<a href="%s" class="toggle-auto-update" data-wp-action="%s">', 1065 wp_nonce_url( $url, 'updates' ), 1066 $action 1067 ); 1068 1069 echo '<span class="dashicons dashicons-update spin hidden"></span>'; 1070 echo '<span class="label">' . $text . '</span>'; 1071 echo '</a>'; 1072 1073 $available_updates = get_site_transient( 'update_plugins' ); 1074 1075 if ( isset( $available_updates->response[ $plugin_file ] ) ) { 1076 printf( 1077 '<div class="auto-update-time%s">%s</div>', 1078 $time_class, 1079 wp_get_auto_update_message() 1080 ); 1081 } 1082 1083 echo '<div class="inline notice error hidden"><p></p></div>'; 1084 echo '</td>'; 1085 1086 break; 977 1087 default: 978 1088 $classes = "$column_name column-$column_name $class"; … … 1001 1111 * 1002 1112 * @since 2.3.0 1113 * @since 5.5.0 Added 'Auto-updates Enabled' and 'Auto-updates Disabled' `$status`. 1003 1114 * 1004 1115 * @param string $plugin_file Path to the plugin file relative to the plugins directory. … … 1006 1117 * @param string $status Status of the plugin. Defaults are 'All', 'Active', 1007 1118 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', 1008 * 'Drop-ins', 'Search', 'Paused'. 1119 * 'Drop-ins', 'Search', 'Paused', 'Auto-updates Enabled', 1120 * 'Auto-updates Disabled'. 1009 1121 */ 1010 1122 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); … … 1017 1129 * 1018 1130 * @since 2.7.0 1131 * @since 5.5.0 Added 'Auto-updates Enabled' and 'Auto-updates Disabled' `$status`. 1019 1132 * 1020 1133 * @param string $plugin_file Path to the plugin file relative to the plugins directory. … … 1022 1135 * @param string $status Status of the plugin. Defaults are 'All', 'Active', 1023 1136 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', 1024 * 'Drop-ins', 'Search', 'Paused'. 1137 * 'Drop-ins', 'Search', 'Paused', 'Auto-updates Enabled', 1138 * 'Auto-updates Disabled'. 1025 1139 */ 1026 1140 do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
Note: See TracChangeset
for help on using the changeset viewer.