Guest User

Untitled

a guest
Oct 4th, 2012
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // function: post_type BEGIN
  4. function post_type()
  5. {
  6.     // Create The Labels (Output) For The Post Type
  7.     $labels =
  8.     array(
  9.         // The plural form of the name of your post type.
  10.         'name' => __( 'What We Do'),
  11.        
  12.         // The singular form of the name of your post type.
  13.         'singular_name' => __('Portfolio'),
  14.        
  15.         // The rewrite of the post type
  16.         'rewrite' =>
  17.             array(
  18.                 // prepends our post type with this slug
  19.                 'slug' => __( 'portfolio' )
  20.             ),
  21.            
  22.         // The menu item for adding a new post.
  23.         'add_new' => _x('Add Item', 'portfolio'),
  24.        
  25.         // The header shown when editing a post.
  26.         'edit_item' => __('Edit Portfolio Item'),
  27.        
  28.         // Shown in the favourites menu in the admin header.
  29.         'new_item' => __('New Portfolio Item'),
  30.        
  31.         // Shown alongside the permalink on the edit post screen.
  32.         'view_item' => __('View Portfolio'),
  33.        
  34.         // Button text for the search box on the edit posts screen.
  35.         'search_items' => __('Search Portfolio'),
  36.        
  37.         // Text to display when no posts are found through search in the admin.
  38.         'not_found' =>  __('No Portfolio Items Found'),
  39.        
  40.         // Text to display when no posts are in the trash.
  41.         'not_found_in_trash' => __('No Portfolio Items Found In Trash'),
  42.          
  43.         // Used as a label for a parent post on the edit posts screen. Only useful for hierarchical post types.
  44.         'parent_item_colon' => ''
  45.     );
  46.    
  47.     // Set Up The Arguements
  48.     $args =
  49.     array(
  50.         // Pass The Array Of Labels
  51.         'labels' => $labels,
  52.        
  53.         // Display The Post Type To Admin
  54.         'public' => true,
  55.        
  56.         // Allow Post Type To Be Queried
  57.         'publicly_queryable' => true,
  58.        
  59.         // Build a UI for the Post Type
  60.         'show_ui' => true,
  61.        
  62.         // Use String for Query Post Type
  63.         'query_var' => true,
  64.        
  65.         // Rewrite the slug
  66.         'rewrite' => true,
  67.        
  68.         // Set type to construct arguements
  69.         'capability_type' => 'post',
  70.        
  71.         // Disable Hierachical - No Parent
  72.         'hierarchical' => false,
  73.        
  74.         // Set Menu Position for where it displays in the navigation bar
  75.         'menu_position' => null,
  76.        
  77.         // Allow the portfolio to support a Title, Editor, Thumbnail
  78.         'supports' =>
  79.             array(
  80.                 'title',
  81.                 'editor',
  82.                 'thumbnail'
  83.             )
  84.     );
  85.    
  86.     // Register The Post Type
  87.     register_post_type(__( 'gallery' ),$args);
  88.    
  89.    
  90. } // function: post_type END
  91.  
  92.  
  93. // function: portfolio_messages BEGIN
  94. function portfolio_messages($messages)
  95. {
  96.     $messages[__( 'portfolio' )] =
  97.         array(
  98.             // Unused. Messages start at index 1
  99.             0 => '',
  100.            
  101.             // Change the message once updated
  102.             1 => sprintf(__('Portfolio Updated. <a href="%s">View portfolio</a>'), esc_url(get_permalink($post_ID))),
  103.            
  104.             // Change the message if custom field has been updated
  105.             2 => __('Custom Field Updated.'),
  106.            
  107.             // Change the message if custom field has been deleted
  108.             3 => __('Custom Field Deleted.'),
  109.            
  110.             // Change the message once portfolio been updated
  111.             4 => __('Portfolio Updated.'),
  112.            
  113.             // Change the message during revisions
  114.             5 => isset($_GET['revision']) ? sprintf( __('Portfolio Restored To Revision From %s'), wp_post_revision_title((int)$_GET['revision'],false)) : false,
  115.            
  116.             // Change the message once published
  117.             6 => sprintf(__('Portfolio Published. <a href="%s">View Portfolio</a>'), esc_url(get_permalink($post_ID))),
  118.            
  119.             // Change the message when saved
  120.             7 => __('Portfolio Saved.'),
  121.            
  122.             // Change the message when submitted item
  123.             8 => sprintf(__('Portfolio Submitted. <a target="_blank" href="%s">Preview Portfolio</a>'), esc_url( add_query_arg('preview','true',get_permalink($post_ID)))),
  124.            
  125.             // Change the message when a scheduled preview has been made
  126.             9 => sprintf(__('Portfolio Scheduled For: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview Portfolio</a>'),date_i18n( __( 'M j, Y @ G:i' ),strtotime($post->post_date)), esc_url(get_permalink($post_ID))),
  127.            
  128.             // Change the message when draft has been made
  129.             10 => sprintf(__('Portfolio Draft Updated. <a target="_blank" href="%s">Preview Portfolio</a>'), esc_url( add_query_arg('preview','true',get_permalink($post_ID)))),
  130.         );
  131.     return $messages;  
  132.    
  133. } // function: portfolio_messages END
  134.  
  135. // function: portfolio_filter BEGIN
  136. function portfolio_filter()
  137. {
  138.     // Register the Taxonomy
  139.     register_taxonomy(__( "filters" ),
  140.    
  141.     // Assign the taxonomy to be part of the portfolio post type
  142.     array(__( "gallery" )),
  143.    
  144.     // Apply the settings for the taxonomy
  145.     array(
  146.         "hierarchical" => true,
  147.         "label" => __( "Filter" ),
  148.         "singular_label" => __( "Filter" ),
  149.         "rewrite" => array(
  150.                 'slug' => 'filter',
  151.                 'hierarchical' => true
  152.                 )
  153.         )
  154.     );
  155. } // function: portfolio_filter END
  156.  
  157.  
  158. add_action('init', 'post_type');
  159. add_action( 'init', 'portfolio_filter', 0 );
  160. add_filter('post_updated_messages', 'portfolio_messages');
  161.  
  162. ?>
RAW Paste Data