Shortcode_Button::__construct PHP Method

__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
    public function __construct($button_slug, $js_button_data, $args = array())
    {
        // Keep this handy
        $this->button_slug = $button_slug;
        // Stash for JS access
        $js_button_data['slug'] = $this->button_slug;
        $this->button_data = wp_parse_args($js_button_data, array('icon' => '', 'qt_button_text' => $this->button_slug, 'button_tooltip' => $this->button_slug, 'author' => '', 'authorurl' => '', 'infourl' => '', 'version' => '', 'l10ncancel' => __('Cancel'), 'l10ninsert' => __('Insert Shortcode'), 'l10nupdate' => __('Update Shortcode'), 'l10nsccontents' => __('Shortcode Contents'), 'l10nsccontents_desc' => '', 'include_close' => false, 'slug' => '', 'modalClass' => 'wp-dialog', 'modalHeight' => 'auto', 'modalWidth' => 500, 'mceView' => false));
        $this->args = wp_parse_args($args, array('cmb_metabox_config' => array(), 'form_display_callback' => '', 'conditional_callback' => false));
        self::$buttons_data[] = $this->button_data;
        $this->index = self::$_index++;
        add_action('init', array($this, 'hooks'));
    }

Usage Example

 /**
  * Constructor
  *
  * @since 0.1.0
  */
 public function __construct($shortcode = '', $version = '', $atts_defaults = array())
 {
     $this->shortcode = $shortcode;
     $this->atts_defaults = $atts_defaults;
     $this->version = $version;
     if (empty($this->shortcode) || empty($this->version)) {
         wp_die(get_class($this) . ' must have $shortcode and $version properties set and non-empty.');
     }
     parent::__construct($this->shortcode, $this->_js_button_data(), $this->_additional_args());
     remove_action('init', array($this, 'hooks'));
     // Since we're hooking in the Shortcode_Button hooks method later, we need to hook in the
     // ajax callbacks now (or they don't get fired).
     add_action('wp_ajax_scb_parse_shortcode', array('Shortcode_Button', 'ajax_parse_shortcode'));
     add_action('wp_ajax_nopriv_scb_parse_shortcode', array('Shortcode_Button', 'ajax_parse_shortcode'));
 }