Automattic\WooCommerce\Admin
WCAdminHelper::is_wc_admin_active_in_date_range
Test if WooCommerce Admin has been active within a pre-defined range.
Method of the class: WCAdminHelper{}
No Hooks.
Returns
true|false. Whether or not WooCommerce admin has been active within the range.
Usage
$result = WCAdminHelper::is_wc_admin_active_in_date_range( $range, $custom_start );
- $range(string) (required)
- range available in WC_ADMIN_STORE_AGE_RANGES.
- $custom_start(int)
- custom start in range.
Default: null
WCAdminHelper::is_wc_admin_active_in_date_range() WCAdminHelper::is wc admin active in date range code WC 10.4.3
public static function is_wc_admin_active_in_date_range( $range, $custom_start = null ) {
if ( ! array_key_exists( $range, self::WC_ADMIN_STORE_AGE_RANGES ) ) {
throw new \InvalidArgumentException(
sprintf(
'"%s" range is not supported, use one of: %s',
$range,
implode( ', ', array_keys( self::WC_ADMIN_STORE_AGE_RANGES ) )
)
);
}
$wc_admin_active_for = self::get_wcadmin_active_for_in_seconds();
$range_data = self::WC_ADMIN_STORE_AGE_RANGES[ $range ];
$start = null !== $custom_start ? $custom_start : $range_data['start'];
if ( $range_data && $wc_admin_active_for >= $start ) {
return isset( $range_data['end'] ) ? $wc_admin_active_for < $range_data['end'] : true;
}
return false;
}