Automattic\WooCommerce\Internal\Admin\Orders
ListTable::months_filter()
Render the months filter dropdown.
Method of the class: ListTable{}
Hooks from the method
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->months_filter();
ListTable::months_filter() ListTable::months filter code WC 9.7.1
private function months_filter() { global $wp_locale; // XXX: [review] we may prefer to move this logic outside of the ListTable class. /** * Filters whether to remove the 'Months' drop-down from the order list table. * * @since 8.6.0 * * @param bool $disable Whether to disable the drop-down. Default false. */ if ( apply_filters( 'woocommerce_' . $this->order_type . '_list_table_disable_months_filter', false ) ) { return; } $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; echo '<select name="m" id="filter-by-date">'; echo '<option ' . selected( $m, 0, false ) . ' value="0">' . esc_html__( 'All dates', 'woocommerce' ) . '</option>'; $order_dates = $this->get_and_maybe_update_months_filter_cache(); foreach ( $order_dates as $date ) { $month = zeroise( $date->month, 2 ); $month_year_text = sprintf( /* translators: 1: Month name, 2: 4-digit year. */ esc_html_x( '%1$s %2$d', 'order dates dropdown', 'woocommerce' ), $wp_locale->get_month( $month ), $date->year ); printf( '<option %1$s value="%2$s">%3$s</option>\n', selected( $m, $date->year . $month, false ), esc_attr( $date->year . $month ), esc_html( $month_year_text ) ); } echo '</select>'; }