Documentation
Documentation
Graphic_Data_Settings_Page
in package
Handles the admin settings page for the Graphic Data plugin.
This class registers the settings page in the WordPress admin menu, initializes all settings fields and sections, enqueues necessary scripts, and provides callback functions for rendering each settings field.
Tags
Table of Contents
Methods
- add_admin_menu() : void
- Adds the Graphic Data Settings page to the WordPress admin menu.
- check_sitewide_footer_status() : void
- Checks the sitewide footer option and initializes it to an empty string if not set.
- enqueue_admin_interactive_default_bar_styles() : void
- Enqueues the Plotly bar chart settings script.
- enqueue_admin_interactive_default_line_styles() : void
- Enqueues the Plotly time series line chart settings script.
- front_page_code_block_field_callback() : void
- Callback function to render the "Front Page Code Block" textarea field.
- get_footer_settings() : WP_REST_Response
- Retrieves footer settings for the REST API endpoint.
- google_analytics_measurement_id_field_callback() : void
- Callback function for rendering the Google Analytics Measurement ID field in the settings page.
- google_tags_container_id_field_callback() : void
- Callback function for rendering the Google Tags Container ID field in the settings page.
- interactive_bar_arguments_callback() : void
- Callback function to render the bar chart arguments text editor field.
- interactive_bar_defaults_callback() : void
- Callback function to render the bar chart custom style settings field.
- interactive_line_arguments_callback() : void
- Callback function to render the line graph arguments text editor field.
- interactive_line_defaults_callback() : void
- Callback function to render the line graph custom style settings field.
- intro_text_field_callback() : void
- Callback function to render the "Intro Text" rich text editor field.
- link_behavior_checkbox_callback() : void
- Callback function to render the link behavior toggle switch.
- register_rest_settings() : void
- Registers custom REST API routes for plugin settings.
- sanitize_graphic_data_settings() : array<string|int, mixed>
- Sanitize all plugin settings before saving and also activates/deactivates tutorial content.
- settings_init() : void
- Initializes the plugin settings, sections, and fields.
- settings_page() : void
- Renders the plugin settings page in the WordPress admin.
- sitewide_footer_field_callback() : void
- Callback function to render the "Site footer" rich text editor field.
- sitewide_footer_title_field_callback() : void
- Callback function to render the "Site footer title" field.
- tutorial_content_description_callback() : void
- Callback function to render the Tutorial Content description text.
- tutorial_content_toggle_callback() : void
- Callback function to render the tutorial content toggle switch.
Methods
add_admin_menu()
Adds the Graphic Data Settings page to the WordPress admin menu.
public
add_admin_menu() : void
Registers a top-level menu page in the admin dashboard that allows users with administrator capability to configure plugin settings.
Tags
check_sitewide_footer_status()
Checks the sitewide footer option and initializes it to an empty string if not set.
public
check_sitewide_footer_status() : void
For some reason, when sitewide footer isn't set, it produces an error in the log. This function corrects that error.
enqueue_admin_interactive_default_bar_styles()
Enqueues the Plotly bar chart settings script.
public
enqueue_admin_interactive_default_bar_styles() : void
Loads the JavaScript file required for configuring default bar chart styles on the plugin settings page. Only enqueues on the settings page.
Tags
enqueue_admin_interactive_default_line_styles()
Enqueues the Plotly time series line chart settings script.
public
enqueue_admin_interactive_default_line_styles() : void
Loads the JavaScript file required for configuring default line chart styles on the plugin settings page. Only enqueues on the settings page.
Tags
front_page_code_block_field_callback()
Callback function to render the "Front Page Code Block" textarea field.
public
front_page_code_block_field_callback() : void
Displays a code block textarea for entering custom code on the front page. Only visible to users with the manage_options capability.
Tags
get_footer_settings()
Retrieves footer settings for the REST API endpoint.
public
get_footer_settings(WP_REST_Request $request) : WP_REST_Response
Returns the sitewide footer title and content from the plugin settings as a JSON response for use by external applications or themes.
Parameters
- $request : WP_REST_Request
-
The REST API request object.
Tags
Return values
WP_REST_Response —The response containing footer settings data.
google_analytics_measurement_id_field_callback()
Callback function for rendering the Google Analytics Measurement ID field in the settings page.
public
google_analytics_measurement_id_field_callback() : void
This function generates an input field for the Google Analytics Measurement ID and provides additional instructions and links for users to configure their Google Analytics setup.
google_tags_container_id_field_callback()
Callback function for rendering the Google Tags Container ID field in the settings page.
public
google_tags_container_id_field_callback() : void
This function generates an input field for the Google Tags Container ID and provides additional instructions and links for users to configure their Google Tag Manager setup. It also includes a JavaScript implementation to dynamically modify and download a JSON container file with user-provided IDs.
interactive_bar_arguments_callback()
Callback function to render the bar chart arguments text editor field.
public
interactive_bar_arguments_callback() : void
Displays a plain text editor for configuring default arguments used when generating interactive bar charts.
Tags
interactive_bar_defaults_callback()
Callback function to render the bar chart custom style settings field.
public
interactive_bar_defaults_callback() : void
Displays a collapsible options panel for configuring custom style defaults for interactive time series bar charts.
Tags
interactive_line_arguments_callback()
Callback function to render the line graph arguments text editor field.
public
interactive_line_arguments_callback() : void
Displays a plain text editor for configuring default arguments used when generating interactive time series line charts.
Tags
interactive_line_defaults_callback()
Callback function to render the line graph custom style settings field.
public
interactive_line_defaults_callback() : void
Displays a collapsible options panel for configuring custom style defaults for interactive time series line charts.
Tags
intro_text_field_callback()
Callback function to render the "Intro Text" rich text editor field.
public
intro_text_field_callback() : void
Tags
link_behavior_checkbox_callback()
Callback function to render the link behavior toggle switch.
public
link_behavior_checkbox_callback() : void
Displays a checkbox toggle for whether links should open by default in a new tab. The value is saved to wp_options as links_new_tab_by_default.
Tags
register_rest_settings()
Registers custom REST API routes for plugin settings.
public
register_rest_settings() : void
Creates a public GET endpoint at 'graphic_data/v1/footer-settings' that provides read-only access to footer settings data.
Tags
sanitize_graphic_data_settings()
Sanitize all plugin settings before saving and also activates/deactivates tutorial content.
public
sanitize_graphic_data_settings(array<string|int, mixed> $input) : array<string|int, mixed>
Validates and sanitizes each field in the graphic data settings array to ensure data integrity and security before saving to the database.
Additionally, this function also is the master function controlling tutorial content. It is weird to have this stuffed into the sanitization function, but it was the best place to put this.
Parameters
- $input : array<string|int, mixed>
-
The raw input values from the settings form.
Tags
Return values
array<string|int, mixed> —The sanitized settings array.
settings_init()
Initializes the plugin settings, sections, and fields.
public
settings_init() : void
Registers the main settings group and creates all settings sections including Theme Display, Google Analytics/Tags, and Interactive Figure Defaults. Also registers individual fields and configures REST API access for specific settings.
Tags
settings_page()
Renders the plugin settings page in the WordPress admin.
public
settings_page() : void
Outputs the HTML form for the settings page, including all registered settings sections and fields. Only accessible to users with the administrator capability.
Tags
sitewide_footer_field_callback()
Callback function to render the "Site footer" rich text editor field.
public
sitewide_footer_field_callback() : void
Tags
sitewide_footer_title_field_callback()
Callback function to render the "Site footer title" field.
public
sitewide_footer_title_field_callback() : void
Tags
tutorial_content_description_callback()
Callback function to render the Tutorial Content description text.
public
tutorial_content_description_callback() : void
Tags
tutorial_content_toggle_callback()
Callback function to render the tutorial content toggle switch.
public
tutorial_content_toggle_callback() : void
Displays a checkbox toggle for enabling/disabling tutorial content. The value is saved to wp_options as tutorial_content.