API / Minn\Runtime / PostRevisions

PostRevisions final class

Minn\Runtime\PostRevisions · public/minn/src/Minn/Runtime/PostRevisions.php · 231 lines

A post's revisions as the reference's wp_save_post_revision keeps them (probe revisions): only for a type that supports revisions and while wp_revisions_to_keep allows any; compared with the latest revision (wp_save_post_revision_check_for_changes, the revision fields with their whitespace evened out, wp_save_post_revision_post_has_changed, whose default also compares the revisioned meta); saved through wp_insert_post and _wp_put_post_revision (whose default copies the revisioned meta); then the oldest dropped past the limit, after wp_save_post_revision_revisions_before_deletion.

Constants and properties

privateFIELDS = array ( 'post_title' => 'Title', 'post_content' => 'Content', 'post_excerpt' => 'Excerpt', )

The revision fields' defaults: the title, the content and the excerpt.

Public

staticall(mixed $post = 0, mixed $args = NULL): array#

A post's revisions (wp_get_post_revisions), newest first unless asked otherwise, keyed by id (or a list of ids); none while its revisions are switched off, unless check_enabled is false.

@return array<int, mixed>
statictoKeep(mixed $post): int#

How many revisions a post keeps (wp_revisions_to_keep): WP_POST_REVISIONS (all, -1, when unset or true), none for a type without revision support, then wp_revisions_to_keep and wp_{type}_revisions_to_keep.

staticenabled(mixed $post): bool#

Whether a post keeps any revisions (wp_revisions_enabled).

staticdelete(mixed $revision): mixed#

A revision deleted (wp_delete_post_revision); anything but a revision is left alone, and nothing comes back.

staticfields(mixed $post = array ( ), mixed $deprecated = false): array#

The fields a revision keeps (_wp_post_revision_fields), through _wp_post_revision_fields; the filtered list is what the next call starts from, as on the reference.

@return array<string, mixed>
staticdata(mixed $post = array ( ), mixed $autosave = false): array#

A revision's row (_wp_post_revision_data): the post's revision fields, its parent, inherit, revision, its name, and the post's modified time as its date.

@return array<string, mixed>
staticsource(mixed $post): array#

A post as a revision's row is made from: its own fields, as an (array) cast gives them.

@return array<string, mixed>
staticupgrade(Minn\Objects\Post $post, array $revisions): bool#

Revisions named before 3.6 brought up to date (_wp_upgrade_revisions_of_post; probe revision-more), under the post's lock (Runtime\OptionLock), let go when the renaming is done. Newest first, each old revision takes its versioned name when its name has the "{id}-revision" or "{id}-autosave" shape, and the author of the old revision before it (the oldest keeps its own). Unless a revision was already up to date, the post is then saved as a revision as a save would save it. False while another upgrade holds the lock.

$revisionslist<object>newest first
staticsave(Minn\Objects\Post $post): ?int#

The new revision's id, or null when none was called for.

staticput(array $data): ?int#

The revision (or autosave) row _wp_post_revision_data made, written through wp_insert_post, then _wp_put_post_revision; its id.

$dataarray<string, mixed>

Internals 4

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

privateversion(string $name): int#

The version a revision's name carries ("{id}-revision-v1" is 1); 0 for a name from before versions, or any other.

privateversionedName(string $name): string#

An old revision's name with its version: "{id}-revision" and "{id}-revision-2" become "{id}-revision-v1"; another shape stays as it is.

privatechanged(Minn\Objects\Post $latest, Minn\Objects\Post $post): bool#

Whether the post differs from its latest revision in the revision fields, or a plugin says so.

privateprune(Minn\Objects\Post $post): void#

The oldest revisions past wp_revisions_to_keep removed (autosaves stay).