ActionScheduler_wpPostStore::mark_complete()publicWC 1.0

Record that an action was completed.

Method of the class: ActionScheduler_wpPostStore{}

Hooks from the method

Return

null. Nothing (null).

Usage

$ActionScheduler_wpPostStore = new ActionScheduler_wpPostStore();
$ActionScheduler_wpPostStore->mark_complete( $action_id );
$action_id(string) (required)
ID of the completed action.

ActionScheduler_wpPostStore::mark_complete() code WC 8.7.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 );
}