Automattic\WooCommerce\Internal\Admin\Orders
ListTable::months_filter
Render the months filter dropdown.
Метод класса: ListTable{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->months_filter();
Код ListTable::months_filter() ListTable::months filter WC 10.5.2
private function months_filter() {
global $wp_locale;
/**
* 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_months_filter_options();
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>';
}