PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +18 -14 6.27 → trunk View file →
@@ -64,8 +64,11 @@
64 64 $atts['sep'] = ' ';
65 65 }
66 66 }
67 67
68 + /**
69 + * @param array $args
70 + */
68 71 public function validate( $args ) {
69 72 $value = $args['value'];
70 73
71 74 if ( trim( $value ) === 'http://' || ! $value ) {
@@ -78,11 +81,12 @@
78 81 FrmEntriesHelper::set_posted_value( $this->field, $value, $args );
79 82
80 83 $errors = array();
81 84
82 - // validate the url format
85 + // Validate the url format
83 86 if ( $value && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
84 87 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
88 + // skipcq: PHP-W1067 -- $this->field is always a field object by the time validate() runs; FrmFieldType's constructor just accepts array|int|object for lazy construction elsewhere.
85 89 } elseif ( $this->field->required == '1' && ! $value ) { // phpcs:ignore Universal.Operators.StrictComparisons
86 90 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
87 91 }
88 92
@@ -89,26 +93,26 @@
89 93 return $errors;
90 94 }
91 95
92 96 protected function prepare_display_value( $value, $atts ) {
93 - if ( $atts['html'] ) {
94 - $images = '';
97 + if ( ! $atts['html'] ) {
98 + return $value;
99 + }
95 100
96 - foreach ( (array) $value as $url ) {
97 - $image_regex = '/(\.(?i)(jpg|jpeg|png|gif))$/';
98 - $is_image = preg_match( $image_regex, $url );
101 + $images = '';
99 102
100 - if ( $is_image ) {
101 - $images .= '<img src="' . esc_url( $url ) . '" class="frm_image_from_url" alt="" /> ';
102 - } else {
103 - $images .= strip_tags( $url );
104 - }
103 + foreach ( (array) $value as $url ) {
104 + $image_regex = '/(\.(?i)(jpg|jpeg|png|gif))$/';
105 + $is_image = preg_match( $image_regex, $url );
106 +
107 + if ( $is_image ) {
108 + $images .= '<img src="' . esc_url( $url ) . '" class="frm_image_from_url" alt="" /> ';
109 + } else {
110 + $images .= strip_tags( $url );
105 111 }
106 -
107 - $value = $images;
108 112 }
109 113
110 - return $value;
114 + return $images;
111 115 }
112 116
113 117 /**
114 118 * @since 4.0.04