Cache API: Cache the results of `get_uploaded_header_images()`.

Fixes #49446.

Props pbiron, SergeyBiryukov, desrosj.


Built from https://develop.svn.wordpress.org/trunk@48152


git-svn-id: http://core.svn.wordpress.org/trunk@47921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
whyisjake 2020-06-23 23:34:06 +00:00
parent cb553e4747
commit 4f69c150b7
2 changed files with 6 additions and 2 deletions

View File

@ -2200,6 +2200,8 @@ function get_post_states( $post ) {
* @return string Media states string.
*/
function _media_states( $post ) {
static $header_images;
$media_states = array();
$stylesheet = get_option( 'stylesheet' );
@ -2207,7 +2209,9 @@ function _media_states( $post ) {
$meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true );
if ( is_random_header_image() ) {
if ( ! isset( $header_images ) ) {
$header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' );
}
if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) {
$media_states[] = __( 'Header Image' );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48151';
$wp_version = '5.5-alpha-48152';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.