woocommerce_wp_radio

Output a radio input box.

Description

woocommerce_wp_radio( (array) $field ); 

Parameters (1)

0. $field (array)
The field.

Usage

  1. if ( !function_exists( 'woocommerce_wp_radio' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/admin/wc-meta-box-functions.php'; 
  3.  
  4. // The field. 
  5. $field = array(); 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = woocommerce_wp_radio($field); 
  9.  

Defined (1)

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

/includes/admin/wc-meta-box-functions.php  
  1. function woocommerce_wp_radio( $field ) { 
  2. global $thepostid, $post; 
  3.  
  4. $thepostid = empty( $thepostid ) ? $post->ID : $thepostid; 
  5. $field['class'] = isset( $field['class'] ) ? $field['class'] : 'select short'; 
  6. $field['style'] = isset( $field['style'] ) ? $field['style'] : ''; 
  7. $field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : ''; 
  8. $field['value'] = isset( $field['value'] ) ? $field['value'] : get_post_meta( $thepostid, $field['id'], true ); 
  9. $field['name'] = isset( $field['name'] ) ? $field['name'] : $field['id']; 
  10. $field['desc_tip'] = isset( $field['desc_tip'] ) ? $field['desc_tip'] : false; 
  11.  
  12. echo '<fieldset class="form-field ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><legend>' . wp_kses_post( $field['label'] ) . '</legend>'; 
  13.  
  14. if ( ! empty( $field['description'] ) && false !== $field['desc_tip'] ) { 
  15. echo wc_help_tip( $field['description'] ); 
  16.  
  17. echo '<ul class="wc-radios">'; 
  18.  
  19. foreach ( $field['options'] as $key => $value ) { 
  20.  
  21. echo '<li><label><input 
  22. name="' . esc_attr( $field['name'] ) . '" 
  23. value="' . esc_attr( $key ) . '" 
  24. type="radio" 
  25. class="' . esc_attr( $field['class'] ) . '" 
  26. style="' . esc_attr( $field['style'] ) . '" 
  27. ' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' 
  28. /> ' . esc_html( $value ) . '</label> 
  29. </li>'; 
  30. echo '</ul>'; 
  31.  
  32. if ( ! empty( $field['description'] ) && false === $field['desc_tip'] ) { 
  33. echo '<span class="description">' . wp_kses_post( $field['description'] ) . '</span>'; 
  34.  
  35. echo '</fieldset>';