diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/class-wp-media-list-table.php --- a/wp/wp-admin/includes/class-wp-media-list-table.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/class-wp-media-list-table.php Tue Dec 15 13:49:49 2020 +0100 @@ -41,8 +41,8 @@ $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); $this->modes = array( - 'list' => __( 'List View' ), - 'grid' => __( 'Grid View' ), + 'list' => __( 'List view' ), + 'grid' => __( 'Grid view' ), ); parent::__construct( @@ -61,20 +61,43 @@ } /** - * @global WP_Query $wp_query + * @global string $mode List table view mode. + * @global WP_Query $wp_query WordPress Query object. * @global array $post_mime_types * @global array $avail_post_mime_types - * @global string $mode */ public function prepare_items() { - global $wp_query, $post_mime_types, $avail_post_mime_types, $mode; + global $mode, $wp_query, $post_mime_types, $avail_post_mime_types; + + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + + // Exclude attachments scheduled for deletion in the next two hours + // if they are for zip packages for interrupted or failed updates. + // See File_Upload_Upgrader class. + $not_in = array(); + + foreach ( _get_cron_array() as $cron ) { + if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) { + $details = reset( $cron['upgrader_scheduled_cleanup'] ); + + if ( ! empty( $details['args'][0] ) ) { + $not_in[] = (int) $details['args'][0]; + } + } + } + + if ( ! empty( $_REQUEST['post__not_in'] ) && is_array( $_REQUEST['post__not_in'] ) ) { + $not_in = array_merge( array_values( $_REQUEST['post__not_in'] ), $not_in ); + } + + if ( ! empty( $not_in ) ) { + $_REQUEST['post__not_in'] = $not_in; + } list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; - $this->set_pagination_args( array( 'total_items' => $wp_query->found_posts, @@ -149,12 +172,12 @@ if ( MEDIA_TRASH ) { if ( $this->is_trash ) { $actions['untrash'] = __( 'Restore' ); - $actions['delete'] = __( 'Delete Permanently' ); + $actions['delete'] = __( 'Delete permanently' ); } else { $actions['trash'] = __( 'Move to Trash' ); } } else { - $actions['delete'] = __( 'Delete Permanently' ); + $actions['delete'] = __( 'Delete permanently' ); } if ( $this->detached ) { @@ -174,16 +197,14 @@ ?>
is_trash ) { - $this->months_dropdown( 'attachment' ); - } + if ( ! $this->is_trash ) { + $this->months_dropdown( 'attachment' ); + } - /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ - do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); + /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ + do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); - submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); - } + submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); @@ -222,7 +243,11 @@ /** */ public function no_items() { - _e( 'No media files found.' ); + if ( $this->is_trash ) { + _e( 'No media files found in Trash.' ); + } else { + _e( 'No media files found.' ); + } } /** @@ -270,8 +295,8 @@
- -
+ + '; - /* translators: column name */ + /* translators: Column name. */ $posts_columns['title'] = _x( 'File', 'column name' ); $posts_columns['author'] = __( 'Author' ); @@ -311,14 +336,14 @@ $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; } - /* translators: column name */ + /* translators: Column name. */ if ( ! $this->detached ) { $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); if ( post_type_supports( 'attachment', 'comments' ) ) { $posts_columns['comments'] = '' . __( 'Comments' ) . ''; } } - /* translators: column name */ + /* translators: Column name. */ $posts_columns['date'] = _x( 'Date', 'column name' ); /** * Filters the Media list table columns. @@ -356,9 +381,10 @@ if ( current_user_can( 'edit_post', $post->ID ) ) { ?> ID, array( 60, 60 ), true, array( 'alt' => '' ) ); - $link_start = $link_end = ''; + $link_start = ''; + $link_end = ''; if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { $link_start = sprintf( '', get_edit_post_link( $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) ); $link_end = ''; @@ -450,16 +477,14 @@ if ( '0000-00-00 00:00:00' === $post->post_date ) { $h_time = __( 'Unpublished' ); } else { - $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post, false ); - if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { - if ( $t_diff < 0 ) { - $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); - } else { - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); - } + $time = get_post_timestamp( $post ); + $time_diff = time() - $time; + + if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { + /* translators: %s: Human-readable time difference. */ + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + $h_time = get_the_time( __( 'Y/m/d' ), $post ); } } @@ -511,7 +536,7 @@ printf( '
%s', $detach_url, - /* translators: %s: title of the post the attachment is attached to */ + /* translators: %s: Title of the post the attachment is attached to. */ esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), __( 'Detach' ) ); @@ -525,7 +550,7 @@ printf( '
%s', $post->ID, - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), __( 'Attach' ) ); @@ -588,7 +613,7 @@ esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) ); } - /* translators: used between list items, there is a space after the comma */ + /* translators: Used between list items, there is a space after the comma. */ echo join( __( ', ' ), $out ); } else { echo '' . get_taxonomy( $taxonomy )->labels->no_terms . ''; @@ -611,7 +636,7 @@ } /** - * @global WP_Post $post + * @global WP_Post $post Global post object. */ public function display_rows() { global $post, $wp_query; @@ -626,8 +651,8 @@ while ( have_posts() ) : the_post(); if ( - ( $this->is_trash && $post->post_status != 'trash' ) - || ( ! $this->is_trash && $post->post_status === 'trash' ) + ( $this->is_trash && 'trash' !== $post->post_status ) + || ( ! $this->is_trash && 'trash' === $post->post_status ) ) { continue; } @@ -654,7 +679,6 @@ /** * @param WP_Post $post * @param string $att_title - * * @return array */ private function _get_row_actions( $post, $att_title ) { @@ -665,7 +689,7 @@ $actions['edit'] = sprintf( '%s', get_edit_post_link( $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), __( 'Edit' ) ); @@ -675,7 +699,7 @@ $actions['trash'] = sprintf( '%s', wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), _x( 'Trash', 'verb' ) ); @@ -685,7 +709,7 @@ '%s', wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), $delete_ays, - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), __( 'Delete Permanently' ) ); @@ -694,7 +718,7 @@ $actions['view'] = sprintf( '%s', get_permalink( $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), __( 'View' ) ); @@ -703,7 +727,7 @@ $actions['attach'] = sprintf( '%s', $post->ID, - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), __( 'Attach' ) ); @@ -713,7 +737,7 @@ $actions['edit'] = sprintf( '%s', get_edit_post_link( $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), __( 'Edit' ) ); @@ -723,7 +747,7 @@ $actions['untrash'] = sprintf( '%s', wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), __( 'Restore' ) ); @@ -731,7 +755,7 @@ $actions['trash'] = sprintf( '%s', wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), _x( 'Trash', 'verb' ) ); @@ -742,7 +766,7 @@ '%s', wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), $delete_ays, - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), __( 'Delete Permanently' ) ); @@ -752,7 +776,7 @@ $actions['view'] = sprintf( '%s', get_permalink( $post->ID ), - /* translators: %s: attachment title */ + /* translators: %s: Attachment title. */ esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), __( 'View' ) ); @@ -781,7 +805,8 @@ * @param object $post Attachment being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. - * @return string Row actions output for media attachments. + * @return string Row actions output for media attachments, or an empty string + * if the current column is not the primary column. */ protected function handle_row_actions( $post, $column_name, $primary ) { if ( $primary !== $column_name ) { @@ -789,6 +814,7 @@ } $att_title = _draft_or_post_title(); + return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); } }