ActionScheduler_wpPostStore::mark_complete()publicWC 1.0

Record that an action was completed.

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

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

Возвращает

null. Ничего.

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

$ActionScheduler_wpPostStore = new ActionScheduler_wpPostStore();
$ActionScheduler_wpPostStore->mark_complete( $action_id );
$action_id(строка) (обязательный)
ID of the completed action.

Код ActionScheduler_wpPostStore::mark_complete() WC 7.1.0

public function mark_complete( $action_id ) {
	$post = get_post( $action_id );
	if ( empty( $post ) || ( self::POST_TYPE !== $post->post_type ) ) {
		/* translators: %s is the action ID */
		throw new InvalidArgumentException( sprintf( __( 'Unidentified action %s', 'woocommerce' ), $action_id ) );
	}
	add_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10, 1 );
	add_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10, 5 );
	$result = wp_update_post(
		array(
			'ID'          => $action_id,
			'post_status' => 'publish',
		),
		true
	);
	remove_filter( 'wp_insert_post_data', array( $this, 'filter_insert_post_data' ), 10 );
	remove_filter( 'pre_wp_unique_post_slug', array( $this, 'set_unique_post_slug' ), 10 );
	if ( is_wp_error( $result ) ) {
		throw new RuntimeException( $result->get_error_message() );
	}

	/**
	 * Fires after a scheduled action has been completed.
	 *
	 * @since 3.4.2
	 *
	 * @param int $action_id Action ID.
	 */
	do_action( 'action_scheduler_completed_action', $action_id );
}