Example #1
0
 function thb_works_post_type()
 {
     /**
      * The post type labels.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $thb_works_labels = array('name' => __('Portfolio', 'thb_text_domain'), 'singular_name' => __('Work', 'thb_text_domain'), 'add_new' => __('Add new', 'thb_text_domain'), 'add_new_item' => __('Add new Work', 'thb_text_domain'), 'edit' => __('Edit', 'thb_text_domain'), 'edit_item' => __('Edit Work', 'thb_text_domain'), 'new_item' => __('New Work', 'thb_text_domain'), 'view' => __('View Work', 'thb_text_domain'), 'view_item' => __('View Work', 'thb_text_domain'), 'search_items' => __('Search Works', 'thb_text_domain'), 'not_found' => __('No Works found', 'thb_text_domain'), 'not_found_in_trash' => __('No Works found in Trash', 'thb_text_domain'), 'parent' => __('Parent Work', 'thb_text_domain'));
     /**
      * The post type arguments.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $options_slug = thb_get_option('works_url_slug');
     $slug = !empty($options_slug) ? $options_slug : 'works';
     $thb_works_args = array('labels' => $thb_works_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => $slug, 'with_front' => true), 'query_var' => true, 'show_in_nav_menus' => false, 'supports' => array('title', 'thumbnail', 'excerpt', 'editor', 'comments'));
     /**
      * Create the post type object.
      */
     $thb_works = new THB_PostType('works', $thb_works_args);
     /**
      * Create the post type taxonomy for Works categories.
      */
     $thb_works_taxonomy = new THB_Taxonomy("portfolio_categories", array('hierarchical' => true, 'label' => __('Portfolio Categories', 'thb_text_domain'), 'singular_label' => __('Portfolio Category', 'thb_text_domain'), 'rewrite' => true, 'query_var' => true));
     $thb_works->addTaxonomy($thb_works_taxonomy);
     /**
      * Add the post type to the theme instance.
      */
     $thb_theme = thb_theme();
     $thb_theme->addPostType($thb_works);
 }
Example #2
0
 /**
  * Create a Footer Stripe custom post type and add it to the theme.
  *
  * @return void
  */
 function thb_create_footerstripes_posttype()
 {
     /**
      * The post type labels.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $thb_footerstripes_labels = array('name' => __('Footer Stripes', 'thb_text_domain'), 'singular_name' => __('Footer Stripe', 'thb_text_domain'), 'add_new' => __('Add new', 'thb_text_domain'), 'add_new_item' => __('Add new Footer Stripe', 'thb_text_domain'), 'edit' => __('Edit', 'thb_text_domain'), 'edit_item' => __('Edit Footer Stripe', 'thb_text_domain'), 'new_item' => __('New Footer Stripe', 'thb_text_domain'), 'view' => __('View Footer Stripe', 'thb_text_domain'), 'view_item' => __('View Footer Stripe', 'thb_text_domain'), 'search_items' => __('Search Footer Stripes', 'thb_text_domain'), 'not_found' => __('No Footer Stripes found', 'thb_text_domain'), 'not_found_in_trash' => __('No Footer Stripes found in Trash', 'thb_text_domain'), 'parent' => __('Parent Footer Stripe', 'thb_text_domain'));
     /**
      * The post type arguments.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $thb_footerstripes_args = array('labels' => $thb_footerstripes_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'footerstripes', 'with_front' => true), 'query_var' => true, 'show_in_nav_menus' => false, 'supports' => array('title'));
     /**
      * Create the post type object.
      */
     $thb_footerstripes = new THB_PostType('footerstripes', $thb_footerstripes_args);
     $thb_footerstripes->setPublicContent(false);
     /**
      * Add the post type to the theme instance.
      */
     thb_theme()->addPostType($thb_footerstripes);
     /**
      * Post type metaboxes
      */
     add_action('wp_loaded', 'thb_add_footerstripes_posttype_config_metabox');
 }
