/** * Constructor * Call parent constructor and add specific hooks * * @param array $meta_box */ public function __construct($meta_box) { // Allow to set 'settings_pages' param by string if (isset($meta_box['settings_pages']) && is_string($meta_box['settings_pages'])) { $meta_box['settings_pages'] = array($meta_box['settings_pages']); } parent::__construct($meta_box); // Prevent adding meta box to post $this->meta_box['post_types'] = $this->meta_box['pages'] = array(); remove_action('add_meta_boxes', array($this, 'add_meta_boxes')); remove_action('save_post_post', array($this, 'save_post')); add_action('mb_settings_page_load', array($this, 'load')); }
/** * Constructor * Call parent constructor and add specific hooks * @param array $meta_box */ public function __construct($meta_box) { // Allow to set 'taxonomies' param by string if (isset($meta_box['taxonomies']) && is_string($meta_box['taxonomies'])) { $meta_box['taxonomies'] = array($meta_box['taxonomies']); } parent::__construct($meta_box); // Prevent adding meta box to post $this->meta_box['post_types'] = $this->meta_box['pages'] = array(); remove_action('add_meta_boxes', array($this, 'add_meta_boxes')); remove_action('save_post_post', array($this, 'save_post')); // Add meta fields to edit term page add_action('load-edit-tags.php', array($this, 'add')); // Save term meta foreach ($this->meta_box['taxonomies'] as $taxonomy) { add_action("edited_{$taxonomy}", array($this, 'save')); } }