/** * Attemps to register a post type. * @link https://codex.wordpress.org/Function_Reference/register_post_type * @return object Returns the result of register_post_type() */ function register() { // Ensure the default options have been set. $customizedOptions = $this->model->getConfiguration() + array('labels' => array(), 'supports' => array('title', 'editor'), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => false, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => false, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => true, 'rewrite' => array(), 'capability_type' => 'post'); $customizedOptions['rewrite'] += array('with_front' => false); $labelParser = new LabelParser($this->model); $labelParser->parse(); $singular = $labelParser->singular(); $plural = $labelParser->plural(); $customizedOptions['labels'] += array('name' => _x($plural, 'Post Type General Name', 'strata'), 'singular_name' => _x($singular, 'Post Type Singular Name', 'strata'), 'menu_name' => __($plural, 'strata'), 'parent_item_colon' => __($singular . ' Item:', 'strata'), 'all_items' => __('All ' . $plural, 'strata'), 'view_item' => __('View ' . $singular . ' Item', 'strata'), 'add_new_item' => __('Add New', 'strata'), 'add_new' => __('Add New', 'strata'), 'edit_item' => __('Edit ' . $singular, 'strata'), 'update_item' => __('Update ' . $singular, 'strata'), 'search_items' => __('Search ' . $plural, 'strata'), 'not_found' => __('Not found', 'strata'), 'not_found_in_trash' => __('Not found in Trash', 'strata')); return register_post_type($this->model->getWordpressKey(), $customizedOptions); }
/** * Registers a taxonomy * @param Taxonomy $taxonomy The taxonomy model * @return object What is being returned by register_taxonomy */ private function registerTaxonomy(Taxonomy $taxonomy) { $labelParser = new LabelParser($taxonomy); $labelParser->parse(); $singular = $labelParser->singular(); $plural = $labelParser->plural(); $key = $this->model->getWordpressKey() . "_" . $taxonomy->getWordpressKey(); $customizedOptions = $taxonomy->getConfiguration() + array('hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => $key, 'show_in_nav_menus' => false, 'show_tagcloud' => false, 'rewrite' => array(), 'capabilities' => array(), 'labels' => array()); $customizedOptions['capabilities'] += array('manage_terms' => 'read', 'edit_terms' => 'read', 'delete_terms' => 'read', 'assign_terms' => 'read'); $customizedOptions['rewrite'] += array('with_front' => true, 'slug' => $key); $customizedOptions['labels'] += array('name' => _x($plural, 'Post Type General Name', 'strata'), 'singular_name' => _x($singular, 'Post Type Singular Name', 'strata'), 'menu_name' => __($plural, 'strata'), 'parent_item_colon' => __($singular . ' Item:', 'strata'), 'all_items' => __('All ' . $plural, 'strata'), 'view_item' => __('View ' . $singular . ' Item', 'strata'), 'add_new_item' => __('Add New', 'strata'), 'add_new' => __('Add New', 'strata'), 'edit_item' => __('Edit ' . $singular, 'strata'), 'update_item' => __('Update ' . $singular, 'strata'), 'search_items' => __('Search ' . $plural, 'strata'), 'not_found' => __('Not found', 'strata'), 'not_found_in_trash' => __('Not found in Trash', 'strata')); $wordpressKey = $taxonomy->getWordpressKey(); Strata::app()->setConfig("runtime.taxonomy.query_vars.{$wordpressKey}", $customizedOptions['query_var']); return register_taxonomy($wordpressKey, array($this->model->getWordpressKey()), $customizedOptions); }