diff --git a/src/wp-admin/css/edit.css b/src/wp-admin/css/edit.css index e37f378852..0ed9b84190 100644 --- a/src/wp-admin/css/edit.css +++ b/src/wp-admin/css/edit.css @@ -863,33 +863,21 @@ span.wp-media-buttons-icon:before { 11.4 - Post formats ------------------------------------------------------------------------------*/ -.post-state-format { - overflow: hidden; +.post-format-icon::before { display: inline-block; vertical-align: middle; height: 20px; width: 20px; - margin-right: 5px; margin-top: -4px; -} - -.post-state-format:before { - display: block; - height: 20px; - width: 20px; - font: normal 20px/1 dashicons !important; + margin-right: 7px; + color: #ddd; + font: normal 20px/1 dashicons; speak: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; -} - -.post-state-format:before, -.post-format-icon:before { - color: #ddd; transition: all .1s ease-in-out; } -a.post-state-format:hover:before, a.post-format-icon:hover:before { color: #00a0d2; } @@ -898,7 +886,7 @@ a.post-format-icon:hover:before { line-height: 2em; } -#post-formats-select .post-format-icon:before { +#post-formats-select .post-format-icon::before { top: 5px; } @@ -907,77 +895,47 @@ input.post-format { } label.post-format-icon { - margin-left: 0px; - padding: 2px 0 2px 0px; + margin-left: 0; + padding: 2px 0; } -.post-format-icon:before { - position: relative; - display: inline-block; - margin-right: 7px; - font: normal 20px/1 dashicons; - speak: none; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -.post-state-format.post-format-standard:before, -.post-format-icon.post-format-standard:before, -a.post-state-format.format-standard:before { +.post-format-icon.post-format-standard::before { content: "\f109"; } -.post-state-format.post-format-image:before, -.post-format-icon.post-format-image:before, -a.post-state-format.format-image:before { +.post-format-icon.post-format-image::before { content: "\f128"; } -.post-state-format.post-format-gallery:before, -.post-format-icon.post-format-gallery:before, -a.post-state-format.format-gallery:before { +.post-format-icon.post-format-gallery::before { content: "\f161"; } -.post-state-format.post-format-audio:before, -.post-format-icon.post-format-audio:before, -a.post-state-format.format-audio:before { +.post-format-icon.post-format-audio::before { content: "\f127"; } -.post-state-format.post-format-video:before, -.post-format-icon.post-format-video:before, -a.post-state-format.format-video:before { +.post-format-icon.post-format-video::before { content: "\f126"; } -.post-state-format.post-format-chat:before, -.post-format-icon.post-format-chat:before, -a.post-state-format.format-chat:before { +.post-format-icon.post-format-chat::before { content: "\f125"; } -.post-state-format.post-format-status:before, -.post-format-icon.post-format-status:before, -a.post-state-format.format-status:before { +.post-format-icon.post-format-status::before { content: "\f130"; } -.post-state-format.post-format-aside:before, -.post-format-icon.post-format-aside:before, -a.post-state-format.format-aside:before { +.post-format-icon.post-format-aside::before { content: "\f123"; } -.post-state-format.post-format-quote:before, -.post-format-icon.post-format-quote:before, -a.post-state-format.format-quote:before { +.post-format-icon.post-format-quote::before { content: "\f122"; } -.post-state-format.post-format-link:before, -.post-format-icon.post-format-link:before, -a.post-state-format.format-link:before { +.post-format-icon.post-format-link::before { content: "\f103"; } diff --git a/src/wp-admin/css/ie.css b/src/wp-admin/css/ie.css index 1719b1839e..00853ab7c8 100644 --- a/src/wp-admin/css/ie.css +++ b/src/wp-admin/css/ie.css @@ -471,12 +471,6 @@ div#dashboard-widgets { display: inline; } -a.post-state-format { - text-indent: 0; - line-height: 0; - font-size: 0; -} - table.ie-fixed { table-layout: fixed; } diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 00c4b7b146..b6dac84bc8 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -458,6 +458,66 @@ class WP_Posts_List_Table extends WP_List_Table { } } + /** + * Displays a formats drop-down for filtering items. + * + * @since 5.2.0 + * @access protected + * + * @param string $post_type Post type key. + */ + protected function formats_dropdown( $post_type ) { + /** + * Filters whether to remove the 'Formats' drop-down from the post list table. + * + * @since 5.2.0 + * + * @param bool $disable Whether to disable the drop-down. Default false. + */ + if ( apply_filters( 'disable_formats_dropdown', false ) ) { + return; + } + + // Make sure the dropdown shows only formats with a post count greater than 0. + $used_post_formats = get_terms( + array( + 'taxonomy' => 'post_format', + 'hide_empty' => true, + ) + ); + + /* + * Return if the post type doesn't have post formats, or there are no posts using formats, + * or if we're in the trash. + */ + if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) { + return; + } + + $displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; + ?> + + + months_dropdown( $this->screen->post_type ); $this->categories_dropdown( $this->screen->post_type ); + $this->formats_dropdown( $this->screen->post_type ); /** * Fires before the Filter button on the Posts and Pages list tables. @@ -943,25 +1004,15 @@ class WP_Posts_List_Table extends WP_List_Table { $pad = str_repeat( '— ', $this->current_level ); echo ''; - $format = get_post_format( $post->ID ); - if ( $format ) { - $label = get_post_format_string( $format ); - - $format_class = 'post-state-format post-format-icon post-format-' . $format; - - $format_args = array( - 'post_format' => $format, - 'post_type' => $post->post_type, - ); - - echo $this->get_edit_link( $format_args, $label . ':', $format_class ); - } + $format = get_post_format( $post->ID ); + $format_classes = ( $format ) ? 'post-format-icon post-format-' . esc_attr( $format ) : ''; $title = _draft_or_post_title(); if ( $can_edit_post && $post->post_status != 'trash' ) { printf( - '%s%s', + '%s%s', + $format_classes, get_edit_post_link( $post->ID ), /* translators: %s: post title */ esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), @@ -969,7 +1020,12 @@ class WP_Posts_List_Table extends WP_List_Table { $title ); } else { - echo $pad . $title; + printf( + '%s%s', + $format_classes, + $pad, + $title + ); } _post_states( $post );