PluginProbe
QuadMenu – Mega Menu / 1.8.8
QuadMenu – Mega Menu v1.8.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / lib / ReduxCore / inc / fields / switch / field_switch.php

field_switch.php in QuadMenu – Mega Menu 1.8.8, at lib/ReduxCore/inc/fields/switch/field_switch.php

79 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 if ( ! class_exists( 'ReduxFramework_switch' ) ) {
9 class ReduxFramework_switch {
10
11 /**
12 * Field Constructor.
13 * Required - must call the parent constructor, then assign field and value to vars, and obviously call the render field function
14 *
15 * @since ReduxFramework 0.0.4
16 */
17 function __construct( $field = array(), $value = '', $parent ) {
18 $this->parent = $parent;
19 $this->field = $field;
20 $this->value = $value;
21 }
22
23 /**
24 * Field Render Function.
25 * Takes the vars and outputs the HTML for the field in the settings
26 *
27 * @since ReduxFramework 0.0.4
28 */
29 function render() {
30
31 $cb_enabled = $cb_disabled = ''; //no errors, please
32 //
33 //Get selected
34 if ( (int) $this->value == 1 ) {
35 $cb_enabled = ' selected';
36 } else {
37 $cb_disabled = ' selected';
38 }
39
40 //Label ON
41 $this->field['on'] = isset( $this->field['on'] ) ? $this->field['on'] : __( 'On', 'redux-framework' );
42
43 //Label OFF
44 $this->field['off'] = isset( $this->field['off'] ) ? $this->field['off'] : __( 'Off', 'redux-framework' );
45
46 echo '<div class="switch-options">';
47 echo '<label class="cb-enable' . $cb_enabled . '" data-id="' . $this->field['id'] . '"><span>' . $this->field['on'] . '</span></label>';
48 echo '<label class="cb-disable' . $cb_disabled . '" data-id="' . $this->field['id'] . '"><span>' . $this->field['off'] . '</span></label>';
49 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 . '" />';
50 echo '</div>';
51 } //function
52
53 /**
54 * Enqueue Function.
55 * If this field requires any scripts, or css define this function and register/enqueue the scripts/css
56 *
57 * @since ReduxFramework 0.0.4
58 */
59 function enqueue() {
60 wp_enqueue_script(
61 'redux-field-switch-js',
62 ReduxFramework::$_url . 'inc/fields/switch/field_switch' . Redux_Functions::isMin() . '.js',
63 array( 'jquery', 'redux-js' ),
64 time(),
65 true
66 );
67
68 if ($this->parent->args['dev_mode']) {
69 wp_enqueue_style(
70 'redux-field-switch-css',
71 ReduxFramework::$_url . 'inc/fields/switch/field_switch.css',
72 array(),
73 time(),
74 'all'
75 );
76 }
77 }
78 }
79 }