Advertisement
Guest User

Untitled

a guest
Oct 20th, 2011
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.40 KB | None | 0 0
  1. <?php
  2.  
  3. $new_meta_boxes_2 =
  4. array(
  5.     "sidebar_override" => array(
  6.          "name" => "sidebar_override",
  7.          "std" => "",
  8.          "title" => "Sidebar Override Text",
  9.          "description" => "Values entered here will override the post title displayed in the sidebar widget."
  10.     ),
  11.  
  12.     "associated_reviews" => array(
  13.         "name" => "associated_reviews",
  14.         "std" => "",
  15.         "title" => "Associated Reviews",
  16.         "description" => "Reviews Associated with this Feature")
  17.     );
  18.  
  19. function new_meta_boxes2() {
  20. global $post, $new_meta_boxes_2;                  
  21.  
  22. $new_meta_boxes = $new_meta_boxes_2;
  23.  
  24. foreach($new_meta_boxes as $meta_box) {
  25. $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
  26.  
  27. if($meta_box_value == "")
  28. $meta_box_value = $meta_box['std'];
  29.  
  30. echo'<div style="width:400px; height:200px; border-right:1px solid #efefef;
  31. border-bottom:1px solid #efefef; padding:15px; float:left;>';
  32.  
  33. echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename"
  34. value="'.wp_create_nonce( -1 ).'" />';
  35. echo'<h2>'.$meta_box['title'].'</h2>';
  36.  
  37. if ($meta_box['name'] != "associated_reviews")
  38. echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="40" /><br />';
  39. else if ($meta_box['name'] == "associated_reviews") {
  40.   $assigned = explode(",", get_post_meta($post->ID, "associated_reviews_value", true));
  41.   echo '<select name="associated_reviews[]" MULTIPLE="multiple" size="5" style="min-height: 80px">';
  42.   global $wpdb;
  43.   $posts = $wpdb->get_col("SELECT ID from wp_posts");
  44.   foreach($posts as $p) {
  45.      $ptype = get_post_type($p);
  46.      if ($ptype == "reviews") {
  47.        $p_data = get_post($p);
  48.        $p_name = $p_data->post_title;
  49.        if (in_array($p, $assigned)) $selected_string = "selected=\"selected\""; else $selected_string = "";
  50.        if ($p_name != "Auto Draft") echo "<option value=\"{$p}\" {$selected_string}>{$p_name}<br /> </option>";
  51.      }
  52.   }
  53.   echo '</select>';
  54. }
  55. echo'<p><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].'</label></p>';
  56. echo'</div>';
  57. }
  58. echo '<div style="clear:both;"></div>';
  59. }
  60.  
  61.  
  62. function create_meta_box3() {
  63. global $theme_name;
  64. if ( function_exists('add_meta_box') ) {
  65. add_meta_box( 'new-meta-boxes', 'Custom Tools Information', 'new_meta_boxes2', 'details',
  66. 'normal', 'high' );
  67. }
  68. }
  69.  
  70.  
  71. add_action('admin_menu', 'create_meta_box3');
  72.  
  73. ?>
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement