ActionScheduler_DBStore::fetch_action()publicWC 1.0

Retrieve an action.

Метод класса: ActionScheduler_DBStore{}

Хуки из метода

Возвращает

ActionScheduler_Action.

Использование

$ActionScheduler_DBStore = new ActionScheduler_DBStore();
$ActionScheduler_DBStore->fetch_action( $action_id );
$action_id(int) (обязательный)
Action ID.

Код ActionScheduler_DBStore::fetch_action() WC 8.7.0

public function fetch_action( $action_id ) {
	/** @var \wpdb $wpdb */
	global $wpdb;
	$data = $wpdb->get_row(
		$wpdb->prepare(
			"SELECT a.*, g.slug AS `group` FROM {$wpdb->actionscheduler_actions} a LEFT JOIN {$wpdb->actionscheduler_groups} g ON a.group_id=g.group_id WHERE a.action_id=%d",
			$action_id
		)
	);

	if ( empty( $data ) ) {
		return $this->get_null_action();
	}

	if ( ! empty( $data->extended_args ) ) {
		$data->args = $data->extended_args;
		unset( $data->extended_args );
	}

	// Convert NULL dates to zero dates.
	$date_fields = array(
		'scheduled_date_gmt',
		'scheduled_date_local',
		'last_attempt_gmt',
		'last_attempt_gmt',
	);
	foreach ( $date_fields as $date_field ) {
		if ( is_null( $data->$date_field ) ) {
			$data->$date_field = ActionScheduler_StoreSchema::DEFAULT_DATE;
		}
	}

	try {
		$action = $this->make_action_from_db_record( $data );
	} catch ( ActionScheduler_InvalidActionException $exception ) {
		do_action( 'action_scheduler_failed_fetch_action', $action_id, $exception );
		return $this->get_null_action();
	}

	return $action;
}