Documentation
Documentation
Graphic_Data_Transfer_Schema
in package
Class Graphic_Data_Transfer_Schema.
Tags
Table of Contents
Constants
- BATCH_META_KEY : mixed = '_graphic_data_transfer_batch'
- Hidden meta key holding the ID of the import that created a post, attachment or term, so the import can be undone.
- INSTANCE_TYPE_TAXONOMY : mixed = 'instance_type'
- Taxonomy that classifies Instances.
- PACKAGE_FORMAT : mixed = 'graphic-data-content-transfer'
- Identifier written to manifest.json so packages can be recognised.
- SCHEMA_VERSION : mixed = 1
- Version of the package format written by the exporter.
- SOURCE_META_KEY : mixed = '_graphic_data_transfer_source'
- Hidden meta key recording where an imported post, attachment or term came from ("<source site URL>#<source ID>"). Used to recognise content that was imported before.
Methods
- get_block_references() : array<string, array<string, string>>
- Block attributes that hold the ID of Graphic Data content, keyed by block name. Found in page content; rewritten (or cleared) on import.
- get_data_file_extensions() : array<string|int, string>
- Extensions accepted for figure data files in a package.
- get_data_path_keys() : array<string|int, string>
- Figure meta keys that hold an absolute server path to a source data file in wp-content/data/figure_<ID>/. The files are bundled in the package and the paths are rebuilt for the target site on import.
- get_exportable_statuses() : array<string|int, string>
- Post statuses that are included in an export.
- get_held_publication_status() : string
- Value of the get_publication_meta_key() field that keeps a post off the site: 'Draft' for Instances, 'draft' for the other types.
- get_import_status() : array{post_status: string, publication_status: string}
- Statuses to give an imported post.
- get_instance_meta_key() : string
- Meta key that ties each post type to its Instance.
- get_meta_keys() : array<string|int, string>
- Meta keys exported for each post type.
- get_post_references() : array<string, string>
- Meta keys whose values are the ID of another post, mapped to the post type they point at. These are rewritten to new IDs on import.
- get_post_types() : array<string|int, string>
- Graphic Data post types, in the order they must be created on import so that every reference points at something that already exists.
- get_publication_meta_key() : string
- Meta key holding the Graphic Data status that controls whether a post is shown on the site.
- get_rebuilt_keys() : array<string|int, string>
- Figure values that are not exported because they are tied to the source site's figure ID and URL and are regenerated on import by the figure HTML rebuild. Listed for reference; they are already absent from get_meta_keys().
- get_required_references() : array<string, string>
- References a post must have to be placed on the site: a Scene needs its Instance; a Modal its Instance and Scene; a Figure its Instance, Scene and Modal. On import, a post whose required reference is empty, points at content that no longer exists, or is left unlinked on the destination site is held (see get_import_status()).
- get_term_meta_keys() : array<string|int, string>
- Term meta keys exported for Instance Type terms.
- get_term_references() : array<string, string>
- Meta keys whose values are the ID of a taxonomy term, mapped to the taxonomy they point at.
- get_unique_meta_keys() : array<string|int, string>
- Meta keys that must be unique across posts of a type. A copy gets a numbered suffix (for example example-instance-2), as WordPress does for slugs.
- get_upgrades() : array<int, callable>
- Steps that bring an older package's content.json up to SCHEMA_VERSION.
- rename_meta_key() : array<string|int, mixed>
- Upgrade helper: rename a meta key on every package post of a type.
- run_upgrades() : array<string|int, mixed>|WP_Error
- Apply upgrade steps in order, from one version to another.
- upgrade_content() : array<string|int, mixed>|WP_Error
- Bring a package's content up to the current format.
- numbered() : array<string|int, string>
- Build a list of numbered meta keys, for example scene_info1..scene_info6.
Constants
BATCH_META_KEY
Hidden meta key holding the ID of the import that created a post, attachment or term, so the import can be undone.
public
mixed
BATCH_META_KEY
= '_graphic_data_transfer_batch'
INSTANCE_TYPE_TAXONOMY
Taxonomy that classifies Instances.
public
mixed
INSTANCE_TYPE_TAXONOMY
= 'instance_type'
PACKAGE_FORMAT
Identifier written to manifest.json so packages can be recognised.
public
mixed
PACKAGE_FORMAT
= 'graphic-data-content-transfer'
SCHEMA_VERSION
Version of the package format written by the exporter.
public
mixed
SCHEMA_VERSION
= 1
Independent of the plugin version. Increment whenever the structure of manifest.json / content.json or the meaning of a field changes, and add a matching upgrade step to get_upgrades() so older packages remain importable. Adding a field does not need a new version: packages made before it simply do not have it, as posts saved before it do not.
SOURCE_META_KEY
Hidden meta key recording where an imported post, attachment or term came from ("<source site URL>#<source ID>"). Used to recognise content that was imported before.
public
mixed
SOURCE_META_KEY
= '_graphic_data_transfer_source'
Methods
get_block_references()
Block attributes that hold the ID of Graphic Data content, keyed by block name. Found in page content; rewritten (or cleared) on import.
public
static get_block_references() : array<string, array<string, string>>
Note that the instanceId attribute of the Figure, Modal and Scene
blocks is not an Instance: it is the block's editor clientId, used to
give each copy of the block a unique frontend target, so it is copied
unchanged.
Return values
array<string, array<string, string>> —Block name => attribute => target post type.
get_data_file_extensions()
Extensions accepted for figure data files in a package.
public
static get_data_file_extensions() : array<string|int, string>
Return values
array<string|int, string>get_data_path_keys()
Figure meta keys that hold an absolute server path to a source data file in wp-content/data/figure_<ID>/. The files are bundled in the package and the paths are rebuilt for the target site on import.
public
static get_data_path_keys() : array<string|int, string>
Return values
array<string|int, string>get_exportable_statuses()
Post statuses that are included in an export.
public
static get_exportable_statuses() : array<string|int, string>
Trash and auto-drafts are deliberately left out.
Return values
array<string|int, string>get_held_publication_status()
Value of the get_publication_meta_key() field that keeps a post off the site: 'Draft' for Instances, 'draft' for the other types.
public
static get_held_publication_status(string $post_type) : string
Given on import to a copy of a post that already exists on the destination, and to a Scene, Modal or Figure missing a required parent (see get_required_references()). The importer lists every post missing a parent in an error message.
Parameters
- $post_type : string
-
Post type slug.
Return values
stringget_import_status()
Statuses to give an imported post.
public
static get_import_status(string $post_type, string $source_status, bool $hold) : array{post_status: string, publication_status: string}
Graphic Data post types are always published in WordPress terms: their edit screens have no Save Draft button, and the admin only offers published posts as parents. Whether one appears on the site is set by its Graphic Data status field instead, so a held post (or one that was not published in WordPress on the source site) keeps post status 'publish' and has that field set to get_held_publication_status(). Pages use ordinary WordPress statuses.
Parameters
- $post_type : string
-
Post type slug (including 'page').
- $source_status : string
-
WordPress post status on the source site.
- $hold : bool
-
True for a copy of an existing post or a post missing a required parent.
Return values
array{post_status: string, publication_status: string} —An empty publication_status means keep the exported value.
get_instance_meta_key()
Meta key that ties each post type to its Instance.
public
static get_instance_meta_key(string $post_type) : string
Used to find everything belonging to an Instance during export, and to group items by Instance in the admin selectors.
Parameters
- $post_type : string
-
Post type slug (including 'page').
Return values
string —Meta key, or an empty string if the type has none.
get_meta_keys()
Meta keys exported for each post type.
public
static get_meta_keys(string $post_type) : array<string|int, string>
Repeating fieldsets are stored by Exopite as one serialized array per
numbered key (for example scene_info3 holds scene_info_text3 and
scene_info_url3), so each numbered key is listed.
Parameters
- $post_type : string
-
Post type slug (including 'page').
Return values
array<string|int, string>get_post_references()
Meta keys whose values are the ID of another post, mapped to the post type they point at. These are rewritten to new IDs on import.
public
static get_post_references(string $post_type) : array<string, string>
Values that are not positive integers (for example a page's
scene_location of "global") are literal and are left untouched.
Parameters
- $post_type : string
-
Post type slug (including 'page').
Return values
array<string, string> —Meta key => target post type.
get_post_types()
Graphic Data post types, in the order they must be created on import so that every reference points at something that already exists.
public
static get_post_types() : array<string|int, string>
Return values
array<string|int, string>get_publication_meta_key()
Meta key holding the Graphic Data status that controls whether a post is shown on the site.
public
static get_publication_meta_key(string $post_type) : string
Parameters
- $post_type : string
-
Post type slug.
Return values
string —Meta key, or an empty string if the type has none.
get_rebuilt_keys()
Figure values that are not exported because they are tied to the source site's figure ID and URL and are regenerated on import by the figure HTML rebuild. Listed for reference; they are already absent from get_meta_keys().
public
static get_rebuilt_keys() : array<string|int, string>
Return values
array<string|int, string>get_required_references()
References a post must have to be placed on the site: a Scene needs its Instance; a Modal its Instance and Scene; a Figure its Instance, Scene and Modal. On import, a post whose required reference is empty, points at content that no longer exists, or is left unlinked on the destination site is held (see get_import_status()).
public
static get_required_references(string $post_type) : array<string, string>
Parameters
- $post_type : string
-
Post type slug.
Return values
array<string, string> —Meta key => target post type.
get_term_meta_keys()
Term meta keys exported for Instance Type terms.
public
static get_term_meta_keys() : array<string|int, string>
Return values
array<string|int, string>get_term_references()
Meta keys whose values are the ID of a taxonomy term, mapped to the taxonomy they point at.
public
static get_term_references(string $post_type) : array<string, string>
Parameters
- $post_type : string
-
Post type slug.
Return values
array<string, string> —Meta key => taxonomy.
get_unique_meta_keys()
Meta keys that must be unique across posts of a type. A copy gets a numbered suffix (for example example-instance-2), as WordPress does for slugs.
public
static get_unique_meta_keys(string $post_type) : array<string|int, string>
Parameters
- $post_type : string
-
Post type slug.
Return values
array<string|int, string>get_upgrades()
Steps that bring an older package's content.json up to SCHEMA_VERSION.
public
static get_upgrades() : array<int, callable>
Keyed by the version each step produces: the step for 2 turns version 1 content into version 2 content. A step receives the decoded content array and returns it changed, for example with rename_meta_key() when a field is renamed. Steps must never be edited or removed once released, because packages made with that version may still exist.
Return values
array<int, callable>rename_meta_key()
Upgrade helper: rename a meta key on every package post of a type.
public
static rename_meta_key(array<string|int, mixed> $content, string $post_type, string $old_key, string $new_key) : array<string|int, mixed>
A value already stored under the new key is kept.
Parameters
- $content : array<string|int, mixed>
-
Decoded content.json.
- $post_type : string
-
Post type slug.
- $old_key : string
-
Key used by the older format.
- $new_key : string
-
Key used by the newer format.
Return values
array<string|int, mixed>run_upgrades()
Apply upgrade steps in order, from one version to another.
public
static run_upgrades(array<string|int, mixed> $content, int $from, int $to, array<int, callable> $steps) : array<string|int, mixed>|WP_Error
Parameters
- $content : array<string|int, mixed>
-
Decoded content.json.
- $from : int
-
Version of the content.
- $to : int
-
Version to reach.
- $steps : array<int, callable>
-
Steps keyed by the version they produce (see get_upgrades()).
Return values
array<string|int, mixed>|WP_Error —Upgraded content.
upgrade_content()
Bring a package's content up to the current format.
public
static upgrade_content(array<string|int, mixed> $content, int $version) : array<string|int, mixed>|WP_Error
Parameters
- $content : array<string|int, mixed>
-
Decoded content.json.
- $version : int
-
The package's schema_version.
Return values
array<string|int, mixed>|WP_Error —Upgraded content.
numbered()
Build a list of numbered meta keys, for example scene_info1..scene_info6.
private
static numbered(string $prefix, int $count) : array<string|int, string>
Parameters
- $prefix : string
-
Key prefix.
- $count : int
-
Highest number.