Documentation
Documentation
Graphic_Data_Revisions
in package
Class Graphic_Data_Revisions.
Tags
Table of Contents
Constants
- FIELD_PREFIX : mixed = 'graphic_data_field__'
- Start of the names given to the fields on the Revisions screen. Kept apart from the meta keys themselves, which are also form fields on the edit screen and so would be copied into autosaves as post fields.
- POST_TYPES : mixed = array('about', 'instance', 'scene', 'modal', 'f...
- Post types whose fields are revisioned.
Properties
- $deleted_revision_files : array<int, array{0: int, 1: string[]}>
- Figure and data file names of each Figure revision being deleted, by revision ID.
-
$labels
: array<string, array{fields: array
, items: array }> - Field labels and fieldset item labels, by post type.
- $saved_revisions : array<int, int>
- Revision saved since the current restore began, by post ID.
Methods
- add_revision_fields() : array<string, string>
- Add each field to the fields the Revisions screen compares.
- add_revisioned_meta_keys() : array<string|int, string>
- Add each Graphic Data type's fields to the meta keys core revisions.
- finish_restore() : void
- Finish restoring a revision.
- get_field_text() : string
- Text of a field for the Revisions screen.
- record_saved_revision() : void
- Note the revision saved for a post during this request.
- remember_revision_data_files() : void
- Note the data files of a Figure revision that is about to be deleted.
- remove_revision_data_files() : void
- Remove the data files that only a deleted Figure revision used.
-
get_labels()
: array{fields: array
, items: array } - Edit screen labels of a post type's fields, from the bulk import column definitions (Graphic_Data_Transfer_Tsv::get_columns()).
Constants
FIELD_PREFIX
Start of the names given to the fields on the Revisions screen. Kept apart from the meta keys themselves, which are also form fields on the edit screen and so would be copied into autosaves as post fields.
public
mixed
FIELD_PREFIX
= 'graphic_data_field__'
POST_TYPES
Post types whose fields are revisioned.
public
mixed
POST_TYPES
= array('about', 'instance', 'scene', 'modal', 'figure')
Properties
$deleted_revision_files
Figure and data file names of each Figure revision being deleted, by revision ID.
private
array<int, array{0: int, 1: string[]}>
$deleted_revision_files
= array()
$labels
Field labels and fieldset item labels, by post type.
private
array<string, array{fields: array, items: array}>
$labels
= array()
$saved_revisions
Revision saved since the current restore began, by post ID.
private
array<int, int>
$saved_revisions
= array()
Methods
add_revision_fields()
Add each field to the fields the Revisions screen compares.
public
add_revision_fields(array<string, string> $fields[, array<string|int, mixed>|WP_Post|null $post = null ]) : array<string, string>
Filter callback for _wp_post_revision_fields. Core reads these fields
from the post object, where they are always empty, so they never count
as a change or get written to a post; get_field_text() supplies what the
Revisions screen shows.
wp_restore_post_revision() is the only caller that passes a revision, just before it updates the post, so that call also marks the start of a restore for finish_restore().
Parameters
- $fields : array<string, string>
-
Field name => label.
- $post : array<string|int, mixed>|WP_Post|null = null
-
Post whose revisions are compared.
Return values
array<string, string>add_revisioned_meta_keys()
Add each Graphic Data type's fields to the meta keys core revisions.
public
add_revisioned_meta_keys(array<string|int, string> $keys, string $post_type) : array<string|int, string>
Filter callback for wp_post_revision_meta_keys.
Parameters
- $keys : array<string|int, string>
-
Revisioned meta keys.
- $post_type : string
-
Post type.
Return values
array<string|int, string>finish_restore()
Finish restoring a revision.
public
finish_restore(int $post_id, int $revision_id) : void
Action callback for wp_restore_post_revision, after core has restored
the fields. Core saves a revision while it restores the title, before
the fields, so that revision holds the fields as they were before the
restore. It is given the restored fields; if no revision was saved,
one is saved now, so the latest revision always matches the post.
Parameters
- $post_id : int
-
Post ID.
- $revision_id : int
-
ID of the revision that was restored.
get_field_text()
Text of a field for the Revisions screen.
public
get_field_text(string $value, string $field, WP_Post $revision) : string
Filter callback for _wp_post_revision_field_{$field}.
Parameters
- $value : string
-
Value read from the post object (unused).
- $field : string
-
Field name (FIELD_PREFIX plus the meta key).
- $revision : WP_Post
-
Revision, or the post itself.
Return values
stringrecord_saved_revision()
Note the revision saved for a post during this request.
public
record_saved_revision(int $revision_id, int $post_id) : void
Action callback for _wp_put_post_revision, after core has copied the
fields into the revision.
Parameters
- $revision_id : int
-
Revision ID.
- $post_id : int
-
Post ID.
remember_revision_data_files()
Note the data files of a Figure revision that is about to be deleted.
public
remember_revision_data_files(int $post_id) : void
Action callback for before_delete_post, while the revision's fields
can still be read.
Parameters
- $post_id : int
-
ID of the post being deleted.
remove_revision_data_files()
Remove the data files that only a deleted Figure revision used.
public
remove_revision_data_files(int $post_id) : void
Action callback for deleted_post.
Parameters
- $post_id : int
-
ID of the deleted post.
get_labels()
Edit screen labels of a post type's fields, from the bulk import column definitions (Graphic_Data_Transfer_Tsv::get_columns()).
private
get_labels(string $post_type) : array{fields: array, items: array}
Parameters
- $post_type : string
-
Post type.