[wp-trac] [WordPress Trac] #63279: Improve `media_library_months_with_files` inside `wp_enqueue_media()`
WordPress Trac
noreply at wordpress.org
Tue Apr 15 15:31:43 UTC 2025
#63279: Improve `media_library_months_with_files` inside `wp_enqueue_media()`
-------------------------+------------------------------
Reporter: apermo | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 4.7.4
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-------------------------+------------------------------
Comment (by spacedmonkey):
WordPress doesn't do refactors for the sake of refactors. So there to be a
benefit the change, other than code tidiness.
Creating a function would be contain the `media_library_months_with_files`
and add caching would add the benefit.
I would use the `wp_cache_get` / `wp_cache_set` apis, not transients. I
would then delete the cache key, in clean_post_cache like this.
{{{#!php
if ( 'attachment' === $post->post_type ) {
wp_cache_delete( 'cache_key', 'post-queries' );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63279#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list