function jogja_core_register_post_types()
{
    if (current_theme_supports('jogja-portfolio')) {
        register_extended_post_type('jogja-portfolio', array('admin_cols' => array('title' => array('title' => 'Project Name'), 'featured_image' => array('title' => 'Project Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'project_categories' => array('title' => 'Project Category', 'taxonomy' => 'project_categories'), 'date'), 'filters' => array('project_categories' => array('title' => 'Project Categories', 'taxonomy' => 'project_categories'), 'project_tags' => array('title' => 'Project Tags', 'taxonomy' => 'project_tags')), 'supports' => array('title', 'editor', 'thumbnail'), 'menu_icon' => 'dashicons-category', 'menu_position' => 7.25, 'has_archive' => false), array('singular' => 'Portfolio', 'plural' => 'Portfolios', 'slug' => 'project'));
        // Register Taxonomy project categories
        register_extended_taxonomy('project_categories', 'jogja-portfolio', array(), array('singular' => 'Category', 'plural' => 'Categories', 'slug' => 'project_cat'));
    }
    if (current_theme_supports('jogja-testimonials')) {
        register_extended_post_type('jogja-testimonials', array('admin_cols' => array('title' => array('title' => 'Name'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail'), 'menu_icon' => 'dashicons-format-chat', 'menu_position' => 8.25, 'has_archive' => false), array('singular' => 'Testimonial', 'plural' => 'Testimonials', 'slug' => 'testimony'));
    }
    if (current_theme_supports('jogja-slides')) {
        register_extended_post_type('jogja-slides', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail'), 'menu_icon' => 'dashicons-camera', 'menu_position' => 8.5, 'has_archive' => false), array('singular' => 'Slide', 'plural' => 'Slides', 'slug' => 'slide'));
    }
    if (current_theme_supports('jogja-galleries')) {
        register_extended_post_type('jogja-galleries', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail', 'editor'), 'menu_icon' => 'dashicons-format-image', 'menu_position' => 8.699999999999999, 'has_archive' => false), array('singular' => 'Gallery', 'plural' => 'Galleries', 'slug' => 'gallery'));
        // Register Taxonomy Gallery categories
        register_extended_taxonomy('gallery_cat', 'jogja-galleries', array(), array('singular' => 'Category', 'plural' => 'Categories', 'slug' => 'gallery_cat'));
    }
    if (current_theme_supports('jogja-events')) {
        register_extended_post_type('jogja-events', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail', 'editor'), 'menu_icon' => 'dashicons-calendar', 'menu_position' => 8.800000000000001, 'has_archive' => false), array('singular' => 'Event', 'plural' => 'Events', 'slug' => 'event'));
    }
    if (current_theme_supports('jogja-stories')) {
        register_extended_post_type('jogja-stories', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail', 'editor'), 'menu_icon' => 'dashicons-sticky', 'menu_position' => 8.9, 'has_archive' => false), array('singular' => 'Story', 'plural' => 'Stories', 'slug' => 'story'));
    }
    if (current_theme_supports('jogja-peoples')) {
        register_extended_post_type('jogja-peoples', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail', 'editor'), 'menu_icon' => 'dashicons-businessman', 'menu_position' => 8.99, 'has_archive' => false), array('singular' => 'People', 'plural' => 'Peoples', 'slug' => 'people'));
        register_extended_taxonomy('people-group', 'jogja-peoples', array(), array('singular' => 'Group', 'plural' => 'Groups', 'slug' => 'group'));
    }
    if (current_theme_supports('jogja-guestbook')) {
        register_extended_post_type('jogja-guestbook', array('admin_cols' => array('title' => array('title' => 'Title'), 'featured_image' => array('title' => 'Image', 'featured_image' => 'thumbnail', 'height' => 80, 'width' => 80), 'date'), 'supports' => array('title', 'thumbnail', 'editor'), 'menu_icon' => 'dashicons-format-chat', 'menu_position' => 8.993, 'has_archive' => false), array('singular' => 'Guest Book', 'plural' => 'Guest Books', 'slug' => 'guest-book'));
    }
}
Example #2
0
 /**
  * Helper function for registering a taxonomy and adding it to this post type. Accepts the same parameters as
  * register_extended_taxonomy(), minus the $object_type parameter. Will fall back to register_taxonomy() if
  * Extended Taxonomies isn't present.
  *
  * Example usage:
  *
  *     $events   = register_extended_post_type( 'event' );
  *     $location = $events->add_taxonomy( 'location' );
  *
  * @param  string $taxonomy The taxonomy name.
  * @param  array  $args     The taxonomy arguments. Optional.
  * @param  array  $names    An associative array of the plural, singular, and slug names. Optional.
  * @return object|false     Taxonomy object, or boolean false if there's a problem.
  */
 public function add_taxonomy($taxonomy, array $args = array(), array $names = array())
 {
     if (taxonomy_exists($taxonomy)) {
         register_taxonomy_for_object_type($taxonomy, $this->post_type);
     } else {
         if (function_exists('register_extended_taxonomy')) {
             register_extended_taxonomy($taxonomy, $this->post_type, $args, $names);
         } else {
             register_taxonomy($taxonomy, $this->post_type, $args);
         }
     }
     return get_taxonomy($taxonomy);
 }
Example #3
0
function doc_agencies_register_taxonomies()
{
    register_extended_taxonomy('agency', 'department', array(), array('tax_plural' => 'agencies'));
}
Example #4
0
<?php

/**
 * Register post types using Extended CPTs (in mu-plugins)
 */
add_action('init', function () {
    register_extended_post_type('video', array('has_archive' => false, 'menu_icon' => 'dashicons-editor-video', 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'), 'admin_cols' => array('featured_image' => array('title' => __('Thumbnail', 'rt'), 'featured_image' => 'thumbnail'), 'title', 'published' => array('title' => __('Published', 'rt'), 'meta_key' => 'published_date')), 'admin_filters' => array()));
    register_extended_post_type('question', array('has_archive' => false, 'menu_icon' => 'dashicons-editor-help', 'admin_cols' => array('title', 'published' => array('title' => __('Published', 'rt'), 'meta_key' => 'published_date')), 'admin_filters' => array()));
    register_extended_post_type('submission', array('menu_icon' => 'dashicons-format-status', 'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'), 'labels' => array('featured_image' => __('Thumbnail', 'rt'), 'set_featured_image' => __('Choose Thumbnail', 'rt'), 'remove_featured_image' => __('Remove Thumbnail', 'rt'), 'use_featured_image' => __('Use as Thumbnail', 'rt')), 'admin_cols' => array('title', 'author', 'submission_type' => array('taxonomy' => 'submission_type'), 'theme' => array('taxonomy' => 'theme'), 'language' => array('taxonomy' => 'language'), 'country' => array('taxonomy' => 'country'), 'published' => array('title' => __('Published', 'rt'), 'meta_key' => 'published_date')), 'admin_filters' => array('submission_type' => array('taxonomy' => 'submission_type'), 'theme' => array('taxonomy' => 'theme'), 'language' => array('taxonomy' => 'language'), 'country' => array('taxonomy' => 'country'))));
    $args = array('hierarchical' => false);
    register_extended_taxonomy('submission_type', 'submission', $args);
    register_extended_taxonomy('theme', 'submission', $args);
    register_extended_taxonomy('language', 'submission', $args);
    register_extended_taxonomy('country', 'submission', $args, array('plural' => 'Countries', 'singular' => 'Country'));
});
/**
 * Remove default taxonomy metaboxes from submission post type
 */
add_action('admin_menu', function () {
    remove_meta_box('themediv', 'submission', 'side');
    remove_meta_box('languagediv', 'submission', 'side');
    remove_meta_box('countrydiv', 'submission', 'side');
});
/**
 * Add posts-to-posts connection types
 */
add_action('p2p_init', function () {
    p2p_register_connection_type(array('name' => 'video_to_question', 'from' => 'video', 'to' => 'question', 'cardinality' => 'one-to-one', 'admin_box' => array('context' => 'advanced'), 'title' => array('from' => __('Question', 'rt'), 'to' => __('Video', 'rt')), 'from_labels' => array('create' => __('Choose Video', 'rt')), 'to_labels' => array('create' => __('Choose Question', 'rt'))));
    p2p_register_connection_type(array('name' => 'submission_to_question', 'from' => 'submission', 'to' => 'question', 'cardinality' => 'one-to-one', 'admin_box' => array('context' => 'advanced'), 'title' => array('from' => __('Question', 'rt'), 'to' => __('Submission', 'rt')), 'from_labels' => array('create' => __('Choose Submission', 'rt')), 'to_labels' => array('create' => __('Choose Question', 'rt'))));
});