WordPress.org

Make WordPress Core

Ticket #43820: 43820.diff

File 43820.diff, 1.1 KB (added by audrasjb, 2 years ago)

Adds Mine filter in list-table media view

  • src/wp-admin/includes/class-wp-media-list-table.php

    diff --git a/src/wp-admin/includes/class-wp-media-list-table.php b/src/wp-admin/includes/class-wp-media-list-table.php
    index 4b29ba6..f022cd3 100644
    a b class WP_Media_List_Table extends WP_List_Table { 
    130130                                _x( 'Trash', 'attachment filter' )
    131131                        );
    132132                }
     133
     134                $type_links['mine'] = sprintf(
     135                        '<option value="mine"%s>%s</option>',
     136                        selected( 'mine' === $filter, true, false ),
     137                        __( 'Mine' )
     138                );
     139
    133140                return $type_links;
    134141        }
    135142
  • src/wp-admin/includes/post.php

    diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php
    index 67ce58c..392fea9 100644
    a b function wp_edit_attachments_query_vars( $q = false ) { 
    12111211                $q['post_parent'] = 0;
    12121212        }
    12131213
     1214        if ( isset( $q['mine'] ) || ( isset( $q['attachment-filter'] ) && 'mine' == $q['attachment-filter'] ) ) {
     1215                $q['author'] = get_current_user_id();
     1216        }
     1217
    12141218        // Filter query clauses to include filenames.
    12151219        if ( isset( $q['s'] ) ) {
    12161220                add_filter( 'posts_clauses', '_filter_query_attachment_filenames' );