Example #3
0
/**
 * Portfolio custom post type.
 *
 * ---
 *
 * The Happy Framework: WordPress Development Framework
 * Copyright 2012, Andrea Gandino & Simone Maranzana
 *
 * Licensed under The MIT License
 * Redistribuitions of files must retain the above copyright notice.
 *
 * @package THB Portfolio
 * @author The Happy Bit <*****@*****.**>
 * @copyright Copyright 2012, Andrea Gandino & Simone Maranzana
 * @link http://
 * @since The Happy Framework v 1.0
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
function thb_portfolio_post_type()
{
    /**
     * The post type labels.
     *
     * @see http://codex.wordpress.org/Function_Reference/register_post_type
     */
    $thb_works_labels = array('name' => __('Portfolio', 'thb-portfolio'), 'singular_name' => __('Work', 'thb-portfolio'), 'add_new' => __('Add new', 'thb-portfolio'), 'add_new_item' => __('Add new Work', 'thb-portfolio'), 'edit' => __('Edit', 'thb-portfolio'), 'edit_item' => __('Edit Work', 'thb-portfolio'), 'new_item' => __('New Work', 'thb-portfolio'), 'view' => __('View Work', 'thb-portfolio'), 'view_item' => __('View Work', 'thb-portfolio'), 'search_items' => __('Search Works', 'thb-portfolio'), 'not_found' => __('No Works found', 'thb-portfolio'), 'not_found_in_trash' => __('No Works found in Trash', 'thb-portfolio'), 'parent' => __('Parent Work', 'thb-portfolio'));
    /**
     * The post type arguments.
     *
     * @see http://codex.wordpress.org/Function_Reference/register_post_type
     */
    if (thb_portfolio_framework_check()) {
        $options_slug = thb_get_option('works_url_slug');
    } else {
        $options_slug = apply_filters('thb_portfolio_slug', '');
    }
    $slug = !empty($options_slug) ? $options_slug : 'works';
    $thb_works_args = array('labels' => $thb_works_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => $slug, 'with_front' => true), 'query_var' => true, 'show_in_nav_menus' => true, 'supports' => array('title', 'thumbnail', 'excerpt', 'editor', 'comments', 'custom-fields'));
    /**
     * Create the post type object.
     */
    register_post_type('works', $thb_works_args);
    if (thb_portfolio_framework_check()) {
        $thb_works = new THB_PostType('works', $thb_works_args);
    }
    /**
     * Create the post type taxonomy for Works categories.
     */
    $thb_portfolio_categories_args = array('hierarchical' => true, 'labels' => array('name' => __('Portfolio Categories', 'thb-portfolio'), 'singular_name' => __('Portfolio Category', 'thb-portfolio'), 'search_items' => __('Search Portfolio Categories', 'thb-portfolio'), 'all_items' => __('All Portfolio Categories', 'thb-portfolio'), 'parent_item' => __('Parent Portfolio Category', 'thb-portfolio'), 'parent_item_colon' => __('Parent Portfolio Category:', 'thb-portfolio'), 'edit_item' => __('Edit Portfolio Category', 'thb-portfolio'), 'update_item' => __('Update Portfolio Category', 'thb-portfolio'), 'add_new_item' => __('Add New Portfolio Category', 'thb-portfolio'), 'new_item_name' => __('New Portfolio Category Name', 'thb-portfolio'), 'menu_name' => __('Portfolio Category', 'thb-portfolio')), 'rewrite' => true, 'query_var' => true);
    register_taxonomy('portfolio_categories', 'works', $thb_portfolio_categories_args);
    if (thb_portfolio_framework_check()) {
        $thb_works_taxonomy = new THB_Taxonomy('portfolio_categories', $thb_portfolio_categories_args);
        $thb_works->addTaxonomy($thb_works_taxonomy);
    }
    /**
     * Add the post type to the theme instance.
     */
    if (thb_portfolio_framework_check()) {
        $thb_theme = thb_theme();
        $thb_theme->addPostType($thb_works);
    }
}
Example #4
0
 /**
  * Create a Slideshow custom post type and add it to the theme.
  *
  * @return void
  */
 function thb_create_slideshows_posttype()
 {
     /**
      * The post type labels.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $thb_slideshows_labels = array('name' => __('Slideshows', 'thb_text_domain'), 'singular_name' => __('Slideshow', 'thb_text_domain'), 'add_new' => __('Add new', 'thb_text_domain'), 'add_new_item' => __('Add new Slideshow', 'thb_text_domain'), 'edit' => __('Edit', 'thb_text_domain'), 'edit_item' => __('Edit Slideshow', 'thb_text_domain'), 'new_item' => __('New Slideshow', 'thb_text_domain'), 'view' => __('View Slideshow', 'thb_text_domain'), 'view_item' => __('View Slideshow', 'thb_text_domain'), 'search_items' => __('Search Slideshows', 'thb_text_domain'), 'not_found' => __('No Slideshows found', 'thb_text_domain'), 'not_found_in_trash' => __('No Slideshows found in Trash', 'thb_text_domain'), 'parent' => __('Parent Slideshow', 'thb_text_domain'));
     /**
      * The post type arguments.
      *
      * @see http://codex.wordpress.org/Function_Reference/register_post_type
      */
     $thb_slideshows_args = array('labels' => $thb_slideshows_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => 'slideshows', 'with_front' => true), 'query_var' => true, 'show_in_nav_menus' => false, 'supports' => array('title'));
     /**
      * Create the post type object.
      */
     $thb_slideshows = new THB_PostType('slideshows', $thb_slideshows_args);
     $thb_slideshows->setPublicContent(false);
     /**
      * Add the post type to the theme instance.
      */
     thb_theme()->addPostType($thb_slideshows);
     /**
      * Post type metaboxes
      */
     add_action('wp_loaded', 'thb_add_slideshows_posttype_config_metabox');
     add_action('wp_loaded', 'thb_add_slideshows_posttype_slides_metabox');
     /**
      * Admin UI customizations
      */
     add_filter('manage_edit-slideshows_columns', 'listTableAddPicsColumn');
     add_action('manage_posts_custom_column', 'listTablePicsColumnContent', 10, 2);
     if (!function_exists('listTableAddPicsColumn')) {
         function listTableAddPicsColumn($defaults)
         {
             $link = __('Slides', 'thb_text_domain');
             $insertAt = 4;
             $defaults = array_slice($defaults, 0, $insertAt, true) + array('slides' => $link) + array_slice($defaults, $insertAt, count($defaults) - $insertAt, true);
             $link = __('Shortcode', 'thb_text_domain');
             $insertAt = 3;
             $defaults = array_slice($defaults, 0, $insertAt, true) + array('shortcode' => $link) + array_slice($defaults, $insertAt, count($defaults) - $insertAt, true);
             $link = __('Type', 'thb_text_domain');
             $insertAt = 5;
             $defaults = array_slice($defaults, 0, $insertAt, true) + array('type' => $link) + array_slice($defaults, $insertAt, count($defaults) - $insertAt, true);
             unset($defaults['date']);
             return $defaults;
         }
     }
     if (!function_exists('listTablePicsColumnContent')) {
         function listTablePicsColumnContent($column_name, $id)
         {
             if ($column_name == 'slides') {
                 $slideshow = new THB_Slideshow($id);
                 foreach ($slideshow->getSlides() as $slide) {
                     $thumb = $slide['thumb'];
                     echo '<img src="' . $thumb . '" alt="" class="list-thumb ' . $slide['type'] . '">';
                 }
             } elseif ($column_name == 'shortcode') {
                 echo '<code>[thb_slideshow id="' . $id . '"]</code>';
             } elseif ($column_name == 'type') {
                 $types = thb_slideshows_types();
                 if (isset($types[thb_get_post_meta($id, 'slideshow_type')])) {
                     echo $types[thb_get_post_meta($id, 'slideshow_type')];
                 }
             }
         }
     }
 }