Advertisement
Viper007Bond

Untitled

Oct 7th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.40 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'init', 'shawnrisk_create_homeslider' );
  4. add_action( 'add_meta_boxes', 'shawnrisk_add_meta_boxes' );
  5. add_action('save_post', 'shawnrisk_save_homeslider_details');
  6. add_action('manage_posts_custom_columns', 'shawnrisk_homeslider_custom_columns');
  7. add_filter('manage_edit-homeslider_columns', 'shawnrisk_homeslider_edit_columns');
  8.  
  9. function create_homeslider() {
  10.     register_post_type( 'homeslider',
  11.         array(
  12.             'labels' => array(
  13.                 'name' => _x('Home Slider', 'post type general name'),
  14.                 'singular_name' => _x('Home Slider', 'post type singular name'),
  15.                 'add_new' => _x('Add New', 'Home Slider'),
  16.                 'add_new_item' => __('Add New Home Slider'),
  17.                 'edit_item' => __('Edit Home Slider'),
  18.                 'new_item' => __('New Home Slider'),
  19.                 'view_item' => __('View Home Slider'),
  20.                 'search_items' => __('Search Home Slider'),
  21.                 'not_found' =>  __('No Home Sliders found'),
  22.                 'not_found_in_trash' => __('No Home Sliders found in Trash'),
  23.                 'parent_item_colon' => ''
  24.             ),
  25.             'public' => true,
  26.             'supports' => array( 'title', 'editor', 'custom-fields', 'revisions', 'excerpt' ),
  27.         )
  28.     );
  29.  
  30.     register_taxonomy("Template", array("homeslider"), array("hierarchical" => true, "label" => "Templates", "singular_label" => "Template", "show_ui" => true, "rewrite" => true));
  31. }
  32.  
  33. function shawnrisk_add_meta_boxes() {
  34.     add_meta_box("actioncall_meta", "Action Call", "shawnrisk_actioncall_meta", "homeslider", "normal", "low");
  35.     add_meta_box("buttontype_meta", "Button Type", "shawnrisk_buttontype_meta", "homeslider", "normal", "low");
  36.     add_meta_box("tagline_meta", "Tag Line", "shawnrisk_tagline_meta", "homeslider", "normal", "low");
  37. }
  38.  
  39. function shawnrisk_actioncall_meta() {
  40.     global $post;
  41.  
  42.     $custom = get_post_custom($post->ID);
  43.     $actioncalls = $custom["actioncalls"][0];
  44.  
  45.     echo '<p><label>Action Call</label><br /> <textarea cols="50" rows="5" name="actioncalls">' . esc_textarea( $actioncalls ) . '</textarea></p>';
  46. }
  47.  
  48. function shawnrisk_buttontype_meta() {
  49.     global $post;
  50.  
  51.     $custom = get_post_custom($post->ID);
  52.     $buttontypes = $custom["buttontypes"][0];
  53.  
  54.     echo '<p><label>Button Type</label><br /> <input type="radio" value="View" name="buttontypes" />View <input type="radio" value="Shop" name="buttontypes" />Shop</p>';
  55. }
  56.  
  57. function shawnrisk_tagline_meta() {
  58.     global $post;
  59.  
  60.     $custom = get_post_custom($post->ID);
  61.     $taglines = $custom["taglines"][0];
  62.  
  63.     echo '<p><label>Tag Line</label><br /> <textarea cols="50" rows="5" name="taglines">' . esc_textarea( $taglines ) . '</textarea></p>';
  64. }
  65.  
  66. function shawnrisk_save_homeslider_details() {
  67.     global $post;
  68.  
  69.     // You need some validation here
  70.     // See http://codex.wordpress.org/Data_Validation
  71.     update_post_meta($post->ID, "actioncalls", $_POST["actioncalls"]);
  72.     update_post_meta($post->ID, "buttontypes", $_POST["buttontypes"]);
  73.     update_post_meta($post->ID, "taglines", $_POST["taglines"]);
  74. }
  75.  
  76.  
  77. function shawnrisk_homeslider_edit_columns($columns) {
  78.     $columns = array(
  79.         "cb" => "<input type="checkbox" />",
  80.         "title" => "Home Slider Title",
  81.         "description" => "Description",
  82.         "date" => "Date Posted",
  83.         "tagline" => "Tag Line",
  84.     );
  85.  
  86.     return $columns;
  87. }
  88.  
  89. function shawnrisk_homeslider_custom_columns($columns) {
  90.     global $post;
  91.  
  92.     switch($columns) {
  93.         case "description":
  94.             the_excerpt();
  95.             break;
  96.         case "date":
  97.             echo the_time('jS F Y');
  98.             break;
  99.         case "tagline":
  100.             echo $custom["taglines"][0];
  101.         break;
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement