public function __construct($taxonomy, $fields, $title = '', $option_callbacks = array()) { // If a title was passed in if ($title) { // Then add a title field to the list of fields for CMB array_unshift($fields['fields'], array('name' => $title, 'id' => sanitize_title($title), 'type' => 'title')); } parent::__construct($taxonomy, $fields, '', $option_callbacks); }
/** * Initiate CMB2 Taxonomy Meta * * @since 1.0.0 * * @param string $taxonomy Taxonomy Slug * @param mixed $meta_box Metabox config array or Metabox ID * @param string $title Optional section title * @param array $option_callbacks Override the option setting/getting */ public function __construct($taxonomy, $metabox, $title = '', $option_callbacks = array()) { $this->cmb = cmb2_get_metabox($metabox); // if passing a metabox ID, and that ID was not found if (!$this->cmb) { return; } // If a title was passed in if ($title) { // Then add a title field to the list of fields for CMB $this->cmb->add_field(array('name' => $title, 'id' => sanitize_title($title), 'type' => 'title'), 1); } parent::__construct($taxonomy, array(), '', $option_callbacks); }