public function init() { $fm = new Fieldmanager_Group(array('name' => 'meta_fields', 'children' => array('text' => new Fieldmanager_Textfield('Text Field'), 'text2' => new Fieldmanager_Select('Dropdown', array('options' => array('first', 'second', 'third', 'fourth')))))); $fm->add_quickedit_box('Custom Text Field', 'post', function ($post_id, $data) { return !empty($data['text']) ? $data['text'] : 'not set'; }, 'Custom Column Column'); }
/** * Add in a FM_Byline meta box w/ all it's bells and whistles * @param string $type * @param string. Optional label * @param array $args */ function add_byline_meta_box($type = 'author', $label = null, $args = array()) { if (is_admin()) { $context = fm_get_context(); $fm_context = $context[0]; $fm_context_type = $context[1]; $label = empty($label) ? fm_bylines_wordify_slug($type) : $label; $defaults = array('name' => 'fm_bylines_' . sanitize_title_with_dashes($type), 'limit' => 0, 'add_more_label' => __('Add another', 'fm_bylines'), 'sortable' => true, 'label' => __('Name', 'fm_bylines'), 'children' => array('byline_id' => new Fieldmanager_Autocomplete(array('default_value' => null, 'datasource' => new Fieldmanager_Datasource_Post(array('query_args' => array('post_type' => $this->name, 'no_found_rows' => true, 'ignore_sticky_posts' => true, 'post_status' => 'publish', 'suppress_filters' => false))))), 'fm_byline_type' => new Fieldmanager_Hidden(array('default_value' => sanitize_title_with_dashes($type))))); $fm_byline_box = new Fieldmanager_Group(wp_parse_args($args, $defaults)); if ('post' == $fm_context) { $fm_byline_box->add_meta_box($label, $fm_context_type, apply_filters('fm_bylines_' . sanitize_title_with_dashes($type) . '_filter_post_metabox_context', 'normal'), apply_filters('fm_bylines_' . sanitize_title_with_dashes($type) . '_filter_post_metabox_priority', 'default')); } elseif ('term' == $fm_context) { $fm_byline_box->add_term_form($label, $fm_context_type); } elseif ('submenu' == $fm_context) { fm_register_submenu_page('fm_bylines_' . sanitize_title_with_dashes($type), apply_filters('fm_bylines_' . sanitize_title_with_dashes($type) . '_filter_metabox_submenu', 'tools.php'), $label); $fm_byline_box->activate_submenu_page(); } elseif ('user' == $fm_context) { $fm_byline_box->add_user_form($label); } elseif ('quickedit' == $fm_context) { $fm_byline_box->add_quickedit_box($label, $fm_context_type, function ($post_id, $data) { return !empty($data['fm_bylines_' . sanitize_title_with_dashes($type)]) ? $data['fm_bylines_' . sanitize_title_with_dashes($type)] : 'not set'; }); } } }