wp/wp-admin/includes/class-wp-plugins-list-table.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-admin/includes/class-wp-plugins-list-table.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-admin/includes/class-wp-plugins-list-table.php	Tue Dec 15 13:49:49 2020 +0100
@@ -16,6 +16,14 @@
  * @see WP_List_Table
  */
 class WP_Plugins_List_Table extends WP_List_Table {
+	/**
+	 * Whether to show the auto-updates UI.
+	 *
+	 * @since 5.5.0
+	 *
+	 * @var bool True if auto-updates UI is to be shown, false otherwise.
+	 */
+	protected $show_autoupdates = true;
 
 	/**
 	 * Constructor.
@@ -39,8 +47,10 @@
 			)
 		);
 
+		$allowed_statuses = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' );
+
 		$status = 'all';
-		if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused' ) ) ) {
+		if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $allowed_statuses, true ) ) {
 			$status = $_REQUEST['plugin_status'];
 		}
 
@@ -49,6 +59,11 @@
 		}
 
 		$page = $this->get_pagenum();
+
+		$this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'plugin' )
+			&& current_user_can( 'update_plugins' )
+			&& ( ! is_multisite() || $this->screen->in_admin( 'network' ) )
+			&& ! in_array( $status, array( 'mustuse', 'dropins' ), true );
 	}
 
 	/**
@@ -101,6 +116,12 @@
 			'dropins'            => array(),
 			'paused'             => array(),
 		);
+		if ( $this->show_autoupdates ) {
+			$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
+
+			$plugins['auto-update-enabled']  = array();
+			$plugins['auto-update-disabled'] = array();
+		}
 
 		$screen = $this->screen;
 
@@ -159,8 +180,6 @@
 			$show_network_active = apply_filters( 'show_network_active_plugins', $show );
 		}
 
-		set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
-
 		if ( $screen->in_admin( 'network' ) ) {
 			$recently_activated = get_site_option( 'recently_activated', array() );
 		} else {
@@ -184,42 +203,69 @@
 		foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
 			// Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
 			if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
-				$plugin_data                    = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
-				$plugins['all'][ $plugin_file ] = $plugin_data;
-				// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
-				if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
-					$plugins['upgrade'][ $plugin_file ] = $plugin_data;
-				}
+				$plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], array( 'update-supported' => true ), $plugin_data );
 			} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
-				$plugin_data                    = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
-				$plugins['all'][ $plugin_file ] = $plugin_data;
-				// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
-				if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
-					$plugins['upgrade'][ $plugin_file ] = $plugin_data;
-				}
+				$plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], array( 'update-supported' => true ), $plugin_data );
+			} elseif ( empty( $plugin_data['update-supported'] ) ) {
+				$plugin_data['update-supported'] = false;
 			}
 
-			// Filter into individual sections
+			/*
+			 * Create the payload that's used for the auto_update_plugin filter.
+			 * This is the same data contained within $plugin_info->(response|no_update) however
+			 * not all plugins will be contained in those keys, this avoids unexpected warnings.
+			 */
+			$filter_payload = array(
+				'id'            => $plugin_file,
+				'slug'          => '',
+				'plugin'        => $plugin_file,
+				'new_version'   => '',
+				'url'           => '',
+				'package'       => '',
+				'icons'         => array(),
+				'banners'       => array(),
+				'banners_rtl'   => array(),
+				'tested'        => '',
+				'requires_php'  => '',
+				'compatibility' => new stdClass(),
+			);
+			$filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) );
+
+			$type = 'plugin';
+			/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
+			$auto_update_forced = apply_filters( "auto_update_{$type}", null, $filter_payload );
+
+			if ( ! is_null( $auto_update_forced ) ) {
+				$plugin_data['auto-update-forced'] = $auto_update_forced;
+			}
+
+			$plugins['all'][ $plugin_file ] = $plugin_data;
+			// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.
+			if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
+				$plugins['upgrade'][ $plugin_file ] = $plugin_data;
+			}
+
+			// Filter into individual sections.
 			if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
 				if ( $show_network_active ) {
-					// On the non-network screen, show inactive network-only plugins if allowed
+					// On the non-network screen, show inactive network-only plugins if allowed.
 					$plugins['inactive'][ $plugin_file ] = $plugin_data;
 				} else {
-					// On the non-network screen, filter out network-only plugins as long as they're not individually active
+					// On the non-network screen, filter out network-only plugins as long as they're not individually active.
 					unset( $plugins['all'][ $plugin_file ] );
 				}
 			} elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
 				if ( $show_network_active ) {
-					// On the non-network screen, show network-active plugins if allowed
+					// On the non-network screen, show network-active plugins if allowed.
 					$plugins['active'][ $plugin_file ] = $plugin_data;
 				} else {
-					// On the non-network screen, filter out network-active plugins
+					// On the non-network screen, filter out network-active plugins.
 					unset( $plugins['all'][ $plugin_file ] );
 				}
 			} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
 				|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
-				// On the non-network screen, populate the active list with plugins that are individually activated
-				// On the network-admin screen, populate the active list with plugins that are network activated
+				// On the non-network screen, populate the active list with plugins that are individually activated.
+				// On the network admin screen, populate the active list with plugins that are network-activated.
 				$plugins['active'][ $plugin_file ] = $plugin_data;
 
 				if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) {
@@ -227,12 +273,25 @@
 				}
 			} else {
 				if ( isset( $recently_activated[ $plugin_file ] ) ) {
-					// Populate the recently activated list with plugins that have been recently activated
+					// Populate the recently activated list with plugins that have been recently activated.
 					$plugins['recently_activated'][ $plugin_file ] = $plugin_data;
 				}
-				// Populate the inactive list with plugins that aren't activated
+				// Populate the inactive list with plugins that aren't activated.
 				$plugins['inactive'][ $plugin_file ] = $plugin_data;
 			}
+
+			if ( $this->show_autoupdates ) {
+				$enabled = in_array( $plugin_file, $auto_updates, true ) && $plugin_data['update-supported'];
+				if ( isset( $plugin_data['auto-update-forced'] ) ) {
+					$enabled = (bool) $plugin_data['auto-update-forced'];
+				}
+
+				if ( $enabled ) {
+					$plugins['auto-update-enabled'][ $plugin_file ] = $plugin_data;
+				} else {
+					$plugins['auto-update-disabled'][ $plugin_file ] = $plugin_data;
+				}
+			}
 		}
 
 		if ( strlen( $s ) ) {
@@ -245,13 +304,13 @@
 			$totals[ $type ] = count( $list );
 		}
 
-		if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) {
+		if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) {
 			$status = 'all';
 		}
 
 		$this->items = array();
 		foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
-			// Translate, Don't Apply Markup, Sanitize HTML
+			// Translate, don't apply markup, sanitize HTML.
 			$this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
 		}
 
@@ -348,7 +407,7 @@
 		if ( ! empty( $_REQUEST['s'] ) ) {
 			$s = esc_html( wp_unslash( $_REQUEST['s'] ) );
 
-			/* translators: %s: plugin search term */
+			/* translators: %s: Plugin search term. */
 			printf( __( 'No plugins found for “%s”.' ), $s );
 
 			// We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link.
@@ -358,7 +417,7 @@
 		} elseif ( ! empty( $plugins['all'] ) ) {
 			_e( 'No plugins found.' );
 		} else {
-			_e( 'You do not appear to have any plugins available at this time.' );
+			_e( 'No plugins are currently available.' );
 		}
 	}
 
