mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@56512 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user