Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $new_meta_boxes_2 =
- array(
- "sidebar_override" => array(
- "name" => "sidebar_override",
- "std" => "",
- "title" => "Sidebar Override Text",
- "description" => "Values entered here will override the post title displayed in the sidebar widget."
- ),
- "associated_reviews" => array(
- "name" => "associated_reviews",
- "std" => "",
- "title" => "Associated Reviews",
- "description" => "Reviews Associated with this Feature")
- );
- function new_meta_boxes2() {
- global $post, $new_meta_boxes_2;
- $new_meta_boxes = $new_meta_boxes_2;
- foreach($new_meta_boxes as $meta_box) {
- $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
- if($meta_box_value == "")
- $meta_box_value = $meta_box['std'];
- echo'<div style="width:400px; height:200px; border-right:1px solid #efefef;
- border-bottom:1px solid #efefef; padding:15px; float:left;>';
- echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename"
- value="'.wp_create_nonce( -1 ).'" />';
- echo'<h2>'.$meta_box['title'].'</h2>';
- if ($meta_box['name'] != "associated_reviews")
- echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="40" /><br />';
- else if ($meta_box['name'] == "associated_reviews") {
- $assigned = explode(",", get_post_meta($post->ID, "associated_reviews_value", true));
- echo '<select name="associated_reviews[]" MULTIPLE="multiple" size="5" style="min-height: 80px">';
- global $wpdb;
- $posts = $wpdb->get_col("SELECT ID from wp_posts");
- foreach($posts as $p) {
- $ptype = get_post_type($p);
- if ($ptype == "reviews") {
- $p_data = get_post($p);
- $p_name = $p_data->post_title;
- if (in_array($p, $assigned)) $selected_string = "selected=\"selected\""; else $selected_string = "";
- if ($p_name != "Auto Draft") echo "<option value=\"{$p}\" {$selected_string}>{$p_name}<br /> </option>";
- }
- }
- echo '</select>';
- }
- echo'<p><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].'</label></p>';
- echo'</div>';
- }
- echo '<div style="clear:both;"></div>';
- }
- function create_meta_box3() {
- global $theme_name;
- if ( function_exists('add_meta_box') ) {
- add_meta_box( 'new-meta-boxes', 'Custom Tools Information', 'new_meta_boxes2', 'details',
- 'normal', 'high' );
- }
- }
- add_action('admin_menu', 'create_meta_box3');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement