Properties

$version

$version : string

Type

string — Class version.

$field_types

$field_types : array

Type

array — static definitions of field types. Can be registered, editted and removed.

$sections

$sections : array

Type

array — conatins all the section and field data.

$options

$options : array

Type

array — store context specific data in this class property. Will negate the need to use get_***

$domain

$domain : string

Type

string — Class text domain.

$url

$url : string

Type

string — fluent url.

$args

$args : array

Type

array — Class args to be run attached after <code>parse_args</code>.

$added_nonce_field

$added_nonce_field : boolean

Type

boolean — used during metabox creation to decide when we should output the security nonce.

Methods

__construct()

__construct(array $args, array $sections) : \none

__construct() parse arguments supplied, setup framework options class.

Parameters

array $args

framework setup arguments. Used to change some base settings for the options including context.

array $sections

the sections an fields to be used.

Returns

\none

register_field_type()

register_field_type(array $field) : \none

Register a field type for use by the framework.

Static interface used so field types can be regsitered at any point, and for any istance of the class.

Parameters

array $field

the data to be supplied. Should be an array similar to:


array(
'type' => '', //how to target the field type
'class_name' => '', //name of the field class
'path' => '', //where the class file is located (so we use lazy loading)
'assets_path' => '' //where the field assets are stored
)

Returns

\none

setup_meta_box_titles()

setup_meta_box_titles() : \none

Hooked into the load post page this then runs the preparation on meta box titles to add the desired icon font if set.

Returns

\none

localize_script()

localize_script( $data) : \none

Localize the main options script

Parameters

$data

Returns

\none

add_screen_settings()

add_screen_settings(string $html) : string

This method adds the HTML required to show the layout options within the screen settings tab.

Parameters

string $html

Returns

string —

$html

save_screen_settings()

save_screen_settings() : \none

Save ajax requests sent via the <code>wp_ajax.

.. action. This saves the layout as either normal or block for the current user.

Returns

\none

remove_box_padding()

remove_box_padding(array $classes) : array

Meta box filter which allows you to add additional classes to the meta box.

the framework uses this to apply 0px padding and margins on the .inside class for better layouts.

Parameters

array $classes

Returns

array —

$classes

box_content_dev()

box_content_dev(object|null $post, array $data) : \none

Display the dev mode meta box.

Parameters

object|null $post

WP_Post object

array $data

additional data

Returns

\none

box_content()

box_content(object|null $post, array $data) : \none

Display meta boxes for all registered sections.

Parameters

object|null $post

WP_Post object

array $data

additional data

Returns

\none

prepare_sections()

prepare_sections(array $sections,  $id) : \none

Loops through supplied data and prepares the $sections array.

This is different for each type of options so lets leave it blank

Parameters

array $sections

framework setup arguments. Used to change some base settings for the options including context.

$id

Returns

\none

section_args()

section_args() : array

Returns the default arguments for the $sections property.

This gets merged with user supplied array via parse_args.

Returns

array

field_args()

field_args() : array

Returns the default arguments for the $field property (nested fields within the $sections property).

This gets merged with user supplied array via parse_args.

Returns

array

prepare_fields()

prepare_fields(array $fields, array $options, string $key) : array

Loops through supplied data and prepares the $fields array.

Function may also call itself on nested fields (groups). Returns a multilevel fields array.

Parameters

array $fields
array $options
string $key

Returns

array

get_options_schema()

get_options_schema() : array

Internal function used to supply the default array keys and types for the sections and fields supplied.

This is used within the format_option() function to ensure all array keys are set when retrieving the values via get_option.

Returns

array

get_default_values()

get_default_values() : array

Attached to the <code>get_option_{$option_name}</code> filter this function merges the value blueprint with the actual data ensuring all keys are set.

Also uses wp_unslash to remove slashes from values.

Returns

array

remove_clones()

remove_clones(array $value) : array

Saving the options usually means the <code>$_POST</code> array conatins the group clones in the array keys.

These usually look like ##field-id-clone##. this function simply looks for the existance of two hashes at the start of the supplied keys and removes them from the returning array if present.

Parameters

array $value

data supplied from the save action.

Returns

array —

$out the sanitized and trimmed array data.

load_assets()

load_assets() : \none

Load assets and add the screen options for any page. Maybe use in extended classes.

Returns

\none

get_required_js()

get_required_js() : array

Returns an array of required fields and there data.

Returns

array

get_conditionals()

get_conditionals() : array

Returns an array of conditional fields and there data.

Returns

array

get_user_caps()

get_user_caps() : array

Returns an array of required fields and there data.

Returns

array

get_user_role()

get_user_role() : string

Returns the current user role

Returns

string

prepare_meta_box_titles()

prepare_meta_box_titles(string $context) : \none

The prepare meta box titles function is used to run through all the sections, check if a dashicon is to be prepended to the title, and if it is alter the global <code>$wp_meta_boxes</code> titles accordingly.

Parameters

string $context

which meta boxes we are going to alter.

Returns

\none

display_lock()

display_lock( $section)

Parameters

$section

display_field_lock()

display_field_lock( $field)

Parameters

$field

parse_args()

parse_args(array $a, array $b, string $filter) : array

Recursive array merging from a default and supplied array.

Very similar function to wp_parse_args except it filters through the whole array tree.

Parameters

array $a

supplied value array.

array $b

default value array.

string $filter

optionally run the array through apply_filters before returning.

Returns

array

provide()

provide(string $key) : array

The provide function is just a shorthand wrapper for suppling a class object and method as array in WordPress actions and filters.

Parameters

string $key

the method name to be added to the array: array( &$this, $key ).

Returns

array

random_string()

random_string(string $length) : string

Helper function used inside the <code>guid()</code> function to generate random strings.

Parameters

string $length

the number of characters to return.

Returns

string

guid()

guid() : string

Guid function used to reformat array index values before sedning them to the fields.

Simply replicates the behaviour found in framework javascript.

Returns

string

default_args()

default_args() : array

Function used across extended classes used in conjunction with <code>parse_args</code> to format supplied arrays and ensure all keys are supplied.

Returns

array

get_field_type()

get_field_type( $key) : string

Returns the field type for any given field.

Parameters

$key

Returns

string