Documentation
Documentation
Graphic_Data_Plugin_Only_Content
in package
Class Graphic_Data_Plugin_Only_Content
Defines methods that content when the Graphic Data plugin is used without the theme.
Tags
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_placeholder_instance() : void
- Create placeholder instance.
- create_placeholder_instance_type() : void
- Creates a placeholder instance type term if the Graphic Data theme is not active.
- create_placeholder_modal() : void
- Creates tutorial modal posts and writes their metadata to the database.
- create_placeholder_scene() : void
- Create example scenes for the placeholder.
- placeholder_content_director() : void
- Ensures a placeholder instance type exists when the Graphic Data theme is not active.
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 $placeholder_id, int $instance_id) : string|false
Takes an image file from within the plugin's directory structure, uploads it to the WordPress media library, generates attachment metadata (including image sizes), and tags the resulting attachment with both a placeholder ID and an instance ID for later lookup or cleanup.
Parameters
- $plugin_relative_path : string
-
Relative path to the image file from the plugin root directory. Example: 'example_files/tutorial/image.jpg'
- $placeholder_id : int
-
Placeholder ID stored in attachment post meta under
graphic_data_placeholder_idto identify placeholder media. - $instance_id : int
-
Instance ID stored in attachment post meta under
graphic_data_instance_idto associate the media with a specific plugin instance.
Tags
Return values
string|false —URL of the uploaded attachment on success, or false if the source file does not exist or the upload process fails.
create_placeholder_instance()
Create placeholder instance.
public
create_placeholder_instance(int $current_user_id) : void
Parameters
- $current_user_id : int
-
The ID of the user to set as post author.
create_placeholder_instance_type()
Creates a placeholder instance type term if the Graphic Data theme is not active.
public
create_placeholder_instance_type() : void
Inserts a new term into the instance_type taxonomy with a predefined name, slug,
and description. Sets its instance_order to one greater than the current maximum,
assigns a navbar name of "Placeholder", and marks it with the
graphic_data_instance_type_placeholder_id meta flag.
Tags
create_placeholder_modal()
Creates tutorial modal posts and writes their metadata to the database.
public
create_placeholder_modal(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
- $current_user_id : int
-
The WordPress user ID to set as the post author.
create_placeholder_scene()
Create example scenes for the placeholder.
public
create_placeholder_scene(int $current_user_id) : void
Parameters
- $current_user_id : int
-
The ID of the user to set as post author.
placeholder_content_director()
Ensures a placeholder instance type exists when the Graphic Data theme is not active.
public
placeholder_content_director() : void
Queries postmeta for the graphic_data_instance_type_placeholder_id key. If no
record is found, delegates to create_placeholder_instance_type() to insert
the placeholder term. Does nothing when the Graphic Data theme is active, since the
theme provides its own instance type management.