Automattic\WooCommerce\Internal\StockNotifications\Admin
ListTable::display_months_dropdown
Display dates dropdown filter.
Method of the class: ListTable{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->display_months_dropdown();
ListTable::display_months_dropdown() ListTable::display months dropdown code WC 10.3.6
<?php
protected function display_months_dropdown() {
global $wp_locale;
$months = $this->data_store->get_distinct_dates();
if ( ! is_array( $months ) ) {
return;
}
$month_count = count( $months );
if ( $month_count < 1 ) {
return;
}
$m = isset( $_GET['m'] ) ? (int) wp_unslash( $_GET['m'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
?>
<label for="filter-by-date" class="screen-reader-text"><?php esc_html_e( 'Filter by date', 'woocommerce' ); ?></label>
<select name="m" id="filter-by-date">
<option<?php selected( $m, 0 ); ?> value="0"><?php esc_html_e( 'All dates', 'woocommerce' ); ?></option>
<?php
foreach ( $months as $arc_row ) {
if ( 0 === (int) $arc_row->year || 0 === (int) $arc_row->month ) {
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$s: month %2$s: year */
sprintf( esc_html__( '%1$s %2$d', 'woocommerce' ), esc_html( $wp_locale->get_month( $month ) ), esc_html( $year ) )
);
}
?>
</select>
<?php
}