Automattic\WooCommerce\Internal\Admin\Orders

ListTable::set_date_args()privateWC 1.0

Implements date (month-based) filtering.

Method of the class: ListTable{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->set_date_args();

ListTable::set_date_args() code WC 8.7.0

private function set_date_args() {
	$year_month = sanitize_text_field( wp_unslash( $_GET['m'] ?? '' ) );

	if ( empty( $year_month ) || ! preg_match( '/^[0-9]{6}$/', $year_month ) ) {
		return;
	}

	$year  = (int) substr( $year_month, 0, 4 );
	$month = (int) substr( $year_month, 4, 2 );

	if ( $month < 0 || $month > 12 ) {
		return;
	}

	$last_day_of_month                      = date_create( "$year-$month" )->format( 'Y-m-t' );
	$this->order_query_args['date_created'] = "$year-$month-01..." . $last_day_of_month;
	$this->has_filter                       = true;
}