Documentation

Graphic_Data_Tutorial_Content
in package

Class Graphic_Data_Tutorial_Content

Defines methods that creates or deletes tutorial content.

Tags
since
1.0.0

Table of Contents

Methods

copy_image_to_media_library()  : string|false
Copies an image file from the plugin directory to the WordPress media library.
create_blank_array()  : array<string|int, mixed>
Build a blank key-value array for a single accordion link slot.
create_graphic_data_settings_content()  : array<string|int, mixed>
Populate tutorial default values for Graphic Data settings options.
create_tutorial_instance_types()  : void
Create example instance type taxonomy terms for the tutorial.
create_tutorial_instances()  : void
Create example instances for the tutorial.
create_tutorial_modals()  : void
Create example modals for the tutorial.
create_tutorial_scenes()  : void
Create example scenes for the tutorial.
delete_graphic_data_settings_content()  : array<string|int, mixed>
Clear tutorial default values from Graphic Data settings options.
delete_tutorial_images()  : void
Deletes all tutorial images from the media library.
delete_tutorial_instance_types()  : void
Deletes all tutorial instance type terms from the database.
delete_tutorial_posts()  : void
Deletes all tutorial posts.
write_modals_to_database()  : void
Creates tutorial modal posts and writes their metadata to the database.

Methods

copy_image_to_media_library()

Copies an image file from the plugin directory to the WordPress media library.

public copy_image_to_media_library(string $plugin_relative_path, int $tutorial_id) : string|false

This method takes an image file from within the plugin's directory structure, uploads it to the WordPress media library, generates the necessary attachment metadata (including image sizes), and associates it with a tutorial ID for later reference or cleanup.

Parameters
$plugin_relative_path : string

The relative path to the image file from the plugin's includes directory. Example: '../example_files/tutorial/image.jpg'

$tutorial_id : int

The tutorial ID to associate with this media library item. This is stored in post meta to keep track of tutorial media.

Tags
since
1.0.0
Return values
string|false

The URL of the uploaded attachment on success, false on failure. Failure can occur if the source file doesn't exist or if the upload process encounters an error.

create_blank_array()

Build a blank key-value array for a single accordion link slot.

public create_blank_array(string $array_key) : array<string|int, mixed>

All link slots for the scene/modal info and photo accordions must have entries in the post meta table (even empty ones) for any slot to be visible. Normal form submissions populate these automatically; tutorial content must construct them manually, which this helper does.

Parameters
$array_key : string

Meta key ending in a numeric index (e.g. scene_info_link1).

Return values
array<string|int, mixed>

Associative array of blank sibling meta keys ready for insertion.

create_graphic_data_settings_content()

Populate tutorial default values for Graphic Data settings options.

public create_graphic_data_settings_content(array<string|int, mixed> $options) : array<string|int, mixed>

Sets the intro text, sitewide footer title, sitewide footer body, and front page code block to pre-written tutorial content. These values are normally configured by the user on the Graphic Data Settings page.

Parameters
$options : array<string|int, mixed>

Existing options array to populate with tutorial content.

Return values
array<string|int, mixed>

The options array with tutorial content values added.

create_tutorial_instance_types()

Create example instance type taxonomy terms for the tutorial.

public create_tutorial_instance_types() : void

Creates two sample instance type terms with predefined names, slugs, and descriptions. Sets appropriate term meta including display order and navbar names.

Tags
global

wpdb $wpdb WordPress database abstraction object.

create_tutorial_instances()

Create example instances for the tutorial.

public create_tutorial_instances(int $current_user_id) : void
Parameters
$current_user_id : int

The ID of the user to set as post author.

create_tutorial_modals()

Create example modals for the tutorial.

public create_tutorial_modals(int $current_user_id) : void
Parameters
$current_user_id : int

The ID of the user to set as post author.

create_tutorial_scenes()

Create example scenes for the tutorial.

public create_tutorial_scenes(int $current_user_id) : void
Parameters
$current_user_id : int

The ID of the user to set as post author.

delete_graphic_data_settings_content()

Clear tutorial default values from Graphic Data settings options.

public delete_graphic_data_settings_content(array<string|int, mixed> $options) : array<string|int, mixed>

Resets the intro text, sitewide footer title, sitewide footer body, and front page code block to empty strings, effectively removing the tutorial content from the Graphic Data settings.

Parameters
$options : array<string|int, mixed>

Existing options array to clear tutorial content from.

Return values
array<string|int, mixed>

The options array with tutorial content values emptied.

delete_tutorial_images()

Deletes all tutorial images from the media library.

public delete_tutorial_images() : void
Tags
since
1.0.0

delete_tutorial_instance_types()

Deletes all tutorial instance type terms from the database.

public delete_tutorial_instance_types() : void

Finds all taxonomy terms that have the 'tutorial_instance_type_id' meta key and removes them along with their associated metadata. Uses wp_delete_term() which handles cleanup of wp_terms, wp_term_taxonomy, and wp_termmeta tables.

Tags
since
1.0.0
global

wpdb $wpdb WordPress database abstraction object.

delete_tutorial_posts()

Deletes all tutorial posts.

public delete_tutorial_posts() : void
Tags
since
1.0.0

write_modals_to_database()

Creates tutorial modal posts and writes their metadata to the database.

public write_modals_to_database(array<string|int, mixed> $modal_array, int $current_user_id) : void

Iterates over a structured array of modal data and inserts each entry as a WordPress post of type 'modal'. For each successfully created post, sets post meta fields based on the keys present in $modal_array.

Parameters
$modal_array : array<string|int, mixed>

Associative array of modal field data, keyed by field name with indexed sub-arrays per modal entry. Expected keys include: 'post_title', 'tutorial_id', 'modal_location', 'modal_scene', 'modal_icons', 'modal_icon_order', 'icon_function', 'icon_scene_out'.

$current_user_id : int

The WordPress user ID to set as the post author.


        
On this page

Search results