Automattic\WooCommerce\Internal\Admin\Orders
ListTable::months_filter()
Render the months filter dropdown.
Метод класса: ListTable{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
// private - только в коде основоного (родительского) класса $result = $this->months_filter();
Код ListTable::months_filter() ListTable::months filter WC 7.5.0
private function months_filter() { // XXX: [review] we may prefer to move this logic outside of the ListTable class. global $wp_locale; global $wpdb; $orders_table = esc_sql( OrdersTableDataStore::get_orders_table_name() ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared $order_dates = $wpdb->get_results( " SELECT DISTINCT YEAR( date_created_gmt ) AS year, MONTH( date_created_gmt ) AS month FROM $orders_table WHERE status NOT IN ( 'trash' ) ORDER BY year DESC, month DESC; " ); $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>'; 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>'; }