Skip to content

Commit 6f8c4e3

Browse files
committed
Rename function and improve docblock
Rename wp_get_media_library_months_with_files() to wp_get_media_library_attachment_months() for clarity and improve the docblock with a usage example and a return description focused on purpose rather than shape.
1 parent ce3c55a commit 6f8c4e3

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/wp-includes/media.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4870,7 +4870,7 @@ function wp_enqueue_media( $args = array() ) {
48704870
* Allows overriding the list of months displayed in the media library.
48714871
*
48724872
* By default, if this filter does not return an array,
4873-
* {@see wp_get_media_library_months_with_files()} will run a query to determine
4873+
* {@see wp_get_media_library_attachment_months()} will run a query to determine
48744874
* the months that have media items. The result is stored in a transient
48754875
* and automatically invalidated when attachments are created, updated,
48764876
* or deleted.
@@ -4886,7 +4886,7 @@ function wp_enqueue_media( $args = array() ) {
48864886
if ( ! is_array( $months ) ) {
48874887
$months = get_transient( 'media_library_months_with_files' );
48884888
if ( false === $months ) {
4889-
$months = wp_get_media_library_months_with_files();
4889+
$months = wp_get_media_library_attachment_months();
48904890
set_transient( 'media_library_months_with_files', $months );
48914891
}
48924892
}
@@ -5151,15 +5151,24 @@ function wp_enqueue_media( $args = array() ) {
51515151
}
51525152

51535153
/**
5154-
* Retrieves the months that have media items.
5154+
* Retrieves the months that have media library attachments.
5155+
*
5156+
* Example:
5157+
*
5158+
* $months = wp_get_media_library_attachment_months();
5159+
* // Returns e.g.:
5160+
* // array(
5161+
* // (object) array( 'year' => '2025', 'month' => '2' ),
5162+
* // (object) array( 'year' => '2024', 'month' => '11' ),
5163+
* // )
51555164
*
51565165
* @since tbd
51575166
*
51585167
* @global wpdb $wpdb WordPress database abstraction object.
51595168
*
5160-
* @return array<int, object{year: string, month: string}> Array of objects with `month` and `year` properties.
5169+
* @return array<int, object{year: string, month: string}> Months with associated attachment post dates.
51615170
*/
5162-
function wp_get_media_library_months_with_files(): array {
5171+
function wp_get_media_library_attachment_months(): array {
51635172
global $wpdb;
51645173
return $wpdb->get_results(
51655174
$wpdb->prepare(

0 commit comments

Comments
 (0)