ReduxFramework_button_set

Main ReduxFramework_button_set class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/button_set/field_button_set.php  
  1. class ReduxFramework_button_set { 
  2.  
  3. /** 
  4. * Holds configuration settings for each field in a model. 
  5. * Defining the field options 
  6. * array['fields'] array Defines the fields to be shown by scaffolding. 
  7. * [fieldName] array Defines the options for a field, or just enables the field if array is not applied. 
  8. * ['name'] string Overrides the field name (default is the array key) 
  9. * ['model'] string (optional) Overrides the model if the field is a belongsTo associated value. 
  10. * ['width'] string Defines the width of the field for paginate views. Examples are "100px" or "auto" 
  11. * ['align'] string Alignment types for paginate views (left, right, center) 
  12. * ['format'] string Formatting options for paginate fields. Options include ('currency', 'nice', 'niceShort', 'timeAgoInWords' or a valid Date() format) 
  13. * ['title'] string Changes the field name shown in views. 
  14. * ['desc'] string The description shown in edit/create views. 
  15. * ['readonly'] boolean True prevents users from changing the value in edit/create forms. 
  16. * ['type'] string Defines the input type used by the Form helper (example 'password') 
  17. * ['options'] array Defines a list of string options for drop down lists. 
  18. * ['editor'] boolean If set to True will show a WYSIWYG editor for this field. 
  19. * ['default'] string The default value for create forms. 
  20. * @param array $arr (See above) 
  21. * @return Object A new editor object. 
  22. * */ 
  23. static $_properties = array( 
  24. 'id' => 'Identifier',  
  25. ); 
  26.  
  27. /** 
  28. * Field Constructor. 
  29. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function 
  30. * @since 1.0.0 
  31. * @access public 
  32. * @return void 
  33. */ 
  34. function __construct( $field = array(), $value = '', $parent ) { 
  35.  
  36. $this->parent = $parent; 
  37. $this->field = $field; 
  38. $this->value = $value; 
  39.  
  40. /** 
  41. * Field Render Function. 
  42. * Takes the vars and outputs the HTML for the field in the settings 
  43. * @since 1.0.0 
  44. * @access public 
  45. * @return void 
  46. */ 
  47. public function render() { 
  48.  
  49. // multi => true renders the field multi-selectable (checkbox vs radio) 
  50. echo '<div class="buttonset ui-buttonset">'; 
  51. $i = 0; 
  52. foreach ( $this->field['options'] as $k => $v ) { 
  53.  
  54. $selected = ''; 
  55. if ( isset( $this->field['multi'] ) && $this->field['multi'] == true ) { 
  56. $type = "checkbox"; 
  57. $multi_suffix = '[]'; 
  58.  
  59. if ( ! empty( $this->value ) && ! is_array( $this->value ) ) { 
  60. $this->value = array( $this->value ); 
  61.  
  62. if ( is_array( $this->value ) && in_array( $k, $this->value ) ) { 
  63. $selected = 'checked="checked"'; 
  64.  
  65. } else { 
  66. $multi_suffix = ""; 
  67. $type = "radio"; 
  68. $selected = checked( $this->value, $k, false ); 
  69.  
  70. echo '<input data-id="' . $this->field['id'] . '" type="' . $type . '" id="' . $this->field['id'] . '-buttonset' . $k . '" name="' . $this->field['name'] . $this->field['name_suffix'] . $multi_suffix . '" class="buttonset-item ' . $this->field['class'] . '" value="' . $k . '" ' . $selected . '/>'; 
  71. echo '<label for="' . $this->field['id'] . '-buttonset' . $k . '">' . $v . '</label>'; 
  72.  
  73. echo '</div>'; 
  74.  
  75. /** 
  76. * Enqueue Function. 
  77. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  78. * @since 1.0.0 
  79. * @access public 
  80. * @return void 
  81. */ 
  82. public function enqueue() { 
  83.  
  84. wp_enqueue_script( 
  85. 'redux-field-button-set-js',  
  86. ReduxFramework::$_url . 'inc/fields/button_set/field_button_set' . Redux_Functions::isMin() . '.js',  
  87. array( 'jquery', 'jquery-ui-core', 'redux-js' ),  
  88. time(),  
  89. true 
  90. );