mirror of
https://github.com/pronamic/woocommerce-subscriptions.git
synced 2025-10-17 14:52:56 +00:00
2.0.19
This commit is contained in:
@@ -116,9 +116,9 @@ function wc_next_scheduled_action( $hook, $args = NULL, $group = '' ) {
|
||||
* @param array $args Possible arguments, with their default values:
|
||||
* 'hook' => '' - the name of the action that will be triggered
|
||||
* 'args' => NULL - the args array that will be passed with the action
|
||||
* 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
|
||||
* 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
||||
* 'date_compare' => '<=' - operator for testing "date". accepted values are '!=', '>', '>=', '<', '<=', '='
|
||||
* 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
|
||||
* 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). Used in UTC timezone.
|
||||
* 'modified_compare' => '<=' - operator for testing "modified". accepted values are '!=', '>', '>=', '<', '<=', '='
|
||||
* 'group' => '' - the group the action belongs to
|
||||
* 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING
|
||||
@@ -136,7 +136,7 @@ function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
|
||||
$store = ActionScheduler::store();
|
||||
foreach ( array('date', 'modified') as $key ) {
|
||||
if ( isset($args[$key]) ) {
|
||||
$args[$key] = ActionScheduler::get_datetime_object($args[$key]);
|
||||
$args[$key] = as_get_datetime_object($args[$key]);
|
||||
}
|
||||
}
|
||||
$ids = $store->query_actions( $args );
|
||||
@@ -157,4 +157,32 @@ function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to create an instance of DateTime based on a given
|
||||
* string and timezone. By default, will return the current date/time
|
||||
* in the UTC timezone.
|
||||
*
|
||||
* Needed because new DateTime() called without an explicit timezone
|
||||
* will create a date/time in PHP's timezone, but we need to have
|
||||
* assurance that a date/time uses the right timezone (which we almost
|
||||
* always want to be UTC), which means we need to always include the
|
||||
* timezone when instantiating datetimes rather than leaving it up to
|
||||
* the PHP default.
|
||||
*
|
||||
* @param mixed $date_string A date/time string. Valid formats are explained in http://php.net/manual/en/datetime.formats.php
|
||||
* @param string $timezone A timezone identifier, like UTC or Europe/Lisbon. The list of valid identifiers is available http://php.net/manual/en/timezones.php
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {
|
||||
if ( is_object($date_string) && $date_string instanceof DateTime ) {
|
||||
$date = $date_string->setTimezone(new DateTimeZone( $timezone ) );
|
||||
} elseif ( is_numeric( $date_string ) ) {
|
||||
$date = new DateTime( '@'.$date_string, new DateTimeZone( $timezone ) );
|
||||
} else {
|
||||
$date = new DateTime( $date_string, new DateTimeZone( $timezone ) );
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
Reference in New Issue
Block a user