@@ -12,46 +12,46 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Divide', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_divide class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Divide extends Redux_Field { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_divide class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Divide extends Redux_Field { |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Field Render Function. |
|
| 24 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | - * |
|
| 26 | - * @since 1.0.0 |
|
| 27 | - * @access public |
|
| 28 | - * @return void |
|
| 29 | - */ |
|
| 30 | - public function render() { |
|
| 31 | - echo '</td></tr></table>'; |
|
| 32 | - echo '<div data-id="' . esc_attr( $this->field['id'] ) . '" id="divide-' . esc_attr( $this->field['id'] ) . '" class="divide ' . esc_attr( $this->field['class'] ) . '"><div class="inner"><span> </span></div></div>'; |
|
| 33 | - echo '<table class="form-table no-border"><tbody><tr><th></th><td>'; |
|
| 34 | - } |
|
| 22 | + /** |
|
| 23 | + * Field Render Function. |
|
| 24 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 25 | + * |
|
| 26 | + * @since 1.0.0 |
|
| 27 | + * @access public |
|
| 28 | + * @return void |
|
| 29 | + */ |
|
| 30 | + public function render() { |
|
| 31 | + echo '</td></tr></table>'; |
|
| 32 | + echo '<div data-id="' . esc_attr( $this->field['id'] ) . '" id="divide-' . esc_attr( $this->field['id'] ) . '" class="divide ' . esc_attr( $this->field['class'] ) . '"><div class="inner"><span> </span></div></div>'; |
|
| 33 | + echo '<table class="form-table no-border"><tbody><tr><th></th><td>'; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Enqueue Function. |
|
| 38 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 39 | - * |
|
| 40 | - * @since 1.0.0 |
|
| 41 | - * @access public |
|
| 42 | - * @return void |
|
| 43 | - */ |
|
| 44 | - public function enqueue() { |
|
| 45 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 46 | - wp_enqueue_style( |
|
| 47 | - 'redux-field-divide', |
|
| 48 | - Redux_Core::$url . 'inc/fields/divide/redux-divide.css', |
|
| 49 | - array(), |
|
| 50 | - $this->timestamp |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - } |
|
| 36 | + /** |
|
| 37 | + * Enqueue Function. |
|
| 38 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 39 | + * |
|
| 40 | + * @since 1.0.0 |
|
| 41 | + * @access public |
|
| 42 | + * @return void |
|
| 43 | + */ |
|
| 44 | + public function enqueue() { |
|
| 45 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 46 | + wp_enqueue_style( |
|
| 47 | + 'redux-field-divide', |
|
| 48 | + Redux_Core::$url . 'inc/fields/divide/redux-divide.css', |
|
| 49 | + array(), |
|
| 50 | + $this->timestamp |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | class_alias( 'Redux_Divide', 'ReduxFramework_Divide' ); |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | $cb_disabled = ''; |
| 28 | 28 | |
| 29 | 29 | // Get selected. |
| 30 | - if ( 1 === (int) $this->value ) { |
|
| 30 | + if ( 1 === ( int ) $this->value ) { |
|
| 31 | 31 | $cb_enabled = ' selected'; |
| 32 | 32 | } else { |
| 33 | 33 | $cb_disabled = ' selected'; |
@@ -11,66 +11,66 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Switch', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Switch |
|
| 16 | - */ |
|
| 17 | - class Redux_Switch extends Redux_Field { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Switch |
|
| 16 | + */ |
|
| 17 | + class Redux_Switch extends Redux_Field { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Field Render Function. |
|
| 21 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 22 | - * |
|
| 23 | - * @since ReduxFramework 0.0.4 |
|
| 24 | - */ |
|
| 25 | - public function render() { |
|
| 26 | - $cb_enabled = ''; |
|
| 27 | - $cb_disabled = ''; |
|
| 19 | + /** |
|
| 20 | + * Field Render Function. |
|
| 21 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 22 | + * |
|
| 23 | + * @since ReduxFramework 0.0.4 |
|
| 24 | + */ |
|
| 25 | + public function render() { |
|
| 26 | + $cb_enabled = ''; |
|
| 27 | + $cb_disabled = ''; |
|
| 28 | 28 | |
| 29 | - // Get selected. |
|
| 30 | - if ( 1 === (int) $this->value ) { |
|
| 31 | - $cb_enabled = ' selected'; |
|
| 32 | - } else { |
|
| 33 | - $cb_disabled = ' selected'; |
|
| 34 | - } |
|
| 29 | + // Get selected. |
|
| 30 | + if ( 1 === (int) $this->value ) { |
|
| 31 | + $cb_enabled = ' selected'; |
|
| 32 | + } else { |
|
| 33 | + $cb_disabled = ' selected'; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - // Label ON. |
|
| 37 | - $this->field['on'] = $this->field['on'] ?? esc_html__( 'On', 'redux-framework' ); |
|
| 36 | + // Label ON. |
|
| 37 | + $this->field['on'] = $this->field['on'] ?? esc_html__( 'On', 'redux-framework' ); |
|
| 38 | 38 | |
| 39 | - // Label OFF. |
|
| 40 | - $this->field['off'] = $this->field['off'] ?? esc_html__( 'Off', 'redux-framework' ); |
|
| 39 | + // Label OFF. |
|
| 40 | + $this->field['off'] = $this->field['off'] ?? esc_html__( 'Off', 'redux-framework' ); |
|
| 41 | 41 | |
| 42 | - echo '<div class="switch-options">'; |
|
| 43 | - echo '<div class="cb-enable label' . esc_attr( $cb_enabled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '"><span>' . esc_html( $this->field['on'] ) . '</span></div>'; |
|
| 44 | - echo '<div class="cb-disable label' . esc_attr( $cb_disabled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '"><span>' . esc_html( $this->field['off'] ) . '</span></div>'; |
|
| 45 | - echo '<input type="hidden" class="checkbox checkbox-input ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" value="' . esc_attr( $this->value ) . '" />'; |
|
| 46 | - echo '</div>'; |
|
| 47 | - } |
|
| 42 | + echo '<div class="switch-options">'; |
|
| 43 | + echo '<div class="cb-enable label' . esc_attr( $cb_enabled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '"><span>' . esc_html( $this->field['on'] ) . '</span></div>'; |
|
| 44 | + echo '<div class="cb-disable label' . esc_attr( $cb_disabled ) . '" data-id="' . esc_attr( $this->field['id'] ) . '"><span>' . esc_html( $this->field['off'] ) . '</span></div>'; |
|
| 45 | + echo '<input type="hidden" class="checkbox checkbox-input ' . esc_attr( $this->field['class'] ) . '" id="' . esc_attr( $this->field['id'] ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" value="' . esc_attr( $this->value ) . '" />'; |
|
| 46 | + echo '</div>'; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Enqueue Function. |
|
| 51 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 52 | - * |
|
| 53 | - * @since ReduxFramework 0.0.4 |
|
| 54 | - */ |
|
| 55 | - public function enqueue() { |
|
| 56 | - wp_enqueue_script( |
|
| 57 | - 'redux-field-switch', |
|
| 58 | - Redux_Core::$url . 'inc/fields/switch/redux-switch' . Redux_Functions::is_min() . '.js', |
|
| 59 | - array( 'jquery', 'redux-js' ), |
|
| 60 | - $this->timestamp, |
|
| 61 | - true |
|
| 62 | - ); |
|
| 49 | + /** |
|
| 50 | + * Enqueue Function. |
|
| 51 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 52 | + * |
|
| 53 | + * @since ReduxFramework 0.0.4 |
|
| 54 | + */ |
|
| 55 | + public function enqueue() { |
|
| 56 | + wp_enqueue_script( |
|
| 57 | + 'redux-field-switch', |
|
| 58 | + Redux_Core::$url . 'inc/fields/switch/redux-switch' . Redux_Functions::is_min() . '.js', |
|
| 59 | + array( 'jquery', 'redux-js' ), |
|
| 60 | + $this->timestamp, |
|
| 61 | + true |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - if ( $this->parent->args['dev_mode'] ) { |
|
| 65 | - wp_enqueue_style( |
|
| 66 | - 'redux-field-switch', |
|
| 67 | - Redux_Core::$url . 'inc/fields/switch/redux-switch.css', |
|
| 68 | - array(), |
|
| 69 | - $this->timestamp |
|
| 70 | - ); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - } |
|
| 64 | + if ( $this->parent->args['dev_mode'] ) { |
|
| 65 | + wp_enqueue_style( |
|
| 66 | + 'redux-field-switch', |
|
| 67 | + Redux_Core::$url . 'inc/fields/switch/redux-switch.css', |
|
| 68 | + array(), |
|
| 69 | + $this->timestamp |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | class_alias( 'Redux_Switch', 'ReduxFramework_Switch' ); |
@@ -11,67 +11,67 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Password', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Password |
|
| 16 | - */ |
|
| 17 | - class Redux_Password extends Redux_Field { |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Password |
|
| 16 | + */ |
|
| 17 | + class Redux_Password extends Redux_Field { |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Field Render Function. |
|
| 21 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 22 | - * |
|
| 23 | - * @since ReduxFramework 1.0.1 |
|
| 24 | - */ |
|
| 25 | - public function render() { |
|
| 26 | - if ( ! empty( $this->field['username'] ) && true === $this->field['username'] ) { |
|
| 27 | - $this->render_combined_field(); |
|
| 28 | - } else { |
|
| 29 | - $this->render_single_field(); |
|
| 30 | - } |
|
| 31 | - } |
|
| 19 | + /** |
|
| 20 | + * Field Render Function. |
|
| 21 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 22 | + * |
|
| 23 | + * @since ReduxFramework 1.0.1 |
|
| 24 | + */ |
|
| 25 | + public function render() { |
|
| 26 | + if ( ! empty( $this->field['username'] ) && true === $this->field['username'] ) { |
|
| 27 | + $this->render_combined_field(); |
|
| 28 | + } else { |
|
| 29 | + $this->render_single_field(); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * This will render a combined User/Password field |
|
| 35 | - * |
|
| 36 | - * @since ReduxFramework 3.0.9 |
|
| 37 | - * @example |
|
| 38 | - * <code> |
|
| 39 | - * array( |
|
| 40 | - * 'id' => 'smtp_account', |
|
| 41 | - * 'type' => 'password', |
|
| 42 | - * 'username' => true, |
|
| 43 | - * 'title' => 'SMTP Account', |
|
| 44 | - * 'placeholder' => array('username' => 'Username') |
|
| 45 | - * ) |
|
| 46 | - * </code> |
|
| 47 | - */ |
|
| 48 | - private function render_combined_field() { |
|
| 49 | - $defaults = array( |
|
| 50 | - 'username' => '', |
|
| 51 | - 'password' => '', |
|
| 52 | - 'placeholder' => array( |
|
| 53 | - 'password' => esc_html__( 'Password', 'redux-framework' ), |
|
| 54 | - 'username' => esc_html__( 'Username', 'redux-framework' ), |
|
| 55 | - ), |
|
| 56 | - ); |
|
| 33 | + /** |
|
| 34 | + * This will render a combined User/Password field |
|
| 35 | + * |
|
| 36 | + * @since ReduxFramework 3.0.9 |
|
| 37 | + * @example |
|
| 38 | + * <code> |
|
| 39 | + * array( |
|
| 40 | + * 'id' => 'smtp_account', |
|
| 41 | + * 'type' => 'password', |
|
| 42 | + * 'username' => true, |
|
| 43 | + * 'title' => 'SMTP Account', |
|
| 44 | + * 'placeholder' => array('username' => 'Username') |
|
| 45 | + * ) |
|
| 46 | + * </code> |
|
| 47 | + */ |
|
| 48 | + private function render_combined_field() { |
|
| 49 | + $defaults = array( |
|
| 50 | + 'username' => '', |
|
| 51 | + 'password' => '', |
|
| 52 | + 'placeholder' => array( |
|
| 53 | + 'password' => esc_html__( 'Password', 'redux-framework' ), |
|
| 54 | + 'username' => esc_html__( 'Username', 'redux-framework' ), |
|
| 55 | + ), |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 58 | + $this->value = wp_parse_args( $this->value, $defaults ); |
|
| 59 | 59 | |
| 60 | - if ( ! empty( $this->field['placeholder'] ) ) { |
|
| 61 | - if ( is_array( $this->field['placeholder'] ) ) { |
|
| 62 | - if ( ! empty( $this->field['placeholder']['password'] ) ) { |
|
| 63 | - $this->value['placeholder']['password'] = $this->field['placeholder']['password']; |
|
| 64 | - } |
|
| 65 | - if ( ! empty( $this->field['placeholder']['username'] ) ) { |
|
| 66 | - $this->value['placeholder']['username'] = $this->field['placeholder']['username']; |
|
| 67 | - } |
|
| 68 | - } else { |
|
| 69 | - $this->value['placeholder']['password'] = $this->field['placeholder']; |
|
| 70 | - } |
|
| 71 | - } |
|
| 60 | + if ( ! empty( $this->field['placeholder'] ) ) { |
|
| 61 | + if ( is_array( $this->field['placeholder'] ) ) { |
|
| 62 | + if ( ! empty( $this->field['placeholder']['password'] ) ) { |
|
| 63 | + $this->value['placeholder']['password'] = $this->field['placeholder']['password']; |
|
| 64 | + } |
|
| 65 | + if ( ! empty( $this->field['placeholder']['username'] ) ) { |
|
| 66 | + $this->value['placeholder']['username'] = $this->field['placeholder']['username']; |
|
| 67 | + } |
|
| 68 | + } else { |
|
| 69 | + $this->value['placeholder']['password'] = $this->field['placeholder']; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // Username field. |
|
| 74 | - echo '<input |
|
| 73 | + // Username field. |
|
| 74 | + echo '<input |
|
| 75 | 75 | type="text" |
| 76 | 76 | autocomplete="off" |
| 77 | 77 | placeholder="' . esc_attr( $this->value['placeholder']['username'] ) . '" |
@@ -80,8 +80,8 @@ discard block |
||
| 80 | 80 | value="' . esc_attr( $this->value['username'] ) . '" |
| 81 | 81 | class="' . esc_attr( $this->field['class'] ) . '" /> '; |
| 82 | 82 | |
| 83 | - // Password field. |
|
| 84 | - echo '<input |
|
| 83 | + // Password field. |
|
| 84 | + echo '<input |
|
| 85 | 85 | type="password" |
| 86 | 86 | autocomplete="off" |
| 87 | 87 | placeholder="' . esc_attr( $this->value['placeholder']['password'] ) . '" |
@@ -89,30 +89,30 @@ discard block |
||
| 89 | 89 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '[password]" |
| 90 | 90 | value="' . esc_attr( $this->value['password'] ) . '" |
| 91 | 91 | class="' . esc_attr( $this->field['class'] ) . '" />'; |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * This will render a single Password field |
|
| 96 | - * |
|
| 97 | - * @since ReduxFramework 3.0.9 |
|
| 98 | - * @example |
|
| 99 | - * <code> |
|
| 100 | - * array( |
|
| 101 | - * 'id' => 'smtp_password', |
|
| 102 | - * 'type' => 'password', |
|
| 103 | - * 'title' => 'SMTP Password' |
|
| 104 | - * ) |
|
| 105 | - * </code> |
|
| 106 | - */ |
|
| 107 | - private function render_single_field() { |
|
| 108 | - echo '<input |
|
| 94 | + /** |
|
| 95 | + * This will render a single Password field |
|
| 96 | + * |
|
| 97 | + * @since ReduxFramework 3.0.9 |
|
| 98 | + * @example |
|
| 99 | + * <code> |
|
| 100 | + * array( |
|
| 101 | + * 'id' => 'smtp_password', |
|
| 102 | + * 'type' => 'password', |
|
| 103 | + * 'title' => 'SMTP Password' |
|
| 104 | + * ) |
|
| 105 | + * </code> |
|
| 106 | + */ |
|
| 107 | + private function render_single_field() { |
|
| 108 | + echo '<input |
|
| 109 | 109 | type="password" |
| 110 | 110 | id="' . esc_attr( $this->field['id'] ) . '" |
| 111 | 111 | name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" |
| 112 | 112 | value="' . esc_attr( $this->value ) . '" |
| 113 | 113 | class="' . esc_attr( $this->field['class'] ) . '" />'; |
| 114 | - } |
|
| 115 | - } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | class_alias( 'Redux_Password', 'ReduxFramework_Password' ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $is_multi = isset( $this->field['multi'] ) && true === (bool) $this->field['multi']; |
|
| 55 | + $is_multi = isset( $this->field['multi'] ) && true === ( bool ) $this->field['multi']; |
|
| 56 | 56 | |
| 57 | 57 | $name = $this->field['name'] . $this->field['name_suffix']; |
| 58 | 58 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->value = array( $this->value ); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - if ( is_array( $this->value ) && in_array( (string) $k, $this->value, true ) ) { |
|
| 85 | + if ( is_array( $this->value ) && in_array( ( string ) $k, $this->value, true ) ) { |
|
| 86 | 86 | $selected = 'checked="checked"'; |
| 87 | 87 | $post_value = $k; |
| 88 | 88 | } |
@@ -12,132 +12,132 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Button_Set', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_button_set class |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Button_Set extends Redux_Field { |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Set field defaults. |
|
| 24 | - */ |
|
| 25 | - public function set_defaults() { |
|
| 26 | - $defaults = array( |
|
| 27 | - 'options' => array(), |
|
| 28 | - 'multi' => false, |
|
| 29 | - ); |
|
| 30 | - |
|
| 31 | - $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Field Render Function. |
|
| 36 | - * Takes the vars and outputs the HTML for the field in the settings |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @access public |
|
| 40 | - * @return void |
|
| 41 | - */ |
|
| 42 | - public function render() { |
|
| 43 | - if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) { |
|
| 44 | - if ( empty( $this->field['args'] ) ) { |
|
| 45 | - $this->field['args'] = array(); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - $this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value ); |
|
| 49 | - |
|
| 50 | - if ( empty( $this->field['options'] ) ) { |
|
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - $is_multi = isset( $this->field['multi'] ) && true === (bool) $this->field['multi']; |
|
| 56 | - |
|
| 57 | - $name = $this->field['name'] . $this->field['name_suffix']; |
|
| 58 | - |
|
| 59 | - // multi => true renders the field multi-selectable (checkbox vs radio). |
|
| 60 | - echo '<div class="buttonset ui-buttonset">'; |
|
| 61 | - |
|
| 62 | - if ( $is_multi ) { |
|
| 63 | - $s = ''; |
|
| 64 | - |
|
| 65 | - if ( empty( $this->value ) ) { |
|
| 66 | - $s = $name; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - echo '<input type="hidden" data-name="' . esc_attr( $name ) . '" class="buttonset-empty" name="' . esc_attr( $s ) . '" value=""/>'; |
|
| 70 | - |
|
| 71 | - $name = $name . '[]'; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - foreach ( $this->field['options'] as $k => $v ) { |
|
| 75 | - $selected = ''; |
|
| 76 | - |
|
| 77 | - if ( $is_multi ) { |
|
| 78 | - $post_value = ''; |
|
| 79 | - $type = 'checkbox'; |
|
| 80 | - |
|
| 81 | - if ( ! empty( $this->value ) && ! is_array( $this->value ) ) { |
|
| 82 | - $this->value = array( $this->value ); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - if ( is_array( $this->value ) && in_array( (string) $k, $this->value, true ) ) { |
|
| 86 | - $selected = 'checked="checked"'; |
|
| 87 | - $post_value = $k; |
|
| 88 | - } |
|
| 89 | - } else { |
|
| 90 | - $type = 'radio'; |
|
| 91 | - |
|
| 92 | - if ( is_scalar( $this->value ) ) { |
|
| 93 | - $selected = checked( $this->value, $k, false ); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $the_val = $k; |
|
| 98 | - $the_name = $name; |
|
| 99 | - $data_val = ''; |
|
| 100 | - $multi_class = ''; |
|
| 101 | - |
|
| 102 | - if ( $is_multi ) { |
|
| 103 | - $the_val = ''; |
|
| 104 | - $the_name = ''; |
|
| 105 | - $data_val = ' data-val=' . $k; |
|
| 106 | - $hidden_name = $name; |
|
| 107 | - $multi_class = 'multi '; |
|
| 108 | - |
|
| 109 | - if ( '' === $post_value ) { |
|
| 110 | - $hidden_name = ''; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - echo '<input type="hidden" class="buttonset-check" id="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '-hidden" name="' . esc_attr( $hidden_name ) . '" value="' . esc_attr( $post_value ) . '"/>'; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - echo '<input' . esc_attr( $data_val ) . ' data-id="' . esc_attr( $this->field['id'] ) . '" type="' . esc_attr( $type ) . '" id="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '" name="' . esc_attr( $the_name ) . '" class="buttonset-item ' . esc_attr( $multi_class ) . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $the_val ) . '" ' . esc_html( $selected ) . '/>'; |
|
| 117 | - echo '<label for="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '">' . esc_html( $v ) . '</label>'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - echo '</div>'; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Enqueue Function. |
|
| 125 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 126 | - * |
|
| 127 | - * @since 1.0.0 |
|
| 128 | - * @access public |
|
| 129 | - * @return void |
|
| 130 | - */ |
|
| 131 | - public function enqueue() { |
|
| 132 | - wp_enqueue_script( |
|
| 133 | - 'redux-field-button-set', |
|
| 134 | - Redux_Core::$url . 'inc/fields/button_set/redux-button-set' . Redux_Functions::is_min() . '.js', |
|
| 135 | - array( 'jquery', 'jquery-ui-core', 'redux-js' ), |
|
| 136 | - $this->timestamp, |
|
| 137 | - true |
|
| 138 | - ); |
|
| 139 | - } |
|
| 140 | - } |
|
| 15 | + /** |
|
| 16 | + * Main Redux_button_set class |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Button_Set extends Redux_Field { |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Set field defaults. |
|
| 24 | + */ |
|
| 25 | + public function set_defaults() { |
|
| 26 | + $defaults = array( |
|
| 27 | + 'options' => array(), |
|
| 28 | + 'multi' => false, |
|
| 29 | + ); |
|
| 30 | + |
|
| 31 | + $this->field = wp_parse_args( $this->field, $defaults ); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Field Render Function. |
|
| 36 | + * Takes the vars and outputs the HTML for the field in the settings |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @access public |
|
| 40 | + * @return void |
|
| 41 | + */ |
|
| 42 | + public function render() { |
|
| 43 | + if ( ! empty( $this->field['data'] ) && empty( $this->field['options'] ) ) { |
|
| 44 | + if ( empty( $this->field['args'] ) ) { |
|
| 45 | + $this->field['args'] = array(); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + $this->field['options'] = $this->parent->wordpress_data->get( $this->field['data'], $this->field['args'], $this->parent->args['opt_name'], $this->value ); |
|
| 49 | + |
|
| 50 | + if ( empty( $this->field['options'] ) ) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + $is_multi = isset( $this->field['multi'] ) && true === (bool) $this->field['multi']; |
|
| 56 | + |
|
| 57 | + $name = $this->field['name'] . $this->field['name_suffix']; |
|
| 58 | + |
|
| 59 | + // multi => true renders the field multi-selectable (checkbox vs radio). |
|
| 60 | + echo '<div class="buttonset ui-buttonset">'; |
|
| 61 | + |
|
| 62 | + if ( $is_multi ) { |
|
| 63 | + $s = ''; |
|
| 64 | + |
|
| 65 | + if ( empty( $this->value ) ) { |
|
| 66 | + $s = $name; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + echo '<input type="hidden" data-name="' . esc_attr( $name ) . '" class="buttonset-empty" name="' . esc_attr( $s ) . '" value=""/>'; |
|
| 70 | + |
|
| 71 | + $name = $name . '[]'; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + foreach ( $this->field['options'] as $k => $v ) { |
|
| 75 | + $selected = ''; |
|
| 76 | + |
|
| 77 | + if ( $is_multi ) { |
|
| 78 | + $post_value = ''; |
|
| 79 | + $type = 'checkbox'; |
|
| 80 | + |
|
| 81 | + if ( ! empty( $this->value ) && ! is_array( $this->value ) ) { |
|
| 82 | + $this->value = array( $this->value ); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + if ( is_array( $this->value ) && in_array( (string) $k, $this->value, true ) ) { |
|
| 86 | + $selected = 'checked="checked"'; |
|
| 87 | + $post_value = $k; |
|
| 88 | + } |
|
| 89 | + } else { |
|
| 90 | + $type = 'radio'; |
|
| 91 | + |
|
| 92 | + if ( is_scalar( $this->value ) ) { |
|
| 93 | + $selected = checked( $this->value, $k, false ); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $the_val = $k; |
|
| 98 | + $the_name = $name; |
|
| 99 | + $data_val = ''; |
|
| 100 | + $multi_class = ''; |
|
| 101 | + |
|
| 102 | + if ( $is_multi ) { |
|
| 103 | + $the_val = ''; |
|
| 104 | + $the_name = ''; |
|
| 105 | + $data_val = ' data-val=' . $k; |
|
| 106 | + $hidden_name = $name; |
|
| 107 | + $multi_class = 'multi '; |
|
| 108 | + |
|
| 109 | + if ( '' === $post_value ) { |
|
| 110 | + $hidden_name = ''; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + echo '<input type="hidden" class="buttonset-check" id="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '-hidden" name="' . esc_attr( $hidden_name ) . '" value="' . esc_attr( $post_value ) . '"/>'; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + echo '<input' . esc_attr( $data_val ) . ' data-id="' . esc_attr( $this->field['id'] ) . '" type="' . esc_attr( $type ) . '" id="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '" name="' . esc_attr( $the_name ) . '" class="buttonset-item ' . esc_attr( $multi_class ) . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $the_val ) . '" ' . esc_html( $selected ) . '/>'; |
|
| 117 | + echo '<label for="' . esc_attr( $this->field['id'] ) . '-buttonset' . esc_attr( $k ) . '">' . esc_html( $v ) . '</label>'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + echo '</div>'; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Enqueue Function. |
|
| 125 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 126 | + * |
|
| 127 | + * @since 1.0.0 |
|
| 128 | + * @access public |
|
| 129 | + * @return void |
|
| 130 | + */ |
|
| 131 | + public function enqueue() { |
|
| 132 | + wp_enqueue_script( |
|
| 133 | + 'redux-field-button-set', |
|
| 134 | + Redux_Core::$url . 'inc/fields/button_set/redux-button-set' . Redux_Functions::is_min() . '.js', |
|
| 135 | + array( 'jquery', 'jquery-ui-core', 'redux-js' ), |
|
| 136 | + $this->timestamp, |
|
| 137 | + true |
|
| 138 | + ); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | class_alias( 'Redux_Button_Set', 'ReduxFramework_Button_Set' ); |
@@ -12,23 +12,23 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Preg_Replace', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Preg_Replace |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Preg_Replace extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Preg_Replace |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Preg_Replace extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Validate Function. |
|
| 22 | - * Takes the vars and validates them |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $that = $this; |
|
| 28 | - $this->value = preg_replace( $this->field['preg']['pattern'], $that->field['preg']['replacement'], $this->value ); |
|
| 29 | - $this->field['current'] = $this->value; |
|
| 20 | + /** |
|
| 21 | + * Field Validate Function. |
|
| 22 | + * Takes the vars and validates them |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $that = $this; |
|
| 28 | + $this->value = preg_replace( $this->field['preg']['pattern'], $that->field['preg']['replacement'], $this->value ); |
|
| 29 | + $this->field['current'] = $this->value; |
|
| 30 | 30 | |
| 31 | - $this->sanitize = $this->field; |
|
| 32 | - } |
|
| 33 | - } |
|
| 31 | + $this->sanitize = $this->field; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -12,22 +12,22 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_Validation_Str_Replace', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_Validation_Str_Replace |
|
| 17 | - */ |
|
| 18 | - class Redux_Validation_Str_Replace extends Redux_Validate { |
|
| 15 | + /** |
|
| 16 | + * Class Redux_Validation_Str_Replace |
|
| 17 | + */ |
|
| 18 | + class Redux_Validation_Str_Replace extends Redux_Validate { |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Field Validate Function. |
|
| 22 | - * Takes the vars and validates them |
|
| 23 | - * |
|
| 24 | - * @since ReduxFramework 1.0.0 |
|
| 25 | - */ |
|
| 26 | - public function validate() { |
|
| 27 | - $this->value = str_replace( $this->field['str']['search'], $this->field['str']['replacement'], $this->value ); |
|
| 20 | + /** |
|
| 21 | + * Field Validate Function. |
|
| 22 | + * Takes the vars and validates them |
|
| 23 | + * |
|
| 24 | + * @since ReduxFramework 1.0.0 |
|
| 25 | + */ |
|
| 26 | + public function validate() { |
|
| 27 | + $this->value = str_replace( $this->field['str']['search'], $this->field['str']['replacement'], $this->value ); |
|
| 28 | 28 | |
| 29 | - $this->field['current'] = $this->value; |
|
| 30 | - $this->sanitize = $this->field; |
|
| 31 | - } |
|
| 32 | - } |
|
| 29 | + $this->field['current'] = $this->value; |
|
| 30 | + $this->sanitize = $this->field; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | // New method to avoid input_var nonsense. Thanks, @harunbasic. |
| 65 | 65 | $values = Redux_Functions_Ex::parse_str( $post_data ); |
| 66 | - $values = $values[ $redux->args['opt_name'] ]; |
|
| 66 | + $values = $values[$redux->args['opt_name']]; |
|
| 67 | 67 | |
| 68 | 68 | if ( ! empty( $values ) ) { |
| 69 | 69 | try { |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | try { |
| 133 | 133 | |
| 134 | 134 | // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
| 135 | - $compiler_css = $core->compilerCSS; // Backward compatibility variable. |
|
| 135 | + $compiler_css = $core->compilerCSS; // Backward compatibility variable. |
|
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | 138 | * Action 'redux/options/{opt_name}/compiler' |
@@ -12,176 +12,176 @@ |
||
| 12 | 12 | |
| 13 | 13 | if ( ! class_exists( 'Redux_AJAX_Save', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Class Redux_AJAX_Save |
|
| 17 | - */ |
|
| 18 | - class Redux_AJAX_Save extends Redux_Class { |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Redux_AJAX_Save constructor. |
|
| 22 | - * array_merge_recursive_distinct |
|
| 23 | - * |
|
| 24 | - * @param object $redux ReduxFramework object. |
|
| 25 | - */ |
|
| 26 | - public function __construct( $redux ) { |
|
| 27 | - parent::__construct( $redux ); |
|
| 28 | - |
|
| 29 | - add_action( 'wp_ajax_' . $this->args['opt_name'] . '_ajax_save', array( $this, 'save' ) ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * AJAX callback to save the option panel values. |
|
| 34 | - * |
|
| 35 | - * @throws ReflectionException Exception. |
|
| 36 | - */ |
|
| 37 | - public function save() { |
|
| 38 | - $redux = null; |
|
| 39 | - |
|
| 40 | - $core = $this->core(); |
|
| 41 | - |
|
| 42 | - if ( ! isset( $_REQUEST['nonce'] ) || ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'redux_ajax_nonce' . $this->args['opt_name'] ) ) ) { |
|
| 43 | - echo wp_json_encode( |
|
| 44 | - array( |
|
| 45 | - 'status' => esc_html__( 'Invalid security credential. Please reload the page and try again.', 'redux-framework' ), |
|
| 46 | - 'action' => '', |
|
| 47 | - ) |
|
| 48 | - ); |
|
| 49 | - die(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - if ( ! Redux_Helpers::current_user_can( $core->args['page_permissions'] ) ) { |
|
| 53 | - echo wp_json_encode( |
|
| 54 | - array( |
|
| 55 | - 'status' => esc_html__( 'Invalid user capability. Please reload the page and try again.', 'redux-framework' ), |
|
| 56 | - 'action' => '', |
|
| 57 | - ) |
|
| 58 | - ); |
|
| 59 | - die(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ( isset( $_POST['opt_name'] ) && ! empty( $_POST['opt_name'] ) && isset( $_POST['data'] ) && ! empty( $_POST['data'] ) ) { |
|
| 63 | - $redux = Redux::instance( sanitize_text_field( wp_unslash( $_POST['opt_name'] ) ) ); |
|
| 64 | - |
|
| 65 | - if ( ! empty( $redux->args['opt_name'] ) ) { |
|
| 66 | - |
|
| 67 | - $post_data = wp_unslash( $_POST['data'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput |
|
| 68 | - |
|
| 69 | - // New method to avoid input_var nonsense. Thanks, @harunbasic. |
|
| 70 | - $values = Redux_Functions_Ex::parse_str( $post_data ); |
|
| 71 | - $values = $values[ $redux->args['opt_name'] ]; |
|
| 72 | - |
|
| 73 | - if ( ! empty( $values ) ) { |
|
| 74 | - try { |
|
| 75 | - if ( true === Redux_Core::$validation_ran ) { |
|
| 76 | - Redux_Core::$validation_ran = false; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $redux->options_class->set( $redux->options_class->validate_options( $values ) ); |
|
| 80 | - |
|
| 81 | - $do_reload = false; |
|
| 82 | - if ( isset( $core->required_class->reload_fields ) && ! empty( $core->required_class->reload_fields ) ) { |
|
| 83 | - if ( ! empty( $core->transients['changed_values'] ) ) { |
|
| 84 | - foreach ( $core->required_class->reload_fields as $val ) { |
|
| 85 | - if ( array_key_exists( $val, $core->transients['changed_values'] ) ) { |
|
| 86 | - $do_reload = true; |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if ( $do_reload || ( isset( $values['defaults'] ) && ! empty( $values['defaults'] ) ) || ( isset( $values['defaults-section'] ) && ! empty( $values['defaults-section'] ) ) || ( isset( $values['import_code'] ) && ! empty( $values['import_code'] ) ) || ( isset( $values['import_link'] ) && ! empty( $values['import_link'] ) ) ) { |
|
| 93 | - echo wp_json_encode( |
|
| 94 | - array( |
|
| 95 | - 'status' => 'success', |
|
| 96 | - 'action' => 'reload', |
|
| 97 | - ) |
|
| 98 | - ); |
|
| 99 | - die(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - $redux->enqueue_class->get_warnings_and_errors_array(); |
|
| 103 | - |
|
| 104 | - $return_array = array( |
|
| 105 | - 'status' => 'success', |
|
| 106 | - 'options' => $redux->options, |
|
| 107 | - 'errors' => $redux->enqueue_class->localize_data['errors'] ?? null, |
|
| 108 | - 'warnings' => $redux->enqueue_class->localize_data['warnings'] ?? null, |
|
| 109 | - 'sanitize' => $redux->enqueue_class->localize_data['sanitize'] ?? null, |
|
| 110 | - ); |
|
| 111 | - } catch ( Exception $e ) { |
|
| 112 | - $return_array = array( 'status' => $e->getMessage() ); |
|
| 113 | - } |
|
| 114 | - } else { |
|
| 115 | - echo wp_json_encode( |
|
| 116 | - array( |
|
| 117 | - 'status' => esc_html__( 'Your panel has no fields. Nothing to save.', 'redux-framework' ), |
|
| 118 | - ) |
|
| 119 | - ); |
|
| 120 | - die(); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) { |
|
| 126 | - Redux_Core::$no_output = true; |
|
| 127 | - $temp = $core->args['output_variables_prefix']; |
|
| 128 | - |
|
| 129 | - // Allow the override of variable's prefix for use by SCSS or LESS. |
|
| 130 | - if ( isset( $core->args['compiler_output_variables_prefix'] ) ) { |
|
| 131 | - $core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix']; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $core->output_class->enqueue(); |
|
| 135 | - $core->args['output_variables_prefix'] = $temp; |
|
| 136 | - |
|
| 137 | - try { |
|
| 138 | - |
|
| 139 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
|
| 140 | - $compiler_css = $core->compilerCSS; // Backward compatibility variable. |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Action 'redux/options/{opt_name}/compiler' |
|
| 144 | - * |
|
| 145 | - * @param array $options Global options. |
|
| 146 | - * @param string $css CSS that get sent to the compiler hook. |
|
| 147 | - * @param array $changed_values Changed option values. |
|
| 148 | - * @param array $output_variables Output variables. |
|
| 149 | - */ |
|
| 150 | - |
|
| 151 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 152 | - do_action( 'redux/options/' . $core->args['opt_name'] . '/compiler', $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables ); |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Action 'redux/options/{opt_name}/compiler/advanced' |
|
| 156 | - * |
|
| 157 | - * @param object $redux ReduxFramework object. |
|
| 158 | - */ |
|
| 159 | - |
|
| 160 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 161 | - do_action( 'redux/options/' . $core->args['opt_name'] . '/compiler/advanced', $core ); |
|
| 162 | - } catch ( Exception $e ) { |
|
| 163 | - $return_array = array( 'status' => $e->getMessage() ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - unset( $core->transients['run_compiler'] ); |
|
| 167 | - $core->transient_class->set(); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - if ( isset( $return_array ) ) { |
|
| 171 | - if ( 'success' === $return_array['status'] ) { |
|
| 172 | - $panel = new Redux_Panel( $redux ); |
|
| 173 | - ob_start(); |
|
| 174 | - $panel->notification_bar(); |
|
| 175 | - $notification_bar = ob_get_contents(); |
|
| 176 | - ob_end_clean(); |
|
| 177 | - $return_array['notification_bar'] = $notification_bar; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 181 | - echo wp_json_encode( apply_filters( 'redux/options/' . $core->args['opt_name'] . '/ajax_save/response', $return_array ) ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - die(); |
|
| 185 | - } |
|
| 186 | - } |
|
| 15 | + /** |
|
| 16 | + * Class Redux_AJAX_Save |
|
| 17 | + */ |
|
| 18 | + class Redux_AJAX_Save extends Redux_Class { |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Redux_AJAX_Save constructor. |
|
| 22 | + * array_merge_recursive_distinct |
|
| 23 | + * |
|
| 24 | + * @param object $redux ReduxFramework object. |
|
| 25 | + */ |
|
| 26 | + public function __construct( $redux ) { |
|
| 27 | + parent::__construct( $redux ); |
|
| 28 | + |
|
| 29 | + add_action( 'wp_ajax_' . $this->args['opt_name'] . '_ajax_save', array( $this, 'save' ) ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * AJAX callback to save the option panel values. |
|
| 34 | + * |
|
| 35 | + * @throws ReflectionException Exception. |
|
| 36 | + */ |
|
| 37 | + public function save() { |
|
| 38 | + $redux = null; |
|
| 39 | + |
|
| 40 | + $core = $this->core(); |
|
| 41 | + |
|
| 42 | + if ( ! isset( $_REQUEST['nonce'] ) || ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'redux_ajax_nonce' . $this->args['opt_name'] ) ) ) { |
|
| 43 | + echo wp_json_encode( |
|
| 44 | + array( |
|
| 45 | + 'status' => esc_html__( 'Invalid security credential. Please reload the page and try again.', 'redux-framework' ), |
|
| 46 | + 'action' => '', |
|
| 47 | + ) |
|
| 48 | + ); |
|
| 49 | + die(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + if ( ! Redux_Helpers::current_user_can( $core->args['page_permissions'] ) ) { |
|
| 53 | + echo wp_json_encode( |
|
| 54 | + array( |
|
| 55 | + 'status' => esc_html__( 'Invalid user capability. Please reload the page and try again.', 'redux-framework' ), |
|
| 56 | + 'action' => '', |
|
| 57 | + ) |
|
| 58 | + ); |
|
| 59 | + die(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ( isset( $_POST['opt_name'] ) && ! empty( $_POST['opt_name'] ) && isset( $_POST['data'] ) && ! empty( $_POST['data'] ) ) { |
|
| 63 | + $redux = Redux::instance( sanitize_text_field( wp_unslash( $_POST['opt_name'] ) ) ); |
|
| 64 | + |
|
| 65 | + if ( ! empty( $redux->args['opt_name'] ) ) { |
|
| 66 | + |
|
| 67 | + $post_data = wp_unslash( $_POST['data'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput |
|
| 68 | + |
|
| 69 | + // New method to avoid input_var nonsense. Thanks, @harunbasic. |
|
| 70 | + $values = Redux_Functions_Ex::parse_str( $post_data ); |
|
| 71 | + $values = $values[ $redux->args['opt_name'] ]; |
|
| 72 | + |
|
| 73 | + if ( ! empty( $values ) ) { |
|
| 74 | + try { |
|
| 75 | + if ( true === Redux_Core::$validation_ran ) { |
|
| 76 | + Redux_Core::$validation_ran = false; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $redux->options_class->set( $redux->options_class->validate_options( $values ) ); |
|
| 80 | + |
|
| 81 | + $do_reload = false; |
|
| 82 | + if ( isset( $core->required_class->reload_fields ) && ! empty( $core->required_class->reload_fields ) ) { |
|
| 83 | + if ( ! empty( $core->transients['changed_values'] ) ) { |
|
| 84 | + foreach ( $core->required_class->reload_fields as $val ) { |
|
| 85 | + if ( array_key_exists( $val, $core->transients['changed_values'] ) ) { |
|
| 86 | + $do_reload = true; |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if ( $do_reload || ( isset( $values['defaults'] ) && ! empty( $values['defaults'] ) ) || ( isset( $values['defaults-section'] ) && ! empty( $values['defaults-section'] ) ) || ( isset( $values['import_code'] ) && ! empty( $values['import_code'] ) ) || ( isset( $values['import_link'] ) && ! empty( $values['import_link'] ) ) ) { |
|
| 93 | + echo wp_json_encode( |
|
| 94 | + array( |
|
| 95 | + 'status' => 'success', |
|
| 96 | + 'action' => 'reload', |
|
| 97 | + ) |
|
| 98 | + ); |
|
| 99 | + die(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + $redux->enqueue_class->get_warnings_and_errors_array(); |
|
| 103 | + |
|
| 104 | + $return_array = array( |
|
| 105 | + 'status' => 'success', |
|
| 106 | + 'options' => $redux->options, |
|
| 107 | + 'errors' => $redux->enqueue_class->localize_data['errors'] ?? null, |
|
| 108 | + 'warnings' => $redux->enqueue_class->localize_data['warnings'] ?? null, |
|
| 109 | + 'sanitize' => $redux->enqueue_class->localize_data['sanitize'] ?? null, |
|
| 110 | + ); |
|
| 111 | + } catch ( Exception $e ) { |
|
| 112 | + $return_array = array( 'status' => $e->getMessage() ); |
|
| 113 | + } |
|
| 114 | + } else { |
|
| 115 | + echo wp_json_encode( |
|
| 116 | + array( |
|
| 117 | + 'status' => esc_html__( 'Your panel has no fields. Nothing to save.', 'redux-framework' ), |
|
| 118 | + ) |
|
| 119 | + ); |
|
| 120 | + die(); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if ( isset( $core->transients['run_compiler'] ) && $core->transients['run_compiler'] ) { |
|
| 126 | + Redux_Core::$no_output = true; |
|
| 127 | + $temp = $core->args['output_variables_prefix']; |
|
| 128 | + |
|
| 129 | + // Allow the override of variable's prefix for use by SCSS or LESS. |
|
| 130 | + if ( isset( $core->args['compiler_output_variables_prefix'] ) ) { |
|
| 131 | + $core->args['output_variables_prefix'] = $core->args['compiler_output_variables_prefix']; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $core->output_class->enqueue(); |
|
| 135 | + $core->args['output_variables_prefix'] = $temp; |
|
| 136 | + |
|
| 137 | + try { |
|
| 138 | + |
|
| 139 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName |
|
| 140 | + $compiler_css = $core->compilerCSS; // Backward compatibility variable. |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Action 'redux/options/{opt_name}/compiler' |
|
| 144 | + * |
|
| 145 | + * @param array $options Global options. |
|
| 146 | + * @param string $css CSS that get sent to the compiler hook. |
|
| 147 | + * @param array $changed_values Changed option values. |
|
| 148 | + * @param array $output_variables Output variables. |
|
| 149 | + */ |
|
| 150 | + |
|
| 151 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 152 | + do_action( 'redux/options/' . $core->args['opt_name'] . '/compiler', $core->options, $compiler_css, $core->transients['changed_values'], $core->output_variables ); |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Action 'redux/options/{opt_name}/compiler/advanced' |
|
| 156 | + * |
|
| 157 | + * @param object $redux ReduxFramework object. |
|
| 158 | + */ |
|
| 159 | + |
|
| 160 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 161 | + do_action( 'redux/options/' . $core->args['opt_name'] . '/compiler/advanced', $core ); |
|
| 162 | + } catch ( Exception $e ) { |
|
| 163 | + $return_array = array( 'status' => $e->getMessage() ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + unset( $core->transients['run_compiler'] ); |
|
| 167 | + $core->transient_class->set(); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + if ( isset( $return_array ) ) { |
|
| 171 | + if ( 'success' === $return_array['status'] ) { |
|
| 172 | + $panel = new Redux_Panel( $redux ); |
|
| 173 | + ob_start(); |
|
| 174 | + $panel->notification_bar(); |
|
| 175 | + $notification_bar = ob_get_contents(); |
|
| 176 | + ob_end_clean(); |
|
| 177 | + $return_array['notification_bar'] = $notification_bar; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 181 | + echo wp_json_encode( apply_filters( 'redux/options/' . $core->args['opt_name'] . '/ajax_save/response', $return_array ) ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + die(); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | 187 | } |
@@ -11,119 +11,119 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Sanitize', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Sanitize |
|
| 16 | - */ |
|
| 17 | - class Redux_Sanitize extends Redux_Class { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Sanitize values from options form (used in settings api validate function) |
|
| 21 | - * |
|
| 22 | - * @since 4.0.0 |
|
| 23 | - * @access public |
|
| 24 | - * |
|
| 25 | - * @param array $plugin_options Plugin Options. |
|
| 26 | - * @param array $options Options. |
|
| 27 | - * @param array $sections Sections array. |
|
| 28 | - * |
|
| 29 | - * @return array $plugin_options |
|
| 30 | - */ |
|
| 31 | - public function sanitize( array $plugin_options, array $options, array $sections ): array { |
|
| 32 | - $core = $this->core(); |
|
| 33 | - |
|
| 34 | - foreach ( $sections as $k => $section ) { |
|
| 35 | - if ( isset( $section['fields'] ) ) { |
|
| 36 | - foreach ( $section['fields'] as $field ) { |
|
| 37 | - |
|
| 38 | - if ( is_array( $field ) ) { |
|
| 39 | - $field['section_id'] = $k; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if ( isset( $field['type'] ) && ( 'text' === $field['type'] || 'textarea' === $field['type'] || 'multi_text' === $field['type'] ) ) { |
|
| 43 | - |
|
| 44 | - // Make sure 'sanitize' field is set. |
|
| 45 | - if ( isset( $field['sanitize'] ) ) { |
|
| 46 | - |
|
| 47 | - // Can we make this an array of validations? |
|
| 48 | - $val_arr = array(); |
|
| 49 | - |
|
| 50 | - if ( is_array( $field['sanitize'] ) ) { |
|
| 51 | - $val_arr = $field['sanitize']; |
|
| 52 | - } else { |
|
| 53 | - $val_arr[] = $field['sanitize']; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - foreach ( $val_arr as $function ) { |
|
| 57 | - |
|
| 58 | - // Check for empty id value. |
|
| 59 | - if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 60 | - continue; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - if ( function_exists( $function ) ) { |
|
| 64 | - if ( empty( $options[ $field['id'] ] ) ) { |
|
| 65 | - $options[ $field['id'] ] = ''; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 69 | - foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 70 | - $before = null; |
|
| 71 | - $after = null; |
|
| 72 | - |
|
| 73 | - if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 74 | - if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 75 | - $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 76 | - } else { |
|
| 77 | - $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 82 | - $after = $options[ $field['id'] ][ $key ]; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - $value = call_user_func( $function, $before ); |
|
| 86 | - |
|
| 87 | - if ( false !== $value ) { |
|
| 88 | - $plugin_options[ $field['id'] ][ $key ] = $value; |
|
| 89 | - } else { |
|
| 90 | - unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $field['current'] = $value; |
|
| 94 | - |
|
| 95 | - $core->sanitize[] = $field; |
|
| 96 | - } |
|
| 97 | - } else { |
|
| 98 | - if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 99 | - if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 100 | - $pofi = $plugin_options[ $field['id'] ]; |
|
| 101 | - } else { |
|
| 102 | - $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 103 | - } |
|
| 104 | - } else { |
|
| 105 | - $pofi = null; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $value = call_user_func( $function, $pofi ); |
|
| 109 | - |
|
| 110 | - $plugin_options[ $field['id'] ] = $value; |
|
| 111 | - |
|
| 112 | - $field['current'] = $value; |
|
| 113 | - |
|
| 114 | - $core->sanitize[] = $field; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - break; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - return $plugin_options; |
|
| 127 | - } |
|
| 128 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Sanitize |
|
| 16 | + */ |
|
| 17 | + class Redux_Sanitize extends Redux_Class { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Sanitize values from options form (used in settings api validate function) |
|
| 21 | + * |
|
| 22 | + * @since 4.0.0 |
|
| 23 | + * @access public |
|
| 24 | + * |
|
| 25 | + * @param array $plugin_options Plugin Options. |
|
| 26 | + * @param array $options Options. |
|
| 27 | + * @param array $sections Sections array. |
|
| 28 | + * |
|
| 29 | + * @return array $plugin_options |
|
| 30 | + */ |
|
| 31 | + public function sanitize( array $plugin_options, array $options, array $sections ): array { |
|
| 32 | + $core = $this->core(); |
|
| 33 | + |
|
| 34 | + foreach ( $sections as $k => $section ) { |
|
| 35 | + if ( isset( $section['fields'] ) ) { |
|
| 36 | + foreach ( $section['fields'] as $field ) { |
|
| 37 | + |
|
| 38 | + if ( is_array( $field ) ) { |
|
| 39 | + $field['section_id'] = $k; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if ( isset( $field['type'] ) && ( 'text' === $field['type'] || 'textarea' === $field['type'] || 'multi_text' === $field['type'] ) ) { |
|
| 43 | + |
|
| 44 | + // Make sure 'sanitize' field is set. |
|
| 45 | + if ( isset( $field['sanitize'] ) ) { |
|
| 46 | + |
|
| 47 | + // Can we make this an array of validations? |
|
| 48 | + $val_arr = array(); |
|
| 49 | + |
|
| 50 | + if ( is_array( $field['sanitize'] ) ) { |
|
| 51 | + $val_arr = $field['sanitize']; |
|
| 52 | + } else { |
|
| 53 | + $val_arr[] = $field['sanitize']; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + foreach ( $val_arr as $function ) { |
|
| 57 | + |
|
| 58 | + // Check for empty id value. |
|
| 59 | + if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 60 | + continue; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + if ( function_exists( $function ) ) { |
|
| 64 | + if ( empty( $options[ $field['id'] ] ) ) { |
|
| 65 | + $options[ $field['id'] ] = ''; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 69 | + foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 70 | + $before = null; |
|
| 71 | + $after = null; |
|
| 72 | + |
|
| 73 | + if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 74 | + if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 75 | + $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 76 | + } else { |
|
| 77 | + $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 82 | + $after = $options[ $field['id'] ][ $key ]; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + $value = call_user_func( $function, $before ); |
|
| 86 | + |
|
| 87 | + if ( false !== $value ) { |
|
| 88 | + $plugin_options[ $field['id'] ][ $key ] = $value; |
|
| 89 | + } else { |
|
| 90 | + unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $field['current'] = $value; |
|
| 94 | + |
|
| 95 | + $core->sanitize[] = $field; |
|
| 96 | + } |
|
| 97 | + } else { |
|
| 98 | + if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 99 | + if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 100 | + $pofi = $plugin_options[ $field['id'] ]; |
|
| 101 | + } else { |
|
| 102 | + $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 103 | + } |
|
| 104 | + } else { |
|
| 105 | + $pofi = null; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $value = call_user_func( $function, $pofi ); |
|
| 109 | + |
|
| 110 | + $plugin_options[ $field['id'] ] = $value; |
|
| 111 | + |
|
| 112 | + $field['current'] = $value; |
|
| 113 | + |
|
| 114 | + $core->sanitize[] = $field; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + break; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + return $plugin_options; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | } |
@@ -56,38 +56,38 @@ discard block |
||
| 56 | 56 | foreach ( $val_arr as $function ) { |
| 57 | 57 | |
| 58 | 58 | // Check for empty id value. |
| 59 | - if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 59 | + if ( ! isset( $field['id'] ) || ! isset( $plugin_options[$field['id']] ) || ( '' === $plugin_options[$field['id']] ) ) { |
|
| 60 | 60 | continue; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if ( function_exists( $function ) ) { |
| 64 | - if ( empty( $options[ $field['id'] ] ) ) { |
|
| 65 | - $options[ $field['id'] ] = ''; |
|
| 64 | + if ( empty( $options[$field['id']] ) ) { |
|
| 65 | + $options[$field['id']] = ''; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if ( is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 69 | - foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 68 | + if ( is_array( $plugin_options[$field['id']] ) && ! empty( $plugin_options[$field['id']] ) ) { |
|
| 69 | + foreach ( $plugin_options[$field['id']] as $key => $value ) { |
|
| 70 | 70 | $before = null; |
| 71 | 71 | $after = null; |
| 72 | 72 | |
| 73 | - if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 74 | - if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 75 | - $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 73 | + if ( isset( $plugin_options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) { |
|
| 74 | + if ( is_array( $plugin_options[$field['id']][$key] ) ) { |
|
| 75 | + $before = $plugin_options[$field['id']][$key]; |
|
| 76 | 76 | } else { |
| 77 | - $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 77 | + $before = trim( $plugin_options[$field['id']][$key] ); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 82 | - $after = $options[ $field['id'] ][ $key ]; |
|
| 81 | + if ( isset( $options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) { |
|
| 82 | + $after = $options[$field['id']][$key]; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $value = call_user_func( $function, $before ); |
| 86 | 86 | |
| 87 | 87 | if ( false !== $value ) { |
| 88 | - $plugin_options[ $field['id'] ][ $key ] = $value; |
|
| 88 | + $plugin_options[$field['id']][$key] = $value; |
|
| 89 | 89 | } else { |
| 90 | - unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 90 | + unset( $plugin_options[$field['id']][$key] ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $field['current'] = $value; |
@@ -95,11 +95,11 @@ discard block |
||
| 95 | 95 | $core->sanitize[] = $field; |
| 96 | 96 | } |
| 97 | 97 | } else { |
| 98 | - if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 99 | - if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 100 | - $pofi = $plugin_options[ $field['id'] ]; |
|
| 98 | + if ( isset( $plugin_options[$field['id']] ) ) { |
|
| 99 | + if ( is_array( $plugin_options[$field['id']] ) ) { |
|
| 100 | + $pofi = $plugin_options[$field['id']]; |
|
| 101 | 101 | } else { |
| 102 | - $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 102 | + $pofi = trim( $plugin_options[$field['id']] ); |
|
| 103 | 103 | } |
| 104 | 104 | } else { |
| 105 | 105 | $pofi = null; |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | |
| 108 | 108 | $value = call_user_func( $function, $pofi ); |
| 109 | 109 | |
| 110 | - $plugin_options[ $field['id'] ] = $value; |
|
| 110 | + $plugin_options[$field['id']] = $value; |
|
| 111 | 111 | |
| 112 | 112 | $field['current'] = $value; |
| 113 | 113 | |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | $result = $defaults; |
| 137 | 137 | |
| 138 | 138 | foreach ( $arr as $k => $v ) { |
| 139 | - if ( is_array( $v ) && isset( $result[ $k ] ) ) { |
|
| 140 | - $result[ $k ] = self::parse_args( $v, $result[ $k ] ); |
|
| 139 | + if ( is_array( $v ) && isset( $result[$k] ) ) { |
|
| 140 | + $result[$k] = self::parse_args( $v, $result[$k] ); |
|
| 141 | 141 | } else { |
| 142 | - $result[ $k ] = $v; |
|
| 142 | + $result[$k] = $v; |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
@@ -534,7 +534,7 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | $result = preg_replace_callback( |
| 536 | 536 | '/[A-Z]/', |
| 537 | - function ( $matches ) { |
|
| 537 | + function( $matches ) { |
|
| 538 | 538 | return '-' . Redux_Core::strtolower( $matches[0] ); |
| 539 | 539 | }, |
| 540 | 540 | $keys |
@@ -13,360 +13,360 @@ |
||
| 13 | 13 | // Don't duplicate me! |
| 14 | 14 | if ( ! class_exists( 'Redux_Functions', false ) ) { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Redux Functions Class |
|
| 18 | - * A Class of useful functions that can/should be shared among all Redux files. |
|
| 19 | - * |
|
| 20 | - * @since 3.0.0 |
|
| 21 | - */ |
|
| 22 | - class Redux_Functions { |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * ReduxFramework object pointer. |
|
| 26 | - * |
|
| 27 | - * @var object |
|
| 28 | - */ |
|
| 29 | - public static $parent; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * ReduxFramework shim object pointer. |
|
| 33 | - * |
|
| 34 | - * @var object |
|
| 35 | - */ |
|
| 36 | - public static $_parent; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Check for the existence of class name via an array of class names. |
|
| 40 | - * |
|
| 41 | - * @param array $class_names Array of class names. |
|
| 42 | - * |
|
| 43 | - * @return string|bool |
|
| 44 | - */ |
|
| 45 | - public static function class_exists_ex( array $class_names = array() ) { |
|
| 46 | - foreach ( $class_names as $class_name ) { |
|
| 47 | - if ( class_exists( $class_name ) ) { |
|
| 48 | - return $class_name; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Check for the existence of file name via an array of file names. |
|
| 57 | - * |
|
| 58 | - * @param array $file_names Array of file names. |
|
| 59 | - * |
|
| 60 | - * @return string|bool |
|
| 61 | - */ |
|
| 62 | - public static function file_exists_ex( array $file_names = array() ) { |
|
| 63 | - foreach ( $file_names as $file_name ) { |
|
| 64 | - if ( file_exists( $file_name ) ) { |
|
| 65 | - return $file_name; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - return false; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** Extract data: |
|
| 73 | - * $field = field_array |
|
| 74 | - * $value = field values |
|
| 75 | - * $core = Redux instance */ |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Parse args to handle deep arrays. The WP one does not. |
|
| 79 | - * |
|
| 80 | - * @param array|string $args Array of args. |
|
| 81 | - * @param array $defaults Defaults array. |
|
| 82 | - * |
|
| 83 | - * @return array |
|
| 84 | - */ |
|
| 85 | - public static function parse_args( $args, array $defaults ): array { |
|
| 86 | - $arr = array(); |
|
| 87 | - |
|
| 88 | - if ( ! is_array( $args ) ) { |
|
| 89 | - $arr[] = $args; |
|
| 90 | - } else { |
|
| 91 | - $arr = $args; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $result = $defaults; |
|
| 95 | - |
|
| 96 | - foreach ( $arr as $k => $v ) { |
|
| 97 | - if ( is_array( $v ) && isset( $result[ $k ] ) ) { |
|
| 98 | - $result[ $k ] = self::parse_args( $v, $result[ $k ] ); |
|
| 99 | - } else { |
|
| 100 | - $result[ $k ] = $v; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $result; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Deprecated: Return min tag for JS and CSS files in dev_mode. |
|
| 109 | - * |
|
| 110 | - * @deprecated No longer using camelCase naming conventions. |
|
| 111 | - * |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public static function isMin(): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 115 | - return self::is_min(); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Return min tag for JS and CSS files in dev_mode. |
|
| 120 | - * |
|
| 121 | - * @return string |
|
| 122 | - */ |
|
| 123 | - public static function is_min(): string { |
|
| 124 | - $min = '.min'; |
|
| 125 | - $dev_mode = false; |
|
| 126 | - |
|
| 127 | - $instances = Redux::all_instances(); |
|
| 128 | - |
|
| 129 | - if ( ! empty( $instances ) ) { |
|
| 130 | - foreach ( $instances as $instance ) { |
|
| 131 | - |
|
| 132 | - if ( empty( self::$parent ) ) { |
|
| 133 | - self::$parent = $instance; |
|
| 134 | - self::$_parent = self::$parent; |
|
| 135 | - } |
|
| 136 | - if ( ! empty( $instance->args['dev_mode'] ) ) { |
|
| 137 | - $dev_mode = true; |
|
| 138 | - self::$parent = $instance; |
|
| 139 | - self::$_parent = self::$parent; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - if ( $dev_mode ) { |
|
| 143 | - $min = ''; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $min; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * Parse CSS from an output/compiler array |
|
| 152 | - * |
|
| 153 | - * @param array $css_array CSS data. |
|
| 154 | - * @param string $style CSS style. |
|
| 155 | - * @param string $value CSS values. |
|
| 156 | - * |
|
| 157 | - * @return string CSS string |
|
| 158 | - * @since 3.2.8 |
|
| 159 | - * @access private |
|
| 160 | - */ |
|
| 161 | - public static function parse_css( array $css_array = array(), string $style = '', string $value = '' ): string { |
|
| 162 | - |
|
| 163 | - // Something wrong happened. |
|
| 164 | - if ( 0 === count( $css_array ) ) { |
|
| 165 | - return ''; |
|
| 166 | - } else { |
|
| 167 | - $css = ''; |
|
| 168 | - $important = false; |
|
| 169 | - |
|
| 170 | - if ( isset( $css_array['important'] ) && true === $css_array['important'] ) { |
|
| 171 | - $important = '!important'; |
|
| 172 | - |
|
| 173 | - unset( $css_array['important'] ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - foreach ( $css_array as $element => $selector ) { |
|
| 177 | - |
|
| 178 | - // The old way. |
|
| 179 | - if ( 0 === $element ) { |
|
| 180 | - return self::the_old_way( $css_array, $style ); |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - // New way continued. |
|
| 184 | - $css_style = $element . ':' . $value . $important . ';'; |
|
| 185 | - |
|
| 186 | - $css .= $selector . '{' . $css_style . '}'; |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - return $css; |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Parse CSS shim. |
|
| 195 | - * |
|
| 196 | - * @param array $css_array CSS data. |
|
| 197 | - * @param string $style CSS style. |
|
| 198 | - * @param string $value CSS values. |
|
| 199 | - * |
|
| 200 | - * @deprecated 4.0 |
|
| 201 | - * |
|
| 202 | - * @return string CSS string |
|
| 203 | - * @since 4.0.0 |
|
| 204 | - * @access public |
|
| 205 | - */ |
|
| 206 | - public static function parseCSS( array $css_array = array(), string $style = '', string $value = '' ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 207 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::parse_css( $css_array, $style, $value )' ); |
|
| 208 | - |
|
| 209 | - return self::parse_css( $css_array, $style, $value ); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Parse CSS the old way, without mode options. |
|
| 214 | - * |
|
| 215 | - * @param array $css_array CSS data. |
|
| 216 | - * @param string $style CSS style. |
|
| 217 | - * |
|
| 218 | - * @return string |
|
| 219 | - */ |
|
| 220 | - private static function the_old_way( array $css_array, string $style ): string { |
|
| 221 | - $keys = implode( ',', $css_array ); |
|
| 222 | - |
|
| 223 | - return $keys . '{' . $style . '}'; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * Return s. |
|
| 228 | - * |
|
| 229 | - * @access public |
|
| 230 | - * @since 4.0.0 |
|
| 231 | - * @return string |
|
| 232 | - */ |
|
| 233 | - public static function gs(): string { |
|
| 234 | - return get_option( 're' . 'dux_p' . 'ro_lic' . 'ense_key', '' ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Deprecated Initialized the WordPress filesystem, if it already isn't. |
|
| 239 | - * |
|
| 240 | - * @since 3.2.3 |
|
| 241 | - * @access public |
|
| 242 | - * @deprecated NO longer using camelCase naming conventions. |
|
| 243 | - * |
|
| 244 | - * @return void |
|
| 245 | - */ |
|
| 246 | - public static function initWpFilesystem() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 247 | - // phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar |
|
| 248 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::init_wp_filesystem()' ); |
|
| 249 | - |
|
| 250 | - self::init_wp_filesystem(); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * Initialized the WordPress filesystem, if it already isn't. |
|
| 255 | - * |
|
| 256 | - * @since 3.2.3 |
|
| 257 | - * @access public |
|
| 258 | - * |
|
| 259 | - * @return void |
|
| 260 | - */ |
|
| 261 | - public static function init_wp_filesystem() { |
|
| 262 | - global $wp_filesystem; |
|
| 263 | - |
|
| 264 | - // Initialize the WordPress filesystem, no more using file_put_contents function. |
|
| 265 | - if ( empty( $wp_filesystem ) ) { |
|
| 266 | - require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 267 | - require_once ABSPATH . '/wp-admin/includes/file.php'; |
|
| 268 | - |
|
| 269 | - WP_Filesystem(); |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * TRU. |
|
| 275 | - * |
|
| 276 | - * @param string $string . |
|
| 277 | - * @param string $opt_name . |
|
| 278 | - * |
|
| 279 | - * @deprecated Ad Remover extension no longer necessary. |
|
| 280 | - * |
|
| 281 | - * @return void |
|
| 282 | - */ |
|
| 283 | - public static function tru( string $string, string $opt_name ) { |
|
| 284 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * DAT. |
|
| 289 | - * |
|
| 290 | - * @param string $fname . |
|
| 291 | - * @param string $opt_name . |
|
| 292 | - * |
|
| 293 | - * @deprecated Ad Remover extension no longer necessary. |
|
| 294 | - * |
|
| 295 | - * @return void |
|
| 296 | - */ |
|
| 297 | - public static function dat( string $fname, string $opt_name ) { |
|
| 298 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - /** |
|
| 302 | - * BUB. |
|
| 303 | - * |
|
| 304 | - * @param string $fname . |
|
| 305 | - * @param string $opt_name . |
|
| 306 | - * |
|
| 307 | - * @deprecated Ad Remover extension no longer necessary. |
|
| 308 | - * |
|
| 309 | - * @return void |
|
| 310 | - */ |
|
| 311 | - public static function bub( string $fname, string $opt_name ) { |
|
| 312 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * YO. |
|
| 317 | - * |
|
| 318 | - * @param string $fname . |
|
| 319 | - * @param string $opt_name . |
|
| 320 | - * |
|
| 321 | - * @deprecated Ad Remover extension no longer necessary. |
|
| 322 | - * |
|
| 323 | - * @return void |
|
| 324 | - */ |
|
| 325 | - public static function yo( string $fname, string $opt_name ) { |
|
| 326 | - _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Sanitize camelCase keys in an array, makes then snake_case. |
|
| 331 | - * |
|
| 332 | - * @param array $arr Array of keys. |
|
| 333 | - * |
|
| 334 | - * @return array |
|
| 335 | - */ |
|
| 336 | - public static function sanitize_camel_case_array_keys( array $arr ): array { |
|
| 337 | - $keys = array_keys( $arr ); |
|
| 338 | - $values = array_values( $arr ); |
|
| 339 | - |
|
| 340 | - $result = preg_replace_callback( |
|
| 341 | - '/[A-Z]/', |
|
| 342 | - function ( $matches ) { |
|
| 343 | - return '-' . Redux_Core::strtolower( $matches[0] ); |
|
| 344 | - }, |
|
| 345 | - $keys |
|
| 346 | - ); |
|
| 347 | - |
|
| 348 | - return array_combine( $result, $values ); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Converts an array into an html data string. |
|
| 353 | - * |
|
| 354 | - * @param array $data example input: array('id'=>'true'). |
|
| 355 | - * |
|
| 356 | - * @return string $data_string example output: data-id='true' |
|
| 357 | - */ |
|
| 358 | - public static function create_data_string( array $data = array() ): string { |
|
| 359 | - $data_string = ''; |
|
| 360 | - |
|
| 361 | - foreach ( $data as $key => $value ) { |
|
| 362 | - if ( is_array( $value ) ) { |
|
| 363 | - $value = implode( '|', $value ); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - $data_string .= ' data-' . $key . '=' . Redux_Helpers::make_bool_str( $value ) . ' '; |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - return $data_string; |
|
| 370 | - } |
|
| 371 | - } |
|
| 16 | + /** |
|
| 17 | + * Redux Functions Class |
|
| 18 | + * A Class of useful functions that can/should be shared among all Redux files. |
|
| 19 | + * |
|
| 20 | + * @since 3.0.0 |
|
| 21 | + */ |
|
| 22 | + class Redux_Functions { |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * ReduxFramework object pointer. |
|
| 26 | + * |
|
| 27 | + * @var object |
|
| 28 | + */ |
|
| 29 | + public static $parent; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * ReduxFramework shim object pointer. |
|
| 33 | + * |
|
| 34 | + * @var object |
|
| 35 | + */ |
|
| 36 | + public static $_parent; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Check for the existence of class name via an array of class names. |
|
| 40 | + * |
|
| 41 | + * @param array $class_names Array of class names. |
|
| 42 | + * |
|
| 43 | + * @return string|bool |
|
| 44 | + */ |
|
| 45 | + public static function class_exists_ex( array $class_names = array() ) { |
|
| 46 | + foreach ( $class_names as $class_name ) { |
|
| 47 | + if ( class_exists( $class_name ) ) { |
|
| 48 | + return $class_name; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Check for the existence of file name via an array of file names. |
|
| 57 | + * |
|
| 58 | + * @param array $file_names Array of file names. |
|
| 59 | + * |
|
| 60 | + * @return string|bool |
|
| 61 | + */ |
|
| 62 | + public static function file_exists_ex( array $file_names = array() ) { |
|
| 63 | + foreach ( $file_names as $file_name ) { |
|
| 64 | + if ( file_exists( $file_name ) ) { |
|
| 65 | + return $file_name; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + return false; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** Extract data: |
|
| 73 | + * $field = field_array |
|
| 74 | + * $value = field values |
|
| 75 | + * $core = Redux instance */ |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Parse args to handle deep arrays. The WP one does not. |
|
| 79 | + * |
|
| 80 | + * @param array|string $args Array of args. |
|
| 81 | + * @param array $defaults Defaults array. |
|
| 82 | + * |
|
| 83 | + * @return array |
|
| 84 | + */ |
|
| 85 | + public static function parse_args( $args, array $defaults ): array { |
|
| 86 | + $arr = array(); |
|
| 87 | + |
|
| 88 | + if ( ! is_array( $args ) ) { |
|
| 89 | + $arr[] = $args; |
|
| 90 | + } else { |
|
| 91 | + $arr = $args; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $result = $defaults; |
|
| 95 | + |
|
| 96 | + foreach ( $arr as $k => $v ) { |
|
| 97 | + if ( is_array( $v ) && isset( $result[ $k ] ) ) { |
|
| 98 | + $result[ $k ] = self::parse_args( $v, $result[ $k ] ); |
|
| 99 | + } else { |
|
| 100 | + $result[ $k ] = $v; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $result; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Deprecated: Return min tag for JS and CSS files in dev_mode. |
|
| 109 | + * |
|
| 110 | + * @deprecated No longer using camelCase naming conventions. |
|
| 111 | + * |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public static function isMin(): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 115 | + return self::is_min(); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * Return min tag for JS and CSS files in dev_mode. |
|
| 120 | + * |
|
| 121 | + * @return string |
|
| 122 | + */ |
|
| 123 | + public static function is_min(): string { |
|
| 124 | + $min = '.min'; |
|
| 125 | + $dev_mode = false; |
|
| 126 | + |
|
| 127 | + $instances = Redux::all_instances(); |
|
| 128 | + |
|
| 129 | + if ( ! empty( $instances ) ) { |
|
| 130 | + foreach ( $instances as $instance ) { |
|
| 131 | + |
|
| 132 | + if ( empty( self::$parent ) ) { |
|
| 133 | + self::$parent = $instance; |
|
| 134 | + self::$_parent = self::$parent; |
|
| 135 | + } |
|
| 136 | + if ( ! empty( $instance->args['dev_mode'] ) ) { |
|
| 137 | + $dev_mode = true; |
|
| 138 | + self::$parent = $instance; |
|
| 139 | + self::$_parent = self::$parent; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + if ( $dev_mode ) { |
|
| 143 | + $min = ''; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $min; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * Parse CSS from an output/compiler array |
|
| 152 | + * |
|
| 153 | + * @param array $css_array CSS data. |
|
| 154 | + * @param string $style CSS style. |
|
| 155 | + * @param string $value CSS values. |
|
| 156 | + * |
|
| 157 | + * @return string CSS string |
|
| 158 | + * @since 3.2.8 |
|
| 159 | + * @access private |
|
| 160 | + */ |
|
| 161 | + public static function parse_css( array $css_array = array(), string $style = '', string $value = '' ): string { |
|
| 162 | + |
|
| 163 | + // Something wrong happened. |
|
| 164 | + if ( 0 === count( $css_array ) ) { |
|
| 165 | + return ''; |
|
| 166 | + } else { |
|
| 167 | + $css = ''; |
|
| 168 | + $important = false; |
|
| 169 | + |
|
| 170 | + if ( isset( $css_array['important'] ) && true === $css_array['important'] ) { |
|
| 171 | + $important = '!important'; |
|
| 172 | + |
|
| 173 | + unset( $css_array['important'] ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + foreach ( $css_array as $element => $selector ) { |
|
| 177 | + |
|
| 178 | + // The old way. |
|
| 179 | + if ( 0 === $element ) { |
|
| 180 | + return self::the_old_way( $css_array, $style ); |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + // New way continued. |
|
| 184 | + $css_style = $element . ':' . $value . $important . ';'; |
|
| 185 | + |
|
| 186 | + $css .= $selector . '{' . $css_style . '}'; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + return $css; |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Parse CSS shim. |
|
| 195 | + * |
|
| 196 | + * @param array $css_array CSS data. |
|
| 197 | + * @param string $style CSS style. |
|
| 198 | + * @param string $value CSS values. |
|
| 199 | + * |
|
| 200 | + * @deprecated 4.0 |
|
| 201 | + * |
|
| 202 | + * @return string CSS string |
|
| 203 | + * @since 4.0.0 |
|
| 204 | + * @access public |
|
| 205 | + */ |
|
| 206 | + public static function parseCSS( array $css_array = array(), string $style = '', string $value = '' ): string { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 207 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::parse_css( $css_array, $style, $value )' ); |
|
| 208 | + |
|
| 209 | + return self::parse_css( $css_array, $style, $value ); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Parse CSS the old way, without mode options. |
|
| 214 | + * |
|
| 215 | + * @param array $css_array CSS data. |
|
| 216 | + * @param string $style CSS style. |
|
| 217 | + * |
|
| 218 | + * @return string |
|
| 219 | + */ |
|
| 220 | + private static function the_old_way( array $css_array, string $style ): string { |
|
| 221 | + $keys = implode( ',', $css_array ); |
|
| 222 | + |
|
| 223 | + return $keys . '{' . $style . '}'; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * Return s. |
|
| 228 | + * |
|
| 229 | + * @access public |
|
| 230 | + * @since 4.0.0 |
|
| 231 | + * @return string |
|
| 232 | + */ |
|
| 233 | + public static function gs(): string { |
|
| 234 | + return get_option( 're' . 'dux_p' . 'ro_lic' . 'ense_key', '' ); // phpcs:ignore Generic.Strings.UnnecessaryStringConcat.Found |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Deprecated Initialized the WordPress filesystem, if it already isn't. |
|
| 239 | + * |
|
| 240 | + * @since 3.2.3 |
|
| 241 | + * @access public |
|
| 242 | + * @deprecated NO longer using camelCase naming conventions. |
|
| 243 | + * |
|
| 244 | + * @return void |
|
| 245 | + */ |
|
| 246 | + public static function initWpFilesystem() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName |
|
| 247 | + // phpcs:ignore Squiz.Commenting.InlineComment.InvalidEndChar |
|
| 248 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', __CLASS__ . '::init_wp_filesystem()' ); |
|
| 249 | + |
|
| 250 | + self::init_wp_filesystem(); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * Initialized the WordPress filesystem, if it already isn't. |
|
| 255 | + * |
|
| 256 | + * @since 3.2.3 |
|
| 257 | + * @access public |
|
| 258 | + * |
|
| 259 | + * @return void |
|
| 260 | + */ |
|
| 261 | + public static function init_wp_filesystem() { |
|
| 262 | + global $wp_filesystem; |
|
| 263 | + |
|
| 264 | + // Initialize the WordPress filesystem, no more using file_put_contents function. |
|
| 265 | + if ( empty( $wp_filesystem ) ) { |
|
| 266 | + require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 267 | + require_once ABSPATH . '/wp-admin/includes/file.php'; |
|
| 268 | + |
|
| 269 | + WP_Filesystem(); |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * TRU. |
|
| 275 | + * |
|
| 276 | + * @param string $string . |
|
| 277 | + * @param string $opt_name . |
|
| 278 | + * |
|
| 279 | + * @deprecated Ad Remover extension no longer necessary. |
|
| 280 | + * |
|
| 281 | + * @return void |
|
| 282 | + */ |
|
| 283 | + public static function tru( string $string, string $opt_name ) { |
|
| 284 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * DAT. |
|
| 289 | + * |
|
| 290 | + * @param string $fname . |
|
| 291 | + * @param string $opt_name . |
|
| 292 | + * |
|
| 293 | + * @deprecated Ad Remover extension no longer necessary. |
|
| 294 | + * |
|
| 295 | + * @return void |
|
| 296 | + */ |
|
| 297 | + public static function dat( string $fname, string $opt_name ) { |
|
| 298 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + /** |
|
| 302 | + * BUB. |
|
| 303 | + * |
|
| 304 | + * @param string $fname . |
|
| 305 | + * @param string $opt_name . |
|
| 306 | + * |
|
| 307 | + * @deprecated Ad Remover extension no longer necessary. |
|
| 308 | + * |
|
| 309 | + * @return void |
|
| 310 | + */ |
|
| 311 | + public static function bub( string $fname, string $opt_name ) { |
|
| 312 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * YO. |
|
| 317 | + * |
|
| 318 | + * @param string $fname . |
|
| 319 | + * @param string $opt_name . |
|
| 320 | + * |
|
| 321 | + * @deprecated Ad Remover extension no longer necessary. |
|
| 322 | + * |
|
| 323 | + * @return void |
|
| 324 | + */ |
|
| 325 | + public static function yo( string $fname, string $opt_name ) { |
|
| 326 | + _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.0', '' ); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Sanitize camelCase keys in an array, makes then snake_case. |
|
| 331 | + * |
|
| 332 | + * @param array $arr Array of keys. |
|
| 333 | + * |
|
| 334 | + * @return array |
|
| 335 | + */ |
|
| 336 | + public static function sanitize_camel_case_array_keys( array $arr ): array { |
|
| 337 | + $keys = array_keys( $arr ); |
|
| 338 | + $values = array_values( $arr ); |
|
| 339 | + |
|
| 340 | + $result = preg_replace_callback( |
|
| 341 | + '/[A-Z]/', |
|
| 342 | + function ( $matches ) { |
|
| 343 | + return '-' . Redux_Core::strtolower( $matches[0] ); |
|
| 344 | + }, |
|
| 345 | + $keys |
|
| 346 | + ); |
|
| 347 | + |
|
| 348 | + return array_combine( $result, $values ); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Converts an array into an html data string. |
|
| 353 | + * |
|
| 354 | + * @param array $data example input: array('id'=>'true'). |
|
| 355 | + * |
|
| 356 | + * @return string $data_string example output: data-id='true' |
|
| 357 | + */ |
|
| 358 | + public static function create_data_string( array $data = array() ): string { |
|
| 359 | + $data_string = ''; |
|
| 360 | + |
|
| 361 | + foreach ( $data as $key => $value ) { |
|
| 362 | + if ( is_array( $value ) ) { |
|
| 363 | + $value = implode( '|', $value ); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + $data_string .= ' data-' . $key . '=' . Redux_Helpers::make_bool_str( $value ) . ' '; |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + return $data_string; |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | 372 | } |