PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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/fields/FrmFieldUrl.php +17 -29 6.336.18 View file →
@@ -9,9 +9,8 @@
9 9 class FrmFieldUrl extends FrmFieldType {
10 10
11 11 /**
12 12 * @var string
13 - *
14 13 * @since 3.0
15 14 */
16 15 protected $type = 'url';
17 16
@@ -48,10 +47,8 @@
48 47 return __( 'Website', 'formidable' );
49 48 }
50 49
51 50 /**
52 - * @param array $atts
53 - *
54 51 * @return void
55 52 */
56 53 protected function fill_default_atts( &$atts ) {
57 54 $defaults = array(
@@ -64,19 +61,15 @@
64 61 $atts['sep'] = ' ';
65 62 }
66 63 }
67 64
68 - /**
69 - * @param array $args
70 - */
71 65 public function validate( $args ) {
72 66 $value = $args['value'];
73 -
74 - if ( trim( $value ) === 'http://' || ! $value ) {
67 + if ( trim( $value ) === 'http://' || empty( $value ) ) {
75 68 $value = '';
76 69 } else {
77 70 $value = esc_url_raw( $value );
78 - $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'https://' . $value;
71 + $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
79 72 }
80 73
81 74 FrmEntriesHelper::set_posted_value( $this->field, $value, $args );
82 75
@@ -81,12 +74,12 @@
81 74 FrmEntriesHelper::set_posted_value( $this->field, $value, $args );
82 75
83 76 $errors = array();
84 77
85 - // Validate the url format
86 - if ( $value && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
78 + // validate the url format
79 + if ( ! empty( $value ) && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
87 80 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
88 - } elseif ( $this->field->required == '1' && ! $value ) { // phpcs:ignore Universal.Operators.StrictComparisons
81 + } elseif ( $this->field->required == '1' && empty( $value ) ) {
89 82 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
90 83 }
91 84
92 85 return $errors;
@@ -92,32 +85,27 @@
92 85 return $errors;
93 86 }
94 87
95 88 protected function prepare_display_value( $value, $atts ) {
96 - if ( ! $atts['html'] ) {
97 - return $value;
98 - }
99 -
100 - $images = '';
101 -
102 - foreach ( (array) $value as $url ) {
103 - $image_regex = '/(\.(?i)(jpg|jpeg|png|gif))$/';
104 - $is_image = preg_match( $image_regex, $url );
105 -
106 - if ( $is_image ) {
107 - $images .= '<img src="' . esc_url( $url ) . '" class="frm_image_from_url" alt="" /> ';
108 - } else {
109 - $images .= strip_tags( $url );
89 + if ( $atts['html'] ) {
90 + $images = '';
91 + foreach ( (array) $value as $url ) {
92 + $image_regex = '/(\.(?i)(jpg|jpeg|png|gif))$/';
93 + $is_image = preg_match( $image_regex, $url );
94 + if ( $is_image ) {
95 + $images .= '<img src="' . esc_url( $url ) . '" class="frm_image_from_url" alt="" /> ';
96 + } else {
97 + $images .= strip_tags( $url );
98 + }
110 99 }
100 + $value = $images;
111 101 }
112 102
113 - return $images;
103 + return $value;
114 104 }
115 105
116 106 /**
117 107 * @since 4.0.04
118 - *
119 - * @param array|string $value
120 108 *
121 109 * @return void
122 110 */
123 111 public function sanitize_value( &$value ) {