WP_Media_List_Table::get_views() WordPress Method
The WP_Media_List_Table::get_views() method is used to generate the list of available views for a list table. Views are used to filter the list table data. The method accepts an array of views as input and outputs an array of links to the views.
WP_Media_List_Table::get_views() #
Return
(array)
Source
File: wp-admin/includes/class-wp-media-list-table.php
protected function get_views() { global $post_mime_types, $avail_post_mime_types; $type_links = array(); $filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter']; $type_links['all'] = sprintf( '<option value=""%s>%s</option>', selected( $filter, true, false ), __( 'All media items' ) ); foreach ( $post_mime_types as $mime_type => $label ) { if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { continue; } $selected = selected( $filter && 0 === strpos( $filter, 'post_mime_type:' ) && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), true, false ); $type_links[ $mime_type ] = sprintf( '<option value="post_mime_type:%s"%s>%s</option>', esc_attr( $mime_type ), $selected, $label[0] ); } $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . _x( 'Unattached', 'media items' ) . '</option>'; $type_links['mine'] = sprintf( '<option value="mine"%s>%s</option>', selected( 'mine' === $filter, true, false ), _x( 'Mine', 'media items' ) ); if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) { $type_links['trash'] = sprintf( '<option value="trash"%s>%s</option>', selected( 'trash' === $filter, true, false ), _x( 'Trash', 'attachment filter' ) ); } return $type_links; }
Expand full source codeCollapse full source codeView on TracView on GitHub