Documentation

NACC
in package

Class NACC

Table of Contents

Constants

DEFAULT_LANGUAGE  = 'en'
DEFAULT_LAYOUT  = 'linear'
DEFAULT_SHOW_SPECIAL  = 'true'
DEFAULT_THEME  = 'NACC-Instance'
SETTINGS_GROUP  = 'nacc-group'

Properties

$instance  : null|self
Singleton instance of the class.
$plugin_dir  : mixed

Methods

__construct()  : mixed
Constructor method for initializing the plugin.
assets()  : void
Enqueue plugin styles and scripts.
create_menu()  : void
Create the plugin's settings menu in the WordPress admin.
draw_settings()  : void
Display the plugin's settings page.
get_instance()  : self
Get an instance of the NACC plugin class.
nacc_content()  : string
Process content and replace a shortcode with CleanTime Calculator HTML.
plugin_setup()  : void
Setup method for initializing the plugin.
register_settings()  : void
Register plugin settings with WordPress.
settings_link()  : array<string|int, mixed>
Add a "Settings" link for the plugin in the WordPress admin.
setup_shortcode()  : string
Setup and render the NACC shortcode.
trigger_after_shortcode_loaded()  : string
Callback function to trigger actions after the 'nacc' shortcode is loaded.
get_shortcode()  : mixed
\brief This will parse the given text, to see if it contains the submitted code. * * The code can be contained in EITHER an HTML comment (<!--CODE-->), OR a double-[[]] * notation. * * \returns Boolean true if the code is found (1 or more instances), OR an associative * array of data that is associated with the code (anything within parentheses). Null * is returned if there is no shortcode detected. * **************************************************************************************
render_keytags()  : void
Render JavaScript for the shortcode.
render_select_option()  : string
Render a dropdown select input for plugin settings.
replace_shortcode()  : string|null
\brief This will parse the given text, to see if it contains the submitted code. * * The code can be contained in EITHER an HTML comment (<!--CODE-->), OR a double-[[]] * notation. * * \returns A string, consisting of the new text. * **************************************************************************************

Constants

Properties

Methods

assets()

Enqueue plugin styles and scripts.

public assets() : void

This method is responsible for enqueueing the necessary CSS and JavaScript files for the NACC plugin to function correctly.

create_menu()

Create the plugin's settings menu in the WordPress admin.

public static create_menu() : void

This method adds the NACC plugin's settings page to the WordPress admin menu. It also adds a settings link in the list of plugins on the plugins page.

draw_settings()

Display the plugin's settings page.

public static draw_settings() : void

This method renders and displays the settings page for the NACC plugin in the WordPress admin. It includes form fields for configuring plugin settings such as theme, language, layout, and special keytags.

get_instance()

Get an instance of the NACC plugin class.

public static get_instance() : self

This method ensures that only one instance of the NACC class is created during the plugin's lifecycle.

Return values
self

An instance of the NACC class.

nacc_content()

Process content and replace a shortcode with CleanTime Calculator HTML.

public nacc_content(string $the_content) : string
Parameters
$the_content : string

The content to process.

Return values
string

The modified content with CleanTime Calculator HTML.

plugin_setup()

Setup method for initializing the plugin.

public plugin_setup() : void

This method checks if the current context is in the admin dashboard or not. If in the admin dashboard, it registers admin-related actions and settings. If not in the admin dashboard, it sets up a shortcode and associated actions.

register_settings()

Register plugin settings with WordPress.

public static register_settings() : void

This method registers the plugin settings with WordPress using the register_setting function. It defines the settings for 'nacc_theme', 'nacc_language', 'nacc_layout', and 'nacc_special'.

Add a "Settings" link for the plugin in the WordPress admin.

public static settings_link(array<string|int, mixed> $links) : array<string|int, mixed>

This method adds a "Settings" link for the NACC plugin in the WordPress admin under the plugins list.

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

An array of plugin action links.

Return values
array<string|int, mixed>

An updated array of plugin action links.

setup_shortcode()

Setup and render the NACC shortcode.

public static setup_shortcode([string|array<string|int, mixed> $attrs = [] ]) : string

This method processes the attributes provided to the [nacc] shortcode and sets up the necessary shortcode attributes for rendering the N.A. Cleantime Calculator. If no shortcode attributes are provided, default values from plugin options are used.

Parameters
$attrs : string|array<string|int, mixed> = []

Shortcode attributes.

Return values
string

The HTML for the NACC shortcode.

trigger_after_shortcode_loaded()

Callback function to trigger actions after the 'nacc' shortcode is loaded.

public static trigger_after_shortcode_loaded(string $output, string $tag[, string|array<string|int, mixed> $attrs = [] ]) : string
Parameters
$output : string

The output content of the shortcode.

$tag : string

The shortcode tag.

$attrs : string|array<string|int, mixed> = []

The attributes passed to the shortcode.

Return values
string

The modified output content.

get_shortcode()

\brief This will parse the given text, to see if it contains the submitted code. * * The code can be contained in EITHER an HTML comment (<!--CODE-->), OR a double-[[]] * notation. * * \returns Boolean true if the code is found (1 or more instances), OR an associative * array of data that is associated with the code (anything within parentheses). Null * is returned if there is no shortcode detected. * **************************************************************************************

private get_shortcode(string $in_text_to_parse) : mixed
Parameters
$in_text_to_parse : string

render_keytags()

Render JavaScript for the shortcode.

private static render_keytags(array<string|int, mixed> $args) : void

This method generates and adds inline JavaScript to initialize the NACC (N.A. Cleantime Calculator) with the provided shortcode attributes.

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

render_select_option()

Render a dropdown select input for plugin settings.

private static render_select_option(string $name, string $selected_value, array<string|int, mixed> $options) : string

This method generates the HTML markup for a dropdown select input field with the specified name and options. It also preselects the option that matches the provided selected value.

Parameters
$name : string

The name attribute for the select input.

$selected_value : string

The value to be preselected in the dropdown.

$options : array<string|int, mixed>

An associative array of options (value => label) for the dropdown.

Return values
string

The generated HTML markup for the select input.

replace_shortcode()

\brief This will parse the given text, to see if it contains the submitted code. * * The code can be contained in EITHER an HTML comment (<!--CODE-->), OR a double-[[]] * notation. * * \returns A string, consisting of the new text. * **************************************************************************************

private replace_shortcode(string $in_text_to_parse, string $in_replacement_text) : string|null
Parameters
$in_text_to_parse : string
$in_replacement_text : string
Return values
string|null

        
On this page

Search results