@@ -399,11 +458,17 @@
 	public function get_columns() {
 		global $status;
 
-		return array(
-			'cb'          => ! in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
+		$columns = array(
+			'cb'          => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '<input type="checkbox" />' : '',
 			'name'        => __( 'Plugin' ),
 			'description' => __( 'Description' ),
 		);
+
+		if ( $this->show_autoupdates ) {
+			$columns['auto-updates'] = __( 'Automatic Updates' );
+		}
+
+		return $columns;
 	}
 
 	/**
@@ -429,36 +494,85 @@
 
 			switch ( $type ) {
 				case 'all':
-					/* translators: %s: plugin count */
-					$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
+					/* translators: %s: Number of plugins. */
+					$text = _nx(
+						'All <span class="count">(%s)</span>',
+						'All <span class="count">(%s)</span>',
+						$count,
+						'plugins'
+					);
 					break;
 				case 'active':
-					/* translators: %s: plugin count */
-					$text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Active <span class="count">(%s)</span>',
+						'Active <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'recently_activated':
-					/* translators: %s: plugin count */
-					$text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Recently Active <span class="count">(%s)</span>',
+						'Recently Active <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'inactive':
-					/* translators: %s: plugin count */
-					$text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Inactive <span class="count">(%s)</span>',
+						'Inactive <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'mustuse':
-					/* translators: %s: plugin count */
-					$text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Must-Use <span class="count">(%s)</span>',
+						'Must-Use <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'dropins':
-					/* translators: %s: plugin count */
-					$text = _n( 'Drop-in <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Drop-in <span class="count">(%s)</span>',
+						'Drop-ins <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'paused':
-					/* translators: %s: plugin count */
-					$text = _n( 'Paused <span class="count">(%s)</span>', 'Paused <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Paused <span class="count">(%s)</span>',
+						'Paused <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 				case 'upgrade':
-					/* translators: %s: plugin count */
-					$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Update Available <span class="count">(%s)</span>',
+						'Update Available <span class="count">(%s)</span>',
+						$count
+					);
+					break;
+				case 'auto-update-enabled':
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Auto-updates Enabled <span class="count">(%s)</span>',
+						'Auto-updates Enabled <span class="count">(%s)</span>',
+						$count
+					);
+					break;
+				case 'auto-update-disabled':
+					/* translators: %s: Number of plugins. */
+					$text = _n(
+						'Auto-updates Disabled <span class="count">(%s)</span>',
+						'Auto-updates Disabled <span class="count">(%s)</span>',
+						$count
+					);
 					break;
 			}
 
@@ -484,11 +598,11 @@
 
 		$actions = array();
 
-		if ( 'active' != $status ) {
+		if ( 'active' !== $status ) {
 			$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
 		}
 
-		if ( 'inactive' != $status && 'recent' != $status ) {
+		if ( 'inactive' !== $status && 'recent' !== $status ) {
 			$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
 		}
 
@@ -496,9 +610,19 @@
 			if ( current_user_can( 'update_plugins' ) ) {
 				$actions['update-selected'] = __( 'Update' );
 			}
-			if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) {
+
+			if ( current_user_can( 'delete_plugins' ) && ( 'active' !== $status ) ) {
 				$actions['delete-selected'] = __( 'Delete' );
 			}
+
+			if ( $this->show_autoupdates ) {
+				if ( 'auto-update-enabled' !== $status ) {
+					$actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' );
+				}
+				if ( 'auto-update-disabled' !== $status ) {
+					$actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' );
+				}
+			}
 		}
 
 		return $actions;
@@ -511,7 +635,7 @@
 	public function bulk_actions( $which = '' ) {
 		global $status;
 
-		if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
+		if ( in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
 			return;
 		}
 
@@ -525,24 +649,24 @@
 	protected function extra_tablenav( $which ) {
 		global $status;
 
-		if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ) ) ) {
+		if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ), true ) ) {
 			return;
 		}
 
 		echo '<div class="alignleft actions">';
 
-		if ( 'recently_activated' == $status ) {
+		if ( 'recently_activated' === $status ) {
 			submit_button( __( 'Clear List' ), '', 'clear-recent-list', false );
 		} elseif ( 'top' === $which && 'mustuse' === $status ) {
 			echo '<p>' . sprintf(
-				/* translators: %s: mu-plugins directory name */
+				/* translators: %s: mu-plugins directory name. */
 				__( 'Files in the %s directory are executed automatically.' ),
 				'<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>'
 			) . '</p>';
 		} elseif ( 'top' === $which && 'dropins' === $status ) {
 			echo '<p>' . sprintf(
-				/* translators: %s: wp-content directory name */
-				__( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ),
+				/* translators: %s: wp-content directory name. */
+				__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
 				'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
 			) . '</p>';
 		}
@@ -566,7 +690,7 @@
 	public function display_rows() {
 		global $status;
 
-		if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
+		if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
 			return;
 		}
 
@@ -585,10 +709,24 @@
 	 */
 	public function single_row( $item ) {
 		global $status, $page, $s, $totals;
+		static $plugin_id_attrs = array();
 
 		list( $plugin_file, $plugin_data ) = $item;
-		$context                           = $status;
-		$screen                            = $this->screen;
+
+		$plugin_slug    = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] );
+		$plugin_id_attr = $plugin_slug;
+
+		// Ensure the ID attribute is unique.
+		$suffix = 2;
+		while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) {
+			$plugin_id_attr = "$plugin_slug-$suffix";
+			$suffix++;
+		}
+
+		$plugin_id_attrs[] = $plugin_id_attr;
+
+		$context = $status;
+		$screen  = $this->screen;
 
 		// Pre-order.
 		$actions = array(
@@ -598,7 +736,7 @@
 			'delete'     => '',
 		);
 
