diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/includes/class-wp-media-list-table.php --- a/wp/wp-admin/includes/class-wp-media-list-table.php Mon Oct 14 18:06:33 2019 +0200 +++ b/wp/wp-admin/includes/class-wp-media-list-table.php Mon Oct 14 18:28:13 2019 +0200 @@ -42,25 +42,25 @@ $this->modes = array( 'list' => __( 'List View' ), - 'grid' => __( 'Grid View' ) + 'grid' => __( 'Grid View' ), ); - parent::__construct( array( - 'plural' => 'media', - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, - ) ); + parent::__construct( + array( + 'plural' => 'media', + 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, + ) + ); } /** - * * @return bool */ public function ajax_user_can() { - return current_user_can('upload_files'); + return current_user_can( 'upload_files' ); } /** - * * @global WP_Query $wp_query * @global array $post_mime_types * @global array $avail_post_mime_types @@ -71,15 +71,17 @@ list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); - $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; + $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; - $this->set_pagination_args( array( - 'total_items' => $wp_query->found_posts, - 'total_pages' => $wp_query->max_num_pages, - 'per_page' => $wp_query->query_vars['posts_per_page'], - ) ); + $this->set_pagination_args( + array( + 'total_items' => $wp_query->found_posts, + 'total_pages' => $wp_query->max_num_pages, + 'per_page' => $wp_query->query_vars['posts_per_page'], + ) + ); } /** @@ -112,7 +114,7 @@ false ); - $type_links[$mime_type] = sprintf( + $type_links[ $mime_type ] = sprintf( '', esc_attr( $mime_type ), $selected, @@ -128,7 +130,7 @@ _x( 'Mine', 'media items' ) ); - if ( $this->is_trash || ( defined( 'MEDIA_TRASH') && MEDIA_TRASH ) ) { + if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { $type_links['trash'] = sprintf( '', selected( 'trash' === $filter, true, false ), @@ -140,7 +142,6 @@ } /** - * * @return array */ protected function get_bulk_actions() { @@ -148,16 +149,17 @@ if ( MEDIA_TRASH ) { if ( $this->is_trash ) { $actions['untrash'] = __( 'Restore' ); - $actions['delete'] = __( 'Delete Permanently' ); + $actions['delete'] = __( 'Delete Permanently' ); } else { - $actions['trash'] = _x( 'Trash', 'verb' ); + $actions['trash'] = __( 'Move to Trash' ); } } else { $actions['delete'] = __( 'Delete Permanently' ); } - if ( $this->detached ) + if ( $this->detached ) { $actions['attach'] = __( 'Attach' ); + } return $actions; } @@ -169,9 +171,9 @@ if ( 'bar' !== $which ) { return; } -?> + ?>
-is_trash ) { $this->months_dropdown( 'attachment' ); @@ -185,30 +187,32 @@ if ( $this->is_trash && current_user_can( 'edit_others_posts' ) && $this->has_items() ) { submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); - } ?> + } + ?>
-get_views(); $this->screen->render_screen_reader_content( 'heading_views' ); -?> + ?>
view_switcher( $mode ); ?> @@ -248,7 +252,7 @@ ?> -extra_tablenav( 'bar' ); /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ @@ -262,25 +266,24 @@ } echo ''; } -?> + ?>
-
+
- '; /* translators: column name */ - $posts_columns['title'] = _x( 'File', 'column name' ); + $posts_columns['title'] = _x( 'File', 'column name' ); $posts_columns['author'] = __( 'Author' ); $taxonomies = get_taxonomies_for_attachments( 'objects' ); @@ -291,8 +294,8 @@ * * @since 3.5.0 * - * @param array $taxonomies An array of registered taxonomies to show for attachments. - * @param string $post_type The post type. Default 'attachment'. + * @param string[] $taxonomies An array of registered taxonomy names to show for attachments. + * @param string $post_type The post type. Default 'attachment'. */ $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); @@ -309,10 +312,11 @@ } /* translators: column name */ - if ( !$this->detached ) { + if ( ! $this->detached ) { $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); - if ( post_type_supports( 'attachment', 'comments' ) ) + if ( post_type_supports( 'attachment', 'comments' ) ) { $posts_columns['comments'] = '' . __( 'Comments' ) . ''; + } } /* translators: column name */ $posts_columns['date'] = _x( 'Date', 'column name' ); @@ -321,15 +325,14 @@ * * @since 2.5.0 * - * @param array $posts_columns An array of columns displayed in the Media list table. - * @param bool $detached Whether the list table contains media not attached - * to any posts. Default true. + * @param string[] $posts_columns An array of columns displayed in the Media list table. + * @param bool $detached Whether the list table contains media not attached + * to any posts. Default true. */ return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); } /** - * * @return array */ protected function get_sortable_columns() { @@ -350,12 +353,16 @@ * @param WP_Post $post The current WP_Post object. */ public function column_cb( $post ) { - if ( current_user_can( 'edit_post', $post->ID ) ) { ?> - + if ( current_user_can( 'edit_post', $post->ID ) ) { + ?> + - post_mime_type ); - $title = _draft_or_post_title(); - $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); + $title = _draft_or_post_title(); + $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); $link_start = $link_end = ''; if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { @@ -387,9 +394,11 @@ > + if ( $thumb ) : + ?> - @@ -412,8 +421,9 @@ * @param WP_Post $post The current WP_Post object. */ public function column_author( $post ) { - printf( '%s', - esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ), + printf( + '%s', + esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), get_the_author() ); } @@ -441,7 +451,7 @@ $h_time = __( 'Unpublished' ); } else { $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post, false ); + $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 ) ); @@ -473,26 +483,31 @@ } if ( $parent ) { - $title = _draft_or_post_title( $post->post_parent ); + $title = _draft_or_post_title( $post->post_parent ); $parent_type = get_post_type_object( $parent->post_type ); if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { -?> + ?> - + post_parent ) ) { -?> - + + $post->post_parent, - 'media[]' => $post->ID, - '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) - ), 'upload.php' ); + if ( $user_can_edit ) : + $detach_url = add_query_arg( + array( + 'parent_post_id' => $post->post_parent, + 'media[]' => $post->ID, + '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ), + ), + 'upload.php' + ); printf( '
%s', $detach_url, @@ -502,8 +517,10 @@ ); endif; } else { - _e( '(Unattached)' ); ?> - + post_parent ); printf( '
%s', @@ -561,11 +578,12 @@ if ( is_array( $terms ) ) { $out = array(); foreach ( $terms as $t ) { - $posts_in_term_qv = array(); + $posts_in_term_qv = array(); $posts_in_term_qv['taxonomy'] = $taxonomy; - $posts_in_term_qv['term'] = $t->slug; + $posts_in_term_qv['term'] = $t->slug; - $out[] = sprintf( '%s', + $out[] = sprintf( + '%s', esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) ); @@ -593,7 +611,6 @@ } /** - * * @global WP_Post $post */ public function display_rows() { @@ -604,9 +621,10 @@ $this->comment_pending_count = get_pending_comments_num( $post_ids ); - add_filter( 'the_title','esc_html' ); + add_filter( 'the_title', 'esc_html' ); - while ( have_posts() ) : the_post(); + while ( have_posts() ) : + the_post(); if ( ( $this->is_trash && $post->post_status != 'trash' ) || ( ! $this->is_trash && $post->post_status === 'trash' ) @@ -614,11 +632,11 @@ continue; } $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; - ?> + ?> single_row_columns( $post ); ?> - %s', wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), @@ -690,9 +708,8 @@ __( 'Attach' ) ); } - } - else { - if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) { + } else { + if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { $actions['edit'] = sprintf( '%s', get_edit_post_link( $post->ID ), @@ -720,7 +737,7 @@ ); } if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { - $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; + $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; $actions['delete'] = sprintf( '%s', wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), @@ -747,11 +764,11 @@ * * @since 2.8.0 * - * @param array $actions An array of action links for each attachment. - * Default 'Edit', 'Delete Permanently', 'View'. - * @param WP_Post $post WP_Post object for the current attachment. - * @param bool $detached Whether the list table contains media not attached - * to any posts. Default true. + * @param string[] $actions An array of action links for each attachment. + * Default 'Edit', 'Delete Permanently', 'View'. + * @param WP_Post $post WP_Post object for the current attachment. + * @param bool $detached Whether the list table contains media not attached + * to any posts. Default true. */ return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); }