Make WordPress Core


Ignore:
Timestamp:
06/28/2020 02:28:23 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Return early from WP_Posts_List_Table::formats_dropdown() if the post type does not support post formats.

This avoids an unnecessary database query for the post_format taxonomy.

Props Chouby.
Fixes #50496.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r47879 r48203  
    486486        }
    487487
     488        // Return if the post type doesn't have post formats or if we're in the Trash.
     489        if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) {
     490            return;
     491        }
     492
    488493        // Make sure the dropdown shows only formats with a post count greater than 0.
    489494        $used_post_formats = get_terms(
     
    494499        );
    495500
    496         /*
    497          * Return if the post type doesn't have post formats, or there are no posts using formats,
    498          * or if we're in the Trash.
    499          */
    500         if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) {
     501        // Return if there are no posts using formats.
     502        if ( ! $used_post_formats ) {
    501503            return;
    502504        }
Note: See TracChangeset for help on using the changeset viewer.