Documentation

graphic_data_plugin.php

The plugin bootstrap file

This file is read by WordPress to generate the plugin information in the plugin admin area. This file also includes all of the dependencies used by the plugin, registers the activation and deactivation functions, and defines a function that starts the plugin.

Tags
link
https://github.com/ioos/sanctuarywatch_graphicdata
wordpress-plugin

Plugin Name: Graphic Data Plugin Plugin URI: https://github.com/ioos/sanctuarywatch_graphicdata Description: This plugin customizes a Wordpress installation for the requirements of the Graphic Data framework. Version: 1.6.7 Author: Graphic Data Team Author URI: https://www.noaa.gov License: GPL-2.0+ License URI: http://www.gnu.org/licenses/gpl-2.0.txt Text Domain: graphic_data_plugin Requires Plugins: svg-support Domain Path: /languages

Table of Contents

Constants

GRAPHIC_DATA_DATA_DIR  : mixed = \WP_CONTENT_DIR . '/data'
The data directory inside of wp-content
GRAPHIC_DATA_DATA_URL  : mixed = \content_url('data')
GRAPHIC_DATA_IS_ACTIVE_THEME  : mixed = \get_template() === 'graphic_data_theme'
Determine whether the Graphic Data Theme is the active theme.
GRAPHIC_DATA_PLUGIN_DIR  : mixed = \plugin_dir_path(__FILE__)
The directory path of the plugin.
GRAPHIC_DATA_PLUGIN_VERSION  : mixed = $graphic_data_plugin_data['Version']

Functions

graphic_data_activate()  : mixed
Plugin activation callback.
graphic_data_deactivate()  : mixed
Plugin deactivation callback.
graphic_data_ensure_public_data_dir()  : void
Ensure the public data directory exists with correct permissions.
graphic_data_register_blocks()  : mixed
Register the blocks in the plugin.
graphic_data_register_figure_block_meta()  : mixed
Register the figure fields for posts.
graphic_data_register_figure_block_routes()  : void
Registers REST API routes for the figure block.
graphic_data_get_figure_block_meta()  : WP_REST_Response|WP_Error
Retrieves figure block meta fields for a given post via the REST API.
graphic_data_plugin_run()  : mixed
Begins execution of the plugin.

Constants

GRAPHIC_DATA_DATA_DIR

The data directory inside of wp-content

public mixed GRAPHIC_DATA_DATA_DIR = \WP_CONTENT_DIR . '/data'

GRAPHIC_DATA_IS_ACTIVE_THEME

Determine whether the Graphic Data Theme is the active theme.

public mixed GRAPHIC_DATA_IS_ACTIVE_THEME = \get_template() === 'graphic_data_theme'

GRAPHIC_DATA_PLUGIN_DIR

The directory path of the plugin.

public mixed GRAPHIC_DATA_PLUGIN_DIR = \plugin_dir_path(__FILE__)

GRAPHIC_DATA_PLUGIN_VERSION

public mixed GRAPHIC_DATA_PLUGIN_VERSION = $graphic_data_plugin_data['Version']

Functions

graphic_data_activate()

Plugin activation callback.

graphic_data_activate() : mixed

Ensures the public data directory exists when the plugin is activated. Creates figure, modal, and scene publishing capabilities for the Author role.

Tags
see
graphic_data_ensure_public_data_dir()

graphic_data_deactivate()

Plugin deactivation callback.

graphic_data_deactivate() : mixed

Removes figure, modal, and scene publishing capabilities from the Author role that were granted on activation.

Tags
see
graphic_data_activate()

graphic_data_ensure_public_data_dir()

Ensure the public data directory exists with correct permissions.

graphic_data_ensure_public_data_dir() : void

Creates GRAPHIC_DATA_DATA_DIR if it does not already exist, sets directory permissions to 0755, and drops an index.php guard file to prevent directory browsing while still allowing direct file access.

On failure the error is persisted to the 'graphic_data_data_dir_error' option so it can be surfaced via admin notices; on success that option is deleted.

Tags
since
1.0.0

graphic_data_register_figure_block_routes()

Registers REST API routes for the figure block.

graphic_data_register_figure_block_routes() : void

Registers a route at graphic-data/v1/figure/<id> supporting:

Both endpoints require the current user to have edit_post capability for the requested post ID.

Hooked to rest_api_init.

graphic_data_get_figure_block_meta()

Retrieves figure block meta fields for a given post via the REST API.

graphic_data_get_figure_block_meta(WP_REST_Request $request) : WP_REST_Response|WP_Error

Handles GET requests to graphic-data/v1/figure/<id>. Returns a flat object of all figure-related post meta, including fields from the figure_science_info and figure_data_info Exopite fieldsets which are unpacked into top-level keys for easier consumption by React.

Parameters
$request : WP_REST_Request

The REST request. Must contain a numeric id param matching a post of type figure.

Return values
WP_REST_Response|WP_Error

Response containing figure meta on success, or a 400 WP_Error if the post is not of type figure.

graphic_data_plugin_run()

Begins execution of the plugin.

graphic_data_plugin_run() : mixed

Since everything within the plugin is registered via hooks, then kicking off the plugin from this point in the file does not affect the page life cycle.

On this page

Search results