Widgets: Improve performance of has_content method in WP_Widget_Media_Gallery class.
In the method `WP_Widget_Media_Gallery::has_content` call `_prime_post_caches` before the foreach loop. This ensures that the post objects are primed in memory before trying to access the post object in `get_post_type`. Props niravsherasiya7707, spacedmonkey, mukesh27. Fixes #58757. Built from https://develop.svn.wordpress.org/trunk@56512 git-svn-id: http://core.svn.wordpress.org/trunk@56024 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d2a504e6cb
commit
5e21330e7d
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.4-alpha-56511';
|
||||
$wp_version = '6.4-alpha-56512';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -248,6 +248,8 @@ class WP_Widget_Media_Gallery extends WP_Widget_Media {
|
|||
protected function has_content( $instance ) {
|
||||
if ( ! empty( $instance['ids'] ) ) {
|
||||
$attachments = wp_parse_id_list( $instance['ids'] );
|
||||
// Prime attachment post caches.
|
||||
_prime_post_caches( $attachments, false, false );
|
||||
foreach ( $attachments as $attachment ) {
|
||||
if ( 'attachment' !== get_post_type( $attachment ) ) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue