WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

ActionScheduler_DBStore::save_action() public WC 1.0

Save an action.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

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

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

Возвращает

int. Action ID.

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

$ActionScheduler_DBStore = new ActionScheduler_DBStore();
$ActionScheduler_DBStore->save_action( $action, $date );
$action(ActionScheduler_Action) (обязательный)
Action object.
$date(DateTime)
Optional schedule date.
По умолчанию: null

Код ActionScheduler_DBStore::save_action() WC 5.8.0

public function save_action( ActionScheduler_Action $action, \DateTime $date = null ) {
	try {

		$this->validate_action( $action );

		/** @var \wpdb $wpdb */
		global $wpdb;
		$data = [
			'hook'                 => $action->get_hook(),
			'status'               => ( $action->is_finished() ? self::STATUS_COMPLETE : self::STATUS_PENDING ),
			'scheduled_date_gmt'   => $this->get_scheduled_date_string( $action, $date ),
			'scheduled_date_local' => $this->get_scheduled_date_string_local( $action, $date ),
			'schedule'             => serialize( $action->get_schedule() ),
			'group_id'             => $this->get_group_id( $action->get_group() ),
		];
		$args = wp_json_encode( $action->get_args() );
		if ( strlen( $args ) <= static::$max_index_length ) {
			$data['args'] = $args;
		} else {
			$data['args']          = $this->hash_args( $args );
			$data['extended_args'] = $args;
		}

		$table_name = ! empty( $wpdb->actionscheduler_actions ) ? $wpdb->actionscheduler_actions : $wpdb->prefix . 'actionscheduler_actions';
		$wpdb->insert( $table_name, $data );
		$action_id = $wpdb->insert_id;

		if ( is_wp_error( $action_id ) ) {
			throw new RuntimeException( $action_id->get_error_message() );
		}
		elseif ( empty( $action_id ) ) {
			throw new RuntimeException( $wpdb->last_error ? $wpdb->last_error : __( 'Database error.', 'woocommerce' ) );
		}

		do_action( 'action_scheduler_stored_action', $action_id );

		return $action_id;
	} catch ( \Exception $e ) {
		/* translators: %s: error message */
		throw new \RuntimeException( sprintf( __( 'Error saving action: %s', 'woocommerce' ), $e->getMessage() ), 0 );
	}
}