@@ -16,82 +16,82 @@ |
||
| 16 | 16 | require_once Redux_Core::$dir . 'inc/extensions/icon_select/font-awesome-5-free.php'; |
| 17 | 17 | |
| 18 | 18 | Redux::set_section( |
| 19 | - $opt_name, |
|
| 20 | - array( |
|
| 21 | - 'title' => esc_html__( 'Icon Select', 'your-textdomain-here' ), |
|
| 22 | - 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/icon-select.html" target="_blank">https://devs.redux.io/core-extensions/icon-select.html</a>', |
|
| 23 | - 'subsection' => true, |
|
| 24 | - 'fields' => array( |
|
| 19 | + $opt_name, |
|
| 20 | + array( |
|
| 21 | + 'title' => esc_html__( 'Icon Select', 'your-textdomain-here' ), |
|
| 22 | + 'desc' => esc_html__( 'For full documentation on this field, visit: ', 'your-textdomain-here' ) . '<a href="https://devs.redux.io/core-extensions/icon-select.html" target="_blank">https://devs.redux.io/core-extensions/icon-select.html</a>', |
|
| 23 | + 'subsection' => true, |
|
| 24 | + 'fields' => array( |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * This field was left in the sample config to display that every effort to maintain backward compatibility with older |
|
| 28 | - * versions of Icon Select has been implemented. |
|
| 29 | - * Please do NOT use argument in this field in your projects. |
|
| 30 | - * They are considered deprecated. |
|
| 31 | - */ |
|
| 32 | - array( |
|
| 33 | - 'id' => 'icon-select-legacy', |
|
| 34 | - 'type' => 'icon_select', |
|
| 35 | - 'title' => esc_html__( 'Legacy Icon Select', 'your-textdomain-here' ), |
|
| 36 | - 'subtitle' => esc_html__( 'Original Icon Select field that maintains backward compatibility with the original extension.', 'your-textdomain-here' ), |
|
| 37 | - 'default' => '', |
|
| 38 | - 'options' => redux_icon_select_fa_5_free(), |
|
| 26 | + /** |
|
| 27 | + * This field was left in the sample config to display that every effort to maintain backward compatibility with older |
|
| 28 | + * versions of Icon Select has been implemented. |
|
| 29 | + * Please do NOT use argument in this field in your projects. |
|
| 30 | + * They are considered deprecated. |
|
| 31 | + */ |
|
| 32 | + array( |
|
| 33 | + 'id' => 'icon-select-legacy', |
|
| 34 | + 'type' => 'icon_select', |
|
| 35 | + 'title' => esc_html__( 'Legacy Icon Select', 'your-textdomain-here' ), |
|
| 36 | + 'subtitle' => esc_html__( 'Original Icon Select field that maintains backward compatibility with the original extension.', 'your-textdomain-here' ), |
|
| 37 | + 'default' => '', |
|
| 38 | + 'options' => redux_icon_select_fa_5_free(), |
|
| 39 | 39 | |
| 40 | - // Disable auto-enqueue of stylesheet if present in the panel. |
|
| 41 | - 'enqueue' => true, |
|
| 40 | + // Disable auto-enqueue of stylesheet if present in the panel. |
|
| 41 | + 'enqueue' => true, |
|
| 42 | 42 | |
| 43 | - // Disable auto-enqueue of stylesheet on the front-end. |
|
| 44 | - 'enqueue_frontend' => true, |
|
| 43 | + // Disable auto-enqueue of stylesheet on the front-end. |
|
| 44 | + 'enqueue_frontend' => true, |
|
| 45 | 45 | |
| 46 | - // Stylesheet URL. |
|
| 47 | - //'stylesheet' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css', |
|
| 46 | + // Stylesheet URL. |
|
| 47 | + //'stylesheet' => 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css', |
|
| 48 | 48 | |
| 49 | - // (Optional) Specify a class prefix if one is needed to initialize the icon. |
|
| 50 | - 'prefix' => 'fa', |
|
| 51 | - ), |
|
| 49 | + // (Optional) Specify a class prefix if one is needed to initialize the icon. |
|
| 50 | + 'prefix' => 'fa', |
|
| 51 | + ), |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * When creating fields for Icon Select, use this as a template instead. |
|
| 55 | - * For detailed documentation, see: https://devs.redux.io/core-extensions/icon-select.html |
|
| 56 | - */ |
|
| 57 | - array( |
|
| 58 | - 'id' => 'icon-select', |
|
| 59 | - 'type' => 'icon_select', |
|
| 60 | - 'title' => esc_html__( 'Icon Select', 'your-textdomain-here' ), |
|
| 61 | - 'subtitle' => esc_html__( 'Select an icon.', 'your-textdomain-here' ), |
|
| 62 | - 'default' => 'fas fa-1', |
|
| 53 | + /** |
|
| 54 | + * When creating fields for Icon Select, use this as a template instead. |
|
| 55 | + * For detailed documentation, see: https://devs.redux.io/core-extensions/icon-select.html |
|
| 56 | + */ |
|
| 57 | + array( |
|
| 58 | + 'id' => 'icon-select', |
|
| 59 | + 'type' => 'icon_select', |
|
| 60 | + 'title' => esc_html__( 'Icon Select', 'your-textdomain-here' ), |
|
| 61 | + 'subtitle' => esc_html__( 'Select an icon.', 'your-textdomain-here' ), |
|
| 62 | + 'default' => 'fas fa-1', |
|
| 63 | 63 | |
| 64 | - // Disable auto-enqueue of stylesheet if present in the panel. |
|
| 65 | - 'enqueue' => true, |
|
| 64 | + // Disable auto-enqueue of stylesheet if present in the panel. |
|
| 65 | + 'enqueue' => true, |
|
| 66 | 66 | |
| 67 | - // Disable auto-enqueue of stylesheet on the front-end. |
|
| 68 | - 'enqueue_frontend' => true, |
|
| 67 | + // Disable auto-enqueue of stylesheet on the front-end. |
|
| 68 | + 'enqueue_frontend' => true, |
|
| 69 | 69 | |
| 70 | - // Stylesheet data. |
|
| 71 | - 'stylesheet' => array( |
|
| 72 | - array( |
|
| 73 | - 'url' => 'https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.2.96/css/materialdesignicons.css', |
|
| 74 | - 'title' => 'Material Icons', |
|
| 75 | - 'prefix' => 'mdi-set', |
|
| 76 | - ), |
|
| 77 | - array( |
|
| 78 | - 'url' => 'https://icons.getbootstrap.com/assets/font/bootstrap-icons.min.css', |
|
| 79 | - 'title' => 'Bootstrap', |
|
| 80 | - 'prefix' => 'bi', |
|
| 81 | - ), |
|
| 82 | - array( |
|
| 83 | - 'url' => 'https://cdn.lineicons.com/4.0/lineicons.css', |
|
| 84 | - 'title' => 'Line Icons', |
|
| 85 | - 'prefix' => 'lni', |
|
| 86 | - ), |
|
| 87 | - array( |
|
| 88 | - 'url' => 'https://cdn.jsdelivr.net/gh/devicons/[email protected]/devicon.min.css', |
|
| 89 | - 'title' => 'Dev Icons', |
|
| 90 | - 'prefix' => '', |
|
| 91 | - ), |
|
| 92 | - ), |
|
| 93 | - ), |
|
| 94 | - ), |
|
| 95 | - ) |
|
| 70 | + // Stylesheet data. |
|
| 71 | + 'stylesheet' => array( |
|
| 72 | + array( |
|
| 73 | + 'url' => 'https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/7.2.96/css/materialdesignicons.css', |
|
| 74 | + 'title' => 'Material Icons', |
|
| 75 | + 'prefix' => 'mdi-set', |
|
| 76 | + ), |
|
| 77 | + array( |
|
| 78 | + 'url' => 'https://icons.getbootstrap.com/assets/font/bootstrap-icons.min.css', |
|
| 79 | + 'title' => 'Bootstrap', |
|
| 80 | + 'prefix' => 'bi', |
|
| 81 | + ), |
|
| 82 | + array( |
|
| 83 | + 'url' => 'https://cdn.lineicons.com/4.0/lineicons.css', |
|
| 84 | + 'title' => 'Line Icons', |
|
| 85 | + 'prefix' => 'lni', |
|
| 86 | + ), |
|
| 87 | + array( |
|
| 88 | + 'url' => 'https://cdn.jsdelivr.net/gh/devicons/[email protected]/devicon.min.css', |
|
| 89 | + 'title' => 'Dev Icons', |
|
| 90 | + 'prefix' => '', |
|
| 91 | + ), |
|
| 92 | + ), |
|
| 93 | + ), |
|
| 94 | + ), |
|
| 95 | + ) |
|
| 96 | 96 | ); |
| 97 | 97 | // phpcs:enable |
@@ -11,241 +11,241 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Validation', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Validation |
|
| 16 | - */ |
|
| 17 | - class Redux_Validation extends Redux_Class { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Validate values from options form (used in settings api validate function) |
|
| 21 | - * calls the custom validation class for the field so authors can override with custom classes |
|
| 22 | - * |
|
| 23 | - * @since 1.0.0 |
|
| 24 | - * @access public |
|
| 25 | - * |
|
| 26 | - * @param array $plugin_options Plugin Options. |
|
| 27 | - * @param array $options Options. |
|
| 28 | - * @param array $sections Sections array. |
|
| 29 | - * |
|
| 30 | - * @return array $plugin_options |
|
| 31 | - */ |
|
| 32 | - public function validate( array $plugin_options, array $options, array $sections ): array { |
|
| 33 | - $core = $this->core(); |
|
| 34 | - |
|
| 35 | - if (null === $core) { |
|
| 36 | - return $plugin_options; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - foreach ( $sections as $k => $section ) { |
|
| 40 | - if ( isset( $section['fields'] ) ) { |
|
| 41 | - foreach ( $section['fields'] as $fkey => $field ) { |
|
| 42 | - if ( is_array( $field ) ) { |
|
| 43 | - $field['section_id'] = $k; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) { |
|
| 47 | - if ( ! isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 48 | - $plugin_options[ $field['id'] ] = 0; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - // Part of Dovy's serialize typography effort. Preserved here in case it becomes a thing. - kp. |
|
| 53 | - /** |
|
| 54 | - * If ( isset ( $field['type'] ) && $field['type'] == 'typography' ) { |
|
| 55 | - * if ( ! is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 56 | - * $plugin_options[ $field['id'] ] = json_decode( $plugin_options[ $field['id'] ], true ); |
|
| 57 | - * } |
|
| 58 | - * } |
|
| 59 | - */ |
|
| 60 | - |
|
| 61 | - if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) { |
|
| 62 | - $plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections ); |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - // Make sure 'validate' field is set. |
|
| 66 | - if ( isset( $field['validate'] ) ) { |
|
| 67 | - |
|
| 68 | - // Can we make this an array of validations? |
|
| 69 | - $val_arr = array(); |
|
| 70 | - |
|
| 71 | - if ( is_array( $field['validate'] ) ) { |
|
| 72 | - $val_arr = $field['validate']; |
|
| 73 | - } else { |
|
| 74 | - $val_arr[] = $field['validate']; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - foreach ( $val_arr as $idx => $val ) { |
|
| 78 | - // shim for old *_not_empty validations. |
|
| 79 | - if ( 'email_not_empty' === $val || 'numeric_not_empty' === $val ) { |
|
| 80 | - $val = 'not_empty'; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - // Make sure 'validate field' is set to 'not_empty'. |
|
| 84 | - $is_not_empty = false; |
|
| 85 | - |
|
| 86 | - if ( 'not_empty' === $val ) { |
|
| 87 | - // Set the flag. |
|
| 88 | - $is_not_empty = true; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // Check for empty id value. |
|
| 92 | - if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 93 | - |
|
| 94 | - // If we are looking for an empty value, in the case of 'not_empty' |
|
| 95 | - // then we need to keep processing. |
|
| 96 | - if ( ! $is_not_empty ) { |
|
| 97 | - |
|
| 98 | - // Empty id and not checking for 'not_empty'. Bail out... |
|
| 99 | - if ( ! isset( $field['validate_callback'] ) ) { |
|
| 100 | - continue; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // Force validate of custom field types. |
|
| 106 | - if ( isset( $field['type'] ) && ! isset( $val ) && ! isset( $field['validate_callback'] ) ) { |
|
| 107 | - if ( 'color' === $field['type'] || 'color_gradient' === $field['type'] ) { |
|
| 108 | - $val = 'color'; |
|
| 109 | - } elseif ( 'date' === $field['type'] ) { |
|
| 110 | - $val = 'date'; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - // No need. Spectrum self validates. |
|
| 115 | - if ( 'color_rgba' === $field['type'] ) { |
|
| 116 | - continue; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // Shim out old color rgba validators. |
|
| 120 | - if ( 'color_rgba' === $val || 'colorrgba' === $val ) { |
|
| 121 | - $val = 'color'; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $validate = 'Redux_Validation_' . $val; |
|
| 125 | - |
|
| 126 | - if ( ! class_exists( $validate ) ) { |
|
| 127 | - $file = str_replace( '_', '-', $val ); |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Filter 'redux/validate/{opt_name}/class/{field.validate}' |
|
| 131 | - * |
|
| 132 | - * @param string $validate validation class file path |
|
| 133 | - */ |
|
| 134 | - |
|
| 135 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 136 | - $class_file = apply_filters( "redux/validate/{$core->args['opt_name']}/class/$val", Redux_Core::$dir . "inc/validation/$val/class-redux-validation-$file.php", $validate ); |
|
| 137 | - |
|
| 138 | - if ( $class_file ) { |
|
| 139 | - if ( file_exists( $class_file ) ) { |
|
| 140 | - require_once $class_file; |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if ( class_exists( $validate ) ) { |
|
| 146 | - if ( empty( $options[ $field['id'] ] ) ) { |
|
| 147 | - $options[ $field['id'] ] = ''; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 151 | - foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 152 | - $before = null; |
|
| 153 | - $after = null; |
|
| 154 | - |
|
| 155 | - if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 156 | - if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 157 | - $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 158 | - } else { |
|
| 159 | - $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 164 | - $after = $options[ $field['id'] ][ $key ]; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - $validation = new $validate( $core, $field, $before, $after ); |
|
| 168 | - |
|
| 169 | - if ( ! empty( $validation->value ) || '0' === $validation->value ) { |
|
| 170 | - $plugin_options[ $field['id'] ][ $key ] = $validation->value; |
|
| 171 | - } else { |
|
| 172 | - unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ( ! empty( $validation->error ) ) { |
|
| 176 | - $core->errors[] = $validation->error; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ( ! empty( $validation->warning ) ) { |
|
| 180 | - $core->warnings[] = $validation->warning; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - if ( ! empty( $validation->sanitize ) ) { |
|
| 184 | - $core->sanitize[] = $validation->sanitize; |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - } else { |
|
| 188 | - if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 189 | - if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 190 | - $pofi = $plugin_options[ $field['id'] ]; |
|
| 191 | - } else { |
|
| 192 | - $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 193 | - } |
|
| 194 | - } else { |
|
| 195 | - $pofi = null; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - $validation = new $validate( $core, $field, $pofi, $options[ $field['id'] ] ); |
|
| 199 | - $plugin_options[ $field['id'] ] = $validation->value; |
|
| 200 | - |
|
| 201 | - if ( ! empty( $validation->error ) ) { |
|
| 202 | - $core->errors[] = $validation->error; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - if ( ! empty( $validation->warning ) ) { |
|
| 206 | - $core->warnings[] = $validation->warning; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if ( ! empty( $validation->sanitize ) ) { |
|
| 210 | - $core->sanitize[] = $validation->sanitize; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - break; |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - if ( isset( $field['validate_callback'] ) && ( is_callable( $field['validate_callback'] ) || ( is_string( $field['validate_callback'] ) && function_exists( $field['validate_callback'] ) ) ) ) { |
|
| 220 | - $callback = $field['validate_callback']; |
|
| 221 | - unset( $field['validate_callback'] ); |
|
| 222 | - |
|
| 223 | - $plugin_option = $plugin_options[ $field['id'] ] ?? null; |
|
| 224 | - $option = $options[ $field['id'] ] ?? null; |
|
| 225 | - |
|
| 226 | - if ( null !== $plugin_option ) { |
|
| 227 | - $callbackvalues = call_user_func( $callback, $field, $plugin_option, $option ); |
|
| 228 | - |
|
| 229 | - $plugin_options[ $field['id'] ] = $callbackvalues['value']; |
|
| 230 | - |
|
| 231 | - if ( isset( $callbackvalues['error'] ) ) { |
|
| 232 | - $core->errors[] = $callbackvalues['error']; |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - if ( isset( $callbackvalues['warning'] ) ) { |
|
| 236 | - $core->warnings[] = $callbackvalues['warning']; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - if ( isset( $callbackvalues['sanitize'] ) ) { |
|
| 240 | - $core->sanitize[] = $callbackvalues['sanitize']; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - return $plugin_options; |
|
| 249 | - } |
|
| 250 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Validation |
|
| 16 | + */ |
|
| 17 | + class Redux_Validation extends Redux_Class { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Validate values from options form (used in settings api validate function) |
|
| 21 | + * calls the custom validation class for the field so authors can override with custom classes |
|
| 22 | + * |
|
| 23 | + * @since 1.0.0 |
|
| 24 | + * @access public |
|
| 25 | + * |
|
| 26 | + * @param array $plugin_options Plugin Options. |
|
| 27 | + * @param array $options Options. |
|
| 28 | + * @param array $sections Sections array. |
|
| 29 | + * |
|
| 30 | + * @return array $plugin_options |
|
| 31 | + */ |
|
| 32 | + public function validate( array $plugin_options, array $options, array $sections ): array { |
|
| 33 | + $core = $this->core(); |
|
| 34 | + |
|
| 35 | + if (null === $core) { |
|
| 36 | + return $plugin_options; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + foreach ( $sections as $k => $section ) { |
|
| 40 | + if ( isset( $section['fields'] ) ) { |
|
| 41 | + foreach ( $section['fields'] as $fkey => $field ) { |
|
| 42 | + if ( is_array( $field ) ) { |
|
| 43 | + $field['section_id'] = $k; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) { |
|
| 47 | + if ( ! isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 48 | + $plugin_options[ $field['id'] ] = 0; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + // Part of Dovy's serialize typography effort. Preserved here in case it becomes a thing. - kp. |
|
| 53 | + /** |
|
| 54 | + * If ( isset ( $field['type'] ) && $field['type'] == 'typography' ) { |
|
| 55 | + * if ( ! is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 56 | + * $plugin_options[ $field['id'] ] = json_decode( $plugin_options[ $field['id'] ], true ); |
|
| 57 | + * } |
|
| 58 | + * } |
|
| 59 | + */ |
|
| 60 | + |
|
| 61 | + if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) { |
|
| 62 | + $plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections ); |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + // Make sure 'validate' field is set. |
|
| 66 | + if ( isset( $field['validate'] ) ) { |
|
| 67 | + |
|
| 68 | + // Can we make this an array of validations? |
|
| 69 | + $val_arr = array(); |
|
| 70 | + |
|
| 71 | + if ( is_array( $field['validate'] ) ) { |
|
| 72 | + $val_arr = $field['validate']; |
|
| 73 | + } else { |
|
| 74 | + $val_arr[] = $field['validate']; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + foreach ( $val_arr as $idx => $val ) { |
|
| 78 | + // shim for old *_not_empty validations. |
|
| 79 | + if ( 'email_not_empty' === $val || 'numeric_not_empty' === $val ) { |
|
| 80 | + $val = 'not_empty'; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + // Make sure 'validate field' is set to 'not_empty'. |
|
| 84 | + $is_not_empty = false; |
|
| 85 | + |
|
| 86 | + if ( 'not_empty' === $val ) { |
|
| 87 | + // Set the flag. |
|
| 88 | + $is_not_empty = true; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // Check for empty id value. |
|
| 92 | + if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 93 | + |
|
| 94 | + // If we are looking for an empty value, in the case of 'not_empty' |
|
| 95 | + // then we need to keep processing. |
|
| 96 | + if ( ! $is_not_empty ) { |
|
| 97 | + |
|
| 98 | + // Empty id and not checking for 'not_empty'. Bail out... |
|
| 99 | + if ( ! isset( $field['validate_callback'] ) ) { |
|
| 100 | + continue; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // Force validate of custom field types. |
|
| 106 | + if ( isset( $field['type'] ) && ! isset( $val ) && ! isset( $field['validate_callback'] ) ) { |
|
| 107 | + if ( 'color' === $field['type'] || 'color_gradient' === $field['type'] ) { |
|
| 108 | + $val = 'color'; |
|
| 109 | + } elseif ( 'date' === $field['type'] ) { |
|
| 110 | + $val = 'date'; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + // No need. Spectrum self validates. |
|
| 115 | + if ( 'color_rgba' === $field['type'] ) { |
|
| 116 | + continue; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // Shim out old color rgba validators. |
|
| 120 | + if ( 'color_rgba' === $val || 'colorrgba' === $val ) { |
|
| 121 | + $val = 'color'; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $validate = 'Redux_Validation_' . $val; |
|
| 125 | + |
|
| 126 | + if ( ! class_exists( $validate ) ) { |
|
| 127 | + $file = str_replace( '_', '-', $val ); |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Filter 'redux/validate/{opt_name}/class/{field.validate}' |
|
| 131 | + * |
|
| 132 | + * @param string $validate validation class file path |
|
| 133 | + */ |
|
| 134 | + |
|
| 135 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 136 | + $class_file = apply_filters( "redux/validate/{$core->args['opt_name']}/class/$val", Redux_Core::$dir . "inc/validation/$val/class-redux-validation-$file.php", $validate ); |
|
| 137 | + |
|
| 138 | + if ( $class_file ) { |
|
| 139 | + if ( file_exists( $class_file ) ) { |
|
| 140 | + require_once $class_file; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if ( class_exists( $validate ) ) { |
|
| 146 | + if ( empty( $options[ $field['id'] ] ) ) { |
|
| 147 | + $options[ $field['id'] ] = ''; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 151 | + foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 152 | + $before = null; |
|
| 153 | + $after = null; |
|
| 154 | + |
|
| 155 | + if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 156 | + if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 157 | + $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 158 | + } else { |
|
| 159 | + $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 164 | + $after = $options[ $field['id'] ][ $key ]; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + $validation = new $validate( $core, $field, $before, $after ); |
|
| 168 | + |
|
| 169 | + if ( ! empty( $validation->value ) || '0' === $validation->value ) { |
|
| 170 | + $plugin_options[ $field['id'] ][ $key ] = $validation->value; |
|
| 171 | + } else { |
|
| 172 | + unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ( ! empty( $validation->error ) ) { |
|
| 176 | + $core->errors[] = $validation->error; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ( ! empty( $validation->warning ) ) { |
|
| 180 | + $core->warnings[] = $validation->warning; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + if ( ! empty( $validation->sanitize ) ) { |
|
| 184 | + $core->sanitize[] = $validation->sanitize; |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + } else { |
|
| 188 | + if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 189 | + if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 190 | + $pofi = $plugin_options[ $field['id'] ]; |
|
| 191 | + } else { |
|
| 192 | + $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 193 | + } |
|
| 194 | + } else { |
|
| 195 | + $pofi = null; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + $validation = new $validate( $core, $field, $pofi, $options[ $field['id'] ] ); |
|
| 199 | + $plugin_options[ $field['id'] ] = $validation->value; |
|
| 200 | + |
|
| 201 | + if ( ! empty( $validation->error ) ) { |
|
| 202 | + $core->errors[] = $validation->error; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + if ( ! empty( $validation->warning ) ) { |
|
| 206 | + $core->warnings[] = $validation->warning; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if ( ! empty( $validation->sanitize ) ) { |
|
| 210 | + $core->sanitize[] = $validation->sanitize; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + break; |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + if ( isset( $field['validate_callback'] ) && ( is_callable( $field['validate_callback'] ) || ( is_string( $field['validate_callback'] ) && function_exists( $field['validate_callback'] ) ) ) ) { |
|
| 220 | + $callback = $field['validate_callback']; |
|
| 221 | + unset( $field['validate_callback'] ); |
|
| 222 | + |
|
| 223 | + $plugin_option = $plugin_options[ $field['id'] ] ?? null; |
|
| 224 | + $option = $options[ $field['id'] ] ?? null; |
|
| 225 | + |
|
| 226 | + if ( null !== $plugin_option ) { |
|
| 227 | + $callbackvalues = call_user_func( $callback, $field, $plugin_option, $option ); |
|
| 228 | + |
|
| 229 | + $plugin_options[ $field['id'] ] = $callbackvalues['value']; |
|
| 230 | + |
|
| 231 | + if ( isset( $callbackvalues['error'] ) ) { |
|
| 232 | + $core->errors[] = $callbackvalues['error']; |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + if ( isset( $callbackvalues['warning'] ) ) { |
|
| 236 | + $core->warnings[] = $callbackvalues['warning']; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + if ( isset( $callbackvalues['sanitize'] ) ) { |
|
| 240 | + $core->sanitize[] = $callbackvalues['sanitize']; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + return $plugin_options; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function validate( array $plugin_options, array $options, array $sections ): array { |
| 33 | 33 | $core = $this->core(); |
| 34 | 34 | |
| 35 | - if (null === $core) { |
|
| 35 | + if ( null === $core ) { |
|
| 36 | 36 | return $plugin_options; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if ( isset( $field['type'] ) && ( 'checkbox' === $field['type'] || 'checkbox_hide_below' === $field['type'] || 'checkbox_hide_all' === $field['type'] ) ) { |
| 47 | - if ( ! isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 48 | - $plugin_options[ $field['id'] ] = 0; |
|
| 47 | + if ( ! isset( $plugin_options[$field['id']] ) ) { |
|
| 48 | + $plugin_options[$field['id']] = 0; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
| 58 | 58 | * } |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | - if ( isset( $core->extensions[ $field['type'] ] ) && method_exists( $core->extensions[ $field['type'] ], '_validate_values' ) ) { |
|
| 62 | - $plugin_options = $core->extensions[ $field['type'] ]->_validate_values( $plugin_options, $field, $sections ); |
|
| 61 | + if ( isset( $core->extensions[$field['type']] ) && method_exists( $core->extensions[$field['type']], '_validate_values' ) ) { |
|
| 62 | + $plugin_options = $core->extensions[$field['type']]->_validate_values( $plugin_options, $field, $sections ); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Make sure 'validate' field is set. |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Check for empty id value. |
| 92 | - if ( ! isset( $field['id'] ) || ! isset( $plugin_options[ $field['id'] ] ) || ( '' === $plugin_options[ $field['id'] ] ) ) { |
|
| 92 | + if ( ! isset( $field['id'] ) || ! isset( $plugin_options[$field['id']] ) || ( '' === $plugin_options[$field['id']] ) ) { |
|
| 93 | 93 | |
| 94 | 94 | // If we are looking for an empty value, in the case of 'not_empty' |
| 95 | 95 | // then we need to keep processing. |
@@ -143,33 +143,33 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if ( class_exists( $validate ) ) { |
| 146 | - if ( empty( $options[ $field['id'] ] ) ) { |
|
| 147 | - $options[ $field['id'] ] = ''; |
|
| 146 | + if ( empty( $options[$field['id']] ) ) { |
|
| 147 | + $options[$field['id']] = ''; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - if ( isset( $plugin_options[ $field['id'] ] ) && is_array( $plugin_options[ $field['id'] ] ) && ! empty( $plugin_options[ $field['id'] ] ) ) { |
|
| 151 | - foreach ( $plugin_options[ $field['id'] ] as $key => $value ) { |
|
| 150 | + if ( isset( $plugin_options[$field['id']] ) && is_array( $plugin_options[$field['id']] ) && ! empty( $plugin_options[$field['id']] ) ) { |
|
| 151 | + foreach ( $plugin_options[$field['id']] as $key => $value ) { |
|
| 152 | 152 | $before = null; |
| 153 | 153 | $after = null; |
| 154 | 154 | |
| 155 | - if ( isset( $plugin_options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 156 | - if ( is_array( $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 157 | - $before = $plugin_options[ $field['id'] ][ $key ]; |
|
| 155 | + if ( isset( $plugin_options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) { |
|
| 156 | + if ( is_array( $plugin_options[$field['id']][$key] ) ) { |
|
| 157 | + $before = $plugin_options[$field['id']][$key]; |
|
| 158 | 158 | } else { |
| 159 | - $before = trim( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 159 | + $before = trim( $plugin_options[$field['id']][$key] ); |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( isset( $options[ $field['id'] ][ $key ] ) && ( ! empty( $plugin_options[ $field['id'] ][ $key ] ) || '0' === $plugin_options[ $field['id'] ][ $key ] ) ) { |
|
| 164 | - $after = $options[ $field['id'] ][ $key ]; |
|
| 163 | + if ( isset( $options[$field['id']][$key] ) && ( ! empty( $plugin_options[$field['id']][$key] ) || '0' === $plugin_options[$field['id']][$key] ) ) { |
|
| 164 | + $after = $options[$field['id']][$key]; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $validation = new $validate( $core, $field, $before, $after ); |
| 168 | 168 | |
| 169 | 169 | if ( ! empty( $validation->value ) || '0' === $validation->value ) { |
| 170 | - $plugin_options[ $field['id'] ][ $key ] = $validation->value; |
|
| 170 | + $plugin_options[$field['id']][$key] = $validation->value; |
|
| 171 | 171 | } else { |
| 172 | - unset( $plugin_options[ $field['id'] ][ $key ] ); |
|
| 172 | + unset( $plugin_options[$field['id']][$key] ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if ( ! empty( $validation->error ) ) { |
@@ -185,18 +185,18 @@ discard block |
||
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } else { |
| 188 | - if ( isset( $plugin_options[ $field['id'] ] ) ) { |
|
| 189 | - if ( is_array( $plugin_options[ $field['id'] ] ) ) { |
|
| 190 | - $pofi = $plugin_options[ $field['id'] ]; |
|
| 188 | + if ( isset( $plugin_options[$field['id']] ) ) { |
|
| 189 | + if ( is_array( $plugin_options[$field['id']] ) ) { |
|
| 190 | + $pofi = $plugin_options[$field['id']]; |
|
| 191 | 191 | } else { |
| 192 | - $pofi = trim( $plugin_options[ $field['id'] ] ); |
|
| 192 | + $pofi = trim( $plugin_options[$field['id']] ); |
|
| 193 | 193 | } |
| 194 | 194 | } else { |
| 195 | 195 | $pofi = null; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - $validation = new $validate( $core, $field, $pofi, $options[ $field['id'] ] ); |
|
| 199 | - $plugin_options[ $field['id'] ] = $validation->value; |
|
| 198 | + $validation = new $validate( $core, $field, $pofi, $options[$field['id']] ); |
|
| 199 | + $plugin_options[$field['id']] = $validation->value; |
|
| 200 | 200 | |
| 201 | 201 | if ( ! empty( $validation->error ) ) { |
| 202 | 202 | $core->errors[] = $validation->error; |
@@ -220,13 +220,13 @@ discard block |
||
| 220 | 220 | $callback = $field['validate_callback']; |
| 221 | 221 | unset( $field['validate_callback'] ); |
| 222 | 222 | |
| 223 | - $plugin_option = $plugin_options[ $field['id'] ] ?? null; |
|
| 224 | - $option = $options[ $field['id'] ] ?? null; |
|
| 223 | + $plugin_option = $plugin_options[$field['id']] ?? null; |
|
| 224 | + $option = $options[$field['id']] ?? null; |
|
| 225 | 225 | |
| 226 | 226 | if ( null !== $plugin_option ) { |
| 227 | 227 | $callbackvalues = call_user_func( $callback, $field, $plugin_option, $option ); |
| 228 | 228 | |
| 229 | - $plugin_options[ $field['id'] ] = $callbackvalues['value']; |
|
| 229 | + $plugin_options[$field['id']] = $callbackvalues['value']; |
|
| 230 | 230 | |
| 231 | 231 | if ( isset( $callbackvalues['error'] ) ) { |
| 232 | 232 | $core->errors[] = $callbackvalues['error']; |
@@ -12,73 +12,73 @@ |
||
| 12 | 12 | // Don't duplicate me! |
| 13 | 13 | if ( ! class_exists( 'Redux_Gallery', false ) ) { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Main Redux_gallery class |
|
| 17 | - * |
|
| 18 | - * @since 3.0.0 |
|
| 19 | - */ |
|
| 20 | - class Redux_Gallery extends Redux_Field { |
|
| 15 | + /** |
|
| 16 | + * Main Redux_gallery class |
|
| 17 | + * |
|
| 18 | + * @since 3.0.0 |
|
| 19 | + */ |
|
| 20 | + class Redux_Gallery 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 '<div class="screenshot">'; |
|
| 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 '<div class="screenshot">'; |
|
| 32 | 32 | |
| 33 | - if ( ! empty( $this->value ) ) { |
|
| 34 | - $ids = explode( ',', $this->value ); |
|
| 33 | + if ( ! empty( $this->value ) ) { |
|
| 34 | + $ids = explode( ',', $this->value ); |
|
| 35 | 35 | |
| 36 | - foreach ( $ids as $attachment_id ) { |
|
| 37 | - $img = wp_get_attachment_image_src( $attachment_id ); |
|
| 38 | - if ( false !== $img ) { |
|
| 39 | - $alt = wp_prepare_attachment_for_js( $attachment_id ); |
|
| 40 | - $alt = $alt['alt'] ?? ''; |
|
| 36 | + foreach ( $ids as $attachment_id ) { |
|
| 37 | + $img = wp_get_attachment_image_src( $attachment_id ); |
|
| 38 | + if ( false !== $img ) { |
|
| 39 | + $alt = wp_prepare_attachment_for_js( $attachment_id ); |
|
| 40 | + $alt = $alt['alt'] ?? ''; |
|
| 41 | 41 | |
| 42 | - echo '<a class="of-uploaded-image" href="' . esc_url( $img[0] ) . '">'; |
|
| 43 | - echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '_' . esc_attr( $attachment_id ) . '" src="' . esc_url( $img[0] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" />'; |
|
| 44 | - echo '</a>'; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 42 | + echo '<a class="of-uploaded-image" href="' . esc_url( $img[0] ) . '">'; |
|
| 43 | + echo '<img class="redux-option-image" id="image_' . esc_attr( $this->field['id'] ) . '_' . esc_attr( $attachment_id ) . '" src="' . esc_url( $img[0] ) . '" alt="' . esc_attr( $alt ) . '" target="_blank" rel="external" />'; |
|
| 44 | + echo '</a>'; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - echo '</div>'; |
|
| 50 | - echo '<a href="#" onclick="return false;" id="edit-gallery" class="gallery-attachments button button-primary">' . esc_html__( 'Add/Edit Gallery', 'redux-framework' ) . '</a> '; |
|
| 51 | - echo '<a href="#" onclick="return false;" id="clear-gallery" class="gallery-attachments button">' . esc_html__( 'Clear Gallery', 'redux-framework' ) . '</a>'; |
|
| 52 | - echo '<input type="hidden" class="gallery_values ' . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $this->value ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" />'; |
|
| 53 | - } |
|
| 49 | + echo '</div>'; |
|
| 50 | + echo '<a href="#" onclick="return false;" id="edit-gallery" class="gallery-attachments button button-primary">' . esc_html__( 'Add/Edit Gallery', 'redux-framework' ) . '</a> '; |
|
| 51 | + echo '<a href="#" onclick="return false;" id="clear-gallery" class="gallery-attachments button">' . esc_html__( 'Clear Gallery', 'redux-framework' ) . '</a>'; |
|
| 52 | + echo '<input type="hidden" class="gallery_values ' . esc_attr( $this->field['class'] ) . '" value="' . esc_attr( $this->value ) . '" name="' . esc_attr( $this->field['name'] . $this->field['name_suffix'] ) . '" />'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Enqueue Function. |
|
| 57 | - * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @access public |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function enqueue() { |
|
| 55 | + /** |
|
| 56 | + * Enqueue Function. |
|
| 57 | + * If this field requires any scripts, or css define this function and register/enqueue the scripts/css |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @access public |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function enqueue() { |
|
| 64 | 64 | |
| 65 | - if ( function_exists( 'wp_enqueue_media' ) ) { |
|
| 66 | - wp_enqueue_media(); |
|
| 67 | - } else { |
|
| 68 | - wp_enqueue_script( 'media-upload' ); |
|
| 69 | - wp_enqueue_script( 'thickbox' ); |
|
| 70 | - wp_enqueue_style( 'thickbox' ); |
|
| 71 | - } |
|
| 65 | + if ( function_exists( 'wp_enqueue_media' ) ) { |
|
| 66 | + wp_enqueue_media(); |
|
| 67 | + } else { |
|
| 68 | + wp_enqueue_script( 'media-upload' ); |
|
| 69 | + wp_enqueue_script( 'thickbox' ); |
|
| 70 | + wp_enqueue_style( 'thickbox' ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - wp_enqueue_script( |
|
| 74 | - 'redux-field-gallery', |
|
| 75 | - Redux_Core::$url . 'inc/fields/gallery/redux-gallery' . Redux_Functions::is_min() . '.js', |
|
| 76 | - array( 'jquery', 'redux-js' ), |
|
| 77 | - $this->timestamp, |
|
| 78 | - true |
|
| 79 | - ); |
|
| 80 | - } |
|
| 81 | - } |
|
| 73 | + wp_enqueue_script( |
|
| 74 | + 'redux-field-gallery', |
|
| 75 | + Redux_Core::$url . 'inc/fields/gallery/redux-gallery' . Redux_Functions::is_min() . '.js', |
|
| 76 | + array( 'jquery', 'redux-js' ), |
|
| 77 | + $this->timestamp, |
|
| 78 | + true |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | class_alias( 'Redux_Gallery', 'ReduxFramework_Gallery' ); |
@@ -11,390 +11,390 @@ |
||
| 11 | 11 | |
| 12 | 12 | if ( ! class_exists( 'Redux_Args', false ) ) { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Class Redux_Args |
|
| 16 | - */ |
|
| 17 | - class Redux_Args { |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Returns entire arguments array. |
|
| 21 | - * |
|
| 22 | - * @var array|mixed |
|
| 23 | - */ |
|
| 24 | - public $get = array(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * ReduxFramework object. |
|
| 28 | - * |
|
| 29 | - * @var ReduxFramework|null |
|
| 30 | - */ |
|
| 31 | - private ?ReduxFramework $parent; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Switch to omit social icons if dev_mode is set to true and Redux defaults are used. |
|
| 35 | - * |
|
| 36 | - * @var bool |
|
| 37 | - */ |
|
| 38 | - public bool $omit_icons = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * Switch to omit support menu items if dev_mode is set to true and redux defaults are used. |
|
| 42 | - * |
|
| 43 | - * @var bool |
|
| 44 | - */ |
|
| 45 | - public bool $omit_items = false; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true. |
|
| 49 | - * |
|
| 50 | - * @var bool |
|
| 51 | - */ |
|
| 52 | - public bool $dev_mode_forced = false; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Redux_Args constructor. |
|
| 56 | - * |
|
| 57 | - * @param ReduxFramework $redux ReduxFramework object. |
|
| 58 | - * @param array $args Global arguments array. |
|
| 59 | - */ |
|
| 60 | - public function __construct( ReduxFramework $redux, array $args ) { |
|
| 61 | - $this->parent = $redux; |
|
| 62 | - |
|
| 63 | - $default = array( |
|
| 64 | - 'opt_name' => '', |
|
| 65 | - 'last_tab' => '', |
|
| 66 | - 'menu_icon' => '', |
|
| 67 | - 'menu_title' => '', |
|
| 68 | - 'page_title' => '', |
|
| 69 | - 'page_slug' => '', |
|
| 70 | - 'page_permissions' => 'manage_options', |
|
| 71 | - 'menu_type' => 'menu', |
|
| 72 | - 'page_parent' => 'themes.php', |
|
| 73 | - 'page_priority' => null, |
|
| 74 | - 'allow_sub_menu' => true, |
|
| 75 | - 'save_defaults' => true, |
|
| 76 | - 'footer_credit' => '', |
|
| 77 | - 'async_typography' => false, |
|
| 78 | - 'disable_google_fonts_link' => false, |
|
| 79 | - 'class' => '', |
|
| 80 | - 'admin_bar' => true, |
|
| 81 | - 'admin_bar_priority' => 999, |
|
| 82 | - 'admin_bar_icon' => '', |
|
| 83 | - 'help_tabs' => array(), |
|
| 84 | - 'help_sidebar' => '', |
|
| 85 | - 'database' => '', |
|
| 86 | - 'customizer' => false, |
|
| 87 | - 'global_variable' => '', |
|
| 88 | - 'output' => true, |
|
| 89 | - 'output_variables_prefix' => '--', |
|
| 90 | - 'compiler_output_variables_prefix' => '$', |
|
| 91 | - 'compiler' => true, |
|
| 92 | - 'output_tag' => true, |
|
| 93 | - 'output_location' => array( 'frontend' ), |
|
| 94 | - 'transient_time' => '', |
|
| 95 | - 'default_show' => false, |
|
| 96 | - 'default_mark' => '', |
|
| 97 | - 'disable_save_warn' => false, |
|
| 98 | - 'open_expanded' => false, |
|
| 99 | - 'hide_expand' => false, |
|
| 100 | - 'network_admin' => false, |
|
| 101 | - 'network_sites' => true, |
|
| 102 | - 'hide_reset' => false, |
|
| 103 | - 'hide_save' => false, |
|
| 104 | - 'hints' => array( |
|
| 105 | - 'icon' => 'el el-question-sign', |
|
| 106 | - 'icon_position' => 'right', |
|
| 107 | - 'icon_color' => 'lightgray', |
|
| 108 | - 'icon_size' => 'normal', |
|
| 109 | - 'tip_style' => array( |
|
| 110 | - 'color' => 'light', |
|
| 111 | - 'shadow' => true, |
|
| 112 | - 'rounded' => false, |
|
| 113 | - 'style' => '', |
|
| 114 | - ), |
|
| 115 | - 'tip_position' => array( |
|
| 116 | - 'my' => 'top_left', |
|
| 117 | - 'at' => 'bottom_right', |
|
| 118 | - ), |
|
| 119 | - 'tip_effect' => array( |
|
| 120 | - 'show' => array( |
|
| 121 | - 'effect' => 'slide', |
|
| 122 | - 'duration' => '500', |
|
| 123 | - 'event' => 'mouseover', |
|
| 124 | - ), |
|
| 125 | - 'hide' => array( |
|
| 126 | - 'effect' => 'fade', |
|
| 127 | - 'duration' => '500', |
|
| 128 | - 'event' => 'click mouseleave', |
|
| 129 | - ), |
|
| 130 | - ), |
|
| 131 | - ), |
|
| 132 | - 'font_weights' => array( |
|
| 133 | - array( |
|
| 134 | - 'id' => '400', |
|
| 135 | - 'name' => __( 'Regular 400', 'redux-framework' ), |
|
| 136 | - ), |
|
| 137 | - array( |
|
| 138 | - 'id' => '400italic', |
|
| 139 | - 'name' => __( 'Regular 400 Italic', 'redux-framework' ), |
|
| 140 | - ), |
|
| 141 | - array( |
|
| 142 | - 'id' => '700', |
|
| 143 | - 'name' => __( 'Bold 700', 'redux-framework' ), |
|
| 144 | - ), |
|
| 145 | - array( |
|
| 146 | - 'id' => '700italic', |
|
| 147 | - 'name' => __( 'Bold 700 Italic', 'redux-framework' ), |
|
| 148 | - ), |
|
| 149 | - ), |
|
| 150 | - 'show_import_export' => true, |
|
| 151 | - 'show_options_object' => true, |
|
| 152 | - 'dev_mode' => true, |
|
| 153 | - 'templates_path' => '', |
|
| 154 | - 'ajax_save' => true, |
|
| 155 | - 'use_cdn' => true, |
|
| 156 | - 'cdn_check_time' => 1440, |
|
| 157 | - 'options_api' => true, |
|
| 158 | - 'allow_tracking' => true, |
|
| 159 | - 'admin_theme' => 'wp', |
|
| 160 | - 'elusive_frontend' => false, |
|
| 161 | - 'fontawesome_frontend' => false, |
|
| 162 | - 'flyout_submenus' => true, |
|
| 163 | - 'font_display' => 'swap', // block|swap|fallback|optional. |
|
| 164 | - 'load_on_cron' => false, |
|
| 165 | - 'search' => false, |
|
| 166 | - 'widget_area' => false, |
|
| 167 | - 'custom_fonts' => true, |
|
| 168 | - ); |
|
| 169 | - |
|
| 170 | - $args = Redux_Functions::parse_args( $args, $default ); |
|
| 171 | - |
|
| 172 | - $args = $this->args( $args ); |
|
| 173 | - |
|
| 174 | - $args = $this->default_cleanup( $args ); |
|
| 175 | - |
|
| 176 | - if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 177 | - $args['font_display'] = 'swap'; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 181 | - $args['async_typography'] = false; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $this->get = $args; |
|
| 185 | - |
|
| 186 | - $this->parent->args = $args; |
|
| 187 | - |
|
| 188 | - if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 189 | - $this->change_demo_defaults( $args ); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - /** |
|
| 194 | - * Builds and sanitizes a global args array. |
|
| 195 | - * |
|
| 196 | - * @param array $args Global args. |
|
| 197 | - * |
|
| 198 | - * @return array |
|
| 199 | - */ |
|
| 200 | - private function args( array $args ): array { |
|
| 201 | - $args = $this->no_errors_please( $args ); |
|
| 202 | - |
|
| 203 | - $this->parent->old_opt_name = $args['opt_name']; |
|
| 204 | - |
|
| 205 | - $args = $this->filters( $args ); |
|
| 206 | - |
|
| 207 | - if ( ! function_exists( 'wp_rand' ) ) { |
|
| 208 | - require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 212 | - $this->parent->old_opt_name = null; |
|
| 213 | - unset( $this->parent->old_opt_name ); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - // Do not save the defaults if we're on a live preview! |
|
| 217 | - if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | - $args['save_defaults'] = false; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - return $this->shim( $args ); |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Apply filters to arg data. |
|
| 226 | - * |
|
| 227 | - * @param array $args Global args. |
|
| 228 | - * |
|
| 229 | - * @return mixed|void |
|
| 230 | - */ |
|
| 231 | - private function filters( array $args ) { |
|
| 232 | - /** |
|
| 233 | - * Filter 'redux/args/{opt_name}' |
|
| 234 | - * |
|
| 235 | - * @param array $args ReduxFramework configuration |
|
| 236 | - */ |
|
| 237 | - |
|
| 238 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 239 | - $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 240 | - |
|
| 241 | - /** |
|
| 242 | - * Filter 'redux/options/{opt_name}/args' |
|
| 243 | - * |
|
| 244 | - * @param array $args ReduxFramework configuration |
|
| 245 | - */ |
|
| 246 | - |
|
| 247 | - // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 248 | - return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Sanitize args that should not be empty. |
|
| 253 | - * |
|
| 254 | - * @param array $args Global args. |
|
| 255 | - * |
|
| 256 | - * @return array |
|
| 257 | - */ |
|
| 258 | - private function no_errors_please( array $args ): array { |
|
| 259 | - if ( empty( $args['transient_time'] ) ) { |
|
| 260 | - $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if ( empty( $args['footer_credit'] ) ) { |
|
| 264 | - |
|
| 265 | - $footer_text = sprintf( |
|
| 266 | - /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 267 | - __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'redux-framework' ), |
|
| 268 | - '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 269 | - '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/?filter=5/#new-post" target="_blank">★★★★★</a>' |
|
| 270 | - ); |
|
| 271 | - $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - if ( empty( $args['menu_title'] ) ) { |
|
| 275 | - $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ( empty( $args['page_title'] ) ) { |
|
| 279 | - $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - // Auto creates the page_slug appropriately. |
|
| 283 | - if ( empty( $args['page_slug'] ) ) { |
|
| 284 | - if ( ! empty( $args['display_name'] ) ) { |
|
| 285 | - $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 286 | - } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 287 | - $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 288 | - } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 289 | - $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 290 | - } else { |
|
| 291 | - $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - return $args; |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - /** |
|
| 299 | - * Shims for much older v3 configs. |
|
| 300 | - * |
|
| 301 | - * @param array $args Global args. |
|
| 302 | - * |
|
| 303 | - * @return array |
|
| 304 | - */ |
|
| 305 | - private function shim( array $args ): array { |
|
| 306 | - /** |
|
| 307 | - * SHIM SECTION |
|
| 308 | - * Old variables and ways of doing things that need correcting. ;) |
|
| 309 | - * */ |
|
| 310 | - // Variable name change. |
|
| 311 | - if ( ! empty( $args['page_cap'] ) ) { |
|
| 312 | - $args['page_permissions'] = $args['page_cap']; |
|
| 313 | - unset( $args['page_cap'] ); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - if ( ! empty( $args['page_position'] ) ) { |
|
| 317 | - $args['page_priority'] = $args['page_position']; |
|
| 318 | - unset( $args['page_position'] ); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - if ( ! empty( $args['page_type'] ) ) { |
|
| 322 | - $args['menu_type'] = $args['page_type']; |
|
| 323 | - unset( $args['page_type'] ); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - return $args; |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 331 | - * |
|
| 332 | - * @param array $args Global args. |
|
| 333 | - */ |
|
| 334 | - private function change_demo_defaults( array $args ) { |
|
| 335 | - if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 336 | - if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 337 | - foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 338 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 339 | - foreach ( $arr as $y ) { |
|
| 340 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 341 | - $this->omit_items = true; |
|
| 342 | - break; |
|
| 343 | - } |
|
| 344 | - } |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - if ( ! empty( $args['share_icons'] ) ) { |
|
| 350 | - foreach ( $args['share_icons'] as $arr ) { |
|
| 351 | - if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 352 | - foreach ( $arr as $y ) { |
|
| 353 | - if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 354 | - $this->omit_icons = true; |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - /** |
|
| 364 | - * Fix other arg criteria that sometimes gets hosed up. |
|
| 365 | - * |
|
| 366 | - * @param array $args Global args. |
|
| 367 | - * |
|
| 368 | - * @return array |
|
| 369 | - * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 370 | - */ |
|
| 371 | - private function default_cleanup( array $args ): array { |
|
| 372 | - |
|
| 373 | - // Fix the global variable name. |
|
| 374 | - if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 375 | - $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 379 | - $args['menu_type'] = 'hidden'; |
|
| 380 | - $args['customizer'] = true; |
|
| 381 | - $args['admin_bar'] = false; |
|
| 382 | - $args['allow_sub_menu'] = false; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - // Check if the Airplane Mode plugin is installed. |
|
| 386 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 387 | - $airplane = Airplane_Mode_Core::getInstance(); |
|
| 388 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 389 | - if ( $airplane->enabled() ) { |
|
| 390 | - $args['use_cdn'] = false; |
|
| 391 | - } |
|
| 392 | - } elseif ( 'on' === $airplane->check_status() ) { |
|
| 393 | - $args['use_cdn'] = false; |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - return $args; |
|
| 398 | - } |
|
| 399 | - } |
|
| 14 | + /** |
|
| 15 | + * Class Redux_Args |
|
| 16 | + */ |
|
| 17 | + class Redux_Args { |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Returns entire arguments array. |
|
| 21 | + * |
|
| 22 | + * @var array|mixed |
|
| 23 | + */ |
|
| 24 | + public $get = array(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * ReduxFramework object. |
|
| 28 | + * |
|
| 29 | + * @var ReduxFramework|null |
|
| 30 | + */ |
|
| 31 | + private ?ReduxFramework $parent; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Switch to omit social icons if dev_mode is set to true and Redux defaults are used. |
|
| 35 | + * |
|
| 36 | + * @var bool |
|
| 37 | + */ |
|
| 38 | + public bool $omit_icons = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * Switch to omit support menu items if dev_mode is set to true and redux defaults are used. |
|
| 42 | + * |
|
| 43 | + * @var bool |
|
| 44 | + */ |
|
| 45 | + public bool $omit_items = false; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Flag to force dev_mod to true if in localhost or WP_DEBUG is set to true. |
|
| 49 | + * |
|
| 50 | + * @var bool |
|
| 51 | + */ |
|
| 52 | + public bool $dev_mode_forced = false; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Redux_Args constructor. |
|
| 56 | + * |
|
| 57 | + * @param ReduxFramework $redux ReduxFramework object. |
|
| 58 | + * @param array $args Global arguments array. |
|
| 59 | + */ |
|
| 60 | + public function __construct( ReduxFramework $redux, array $args ) { |
|
| 61 | + $this->parent = $redux; |
|
| 62 | + |
|
| 63 | + $default = array( |
|
| 64 | + 'opt_name' => '', |
|
| 65 | + 'last_tab' => '', |
|
| 66 | + 'menu_icon' => '', |
|
| 67 | + 'menu_title' => '', |
|
| 68 | + 'page_title' => '', |
|
| 69 | + 'page_slug' => '', |
|
| 70 | + 'page_permissions' => 'manage_options', |
|
| 71 | + 'menu_type' => 'menu', |
|
| 72 | + 'page_parent' => 'themes.php', |
|
| 73 | + 'page_priority' => null, |
|
| 74 | + 'allow_sub_menu' => true, |
|
| 75 | + 'save_defaults' => true, |
|
| 76 | + 'footer_credit' => '', |
|
| 77 | + 'async_typography' => false, |
|
| 78 | + 'disable_google_fonts_link' => false, |
|
| 79 | + 'class' => '', |
|
| 80 | + 'admin_bar' => true, |
|
| 81 | + 'admin_bar_priority' => 999, |
|
| 82 | + 'admin_bar_icon' => '', |
|
| 83 | + 'help_tabs' => array(), |
|
| 84 | + 'help_sidebar' => '', |
|
| 85 | + 'database' => '', |
|
| 86 | + 'customizer' => false, |
|
| 87 | + 'global_variable' => '', |
|
| 88 | + 'output' => true, |
|
| 89 | + 'output_variables_prefix' => '--', |
|
| 90 | + 'compiler_output_variables_prefix' => '$', |
|
| 91 | + 'compiler' => true, |
|
| 92 | + 'output_tag' => true, |
|
| 93 | + 'output_location' => array( 'frontend' ), |
|
| 94 | + 'transient_time' => '', |
|
| 95 | + 'default_show' => false, |
|
| 96 | + 'default_mark' => '', |
|
| 97 | + 'disable_save_warn' => false, |
|
| 98 | + 'open_expanded' => false, |
|
| 99 | + 'hide_expand' => false, |
|
| 100 | + 'network_admin' => false, |
|
| 101 | + 'network_sites' => true, |
|
| 102 | + 'hide_reset' => false, |
|
| 103 | + 'hide_save' => false, |
|
| 104 | + 'hints' => array( |
|
| 105 | + 'icon' => 'el el-question-sign', |
|
| 106 | + 'icon_position' => 'right', |
|
| 107 | + 'icon_color' => 'lightgray', |
|
| 108 | + 'icon_size' => 'normal', |
|
| 109 | + 'tip_style' => array( |
|
| 110 | + 'color' => 'light', |
|
| 111 | + 'shadow' => true, |
|
| 112 | + 'rounded' => false, |
|
| 113 | + 'style' => '', |
|
| 114 | + ), |
|
| 115 | + 'tip_position' => array( |
|
| 116 | + 'my' => 'top_left', |
|
| 117 | + 'at' => 'bottom_right', |
|
| 118 | + ), |
|
| 119 | + 'tip_effect' => array( |
|
| 120 | + 'show' => array( |
|
| 121 | + 'effect' => 'slide', |
|
| 122 | + 'duration' => '500', |
|
| 123 | + 'event' => 'mouseover', |
|
| 124 | + ), |
|
| 125 | + 'hide' => array( |
|
| 126 | + 'effect' => 'fade', |
|
| 127 | + 'duration' => '500', |
|
| 128 | + 'event' => 'click mouseleave', |
|
| 129 | + ), |
|
| 130 | + ), |
|
| 131 | + ), |
|
| 132 | + 'font_weights' => array( |
|
| 133 | + array( |
|
| 134 | + 'id' => '400', |
|
| 135 | + 'name' => __( 'Regular 400', 'redux-framework' ), |
|
| 136 | + ), |
|
| 137 | + array( |
|
| 138 | + 'id' => '400italic', |
|
| 139 | + 'name' => __( 'Regular 400 Italic', 'redux-framework' ), |
|
| 140 | + ), |
|
| 141 | + array( |
|
| 142 | + 'id' => '700', |
|
| 143 | + 'name' => __( 'Bold 700', 'redux-framework' ), |
|
| 144 | + ), |
|
| 145 | + array( |
|
| 146 | + 'id' => '700italic', |
|
| 147 | + 'name' => __( 'Bold 700 Italic', 'redux-framework' ), |
|
| 148 | + ), |
|
| 149 | + ), |
|
| 150 | + 'show_import_export' => true, |
|
| 151 | + 'show_options_object' => true, |
|
| 152 | + 'dev_mode' => true, |
|
| 153 | + 'templates_path' => '', |
|
| 154 | + 'ajax_save' => true, |
|
| 155 | + 'use_cdn' => true, |
|
| 156 | + 'cdn_check_time' => 1440, |
|
| 157 | + 'options_api' => true, |
|
| 158 | + 'allow_tracking' => true, |
|
| 159 | + 'admin_theme' => 'wp', |
|
| 160 | + 'elusive_frontend' => false, |
|
| 161 | + 'fontawesome_frontend' => false, |
|
| 162 | + 'flyout_submenus' => true, |
|
| 163 | + 'font_display' => 'swap', // block|swap|fallback|optional. |
|
| 164 | + 'load_on_cron' => false, |
|
| 165 | + 'search' => false, |
|
| 166 | + 'widget_area' => false, |
|
| 167 | + 'custom_fonts' => true, |
|
| 168 | + ); |
|
| 169 | + |
|
| 170 | + $args = Redux_Functions::parse_args( $args, $default ); |
|
| 171 | + |
|
| 172 | + $args = $this->args( $args ); |
|
| 173 | + |
|
| 174 | + $args = $this->default_cleanup( $args ); |
|
| 175 | + |
|
| 176 | + if ( ! in_array( $args['font_display'], array( 'block', 'swap', 'fallback', 'optional' ), true ) ) { |
|
| 177 | + $args['font_display'] = 'swap'; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + if ( isset( $args['async_typography'] ) && $args['async_typography'] ) { |
|
| 181 | + $args['async_typography'] = false; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $this->get = $args; |
|
| 185 | + |
|
| 186 | + $this->parent->args = $args; |
|
| 187 | + |
|
| 188 | + if ( 'redux_extensions_demo' !== $args['opt_name'] && 'redux_demo' !== $args['opt_name'] ) { |
|
| 189 | + $this->change_demo_defaults( $args ); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + /** |
|
| 194 | + * Builds and sanitizes a global args array. |
|
| 195 | + * |
|
| 196 | + * @param array $args Global args. |
|
| 197 | + * |
|
| 198 | + * @return array |
|
| 199 | + */ |
|
| 200 | + private function args( array $args ): array { |
|
| 201 | + $args = $this->no_errors_please( $args ); |
|
| 202 | + |
|
| 203 | + $this->parent->old_opt_name = $args['opt_name']; |
|
| 204 | + |
|
| 205 | + $args = $this->filters( $args ); |
|
| 206 | + |
|
| 207 | + if ( ! function_exists( 'wp_rand' ) ) { |
|
| 208 | + require_once ABSPATH . '/wp-includes/pluggable.php'; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + if ( $args['opt_name'] === $this->parent->old_opt_name ) { |
|
| 212 | + $this->parent->old_opt_name = null; |
|
| 213 | + unset( $this->parent->old_opt_name ); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + // Do not save the defaults if we're on a live preview! |
|
| 217 | + if ( 'customize' === $GLOBALS['pagenow'] && isset( $_GET['customize_theme'] ) && ! empty( $_GET['customize_theme'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
|
| 218 | + $args['save_defaults'] = false; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + return $this->shim( $args ); |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Apply filters to arg data. |
|
| 226 | + * |
|
| 227 | + * @param array $args Global args. |
|
| 228 | + * |
|
| 229 | + * @return mixed|void |
|
| 230 | + */ |
|
| 231 | + private function filters( array $args ) { |
|
| 232 | + /** |
|
| 233 | + * Filter 'redux/args/{opt_name}' |
|
| 234 | + * |
|
| 235 | + * @param array $args ReduxFramework configuration |
|
| 236 | + */ |
|
| 237 | + |
|
| 238 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 239 | + $args = apply_filters( "redux/args/{$args['opt_name']}", $args ); |
|
| 240 | + |
|
| 241 | + /** |
|
| 242 | + * Filter 'redux/options/{opt_name}/args' |
|
| 243 | + * |
|
| 244 | + * @param array $args ReduxFramework configuration |
|
| 245 | + */ |
|
| 246 | + |
|
| 247 | + // phpcs:ignore WordPress.NamingConventions.ValidHookName |
|
| 248 | + return apply_filters( "redux/options/{$args['opt_name']}/args", $args ); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Sanitize args that should not be empty. |
|
| 253 | + * |
|
| 254 | + * @param array $args Global args. |
|
| 255 | + * |
|
| 256 | + * @return array |
|
| 257 | + */ |
|
| 258 | + private function no_errors_please( array $args ): array { |
|
| 259 | + if ( empty( $args['transient_time'] ) ) { |
|
| 260 | + $args['transient_time'] = 60 * MINUTE_IN_SECONDS; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if ( empty( $args['footer_credit'] ) ) { |
|
| 264 | + |
|
| 265 | + $footer_text = sprintf( |
|
| 266 | + /* translators: 1: Redux, 2: Link to plugin review */ |
|
| 267 | + __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'redux-framework' ), |
|
| 268 | + '<strong>' . __( 'Redux', 'redux-framework' ) . '</strong>', |
|
| 269 | + '<a href="https://wordpress.org/support/plugin/redux-framework/reviews/?filter=5/#new-post" target="_blank">★★★★★</a>' |
|
| 270 | + ); |
|
| 271 | + $args['footer_credit'] = '<span id="footer-thankyou">' . $footer_text . '</span>'; |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + if ( empty( $args['menu_title'] ) ) { |
|
| 275 | + $args['menu_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ( empty( $args['page_title'] ) ) { |
|
| 279 | + $args['page_title'] = esc_html__( 'Options', 'redux-framework' ); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + // Auto creates the page_slug appropriately. |
|
| 283 | + if ( empty( $args['page_slug'] ) ) { |
|
| 284 | + if ( ! empty( $args['display_name'] ) ) { |
|
| 285 | + $args['page_slug'] = sanitize_html_class( $args['display_name'] ); |
|
| 286 | + } elseif ( ! empty( $args['page_title'] ) ) { |
|
| 287 | + $args['page_slug'] = sanitize_html_class( $args['page_title'] ); |
|
| 288 | + } elseif ( ! empty( $args['menu_title'] ) ) { |
|
| 289 | + $args['page_slug'] = sanitize_html_class( $args['menu_title'] ); |
|
| 290 | + } else { |
|
| 291 | + $args['page_slug'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + return $args; |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + /** |
|
| 299 | + * Shims for much older v3 configs. |
|
| 300 | + * |
|
| 301 | + * @param array $args Global args. |
|
| 302 | + * |
|
| 303 | + * @return array |
|
| 304 | + */ |
|
| 305 | + private function shim( array $args ): array { |
|
| 306 | + /** |
|
| 307 | + * SHIM SECTION |
|
| 308 | + * Old variables and ways of doing things that need correcting. ;) |
|
| 309 | + * */ |
|
| 310 | + // Variable name change. |
|
| 311 | + if ( ! empty( $args['page_cap'] ) ) { |
|
| 312 | + $args['page_permissions'] = $args['page_cap']; |
|
| 313 | + unset( $args['page_cap'] ); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + if ( ! empty( $args['page_position'] ) ) { |
|
| 317 | + $args['page_priority'] = $args['page_position']; |
|
| 318 | + unset( $args['page_position'] ); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + if ( ! empty( $args['page_type'] ) ) { |
|
| 322 | + $args['menu_type'] = $args['page_type']; |
|
| 323 | + unset( $args['page_type'] ); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + return $args; |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Verify to see if dev has bothered to change admin bar links and share icons from demo data to their own. |
|
| 331 | + * |
|
| 332 | + * @param array $args Global args. |
|
| 333 | + */ |
|
| 334 | + private function change_demo_defaults( array $args ) { |
|
| 335 | + if ( $args['dev_mode'] || true === Redux_Helpers::is_local_host() ) { |
|
| 336 | + if ( ! empty( $args['admin_bar_links'] ) ) { |
|
| 337 | + foreach ( $args['admin_bar_links'] as $arr ) { |
|
| 338 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 339 | + foreach ( $arr as $y ) { |
|
| 340 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 341 | + $this->omit_items = true; |
|
| 342 | + break; |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + if ( ! empty( $args['share_icons'] ) ) { |
|
| 350 | + foreach ( $args['share_icons'] as $arr ) { |
|
| 351 | + if ( is_array( $arr ) && ! empty( $arr ) ) { |
|
| 352 | + foreach ( $arr as $y ) { |
|
| 353 | + if ( strpos( Redux_Core::strtolower( $y ), 'redux' ) !== false ) { |
|
| 354 | + $this->omit_icons = true; |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Fix other arg criteria that sometimes gets hosed up. |
|
| 365 | + * |
|
| 366 | + * @param array $args Global args. |
|
| 367 | + * |
|
| 368 | + * @return array |
|
| 369 | + * @noinspection PhpStrictComparisonWithOperandsOfDifferentTypesInspection |
|
| 370 | + */ |
|
| 371 | + private function default_cleanup( array $args ): array { |
|
| 372 | + |
|
| 373 | + // Fix the global variable name. |
|
| 374 | + if ( '' === $args['global_variable'] && false !== $args['global_variable'] ) { |
|
| 375 | + $args['global_variable'] = str_replace( '-', '_', $args['opt_name'] ); |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + if ( isset( $args['customizer_only'] ) && $args['customizer_only'] ) { |
|
| 379 | + $args['menu_type'] = 'hidden'; |
|
| 380 | + $args['customizer'] = true; |
|
| 381 | + $args['admin_bar'] = false; |
|
| 382 | + $args['allow_sub_menu'] = false; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + // Check if the Airplane Mode plugin is installed. |
|
| 386 | + if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 387 | + $airplane = Airplane_Mode_Core::getInstance(); |
|
| 388 | + if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 389 | + if ( $airplane->enabled() ) { |
|
| 390 | + $args['use_cdn'] = false; |
|
| 391 | + } |
|
| 392 | + } elseif ( 'on' === $airplane->check_status() ) { |
|
| 393 | + $args['use_cdn'] = false; |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + return $args; |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | 400 | } |