Guest User

Untitled

a guest
May 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. function new_meta_boxes() {
  3. global $post, $new_meta_boxes;
  4.  
  5. foreach($new_meta_boxes as $meta_box) {
  6.  
  7. echo'<input type="hidden" name="'.$meta_box['name'].'_noncename" id="'.$meta_box['name'].'_noncename" value="'.wp_create_nonce( plugin_basename(__FILE__) ).'" />';
  8.  
  9. echo'<h2>'.$meta_box['title'].'</h2>';
  10.  
  11. if( $meta_box['type'] == "text" ) {
  12.  
  13. $meta_box_value = get_post_meta($post->ID, $meta_box['name'].'_value', true);
  14.  
  15. if($meta_box_value == "")
  16. $meta_box_value = $meta_box['std'];
  17.  
  18. echo'<input type="text" name="'.$meta_box['name'].'_value" value="'.$meta_box_value.'" size="55" /><br />';
  19.  
  20. } elseif ( $meta_box['type'] == "select" ) {
  21.  
  22. echo'<select name="'.$meta_box['name'].'_value">';
  23.  
  24. foreach ($meta_box['options'] as $option) {
  25.  
  26. echo'<option';
  27. if ( get_post_meta($post->ID, $meta_box['name'].'_value', true) == $option ) {
  28. echo ' selected="selected"';
  29. } elseif ( $option == $meta_box['std'] ) {
  30. echo ' selected="selected"';
  31. }
  32. echo'>'. $option .'</option>';
  33.  
  34. }
  35.  
  36. echo'</select>';
  37.  
  38. }
  39.  
  40. echo'<p><label for="'.$meta_box['name'].'_value">'.$meta_box['description'].'</label></p>';
  41. }
  42. }
  43. ?>
Add Comment
Please, Sign In to add comment