API / Minn\Runtime / PostWrites

PostWrites final class

Minn\Runtime\PostWrites · public/minn/src/Minn/Runtime/PostWrites.php · 551 lines

Posts written as WordPress's post functions write them: a post stored and changed (its columns through their filters, then its terms, meta and template), published, sent to the trash and back, deleted with what hangs off it, its terms and categories set, made sticky or not; each step with the actions the reference fires in its order, and the cached rows let go.

Public

staticinsert(mixed $postarr, mixed $wpError = false, mixed $fireAfterHooks = true): mixed#

A post stored or changed (wp_insert_post): its id, 0 or the error when it cannot be; the revision is saved from wp_after_insert_post when the after hooks fire.

staticupdate(mixed $postarr = array ( ), mixed $wpError = false, mixed $fireAfterHooks = true): mixed#

A post changed (wp_update_post): the stored post under the given fields, as the reference merges them; an attachment saved as one.

staticdelete(mixed $postId = 0, mixed $force = false): mixed#

A post deleted (wp_delete_post): a post or page to the trash first unless forced or the trash is off; an attachment as one; otherwise unstuck, its terms, children, revisions, comments and meta taken away, then the row. The post, or what pre_delete_post answered.

statictrash(mixed $postId = 0): mixed#

A post to the trash (wp_trash_post): its status, time and slug kept for the way back; the post as it was, or false.

staticuntrash(mixed $postId = 0): mixed#

A post back from the trash (wp_untrash_post): to draft unless wp_untrash_post_status says otherwise (an attachment to inherit), its slug given back; the post as it was, or false.

staticafterInsert(mixed $post, mixed $update, mixed $postBefore): void#

What plugins hear once a post and all it carries are saved (wp_after_insert_post).

staticpublish(mixed $post): void#

A post published now (wp_publish_post), a floating date settled, with the save's actions.

staticpublishFuture(mixed $post): void#

The publish_future_post event's work (check_and_publish_future_post): a scheduled post whose time has come goes out; one early is scheduled again.

statictransitionStatus(mixed $newStatus, mixed $oldStatus, mixed $post): void#

The status change announced (wp_transition_post_status). The named hooks fire only for names that exist, so a stored status cannot forge another action's name: {old}_to_{new} when the new status is registered and the old one is too (or is "new"), {new}_{type} when the new status and the post type are registered.

staticsetCategories(mixed $postId = 0, mixed $categories = array ( ), mixed $append = false): mixed#

A post's categories set (wp_set_post_categories): posts, and the types default_category_post_types adds, fall back to the default category.

staticsetTerms(mixed $postId = 0, mixed $terms = '', mixed $taxonomy = 'post_tag', mixed $append = false): mixed#

A post's terms of a taxonomy set (wp_set_post_terms): a comma list split, a hierarchical taxonomy's terms by id.

staticsetTags(mixed $postId = 0, mixed $tags = '', mixed $append = false): mixed#

A post's tags set (wp_set_post_tags).

staticstick(mixed $postId): void#

A post made sticky (stick_post), then post_stuck; nothing when it already is.

staticunstick(mixed $postId): void#

A post no longer sticky (unstick_post), then post_unstuck; nothing when it was not.

staticuniqueSlug(mixed $slug, mixed $postId, mixed $status, mixed $type, mixed $parent): mixed#

A slug no other post holds (wp_unique_post_slug), through the reference's slug filters; drafts, pending posts and revisions keep theirs.

staticsuffixTrashed(mixed $postName, mixed $postId = 0): void#

Every trashed post holding a slug (but the one named) given the __trashed suffix, so a live post may take it (wp_add_trashed_suffix_to_post_name_for_trashed_posts).

staticsuffixTrashedPost(mixed $post): mixed#

A post's slug given the __trashed suffix once, the slug it wanted kept (wp_add_trashed_suffix_to_post_name_for_post); the slug it now has.

staticbeforeSave(array $data, int $postId = 0): void#

What plugins hear before a post's row is written: pre_post_insert for a new post, pre_post_update for one that exists. @param array<string, mixed> $data

$dataarray<string, mixed>
staticsaved(int $postId, mixed $update, ?Minn\Objects\Post $postBefore): ?Minn\Objects\Post#

What plugins hear once a post's row and its own terms are written, in the reference's order: the caches let go, the status transition, the edit actions for an update, the save actions.

staticdeleteMeta(int $postId): void#

Each meta row of a post removed by its id, with the hooks of each.

Internals 10

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privateslugFromId(int $id, array $columns, string $type): void#

A live post left without a slug (no title to make one from) takes its id, made free. @param array<string, mixed> $columns

$columnsarray<string, mixed>
privatestickies(): array#
@return list<int> the sticky posts' ids
privatefreeSlug(array $columns, int $postId): void#

A trashed post still holding the slug a save wants gives it up first, unless add_trashed_suffix_to_trashed_posts says no. @param array<string, mixed> $columns

$columnsarray<string, mixed>
privatetemplateRefusal(int $id, mixed $kept, mixed $wpError): mixed#

A page template the theme does not offer: the post stands either way; asked for an error, the save stops there with one (no save hooks), otherwise the post keeps the default template.

privateinputs(int $id, array $postarr, string $type, string $status, mixed $update): bool#

The terms, meta and template a postarr carries beside the columns; false when the page template is not one the theme offers.

$postarrarray<string, mixed>
privateattachmentSaved(int $id, array $postarr, ?Minn\Objects\Post $postBefore): int#

An attachment's save ends as the reference's does: its file recorded, then add_attachment, or edit_attachment and attachment_updated; no save_post actions, and no wp_after_insert_post whatever the caller asks (a REST save fires that itself).

$postarrarray<string, mixed>
privatetrashSaved(Minn\Objects\Post $post): void#

A trash or its undoing ends as the save it is: an attachment's, or a post's with its transition and wp_after_insert_post.

privateremove(Minn\Objects\Post $post): Minn\Objects\Post#

The row itself, between the delete actions, typed and untyped, and the caches let go after.

privateinserter(): Minn\Runtime\PostInsert#

The insert decisions, with the site's options, the user's capabilities and the date helpers handed in.

privatewriter(): Minn\Content\PostWriter#