get_results( $wpdb->prepare( " SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month FROM $wpdb->posts WHERE post_type = %s ORDER BY post_date DESC ", 'attachment' ) ); return $library_months_with_files; } /** * Display a monthly dropdown for filtering items * * Adapted from /wp-admin/includes/class-wp-list-table.php function months_dropdown() * * @since 1.20 * * @return array ( value => label ) pairs */ private static function _months_dropdown() { global $wp_locale; $months = self::mla_media_library_months_with_files_filter(); $month_count = count( $months ); $month_array = array( '0' => __( 'Show all dates', 'media-library-assistant' ) ); if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { return $month_array; } foreach ( $months as $arc_row ) { if ( 0 == $arc_row->year ) { continue; } $month = zeroise( $arc_row->month, 2 ); $year = $arc_row->year; $month_array[ esc_attr( $arc_row->year . $month ) ] = /* translators: 1: month name, 2: 4-digit year */ sprintf( __( '%1$s %2$d', 'media-library-assistant' ), $wp_locale->get_month( $month ), $year ); } return apply_filters( 'mla_media_modal_months_dropdown', $month_array, 'attachment' ); } /** * Extract value and text elements from Dropdown HTML option tags * * @since 1.20 * * @param string HTML markup for taxonomy terms dropdown