| @@ -88,51 +88,5 @@ | ||
| 88 | 88 | <div class="elementor-control-field-description">{{{ data.description }}}</div> |
| 89 | 89 | <# } #> |
| 90 | 90 | <?php |
| 91 | 91 | } |
| 92 | - | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * @param string|array $value | |
| 96 | - * @param array $config | |
| 97 | - * | |
| 98 | - * @return string|array | |
| 99 | - */ | |
| 100 | - public function before_save( $value, array $config ) { | |
| 101 | - return $this->validate_value( $value, $config ); | |
| 102 | - } | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * Validate the value is listed in the control options config. | |
| 106 | - * | |
| 107 | - * Avoid change settings like `html_tag` & `title_size` to a `script` tag. | |
| 108 | - * | |
| 109 | - * @param string|array $value | |
| 110 | - * @param array $config | |
| 111 | - * | |
| 112 | - * @return string|array | |
| 113 | - */ | |
| 114 | - private function validate_value( $value, array $config ) { | |
| 115 | - // Handle multiple select. | |
| 116 | - if ( ! empty( $config['multiple'] ) ) { | |
| 117 | - $validated_value = []; | |
| 118 | - | |
| 119 | - foreach ( $value as $index => $item ) { | |
| 120 | - if ( isset( $config['options'][ $item ] ) ) { | |
| 121 | - $validated_value[ $index ] = $item; | |
| 122 | - } | |
| 123 | - } | |
| 124 | - | |
| 125 | - $value = $validated_value; | |
| 126 | - $is_valid = true; | |
| 127 | - } else { | |
| 128 | - $is_valid = isset( $config['options'][ $value ] ); | |
| 129 | - } | |
| 130 | - | |
| 131 | - // If it's not one of the control options. reset it to default. | |
| 132 | - if ( ! $is_valid ) { | |
| 133 | - $value = $config['default']; | |
| 134 | - } | |
| 135 | - | |
| 136 | - return $value; | |
| 137 | - } | |
| 138 | 92 | } |