You appear to be a bot. Output may be restricted
Description
Display a monthly dropdown for filtering items
Usage
BW_List_Table::months_dropdown( $post_type );
Parameters
- $post_type
- ( string ) required –
Returns
voidSource
File name: oik/admin/class-bw-list-table.phpLines:
1 to 61 of 61
protected function months_dropdown( $post_type ) { global $wpdb, $wp_locale; /** * Filter whether to remove the 'Months' drop-down from the post list table. * * @since 4.2.0 * * @param bool $disable Whether to disable the drop-down. Default false. * @param string $post_type The post type. */ if ( apply_filters( 'disable_months_dropdown', false, $post_type ) ) { return; } $months = $wpdb->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 ", $post_type ) ); /** * Filter the 'Months' drop-down results. * * @since 3.7.0 * * @param object $months The months drop-down query results. * @param string $post_type The post type. */ $months = apply_filters( 'months_dropdown_results', $months, $post_type ); $month_count = count( $months ); if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) return; $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; ?> <label for="filter-by-date" class="screen-reader-text"><?php _e( 'Filter by date' ); ?></label> <select name="m" id="filter-by-date"> <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> <?php foreach ( $months as $arc_row ) { if ( 0 == $arc_row->year ) continue; $month = zeroise( $arc_row->month, 2 ); $year = $arc_row->year; printf( "<option %s value='%s'>%s</option>\n", selected( $m, $year . $month, false ), esc_attr( $arc_row->year . $month ), /* translators: 1: month name, 2: 4-digit year */ sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) ); } ?> </select> <?php }View on GitHub View on Trac