Guide

Post Publish Pipeline architecture

Sync and async lifecycle hooks for web and REST contexts.

Design

WordPress status transitions are noisy. This plugin normalizes them into predictable actions and skips WP-CLI on purpose — pipeline hooks are for web/REST contexts only.

Flow

Lifecycle tiers

3 relationships
Immediate work on sync; deferred side effects on async.

Sync tier

Runs during the save request. Use for mutations, cache invalidation, and anything the editor or frontend must see immediately.

HookFires when
prc_platform_on_post_initNew post first created
prc_platform_on_incremental_saveSaved while draft or publish
prc_platform_on_publishTransitions to publish
prc_platform_on_updateAlready-published post updated
prc_platform_on_unpublishLeaves publish
prc_platform_on_trash / prc_platform_on_untrashTrash / restore
prc_platform_on_status_transitionCatch-all ($post, $current, $prior, $has_blocks)

Per-post-type variants exist: prc_platform_on_{post_type}_publish, and so on.

Async tier

For terminal lifecycle events, the pipeline enqueues Action Scheduler job prc_platform_post_publish_pipeline_async_dispatch (group prc-post-publish-pipeline) and fires parallel async hooks with a freshly loaded post: prc_platform_async_on_publish, _update, _unpublish, _trash, _untrash, _incremental_save.

prior_status is not available on async hooks. The pipeline does not auto-enqueue incremental_save; consumers enqueue it from sync when work should be deferred.

\PRC\Platform\Post_Publish_Pipeline\enqueue_async_event( $post_id, 'publish' );

Supported events: publish, update, unpublish, untrash, trash, incremental_save.

JavaScript actions

Editor script dispatches @wordpress/hooks actions such as prc-platform.onPostInit, onIncrementalSave, onPublish, onUpdate, onUnpublish, onStatusTransition, and onSiteEdit. Payload shape includes edits, postId, postType, postStatus, priorStatus, isSiteEditor where applicable.

Allowed post types

Default tracked types include post, feature, quiz, fact-sheet, short-read, events, mini-course, press-release, block_module, collections. Extend with:

add_filter( 'prc_platform_post_publish_pipeline_post_types', function ( $types ) {
	$types[] = 'my-cpt';
	return $types;
} );

Skip processing for a write with prc_platform_post_publish_pipeline_should_process (return false).

Was this helpful?