xinwp_option_display

The Advantage xinwp option display function.

Description

xinwp_option_display( (string) $option_name ); 

Parameters (1)

0. $option_name (string)
The option name.

Usage

  1. if ( !function_exists( 'xinwp_option_display' ) ) { 
  2. require_once '/inc/theme-options.php'; 
  3.  
  4. // The option name. 
  5. $option_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = xinwp_option_display($option_name); 
  9.  

Defined (1)

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

/inc/theme-options.php  
  1. function xinwp_option_display( $option_name ) { 
  2. global $advantage_options, $advantage_theme_options, $advantage_fonts; 
  3. $theme_option = $advantage_theme_options[ $option_name ]; 
  4. $options = $advantage_options; 
  5. if ( $theme_option['type'] != 'hidden' && empty( $theme_option['fieldonly'] ) ) { 
  6. if ( isset( $theme_option['label'] ) ) { 
  7. echo '<div class="grid_3 alpha">';  
  8. echo '<p><b>' . $theme_option['label'] . '</b></p></div>';  
  9. echo '<div class="grid_9"><p>';  
  10. switch ( $theme_option['type'] ) { 
  11. case 'radio': 
  12. $values = $theme_option['values']; 
  13. foreach ( $values as $value ) { 
  14. printf( '<input id="advantage_theme_options[%1$s]_%2$s" name="advantage_theme_options[%1$s]" type="radio" value="%2$s" %3$s />',  
  15. $theme_option['name'],  
  16. $value['key'],  
  17. checked( $value['key'], $options[$theme_option['name']], false ) ); 
  18. printf( '<label class="description" for="advantage_theme_options[%1$s]_%2$s">%3$s</label>',  
  19. $theme_option['name'],  
  20. $value['key'],  
  21. esc_attr( $value['label'] ) ); 
  22. break; 
  23. case 'checkbox': 
  24. printf( '<input id="advantage_theme_options[%1$s]" name="advantage_theme_options[%1$s]" type="checkbox" value="1" %2$s />',  
  25. $theme_option['name'],  
  26. checked( '1', $options[$theme_option['name']], false ) ); 
  27. printf( '<label class="description" for="advantage_theme_options[%1$s]">%2$s</label>',  
  28. $theme_option['name'],  
  29. esc_attr( $theme_option['desc'] ) ); 
  30. break;  
  31. case 'url': 
  32. case 'text': 
  33. printf( '<input name="advantage_theme_options[%s]" type="text" value="%s" size="80" />',  
  34. $theme_option['name'],  
  35. esc_attr( $options[$theme_option['name']] ) ); 
  36. break; 
  37. case 'color': 
  38. printf( '<input name="advantage_theme_options[%1$s]" type="text" value="%2$s" class="advantage-color-field" />',  
  39. $theme_option['name'],  
  40. esc_attr( $options[$theme_option['name']] ) ); 
  41. break; 
  42. case 'textarea': 
  43. printf( '<textarea name="advantage_theme_options[%s]" cols="120" rows="%s">%s</textarea>',  
  44. $theme_option['name'],  
  45. $theme_option['row'],  
  46. esc_textarea( $options[ $theme_option['name'] ] ) ); 
  47. break; 
  48. case 'number': 
  49. if ( ! empty( $theme_option['fieldonly'] ) && ! empty( $theme_option['label'] ) ) 
  50. printf( '<label class="description">%s</label>', esc_attr( $theme_option['label'] ) ); 
  51. printf( '<input name="advantage_theme_options[%s]" type="text" value="%s" size="4" />',  
  52. $theme_option['name'],  
  53. esc_attr( $options[ $theme_option['name'] ] ) ); 
  54. if ( ! empty( $theme_option['desc'] ) ) 
  55. printf( '<label class="description">%s</label>', esc_attr( $theme_option['desc'] ) ); 
  56. echo '    '; 
  57. break; 
  58. case 'select': 
  59. printf( '<select name="advantage_theme_options[%s]" >',  
  60. $theme_option['name'] ); 
  61. foreach ( $theme_option['values'] as $value ) { 
  62. printf ('<option value="%1$s" %2$s>%3$s</option>',  
  63. $value['key'],  
  64. selected( $options[$theme_option['name']], $value['key'], false ),  
  65. $value['label'] ); 
  66. echo '</select>'; 
  67. break; 
  68. case 'font': 
  69. printf( '<select style="font-family:%2$s;font-size:14px;" name="advantage_theme_options[%1$s]" >',  
  70. $theme_option['name'],  
  71. $advantage_fonts[ $options[ $theme_option['name'] ] ]['family'] ); 
  72. $old_font_type = ''; 
  73. foreach ( $theme_option['values'] as $value ) { 
  74. if ( $value['type'] != $old_font_type ) { 
  75. if ( $old_font_type != '' ) 
  76. echo '</optgroup>'; 
  77. printf( '<optgroup label="%1$s">', $value['type'] );  
  78. printf( '<option style="font-family: %4$s;%5$s" value="%1$s" %2$s>%3$s</option>',  
  79. $value['key'],  
  80. selected( $options[ $theme_option['name'] ], $value['key'], false ),  
  81. $value['label'],  
  82. $value['family'],  
  83. ( empty( $value['url'] ) ? '' : 'color:blue;' ) ); 
  84. $old_font_type = $value['type'];  
  85. echo '</optgroup>'; 
  86. echo '</select>'; 
  87. printf( '  <span style="font-family:%2$s;font-size:16px;%3$s">%1$s</span>',  
  88. 'The quick brown fox jumps over the lazy dog.',  
  89. $advantage_fonts[$options[$theme_option['name']]]['family'],  
  90. ( empty($advantage_fonts[ $options[ $theme_option['name'] ] ]['url'] ) ? '' : 'color:blue;' ) ); 
  91. break; 
  92. case 'category': 
  93. printf( '<select name="advantage_theme_options[%s]" >',  
  94. $theme_option['name'] ); 
  95. $selected_category = $options[ $theme_option['name'] ]; 
  96. printf( '<option value="0" %1$s>%2$s</option>',  
  97. selected( $options[ $theme_option['name'] ], 0, false ),  
  98. __('All Categories', 'advantage') ); 
  99.  
  100. foreach ( advantage_categories() as $option ) { 
  101. printf( '<option value="%1$s" %2$s>%3$s</option>',  
  102. $option->term_id,  
  103. selected( $selected_category, $option->term_id, false ),  
  104. $option->name ); 
  105. echo '</select>'; 
  106. break; 
  107. case 'hidden': 
  108. printf( '<input id="%1$s" name="advantage_theme_options[%1$s]" type="hidden" value="%2$s" />',  
  109. $theme_option['name'],  
  110. esc_attr( $options[ $theme_option['name'] ] ) ); 
  111. break; 
  112. default: 
  113. echo __( 'Not Availavle Yet', 'advantage' );  
  114. if ( $theme_option['type'] != 'hidden' && empty( $theme_option['fieldonly'] ) ) { 
  115. echo '</p>'; 
  116. if ( ! empty( $theme_option['helptext'] ) ) 
  117. printf( '<p><label class="helptext">%s</label></p>', $theme_option['helptext']); 
  118. echo '</div><div class="clear"></div>';