PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmStyle.php +5 -118 6.36.1 View file →
@@ -44,11 +44,8 @@
44 44 public function save( $settings ) {
45 45 return FrmDb::save_settings( $settings, 'frm_styles' );
46 46 }
47 47
48 - /**
49 - * @return void
50 - */
51 48 public function duplicate( $id ) {
52 49 // Duplicating is a pro feature. This is handled in FrmProStyle::duplicate instead.
53 50 }
54 51
@@ -240,120 +237,19 @@
240 237 $sanitized_settings[ $key ] = sanitize_textarea_field( $settings[ $key ] );
241 238 } else {
242 239 $sanitized_settings[ $key ] = $defaults[ $key ];
243 240 }
244 -
245 - if ( 'custom_css' !== $key ) {
246 - $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] );
247 - }
248 241 }
249 242 return $sanitized_settings;
250 243 }
251 244
252 245 /**
253 - * Remove any characters that should not be used in CSS.
254 - *
255 - * @since 6.2.3
256 - *
257 - * @param string $setting
258 - * @return string
259 - */
260 - private function strip_invalid_characters( $setting ) {
261 - $characters_to_remove = array( '{', '}', ';', '[', ']' );
262 -
263 - // RGB is handled instead in self::maybe_sanitize_rgba_value.
264 - if ( 0 !== strpos( $setting, 'rgb' ) ) {
265 - $setting = $this->maybe_fix_braces( $setting, $characters_to_remove );
266 - }
267 -
268 - return str_replace( $characters_to_remove, '', $setting );
269 - }
270 -
271 - /**
272 - * @since 6.2.3
273 - *
274 - * @param string $setting
275 - * @param array $characters_to_remove
276 - * @return string
277 - */
278 - private function maybe_fix_braces( $setting, &$characters_to_remove ) {
279 - $number_of_opening_braces = substr_count( $setting, '(' );
280 - $number_of_closing_braces = substr_count( $setting, ')' );
281 -
282 - if ( $number_of_opening_braces === $number_of_closing_braces ) {
283 - return $this->trim_braces( $setting );
284 - }
285 -
286 - if ( $this->should_remove_every_brace( $setting ) ) {
287 - // Add to $characters_to_remove to remove when str_replace is called.
288 - array_push( $characters_to_remove, '(', ')' );
289 - return $setting;
290 - }
291 -
292 - return $this->trim_braces( $setting );
293 - }
294 -
295 - /**
296 - * @since 6.2.3
297 - *
298 - * @param string $input
299 - * @return string
300 - */
301 - private function trim_braces( $input ) {
302 - $output = $input;
303 - // Remove any ( from the start of the string as no CSS values expect at the first character.
304 - if ( $output ) {
305 - if ( in_array( $output[0], array( '(', ')' ), true ) ) {
306 - $output = ltrim( $output, '()' );
307 - }
308 - }
309 - // Remove extra braces from the end.
310 - if ( in_array( substr( $output, -1 ), array( '(', ')' ), true ) ) {
311 - $output = rtrim( $output, '()' );
312 - if ( false !== strpos( $output, '(' ) ) {
313 - $output .= ')';
314 - }
315 - }
316 - return $output;
317 - }
318 -
319 - /**
320 - * @since 6.2.3
321 - *
322 - * @param string $setting
323 - * @return bool
324 - */
325 - private function should_remove_every_brace( $setting ) {
326 - if ( 0 === strpos( trim( $setting, '()' ), 'calc' ) ) {
327 - // Support calc() sizes. We do not want to remove all braces when calc is used.
328 - return false;
329 - }
330 -
331 - // Matches hex values but also checks for unexpected ( and ).
332 - $looks_like_a_hex_value = preg_match( '/^(?:\()?(?!#?[a-fA-F0-9]*[^\(#\)\da-fA-F])[a-fA-F0-9\(\)]*(?:\))?$/', $setting );
333 - if ( $looks_like_a_hex_value ) {
334 - return true;
335 - }
336 -
337 - // Matches size values but also checks for unexpected ( and ).
338 - // This is case insensitive so it will catch PX, PT, etc, as well.
339 - $looks_like_a_size = preg_match( '/\(?[+-]?\d*\.?\d+(?:px|%|em|rem|ex|pt|pc|mm|cm|in)\)?/i', $setting );
340 - if ( $looks_like_a_size ) {
341 - return true;
342 - }
343 -
344 - return false;
345 - }
346 -
347 - /**
348 246 * @since 3.01.01
349 - *
350 - * @param string $setting
351 - * @return bool
352 247 */
353 248 private function is_color( $setting ) {
354 249 $extra_colors = array( 'error_bg', 'error_border', 'error_text' );
355 - return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors, true );
250 +
251 + return strpos( $setting, 'color' ) !== false || in_array( $setting, $extra_colors );
356 252 }
357 253
358 254 /**
359 255 * @since 3.01.01
@@ -546,11 +442,8 @@
546 442
547 443 return $styles;
548 444 }
549 445
550 - /**
551 - * @param array|null $styles
552 - */
553 446 public function get_default_style( $styles = null ) {
554 447 if ( ! isset( $styles ) ) {
555 448 $styles = $this->get_all( 'menu_order', 'DESC', 1 );
556 449 }
@@ -769,9 +662,9 @@
769 662 );
770 663 }
771 664
772 665 /**
773 - * Don't let imbalanced font families ruin the whole stylesheet.
666 + * Don't let imbalanced font families ruin the whole stylesheet
774 667 *
775 668 * @param string $value
776 669 * @return string
777 670 */
@@ -779,18 +672,12 @@
779 672 $balanced_characters = array( '"', "'" );
780 673 foreach ( $balanced_characters as $char ) {
781 674 $char_count = substr_count( $value, $char );
782 675 $is_balanced = $char_count % 2 == 0;
783 -
784 - if ( $is_balanced ) {
785 - continue;
786 - }
787 -
788 - if ( $value && $char === $value[ strlen( $value ) - 1 ] ) {
789 - $value = $char . $value;
790 - } else {
676 + if ( ! $is_balanced ) {
791 677 $value .= $char;
792 678 }
793 679 }
680 +
794 681 return $value;
795 682 }
796 683 }