advantage_meta_display

The Advantage advantage meta display function.

Description

advantage_meta_display(); 

Usage

  1. if ( !function_exists( 'advantage_meta_display' ) ) { 
  2. require_once '/inc/lib-admin.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = advantage_meta_display(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/lib-admin.php  
  1. function advantage_meta_display() { 
  2. global $advantage_meta_box, $post; 
  3.  
  4. // Use nonce for verification 
  5. echo '<input type="hidden" name="advantage_meta_box_nonce" value="', wp_create_nonce( basename( __FILE__ ) ), '" />'; 
  6.  
  7. foreach ( $advantage_meta_box[ $post->post_type ]['fields'] as $field ) { 
  8. $meta = get_post_meta( $post->ID, $field['id'], true); 
  9.  
  10. if ('hidden' != $field['type'] ) 
  11. echo '<p id="p' . $field['id'] . '"><strong>' . $field['name'] . ' </strong>'; 
  12.  
  13. switch ( $field['type'] ) { 
  14. case 'text': 
  15. echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ( $meta ? $meta : $field['default'] ) . '" size="30" />'; 
  16. break; 
  17. case 'hidden': 
  18. echo '<input type="hidden" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ( $meta ? $meta : $field['default'] ) . '" />'; 
  19. break; 
  20. case 'textarea': 
  21. echo '<textarea name="' . $field['id'] . '" id="'. $field['id'] . '" cols="60" rows="4" >' . ( $meta ? $meta : $field['default'] ) . '</textarea>' . '<br />' . $field['desc']; 
  22. break; 
  23. case 'number': 
  24. echo '<input type="text" name="' . $field['id'] . '" id="' . $field['id'] . '" value="' . ( $meta ? $meta : $field['default'] ) . '" size="4" />'; 
  25. break; 
  26. case 'select': 
  27. echo '<select name="'. $field['id'] . '" id="'. $field['id'] . '">'; 
  28. foreach ( $field['options'] as $option ) { 
  29. echo '<option value="' . $option['key'] . '" ' . ( $meta == $option['key'] ? ' selected="selected"' : '' ) . '>' . $option['name'] . '</option>'; 
  30. echo '</select> ' . $field['desc']; 
  31. break; 
  32. case 'category': 
  33. echo '<select name="'. $field['id'] . '" id="'. $field['id'] . '">';  
  34. echo '<option value="" ' . ( $meta ? '' : 'selected="selected"' ) . '>' . __('All Categories', 'advantage') . '</option>'; 
  35. foreach ( advantage_categories() as $category ) { 
  36. echo '<option value="' . $category->term_id . '" ' . ( $meta == $category->term_id ? ' selected="selected"' : '' ) . '>' . $category->name . '</option>'; 
  37. echo '</select>'; 
  38. break; 
  39. case 'radio': 
  40. foreach ( $field['options'] as $option ) { 
  41. echo '<label class="description"><input type="radio" name="' . $field['id'] . '" value="' . $option['key'] . '"' . ( $meta == $option['key'] ? ' checked="checked"' : '' ) . ' /> ' . $option['name'] . '</label>'; 
  42. break; 
  43. case 'checkbox': 
  44. echo '<label class="description"><input type="checkbox" name="' . $field['id'] . '" id="' . $field['id'] . '" value="1"' . ( $meta ? ' checked="checked"' : '' ) . ' /> ' . $field['desc'] . '</label>'; 
  45. break; 
  46. echo '</p>';