ActionScheduler_wpPostStore::get_actions_by_group
Get IDs of actions within a certain group and up to a certain date/time.
Метод класса: ActionScheduler_wpPostStore{}
Хуков нет.
Возвращает
Массив. IDs of actions in the appropriate group and before the appropriate time.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_actions_by_group( $group, $limit, $date );
- $group(строка) (обязательный)
- The group to use in finding actions.
- $limit(int) (обязательный)
- The number of actions to retrieve.
- $date(DateTime) (обязательный)
- DateTime object representing cutoff time for actions. Actions retrieved will be up to and including this DateTime.
Код ActionScheduler_wpPostStore::get_actions_by_group() ActionScheduler wpPostStore::get actions by group WC 10.3.5
protected function get_actions_by_group( $group, $limit, DateTime $date ) {
// Ensure the group exists before continuing.
if ( ! term_exists( $group, self::GROUP_TAXONOMY ) ) {
/* translators: %s is the group name */
throw new InvalidArgumentException( sprintf( __( 'The group "%s" does not exist.', 'woocommerce' ), $group ) );
}
// Set up a query for post IDs to use later.
$query = new WP_Query();
$query_args = array(
'fields' => 'ids',
'post_type' => self::POST_TYPE,
'post_status' => ActionScheduler_Store::STATUS_PENDING,
'has_password' => false,
'posts_per_page' => $limit * 3,
'suppress_filters' => true, // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters
'no_found_rows' => true,
'orderby' => array(
'menu_order' => 'ASC',
'date' => 'ASC',
'ID' => 'ASC',
),
'date_query' => array(
'column' => 'post_date_gmt',
'before' => $date->format( 'Y-m-d H:i' ),
'inclusive' => true,
),
'tax_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery
array(
'taxonomy' => self::GROUP_TAXONOMY,
'field' => 'slug',
'terms' => $group,
'include_children' => false,
),
),
);
return $query->query( $query_args );
}