ReduxFramework_switch

The Gravity Forms Advanced File Uploader ReduxFramework switch class.

Defined (1)

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

/inc/ReduxFramework/ReduxCore/inc/fields/switch/field_switch.php  
  1. class ReduxFramework_switch { 
  2.  
  3. /** 
  4. * Field Constructor. 
  5. * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function 
  6. * @since ReduxFramework 0.0.4 
  7. */ 
  8. function __construct( $field = array(), $value = '', $parent ) { 
  9. $this->parent = $parent; 
  10. $this->field = $field; 
  11. $this->value = $value; 
  12.  
  13. /** 
  14. * Field Render Function. 
  15. * Takes the vars and outputs the HTML for the field in the settings 
  16. * @since ReduxFramework 0.0.4 
  17. */ 
  18. function render() { 
  19.  
  20. $cb_enabled = $cb_disabled = ''; //no errors, please 
  21. // 
  22. //Get selected 
  23. if ( (int) $this->value == 1 ) { 
  24. $cb_enabled = ' selected'; 
  25. } else { 
  26. $cb_disabled = ' selected'; 
  27.  
  28. //Label ON 
  29. $this->field['on'] = isset( $this->field['on'] ) ? $this->field['on'] : __( 'On', 'redux-framework' ); 
  30.  
  31. //Label OFF 
  32. $this->field['off'] = isset( $this->field['off'] ) ? $this->field['off'] : __( 'Off', 'redux-framework' ); 
  33.  
  34. echo '<div class="switch-options">'; 
  35. echo '<label class="cb-enable' . $cb_enabled . '" data-id="' . $this->field['id'] . '"><span>' . $this->field['on'] . '</span></label>'; 
  36. echo '<label class="cb-disable' . $cb_disabled . '" data-id="' . $this->field['id'] . '"><span>' . $this->field['off'] . '</span></label>'; 
  37. echo '<input type="hidden" class="checkbox checkbox-input' . $this->field['class'] . '" id="' . $this->field['id'] . '" name="' . $this->field['name'] . $this->field['name_suffix'] . '" value="' . $this->value . '" />'; 
  38. echo '</div>'; 
  39. } //function 
  40.  
  41. /** 
  42. * Enqueue Function. 
  43. * If this field requires any scripts, or css define this function and register/enqueue the scripts/css 
  44. * @since ReduxFramework 0.0.4 
  45. */ 
  46. function enqueue() { 
  47.  
  48. wp_enqueue_script( 
  49. 'redux-field-switch-js',  
  50. ReduxFramework::$_url . 'inc/fields/switch/field_switch' . Redux_Functions::isMin() . '.js',  
  51. array( 'jquery', 'redux-js' ),  
  52. time(),  
  53. true 
  54. ); 
  55.  
  56. redux_enqueue_style( 
  57. $this->parent,  
  58. 'redux-field-switch-css',  
  59. ReduxFramework::$_url . 'inc/fields/switch/field_switch.css',  
  60. ReduxFramework::$_dir . 'inc/fields/switch',  
  61. array(),  
  62. time(),  
  63. false 
  64. );  
  65.  
  66. // wp_enqueue_style( 
  67. // 'redux-field-switch-css',  
  68. // ReduxFramework::$_url . 'inc/fields/switch/field_switch.css',  
  69. // time(),  
  70. // true 
  71. // );