/** * Constructor - get the class hooked in and ready * * @since 1.1.0 * @access public * @param array $meta_box */ public function __construct($meta_box) { // Load only in admin area. if (!is_admin()) { return; } // Prepare the metabox values with the class variables. $this->_meta_box = $meta_box; $this->fields =& $this->_meta_box['fields']; // Display error messages add_action('admin_notices', array($this, 'display_errors')); $check_metabox = $this->check_meta_box($this->_meta_box); if (!empty($check_metabox->errors)) { $this->errors = $check_metabox; return; } // Set default values for fields $this->_meta_box['fields'] = Pretty_Metabox::normalize_fields($this->_meta_box['fields']); // Show Custom Fields add_action('show_user_profile', array($this, 'show_metabox')); add_action('edit_user_profile', array($this, 'show_metabox')); // Save Custom fields add_action('personal_options_update', array($this, 'save_metabox')); add_action('edit_user_profile_update', array($this, 'save_metabox')); // Enqueue styles and scripts add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); }
/** * Constructor - get the class hooked in and ready * * @since 1.0.0 * @access public * @param array $meta_box */ public function __construct($meta_box) { // Load only in admin area. if (!is_admin()) { return; } // Prepare the metabox values with the class variables. $this->_meta_box = $meta_box; $this->fields =& $this->_meta_box['fields']; // Display error messages add_action('admin_notices', array($this, 'display_errors')); $check_metabox = $this->check_meta_box($this->_meta_box); if (!empty($check_metabox->errors)) { $this->errors = $check_metabox; return; } // Set default values for fields $this->_meta_box['fields'] = Pretty_Metabox::normalize_fields($this->_meta_box['fields']); // Run metabox output & save methods foreach ($this->_meta_box['taxonomy'] as $page) { //add fields to edit form add_action($page . '_edit_form_fields', array($this, 'show_edit_form')); //add fields to add new form add_action($page . '_add_form_fields', array($this, 'show_new_form')); // this saves the edit fields add_action('edited_' . $page, array($this, 'save'), 10, 2); // this saves the add fields add_action('created_' . $page, array($this, 'save'), 10, 2); } //delete term meta on term deletion add_action('delete_term', array($this, 'delete_term_metadata'), 10, 2); // Enqueue styles and scripts add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); }