-		// Do not restrict by default
+		// Do not restrict by default.
 		$restrict_network_active = false;
 		$restrict_network_only   = false;
 
@@ -610,17 +748,17 @@
 			if ( $plugin_file != $plugin_data['Name'] ) {
 				$plugin_name .= '<br/>' . $plugin_data['Name'];
 			}
-			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
+			if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant.
 				$is_active   = true;
 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
-			} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
+			} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true.
 				$is_active   = true;
 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
 			} else {
 				$is_active   = false;
 				$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' .
 					sprintf(
-						/* translators: 1: drop-in constant name, 2: wp-config.php */
+						/* translators: 1: Drop-in constant name, 2: wp-config.php */
 						__( 'Requires %1$s in %2$s file.' ),
 						"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
 						'<code>wp-config.php</code>'
@@ -641,17 +779,36 @@
 			if ( $screen->in_admin( 'network' ) ) {
 				if ( $is_active ) {
 					if ( current_user_can( 'manage_network_plugins' ) ) {
-						/* translators: %s: plugin name */
-						$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>';
+						$actions['deactivate'] = sprintf(
+							'<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Network Deactivate' )
+						);
 					}
 				} else {
 					if ( current_user_can( 'manage_network_plugins' ) ) {
-						/* translators: %s: plugin name */
-						$actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>';
+						$actions['activate'] = sprintf(
+							'<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Network Activate' )
+						);
 					}
+
 					if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
-						/* translators: %s: plugin name */
-						$actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
+						$actions['delete'] = sprintf(
+							'<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Delete' )
+						);
 					}
 				}
 			} else {
@@ -665,26 +822,51 @@
 					);
 				} elseif ( $is_active ) {
 					if ( current_user_can( 'deactivate_plugin', $plugin_file ) ) {
-						/* translators: %s: plugin name */
-						$actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
+						$actions['deactivate'] = sprintf(
+							'<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Deactivate' )
+						);
 					}
+
 					if ( current_user_can( 'resume_plugin', $plugin_file ) && is_plugin_paused( $plugin_file ) ) {
-						/* translators: %s: plugin name */
-						$actions['resume'] = '<a class="resume-link" href="' . wp_nonce_url( 'plugins.php?action=resume&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'resume-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Resume %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Resume' ) . '</a>';
+						$actions['resume'] = sprintf(
+							'<a href="%s" id="resume-%s" class="resume-link" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=resume&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'resume-plugin_' . $plugin_file ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Resume %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Resume' )
+						);
 					}
 				} else {
 					if ( current_user_can( 'activate_plugin', $plugin_file ) ) {
-						/* translators: %s: plugin name */
-						$actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>';
+						$actions['activate'] = sprintf(
+							'<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Activate' )
+						);
 					}
 
 					if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
-						/* translators: %s: plugin name */
-						$actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
+						$actions['delete'] = sprintf(
+							'<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>',
+							wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ),
+							esc_attr( $plugin_id_attr ),
+							/* translators: %s: Plugin name. */
+							esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ),
+							__( 'Delete' )
+						);
 					}
-				} // end if $is_active
-			} // end if $screen->in_admin( 'network' )
-		} // end if $context
+				} // End if $is_active.
+			} // End if $screen->in_admin( 'network' ).
+		} // End if $context.
 
 		$actions = array_filter( $actions );
 
