PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
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 -45 6.285.4 View file →
@@ -9,21 +9,13 @@
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';
16 + protected $display_type = 'text';
17 17
18 - /**
19 - * @var bool
20 - */
21 - protected $array_allowed = false;
22 -
23 - /**
24 - * @return bool[]
25 - */
26 18 protected function field_settings_for_type() {
27 19 return array(
28 20 'size' => true,
29 21 'clear_on_focus' => true,
@@ -40,20 +32,12 @@
40 32 'show_image' => 0,
41 33 );
42 34 }
43 35
44 - /**
45 - * @return string
46 - */
47 36 protected function get_field_name() {
48 37 return __( 'Website', 'formidable' );
49 38 }
50 39
51 - /**
52 - * @param array $atts
53 - *
54 - * @return void
55 - */
56 40 protected function fill_default_atts( &$atts ) {
57 41 $defaults = array(
58 42 'sep' => ', ',
59 43 'html' => false,
@@ -64,19 +48,15 @@
64 48 $atts['sep'] = ' ';
65 49 }
66 50 }
67 51
68 - /**
69 - * @param array $args
70 - */
71 52 public function validate( $args ) {
72 53 $value = $args['value'];
73 -
74 - if ( trim( $value ) === 'http://' || ! $value ) {
54 + if ( trim( $value ) == 'http://' || empty( $value ) ) {
75 55 $value = '';
76 56 } else {
77 57 $value = esc_url_raw( $value );
78 - $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'https://' . $value;
58 + $value = preg_match( '/^(https?|ftps?|mailto|news|feed|telnet):/is', $value ) ? $value : 'http://' . $value;
79 59 }
80 60
81 61 FrmEntriesHelper::set_posted_value( $this->field, $value, $args );
82 62
@@ -81,12 +61,12 @@
81 61 FrmEntriesHelper::set_posted_value( $this->field, $value, $args );
82 62
83 63 $errors = array();
84 64
85 - // Validate the url format
86 - if ( $value && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
65 + // validate the url format
66 + if ( ! empty( $value ) && ! preg_match( '/^http(s)?:\/\/(?:localhost|(?:[\da-z\.-]+\.[\da-z\.-]+))/i', $value ) ) {
87 67 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'invalid' );
88 - } elseif ( $this->field->required == '1' && ! $value ) { // phpcs:ignore Universal.Operators.StrictComparisons
68 + } elseif ( $this->field->required == '1' && empty( $value ) ) {
89 69 $errors[ 'field' . $args['id'] ] = FrmFieldsHelper::get_error_msg( $this->field, 'blank' );
90 70 }
91 71
92 72 return $errors;
@@ -92,34 +72,27 @@
92 72 return $errors;
93 73 }
94 74
95 75 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 );
76 + if ( $atts['html'] ) {
77 + $images = '';
78 + foreach ( (array) $value as $url ) {
79 + $image_regex = '/(\.(?i)(jpg|jpeg|png|gif))$/';
80 + $is_image = preg_match( $image_regex, $url );
81 + if ( $is_image ) {
82 + $images .= '<img src="' . esc_attr( $url ) . '" class="frm_image_from_url" alt="" /> ';
83 + } else {
84 + $images .= strip_tags( $url );
85 + }
110 86 }
87 + $value = $images;
111 88 }
112 89
113 - return $images;
90 + return $value;
114 91 }
115 92
116 93 /**
117 94 * @since 4.0.04
118 - *
119 - * @param array|string $value
120 - *
121 - * @return void
122 95 */
123 96 public function sanitize_value( &$value ) {
124 97 FrmAppHelper::sanitize_value( 'esc_url_raw', $value );
125 98 }