Documentation

Graphic_Data_Figure
in package

Handles the Figure custom post type for the Graphic Data plugin.

Registers the Figure post type, its custom fields and metaboxes, admin list table columns, filter dropdowns, REST API fields and routes, and file upload/delete handlers for interactive figure data.

Tags
since
1.0.0

Table of Contents

Methods

change_figure_columns()  : array<string|int, mixed>
Set custom columns for the Figure post type admin list table.
cleanup_expired_figure_filters()  : void
Clean up expired figure filter values in user metadata.
create_figure_fields()  : mixed
Create custom fields, using metaboxes, for Figure custom content type.
custom_content_type_figure()  : mixed
Create Figure custom content type.
custom_figure_column()  : mixed
Populate custom fields for Figure content type in the admin screen.
custom_file_delete_handler()  : void
Handles the custom file deletion process for the Graphic Data plugin.
custom_file_upload_handler()  : void
Handles the custom file upload process for the Graphic Data plugin.
enqueue_admin_interactive_graph_script()  : void
Enqueue admin scripts for the Figure post type edit screen.
figure_filter_dropdowns()  : void
Add filter dropdowns for the Figure admin screen with persistent selection support.
figure_location_filter_results()  : void
Filter the Figure admin screen results based on selected or stored filter values.
filter_figure_by_figure_modal()  : array<string|int, mixed>
Filter REST API query arguments to support filtering figure custom posts by meta fields.
get_alt_text_by_url_callback()  : WP_REST_Response
Callback function for the /media/alt-text-by-url REST route.
get_figure_filter_value()  : bool|string|int
Check if stored filter values are still valid and retrieve them if they are.
register_figure_rest_fields()  : mixed
Register Figure custom fields for use by REST API.
register_get_alt_text_by_url_route()  : mixed
Registers a custom REST API route to get alt text by image URL.
store_figure_filter_values()  : void
Store figure filter values in user metadata with 20-minute expiration.

Methods

change_figure_columns()

Set custom columns for the Figure post type admin list table.

public change_figure_columns(array<string|int, mixed> $columns) : array<string|int, mixed>

Replaces the default WordPress admin columns with custom columns specific to the Figure custom post type, including instance, scene, icon, tab, order, image location, and status information.

Intended as a callback for the 'manage_figure_posts_columns' filter.

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

Default WordPress admin columns array where keys are column IDs and values are column labels.

Tags
since
1.0.0
link
https://www.smashingmagazine.com/2017/12/customizing-admin-columns-wordpress/
Return values
array<string|int, mixed>

Modified columns array with custom Figure-specific columns.

cleanup_expired_figure_filters()

Clean up expired figure filter values in user metadata.

public cleanup_expired_figure_filters() : void

This function runs on admin page load and checks if any stored filter values have exceeded their 20-minute expiration time. Any expired values are removed from the database to maintain clean user metadata and prevent stale filters from being applied.

Tags
since
1.0.0
access

public

create_figure_fields()

Create custom fields, using metaboxes, for Figure custom content type.

public create_figure_fields([bool $return_fields_only = false ]) : mixed
Parameters
$return_fields_only : bool = false

If true, only return the custom fields array without registering the metabox (used as part of field validation).

Tags
since
1.0.0

custom_content_type_figure()

Create Figure custom content type.

public custom_content_type_figure() : mixed
Tags
since
1.0.0

custom_figure_column()

Populate custom fields for Figure content type in the admin screen.

public custom_figure_column(string $column, int $post_id) : mixed
Parameters
$column : string

The name of the column.

$post_id : int

The database id of the post.

Tags
since
1.0.0

custom_file_delete_handler()

Handles the custom file deletion process for the Graphic Data plugin.

public static custom_file_delete_handler() : void

Validates the provided post ID and file name, deletes the specified file, and updates the post metadata.

Return values
void

Outputs a JSON response indicating success or failure.

custom_file_upload_handler()

Handles the custom file upload process for the Graphic Data plugin.

public static custom_file_upload_handler() : void

