RWMB_Select_Field

The Evolved RWMB Select Field class.

Defined (1)

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

/meta-box/inc/fields/select.php  
  1. class RWMB_Select_Field 
  2. /** 
  3. * Enqueue scripts and styles 
  4. * @return void 
  5. */ 
  6. static function admin_enqueue_scripts( ) 
  7. wp_enqueue_style( 'rwmb-select', RWMB_CSS_URL.'select.css', RWMB_VER ); 
  8.  
  9. /** 
  10. * Get field HTML 
  11. * @param string $html 
  12. * @param mixed $meta 
  13. * @param array $field 
  14. * @return string 
  15. */ 
  16. static function html( $html, $meta, $field ) 
  17. if ( ! is_array( $meta ) ) 
  18. $meta = (array) $meta; 
  19.  
  20. $std = isset( $field['disabled'] ) ? $field['disabled'] : false; 
  21. $disabled = disabled( $std, true, false ); 
  22.  
  23. $id = " id='{$field['id']}'"; 
  24. $name = " name='{$field['field_name']}'"; 
  25. $name .= $field['multiple'] ? " multiple='multiple'" : "" ; 
  26.  
  27. $html = "<select class='rwmb-select'{$name}{$id}{$disabled}>"; 
  28. foreach ( $field['options'] as $key => $value ) 
  29. $selected = selected( in_array( $key, $meta ), true, false ); 
  30. $html .= "<option value='{$key}'{$selected}>{$value}</option>"; 
  31. $html .= "</select>"; 
  32.  
  33. return $html;