Documentation

Graphic_Data_Content_Transfer
in package

Class Graphic_Data_Content_Transfer.

Tags
since
1.10.0

Table of Contents

Constants

CAPABILITY  : mixed = 'edit_others_posts'
Capability required to open the page.
FULL_CAPABILITY  : mixed = 'manage_options'
Capability required for everything beyond single-figure transfers.
NONCE_ACTION  : mixed = 'graphic_data_content_transfer'
Nonce action used for all Content Transfer requests.
PAGE_SLUG  : mixed = 'graphic-data-content-transfer'
This page's admin menu slug.
PARENT_SLUG  : mixed = 'graphic-data-search'
Parent admin menu slug that this page hangs off of.
SELECTABLE_TYPES  : mixed = array('scene', 'modal', 'figure')
Post types that administrators can pick individually.

Properties

$page_hook  : string
Full hook suffix for this page (populated once WP registers it).
$plugin_url  : string
Absolute URL to the plugin root (for asset URLs).
$version  : string
Version string used for asset cache-busting.

Methods

__construct()  : mixed
Constructor.
ajax_html_figure()  : mixed
Handle AJAX: what the browser needs to build one Figure's HTML.
ajax_html_list()  : mixed
Handle AJAX: list the Figures whose standalone HTML should be built: the queue of imported Figures, or (administrators only) every Figure or those in one Instance.
ajax_html_save()  : mixed
Handle AJAX: save one Figure's two HTML files.
ajax_import_cancel()  : mixed
Handle AJAX: abandon an import that has not started.
ajax_import_links()  : mixed
Handle AJAX: check whether some of the web addresses in an uploaded package can be reached.
ajax_import_run()  : mixed
Handle AJAX: run the next step of an import. The first request also carries the user's link and tab choices as JSON.
ajax_import_undo()  : mixed
Handle AJAX: undo an import.
ajax_import_upload()  : mixed
Handle AJAX: receive one chunk of an import package. The first chunk starts a job; once the last arrives, the package is checked and the dry-run report is returned.
ajax_preview()  : mixed
Handle AJAX: describe what an export would contain without creating it.
ajax_render_save()  : mixed
Handle AJAX: save a bulk-imported Interactive figure's saved figure, built in the browser from its settings.
enqueue_assets()  : mixed
Enqueue CSS and the ES module for the Content Transfer page only.
handle_export()  : mixed
Handle admin-post.php: build the package and send it as a download.
handle_tsv_template()  : mixed
Handle admin-post.php: send the bulk import template.
register_submenu()  : mixed
Register the Content Transfer submenu page.
render_page()  : mixed
Render the admin page markup.
can_undo()  : bool
Whether the current user may undo an import: administrators can undo any; Editors only their own single-Figure imports.
check_import_request()  : void
Stop an import request that lacks a valid nonce or the capability.
check_selectable_post()  : WP_Error|null
Check that a submitted post ID is an allowed type that the current user may export.
count_tree_items()  : int
Count posts and all their descendants.
die_with_error()  : void
Stop a non-AJAX request with an error message and a link back.
get_display_title()  : string
Post title, or a placeholder for untitled posts.
get_exportable_posts()  : array<string|int, WP_Post>
Every exportable post of a type, sorted by title. Cached per request because the page lists Instances more than once.
get_exporter()  : Graphic_Data_Transfer_Exporter|Graphic_Data_Transfer_Tsv_Exporter
Exporter for a selection in the submitted format: a package, or (administrators only) spreadsheets for a bulk import.
get_rebuild_figure()  : int
The Figure named in a rebuild request, if the user may rebuild it: administrators any Figure they can edit, Editors only queued Figures.
get_selection_from_request()  : array<string|int, mixed>|WP_Error
Read and validate the export selection from the submitted form, enforcing what the current user is allowed to export.
load_importer()  : Graphic_Data_Transfer_Importer
Load an import job or stop with an error.
render_content_tree()  : void
Output every Scene, Modal and Figure as a checkbox tree, nested Instance → Scene → Modal → Figure, with one collapsible group per Instance. Items whose parent is missing (for example a Modal whose Scene was deleted) are listed in a final group.
render_figure_select()  : void
Output a select listing every Figure, grouped by Instance (the Editor's single-figure export).
render_import_history()  : void
Output the list of recent imports, with an Undo button for each.
render_import_section()  : void
Output the Import section and the import history.
render_instance_checkboxes()  : void
Output a checkbox for every Instance.
render_rebuild_section()  : void
Output the panel that builds the standalone HTML of imported Figures (and, for administrators, rebuilds it for every Figure or an Instance).
render_tree_branch()  : void
Output a nested list of checkboxes for posts and their descendants.
render_tree_group()  : void
Output one collapsible group of the content tree.

Constants

CAPABILITY

Capability required to open the page.

public mixed CAPABILITY = 'edit_others_posts'

edit_others_posts is held by the Editor role and above. Editors are limited to single-figure transfers (and to undoing their own imports); see FULL_CAPABILITY.

FULL_CAPABILITY

Capability required for everything beyond single-figure transfers.

public mixed FULL_CAPABILITY = 'manage_options'

NONCE_ACTION

Nonce action used for all Content Transfer requests.

public mixed NONCE_ACTION = 'graphic_data_content_transfer'

PARENT_SLUG

Parent admin menu slug that this page hangs off of.

public mixed PARENT_SLUG = 'graphic-data-search'

SELECTABLE_TYPES

Post types that administrators can pick individually.

public mixed SELECTABLE_TYPES = array('scene', 'modal', 'figure')

Properties

$page_hook

Full hook suffix for this page (populated once WP registers it).

private string $page_hook = ''

Methods

__construct()

Constructor.

public __construct([string $plugin_url = '' ][, string $version = '1.0.0' ]) : mixed
Parameters
$plugin_url : string = ''

Absolute URL to the plugin root, with trailing slash.

$version : string = '1.0.0'

Version string for asset URLs.

ajax_html_figure()

Handle AJAX: what the browser needs to build one Figure's HTML.

public ajax_html_figure() : mixed

ajax_html_list()

Handle AJAX: list the Figures whose standalone HTML should be built: the queue of imported Figures, or (administrators only) every Figure or those in one Instance.

public ajax_html_list() : mixed

ajax_html_save()

Handle AJAX: save one Figure's two HTML files.

public ajax_html_save() : mixed

ajax_import_cancel()

Handle AJAX: abandon an import that has not started.

public ajax_import_cancel() : mixed

Handle AJAX: check whether some of the web addresses in an uploaded package can be reached.

public ajax_import_links() : mixed

ajax_import_run()

Handle AJAX: run the next step of an import. The first request also carries the user's link and tab choices as JSON.

public ajax_import_run() : mixed

ajax_import_upload()

Handle AJAX: receive one chunk of an import package. The first chunk starts a job; once the last arrives, the package is checked and the dry-run report is returned.

public ajax_import_upload() : mixed

ajax_preview()

Handle AJAX: describe what an export would contain without creating it.

public ajax_preview() : mixed

ajax_render_save()

Handle AJAX: save a bulk-imported Interactive figure's saved figure, built in the browser from its settings.

public ajax_render_save() : mixed

enqueue_assets()

Enqueue CSS and the ES module for the Content Transfer page only.

public enqueue_assets(string $hook_suffix) : mixed
Parameters
$hook_suffix : string

Current admin page hook.

handle_export()

Handle admin-post.php: build the package and send it as a download.

public handle_export() : mixed

handle_tsv_template()

Handle admin-post.php: send the bulk import template.

public handle_tsv_template() : mixed

register_submenu()

Register the Content Transfer submenu page.

public register_submenu() : mixed

can_undo()

Whether the current user may undo an import: administrators can undo any; Editors only their own single-Figure imports.

private can_undo(array<string|int, mixed> $batch) : bool
Parameters
$batch : array<string|int, mixed>

Import record.

Return values
bool

check_import_request()

Stop an import request that lacks a valid nonce or the capability.

private check_import_request() : void

Editors may make requests too: their jobs only accept single-Figure packages (see Graphic_Data_Transfer_Importer::create_job()), and they can only undo their own imports (see can_undo()).

check_selectable_post()

Check that a submitted post ID is an allowed type that the current user may export.

private check_selectable_post(int $post_id, array<string|int, string> $types) : WP_Error|null
Parameters
$post_id : int

Post ID.

$types : array<string|int, string>

Allowed post types.

Return values
WP_Error|null —

Error, or null if the post is acceptable.

count_tree_items()

Count posts and all their descendants.

private count_tree_items(array<string|int, WP_Post> $posts, array<string|int, mixed> $children) : int
Parameters
$posts : array<string|int, WP_Post>

Posts at this level.

$children : array<string|int, mixed>

Child posts keyed by parent post ID.

Return values
int

die_with_error()

Stop a non-AJAX request with an error message and a link back.

private die_with_error(WP_Error $error) : void
Parameters
$error : WP_Error

Error to show.

get_display_title()

Post title, or a placeholder for untitled posts.

private get_display_title(WP_Post $post) : string
Parameters
$post : WP_Post

Post.

Return values
string

get_exportable_posts()

Every exportable post of a type, sorted by title. Cached per request because the page lists Instances more than once.

private get_exportable_posts(string $post_type) : array<string|int, WP_Post>
Parameters
$post_type : string

Post type.

Return values
array<string|int, WP_Post>

get_rebuild_figure()

The Figure named in a rebuild request, if the user may rebuild it: administrators any Figure they can edit, Editors only queued Figures.

private get_rebuild_figure() : int
Return values
int —

Figure ID.

get_selection_from_request()

Read and validate the export selection from the submitted form, enforcing what the current user is allowed to export.

private get_selection_from_request() : array<string|int, mixed>|WP_Error
Return values
array<string|int, mixed>|WP_Error —

Normalised selection.

render_content_tree()

Output every Scene, Modal and Figure as a checkbox tree, nested Instance → Scene → Modal → Figure, with one collapsible group per Instance. Items whose parent is missing (for example a Modal whose Scene was deleted) are listed in a final group.

private render_content_tree() : void

render_figure_select()

Output a select listing every Figure, grouped by Instance (the Editor's single-figure export).

private render_figure_select() : void

render_import_history()

Output the list of recent imports, with an Undo button for each.

private render_import_history(bool $full) : void

Editors see only their own imports.

Parameters
$full : bool

Whether the user may see and undo every import.

render_import_section()

Output the Import section and the import history.

private render_import_section(bool $full) : void
Parameters
$full : bool

Whether the user may import any package, rather than a single Figure only.

render_instance_checkboxes()

Output a checkbox for every Instance.

private render_instance_checkboxes() : void

render_rebuild_section()

Output the panel that builds the standalone HTML of imported Figures (and, for administrators, rebuilds it for every Figure or an Instance).

private render_rebuild_section(bool $full) : void
Parameters
$full : bool

Whether the user is an administrator.

render_tree_branch()

Output a nested list of checkboxes for posts and their descendants.

private render_tree_branch(array<string|int, WP_Post> $posts, array<string|int, mixed> $children) : void
Parameters
$posts : array<string|int, WP_Post>

Posts at this level.

$children : array<string|int, mixed>

Child posts keyed by parent post ID.

render_tree_group()

Output one collapsible group of the content tree.

private render_tree_group(string $label, array<string|int, WP_Post> $posts, array<string|int, mixed> $children) : void
Parameters
$label : string

Group heading.

$posts : array<string|int, WP_Post>

Top-level posts in the group.

$children : array<string|int, mixed>

Child posts keyed by parent post ID.

On this page

Search results