- Timestamp:
- 03/21/2019 03:30:52 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-posts-list-table.php
r44822 r44961 460 460 461 461 /** 462 * Displays a formats drop-down for filtering items. 463 * 464 * @since 5.2.0 465 * @access protected 466 * 467 * @param string $post_type Post type key. 468 */ 469 protected function formats_dropdown( $post_type ) { 470 /** 471 * Filters whether to remove the 'Formats' drop-down from the post list table. 472 * 473 * @since 5.2.0 474 * 475 * @param bool $disable Whether to disable the drop-down. Default false. 476 */ 477 if ( apply_filters( 'disable_formats_dropdown', false ) ) { 478 return; 479 } 480 481 // Make sure the dropdown shows only formats with a post count greater than 0. 482 $used_post_formats = get_terms( 483 array( 484 'taxonomy' => 'post_format', 485 'hide_empty' => true, 486 ) 487 ); 488 489 /* 490 * Return if the post type doesn't have post formats, or there are no posts using formats, 491 * or if we're in the trash. 492 */ 493 if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) { 494 return; 495 } 496 497 $displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; 498 ?> 499 <label for="filter-by-format" class="screen-reader-text"><?php _e( 'Filter by post format' ); ?></label> 500 <select name="post_format" id="filter-by-format"> 501 <option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option> 502 <?php 503 foreach ( $used_post_formats as $used_post_format ) { 504 // Post format slug. 505 $slug = str_replace( 'post-format-', '', $used_post_format->slug ); 506 // Pretty, translated version of the post format slug. 507 $pretty_name = get_post_format_string( $slug ); 508 // Skip the standard post format. 509 if ( 'standard' === $slug ) { 510 continue; 511 } 512 ?> 513 <option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option> 514 <?php 515 } 516 ?> 517 </select> 518 <?php 519 } 520 521 /** 462 522 * @param string $which 463 523 */ … … 471 531 $this->months_dropdown( $this->screen->post_type ); 472 532 $this->categories_dropdown( $this->screen->post_type ); 533 $this->formats_dropdown( $this->screen->post_type ); 473 534 474 535 /** … … 944 1005 echo '<strong>'; 945 1006 946 $format = get_post_format( $post->ID ); 947 if ( $format ) { 948 $label = get_post_format_string( $format ); 949 950 $format_class = 'post-state-format post-format-icon post-format-' . $format; 951 952 $format_args = array( 953 'post_format' => $format, 954 'post_type' => $post->post_type, 955 ); 956 957 echo $this->get_edit_link( $format_args, $label . ':', $format_class ); 958 } 1007 $format = get_post_format( $post->ID ); 1008 $format_classes = ( $format ) ? 'post-format-icon post-format-' . esc_attr( $format ) : ''; 959 1009 960 1010 $title = _draft_or_post_title(); … … 962 1012 if ( $can_edit_post && $post->post_status != 'trash' ) { 963 1013 printf( 964 '<a class="row-title" href="%s" aria-label="%s">%s%s</a>', 1014 '<a class="row-title %s" href="%s" aria-label="%s">%s%s</a>', 1015 $format_classes, 965 1016 get_edit_post_link( $post->ID ), 966 1017 /* translators: %s: post title */ … … 970 1021 ); 971 1022 } else { 972 echo $pad . $title; 1023 printf( 1024 '<span class="%s">%s%s</span>', 1025 $format_classes, 1026 $pad, 1027 $title 1028 ); 973 1029 } 974 1030 _post_states( $post );
Note: See TracChangeset
for help on using the changeset viewer.