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. git-svn-id: https://develop.svn.wordpress.org/trunk@48203 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dda16f9096
commit
bd03636941
@ -485,6 +485,11 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return if the post type doesn't have post formats or if we're in the Trash.
|
||||||
|
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure the dropdown shows only formats with a post count greater than 0.
|
// Make sure the dropdown shows only formats with a post count greater than 0.
|
||||||
$used_post_formats = get_terms(
|
$used_post_formats = get_terms(
|
||||||
array(
|
array(
|
||||||
@ -493,11 +498,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
// Return if there are no posts using formats.
|
||||||
* Return if the post type doesn't have post formats, or there are no posts using formats,
|
if ( ! $used_post_formats ) {
|
||||||
* or if we're in the Trash.
|
|
||||||
*/
|
|
||||||
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || ! $used_post_formats || $this->is_trash ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user