Validates the uploaded file, ensures it is of an allowed type, and stores it in the appropriate directory. Updates the post metadata with the file path upon successful upload.

Return values
void

Outputs a JSON response indicating success or failure.

enqueue_admin_interactive_graph_script()

Enqueue admin scripts for the Figure post type edit screen.

public enqueue_admin_interactive_graph_script(string $hook) : void

Loads the admin-figure.js script with REST API credentials for interactive graph data retrieval, and localizes default line and bar chart arguments from the plugin settings page for use by the Plotly charting scripts.

Only enqueued on the post.php and post-new.php screens for the 'figure' post type.

Parameters
$hook : string

The current admin page hook suffix.

Tags
since
1.0.0

figure_filter_dropdowns()

Add filter dropdowns for the Figure admin screen with persistent selection support.

public figure_filter_dropdowns() : void

This function creates and outputs filter dropdowns for instance, scene, and icon on the Figure post type admin screen. It first checks for filter values in the URL parameters, then falls back to stored user metadata values if they haven't expired. After displaying the dropdowns, it stores the current selections for future use. The dropdowns are hierarchical - scene options depend on instance selection, and icon options depend on scene selection.

Tags
since
1.0.0
access

public

figure_location_filter_results()

Filter the Figure admin screen results based on selected or stored filter values.

public figure_location_filter_results(WP_Query $query) : void

This function modifies the WordPress query to filter Figure posts based on the selected instance, scene, or icon values. It first checks for values in the URL parameters, then falls back to stored user metadata values that haven't expired. This ensures filter persistence for 20 minutes across page loads. The filtering logic follows a hierarchical approach where icon takes precedence over scene, which takes precedence over instance.

Parameters
$query : WP_Query

The WordPress Query instance being filtered.

Tags
since
1.0.0
access

public

filter_figure_by_figure_modal()

Filter REST API query arguments to support filtering figure custom posts by meta fields.

public filter_figure_by_figure_modal(array<string|int, mixed> $args, WP_REST_Request $request) : array<string|int, mixed>

Appends meta_query clauses to the WP_Query arguments when the REST request includes 'figure_modal', 'figure_published', or 'id' parameters. Intended to be hooked into the 'rest_figure_query' filter.

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

The WP_Query arguments for the REST API request.

$request : WP_REST_Request

The current REST API request object.

Tags
since
1.0.0
Return values
array<string|int, mixed>

Modified query arguments with additional meta_query clauses.

get_alt_text_by_url_callback()

Callback function for the /media/alt-text-by-url REST route.

public get_alt_text_by_url_callback(WP_REST_Request $request) : WP_REST_Response

Retrieves the alt text for an image given its URL.

Parameters
$request : WP_REST_Request

The REST API request object.

Tags
since
1.0.1
Return values
WP_REST_Response

The REST API response.

get_figure_filter_value()

Check if stored filter values are still valid and retrieve them if they are.

public get_figure_filter_value(string $meta_key) : bool|string|int

This function retrieves a stored filter value from user metadata and verifies if it has exceeded its expiration time. If the value has expired, it cleans up the metadata entries and returns false. Otherwise, it returns the stored value.

Parameters
$meta_key : string

The meta key to check expiration for.

Tags
since
1.0.0
access

public

Return values
bool|string|int

False if expired or not found, the value if still valid.

register_figure_rest_fields()

Register Figure custom fields for use by REST API.

public register_figure_rest_fields() : mixed
Tags
since
1.0.0

register_get_alt_text_by_url_route()

Registers a custom REST API route to get alt text by image URL.

public register_get_alt_text_by_url_route() : mixed
Tags
since
1.0.1

store_figure_filter_values()

Store figure filter values in user metadata with 20-minute expiration.

public store_figure_filter_values() : void

This function captures the current Figure filter selections from the URL parameters and stores them in user metadata with a 20-minute expiration timestamp. It handles all three filter types: instance, scene, and icon.

Tags
since
1.0.0
access

public


        
On this page

Search results