@@ -765,14 +947,19 @@
 		$compatible_php = is_php_version_compatible( $requires_php );
 		$class          = $is_active ? 'active' : 'inactive';
 		$checkbox_id    = 'checkbox_' . md5( $plugin_data['Name'] );
-		if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) || ! $compatible_php ) {
+		if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) {
 			$checkbox = '';
 		} else {
-			/* translators: %s: plugin name */
-			$checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . '</label>'
-				. "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />";
+			$checkbox = sprintf(
+				'<label class="screen-reader-text" for="%1$s">%2$s</label>' .
+				'<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />',
+				$checkbox_id,
+				/* translators: %s: Plugin name. */
+				sprintf( __( 'Select %s' ), $plugin_data['Name'] ),
+				esc_attr( $plugin_file )
+			);
 		}
-		if ( 'dropins' != $context ) {
+		if ( 'dropins' !== $context ) {
 			$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
 			$plugin_name = $plugin_data['Name'];
 		}
@@ -787,7 +974,10 @@
 			$class .= ' paused';
 		}
 
-		$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
+		if ( is_uninstallable_plugin( $plugin_file ) ) {
+			$class .= ' is-uninstallable';
+		}
+
 		printf(
 			'<tr class="%s" data-slug="%s" data-plugin="%s">',
 			esc_attr( $class ),
@@ -797,9 +987,12 @@
 
 		list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
 
+		$auto_updates      = (array) get_site_option( 'auto_update_plugins', array() );
+		$available_updates = get_site_transient( 'update_plugins' );
+
 		foreach ( $columns as $column_name => $column_display_name ) {
 			$extra_classes = '';
-			if ( in_array( $column_name, $hidden ) ) {
+			if ( in_array( $column_name, $hidden, true ) ) {
 				$extra_classes = ' hidden';
 			}
 
@@ -821,7 +1014,7 @@
 
 					$plugin_meta = array();
 					if ( ! empty( $plugin_data['Version'] ) ) {
-						/* translators: %s: plugin version number */
+						/* translators: %s: Plugin version number. */
 						$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
 					}
 					if ( ! empty( $plugin_data['Author'] ) ) {
@@ -829,11 +1022,11 @@
 						if ( ! empty( $plugin_data['AuthorURI'] ) ) {
 							$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
 						}
-						/* translators: %s: plugin version number */
+						/* translators: %s: Plugin author name. */
 						$plugin_meta[] = sprintf( __( 'By %s' ), $author );
 					}
 
-					// Details link using API info, if available
+					// Details link using API info, if available.
 					if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
 						$plugin_meta[] = sprintf(
 							'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
@@ -843,7 +1036,7 @@
 									'&TB_iframe=true&width=600&height=550'
 								)
 							),
-							/* translators: %s: plugin name */
+							/* translators: %s: Plugin name. */
 							esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ),
 							esc_attr( $plugin_name ),
 							__( 'View details' )
@@ -861,16 +1054,17 @@
 					 *
 					 * @since 2.8.0
 					 *
-					 * @param string[] $plugin_meta An array of the plugin's metadata,
-					 *                              including the version, author,
-					 *                              author URI, and plugin URI.
+					 * @param string[] $plugin_meta An array of the plugin's metadata, including
+					 *                              the version, author, author URI, and plugin URI.
 					 * @param string   $plugin_file Path to the plugin file relative to the plugins directory.
 					 * @param array    $plugin_data An array of plugin data.
-					 * @param string   $status      Status of the plugin. Defaults are 'All', 'Active',
-					 *                              'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
-					 *                              'Drop-ins', 'Search', 'Paused'.
+					 * @param string   $status      Status filter currently applied to the plugin list. Possible
+					 *                              values are: 'all', 'active', 'inactive', 'recently_activated',
+					 *                              'upgrade', 'mustuse', 'dropins', 'search', 'paused',
+					 *                              'auto-update-enabled', 'auto-update-disabled'.
 					 */
 					$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
+
 					echo implode( ' | ', $plugin_meta );
 
 					echo '</div>';
@@ -889,6 +1083,87 @@
 
 					echo '</td>';
 					break;
+				case 'auto-updates':
+					if ( ! $this->show_autoupdates ) {
+						break;
+					}
+
+					echo "<td class='column-auto-updates{$extra_classes}'>";
+
+					$html = array();
+
+					if ( isset( $plugin_data['auto-update-forced'] ) ) {
+						if ( $plugin_data['auto-update-forced'] ) {
+							// Forced on.
+							$text = __( 'Auto-updates enabled' );
+						} else {
+							$text = __( 'Auto-updates disabled' );
+						}
+						$action     = 'unavailable';
+						$time_class = ' hidden';
+					} elseif ( empty( $plugin_data['update-supported'] ) ) {
+						$text       = '';
+						$action     = 'unavailable';
+						$time_class = ' hidden';
+					} elseif ( in_array( $plugin_file, $auto_updates, true ) ) {
+						$text       = __( 'Disable auto-updates' );
+						$action     = 'disable';
+						$time_class = '';
+					} else {
+						$text       = __( 'Enable auto-updates' );
+						$action     = 'enable';
+						$time_class = ' hidden';
+					}
+
+					$query_args = array(
+						'action'        => "{$action}-auto-update",
+						'plugin'        => $plugin_file,
+						'paged'         => $page,
+						'plugin_status' => $status,
+					);
+
+					$url = add_query_arg( $query_args, 'plugins.php' );
+
+					if ( 'unavailable' == $action ) {
+						$html[] = '<span class="label">' . $text . '</span>';
+					} else {
+						$html[] = sprintf(
+							'<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">',
+							wp_nonce_url( $url, 'updates' ),
+							$action
+						);
+
+						$html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>';
+						$html[] = '<span class="label">' . $text . '</span>';
+						$html[] = '</a>';
+					}
+
+					if ( ! empty( $plugin_data['update'] ) ) {
+						$html[] = sprintf(
+							'<div class="auto-update-time%s">%s</div>',
+							$time_class,
+							wp_get_auto_update_message()
+						);
+					}
+
+					$html = implode( '', $html );
+
+					/**
+					 * Filters the HTML of the auto-updates setting for each plugin in the Plugins list table.
+					 *
+					 * @since 5.5.0
+					 *
+					 * @param string $html        The HTML of the plugin's auto-update column content, including
+					 *                            toggle auto-update action links and time to next update.
+					 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
+					 * @param array  $plugin_data An array of plugin data.
+					 */
+					echo apply_filters( 'plugin_auto_update_setting_html', $html, $plugin_file, $plugin_data );
+
+					echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>';
+					echo '</td>';
+
+					break;
 				default:
 					$classes = "$column_name column-$column_name $class";
 
@@ -915,12 +1190,14 @@
 		 * Fires after each row in the Plugins list table.
 		 *
 		 * @since 2.3.0
+		 * @since 5.5.0 Added 'auto-update-enabled' and 'auto-update-disabled' to possible values for `$status`.
 		 *
 		 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
 		 * @param array  $plugin_data An array of plugin data.
-		 * @param string $status      Status of the plugin. Defaults are 'All', 'Active',
-		 *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
-		 *                            'Drop-ins', 'Search', 'Paused'.
+		 * @param string $status      Status filter currently applied to the plugin list. Possible
+		 *                            values are: 'all', 'active', 'inactive', 'recently_activated',
+		 *                            'upgrade', 'mustuse', 'dropins', 'search', 'paused',
+		 *                            'auto-update-enabled', 'auto-update-disabled'.
 		 */
 		do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
 
@@ -931,12 +1208,14 @@
 		 * to the plugin file, relative to the plugins directory.
 		 *
 		 * @since 2.7.0
+		 * @since 5.5.0 Added 'auto-update-enabled' and 'auto-update-disabled' to possible values for `$status`.
 		 *
 		 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
 		 * @param array  $plugin_data An array of plugin data.
-		 * @param string $status      Status of the plugin. Defaults are 'All', 'Active',
-		 *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
-		 *                            'Drop-ins', 'Search', 'Paused'.
+		 * @param string $status      Status filter currently applied to the plugin list. Possible
+		 *                            values are: 'all', 'active', 'inactive', 'recently_activated',
+		 *                            'upgrade', 'mustuse', 'dropins', 'search', 'paused',
+		 *                            'auto-update-enabled', 'auto-update-disabled'.
 		 */
 		do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
 	}