PHP Class Shortcode_Button

Datei anzeigen Open project: jtsternberg/Shortcode_Button Class Usage Examples

Protected Properties

Property Type Description
$_index
$args
$button_data
$buttons_data
$dir
$enqueued
$handle
$index
$scripts_url

Public Methods

Method Description
__construct ( string $button_slug, array $js_button_data, array $args = [] ) Button name
__get ( string $property ) : mixed Magic getter for our object.
add_button ( $plugin_array ) and tell tinymce where it lives
add_modal_form ( ) Include our button form in a modal
add_quicktag_button_script ( ) Enqueue our quicktag/general purpose button script, and localize our button data
ajax_parse_shortcode ( ) Parse shortcode for display within a TinyMCE view.
button_init ( ) Hook our buttons in to tinymce
do_cmb_form ( ) Use CMB2 cmb2_metabox_form to output form display
filter_form_fields ( $updated, $allvalues = [] ) : array Pass values through a variable filter hook before sending back to JS "{$button_slug}_shortcode_fields"
form_callback ( ) : mixed Check button data for form dislay callback
get_cmb_config ( ) : mixed Get the cmb config array from button args
get_cmb_object ( ) : mixed Use the passed-in CMB2 form args to retrieve a CMB2 object
hooks ( ) Hook it all in. non-ajax hooks check for a conditional callback
process_cmb_form ( array $fields ) CMB2 form processing.
process_form ( ) Ajax form processing.
register_button ( $buttons ) register it with tinymce
sanitize_cmb_fields ( array $fields ) : array Uses CMB2 field processing to sanitize fields (Only applies if cmb_metabox_config parameter exists)
send_json_success ( $send )
url ( string $path = '' ) : string Get script url

Method Details

__construct() public method

Button name
Since: 0.1.0
public __construct ( string $button_slug, array $js_button_data, array $args = [] )
$button_slug string Button name/slug
$js_button_data array Button arguments passed to Javascript
$args array (optional) Override arguments

__get() public method

Magic getter for our object.
Since: 0.1.0
public __get ( string $property ) : mixed
$property string Object property to retrieve
return mixed

add_button() public method

and tell tinymce where it lives
public add_button ( $plugin_array )

add_modal_form() public method

Include our button form in a modal
Since: 0.1.0
public add_modal_form ( )

add_quicktag_button_script() public static method

Enqueue our quicktag/general purpose button script, and localize our button data
Since: 0.1.0
public static add_quicktag_button_script ( )

ajax_parse_shortcode() public static method

Parse shortcode for display within a TinyMCE view.
public static ajax_parse_shortcode ( )

button_init() public method

Hook our buttons in to tinymce
Since: 0.1.0
public button_init ( )

do_cmb_form() public method

Only applies if cmb_metabox_config parameter exists. CMB2 must be included prior to running this script.
Since: 0.1.0
public do_cmb_form ( )

filter_form_fields() public method

Pass values through a variable filter hook before sending back to JS "{$button_slug}_shortcode_fields"
Since: 0.1.0
public filter_form_fields ( $updated, $allvalues = [] ) : array
return array Filtered field values

form_callback() public method

Check button data for form dislay callback
Since: 0.1.0
public form_callback ( ) : mixed
return mixed Form display callback (or false)

get_cmb_config() public method

Get the cmb config array from button args
Since: 0.1.0
public get_cmb_config ( ) : mixed
return mixed CMB2 form args (or false)

get_cmb_object() public method

Use the passed-in CMB2 form args to retrieve a CMB2 object
Since: 0.1.0
public get_cmb_object ( ) : mixed
return mixed Returns a CMB2 object or null;

hooks() public method

Hook it all in. non-ajax hooks check for a conditional callback
Since: 0.1.0
public hooks ( )

process_cmb_form() public method

(Only applies if cmb_metabox_config parameter exists)
Since: 0.1.0
public process_cmb_form ( array $fields )
$fields array Field values to process

process_form() public method

Uses dynamic filter before returning: "{$button_slug}_shortcode_fields"
Since: 0.1.0
public process_form ( )

register_button() public method

register it with tinymce
public register_button ( $buttons )

sanitize_cmb_fields() public method

Uses CMB2 field processing to sanitize fields (Only applies if cmb_metabox_config parameter exists)
Since: 0.1.0
public sanitize_cmb_fields ( array $fields ) : array
$fields array Field values to sanitize
return array Array of sanitized fields

send_json_success() public static method

public static send_json_success ( $send )

url() public static method

Get script url
Since: 0.1.0
public static url ( string $path = '' ) : string
$path string Path to append to url
return string Script url plus path if passed in

Property Details

$_index protected_oe static_oe property

protected static $_index

$args protected_oe property

protected $args

$button_data protected_oe property

protected $button_data

$buttons_data protected_oe static_oe property

protected static $buttons_data

$dir protected_oe static_oe property

protected static $dir

$enqueued protected_oe static_oe property

protected static $enqueued

$handle protected_oe static_oe property

protected static $handle

$index protected_oe property

protected $index

$scripts_url protected_oe static_oe property

protected static $scripts_url