Example #1
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 #2
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')];
                 }
             }
         }
     }
 }