/** * Constructs the meta box * * @param string $id * @param string|array $title * @param array|string $fields * @param string $post_type_name * @param string $context * @param string $priority * * @author Gijs Jorissen * @since 0.2 * */ function __construct($id, $title, $post_type, $data = array(), $context = 'normal', $priority = 'default') { if (!empty($title)) { parent::__construct($title); $this->id = $id; $this->post_types = (array) $post_type; $this->context = $context; $this->priority = $priority; // Chack if the class, function or method exist, otherwise use cuztom callback if (Cuztom::is_wp_callback($data)) { $this->callback = $data; } else { $this->callback = array(&$this, 'callback'); // Build the meta box and fields $this->data = $this->build($data); foreach ($this->post_types as $post_type) { add_filter('manage_' . $post_type . '_posts_columns', array(&$this, 'add_column')); add_action('manage_' . $post_type . '_posts_custom_column', array(&$this, 'add_column_content'), 10, 2); add_action('manage_edit-' . $post_type . '_sortable_columns', array(&$this, 'add_sortable_column'), 10, 2); } add_action('save_post', array(&$this, 'save_post')); add_action('post_edit_form_tag', array(&$this, 'edit_form_tag')); } // Add the meta box add_action('add_meta_boxes', array(&$this, 'add_meta_box')); } }
/** * Constructor for User Meta * * @param string $id * @param string|array $title * @param string|array $locations * @param array $data * * @author Gijs Jorissen * @since 1.5 * */ function __construct($id, $title, $locations, $data = array()) { parent::__construct($title); $this->id = $id; $this->locations = array('show_user_profile', 'edit_user_profile'); // Chack if the class, function or method exist, otherwise use cuztom callback if (Cuztom::is_wp_callback($data)) { $this->callback = $data; } else { $this->callback = array(&$this, 'callback'); // Build the meta box and fields $this->data = $this->build($data); add_action('personal_options_update', array(&$this, 'save_user')); add_action('edit_user_profile_update', array(&$this, 'save_user')); add_action('user_edit_form_tag', array(&$this, 'edit_form_tag')); } foreach ($this->locations as $location) { add_action($location, $this->callback); } }