/** * 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'; }); } } }
/** * If we are on a byline type archive, set the title correctly */ public function set_archive_title($title_parts) { if (is_post_type_archive($this->name)) { $object = get_queried_object(); if (!empty($object->label) && $title_parts[0] == $object->label) { $type = $this->get_byline_type(); if (!empty($type)) { $title = fm_bylines_wordify_slug($type); } else { $title = fm_bylines_wordify_slug(apply_filters('fm_bylines_filter_rewrite_slug', $this->slug)); } $title_parts[0] = apply_filters('fm_bylines_filter_archive_title', $title); } } return $title_parts; }