PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24
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/helpers/FrmAppHelper.php +279 -684 6.276.24 View file →
@@ -9,9 +9,9 @@
9 9 * Version of the database we are moving to.
10 10 *
11 11 * @var int
12 12 */
13 - public static $db_version = 104;
13 + public static $db_version = 103;
14 14
15 15 /**
16 16 * Used by the API add-on.
17 17 *
@@ -28,9 +28,9 @@
28 28 * @since 2.0
29 29 *
30 30 * @var string
31 31 */
32 - public static $plug_version = '6.27';
32 + public static $plug_version = '6.24';
33 33
34 34 /**
35 35 * @var bool
36 36 */
@@ -55,9 +55,9 @@
55 55 /**
56 56 * @return string
57 57 */
58 58 public static function plugin_path() {
59 - return dirname( __DIR__, 2 );
59 + return dirname( dirname( __DIR__ ) );
60 60 }
61 61
62 62 /**
63 63 * @return string
@@ -85,9 +85,8 @@
85 85 * Get the name of this site
86 86 * Used for [sitename] shortcode
87 87 *
88 88 * @since 2.0
89 - *
90 89 * @return string
91 90 */
92 91 public static function site_name() {
93 92 return get_option( 'blogname' );
@@ -94,15 +93,13 @@
94 93 }
95 94
96 95 /**
97 96 * @param string $url
98 - *
99 97 * @return string
100 98 */
101 99 public static function make_affiliate_url( $url ) {
102 100 $affiliate_id = self::get_affiliate();
103 -
104 - if ( $affiliate_id ) {
101 + if ( ! empty( $affiliate_id ) ) {
105 102 $url = str_replace( array( 'http://', 'https://' ), '', $url );
106 103 $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url );
107 104 }
108 105
@@ -117,124 +114,55 @@
117 114 }
118 115
119 116 /**
120 117 * @since 3.04.02
121 - *
122 - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
118 + * @param array|string $args
123 119 * @param string $page
124 120 */
125 121 public static function admin_upgrade_link( $args, $page = '' ) {
126 - if ( $page ) {
122 + if ( empty( $page ) ) {
123 + $page = 'https://formidableforms.com/lite-upgrade/';
124 + } else {
127 125 $page = str_replace( 'https://formidableforms.com/', '', $page );
128 126 $page = 'https://formidableforms.com/' . $page;
127 + }
128 +
129 + $anchor = '';
130 + if ( is_array( $args ) ) {
131 + $medium = isset( $args['medium'] ) ? $args['medium'] : '';
132 + if ( isset( $args['content'] ) ) {
133 + $content = $args['content'];
134 + }
135 + if ( isset( $args['anchor'] ) ) {
136 + $anchor = '#' . $args['anchor'];
137 + }
129 138 } else {
130 - $page = 'https://formidableforms.com/lite-upgrade/';
139 + $medium = $args;
131 140 }
132 141
133 - $args = is_array( $args ) ? self::adjust_legacy_utm_args( $args ) : array( 'campaign' => $args );
134 -
135 142 $query_args = array(
136 - 'utm_source' => 'plugin',
137 - 'utm_medium' => self::get_utm_medium(),
143 + 'utm_source' => 'WordPress',
144 + 'utm_medium' => $medium,
145 + 'utm_campaign' => 'liteplugin',
138 146 );
139 - $query_args = self::maybe_add_utm_license( $query_args );
140 147
141 - if ( isset( $args['campaign'] ) ) {
142 - $query_args['utm_campaign'] = $args['campaign'];
148 + if ( isset( $content ) ) {
149 + $query_args['utm_content'] = $content;
143 150 }
144 151
145 - if ( isset( $args['content'] ) ) {
146 - $query_args['utm_content'] = $args['content'];
147 - }
148 -
149 - if ( isset( $args['param'] ) ) {
152 + if ( is_array( $args ) && isset( $args['param'] ) ) {
150 153 $query_args['f'] = $args['param'];
151 154 }
152 155
153 - if ( ! empty( $args['plan'] ) ) {
156 + if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
154 157 $query_args['plan'] = $args['plan'];
155 158 }
156 159
157 - $link = add_query_arg( $query_args, $page );
158 -
159 - if ( isset( $args['anchor'] ) ) {
160 - $link .= '#' . $args['anchor'];
161 - }
162 -
160 + $link = add_query_arg( $query_args, $page ) . $anchor;
163 161 return self::make_affiliate_url( $link );
164 162 }
165 163
166 164 /**
167 - * If medium is "pro", add an additional utm_license param with their active license type.
168 - *
169 - * @since 6.25.1
170 - *
171 - * @param array $query_args
172 - * @param string $link
173 - *
174 - * @return array
175 - */
176 - private static function maybe_add_utm_license( $query_args, $link = '' ) {
177 - $medium = $query_args['utm_medium'] ?? self::pull_medium_from_link( $link );
178 -
179 - if ( 'pro' === $medium && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) {
180 - $query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() );
181 - }
182 -
183 - return $query_args;
184 - }
185 -
186 - /**
187 - * @since 6.26
188 - *
189 - * @param string $link
190 - *
191 - * @return string
192 - */
193 - private static function pull_medium_from_link( $link ) {
194 - if ( ! $link ) {
195 - return '';
196 - }
197 -
198 - $parsed = parse_url( $link );
199 -
200 - if ( ! is_array( $parsed ) || ! isset( $parsed['query'] ) ) {
201 - return '';
202 - }
203 -
204 - $query_args = wp_parse_args( $parsed['query'] );
205 -
206 - return empty( $query_args['utm_medium'] ) ? '' : $query_args['utm_medium'];
207 - }
208 -
209 - /**
210 - * @since 6.25.1
211 - *
212 - * @return string
213 - */
214 - private static function get_utm_medium() {
215 - return self::pro_is_connected() ? 'pro' : 'lite';
216 - }
217 -
218 - /**
219 - * Change campaign from "liteplugin" to what we're currently using for medium.
220 - *
221 - * @since 6.25.1
222 - *
223 - * @param array $args
224 - *
225 - * @return array
226 - */
227 - private static function adjust_legacy_utm_args( $args ) {
228 - if ( isset( $args['medium'] ) ) {
229 - $args['campaign'] = $args['medium'];
230 - unset( $args['medium'] );
231 - }
232 -
233 - return $args;
234 - }
235 -
236 - /**
237 165 * @since 6.21
238 166 *
239 167 * @param string $cta_link
240 168 * @param array $utm
@@ -239,29 +167,26 @@
239 167 * @param string $cta_link
240 168 * @param array $utm
241 169 */
242 170 public static function maybe_add_missing_utm( $cta_link, $utm ) {
243 - $utm = self::adjust_legacy_utm_args( $utm );
244 171 $query_args = array();
245 172
246 - if ( ! str_contains( $cta_link, 'utm_source' ) ) {
247 - $query_args['utm_source'] = 'plugin';
173 + if ( false === strpos( $cta_link, 'utm_source' ) ) {
174 + $query_args['utm_source'] = 'WordPress';
248 175 }
249 176
250 - if ( ! str_contains( $cta_link, 'utm_medium' ) ) {
251 - $query_args['utm_medium'] = self::get_utm_medium();
177 + if ( false === strpos( $cta_link, 'utm_campaign' ) ) {
178 + $query_args['utm_campaign'] = 'liteplugin';
252 179 }
253 180
254 - if ( ! str_contains( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) {
255 - $query_args['utm_campaign'] = $utm['campaign'];
181 + if ( false === strpos( $cta_link, 'utm_medium' ) && isset( $utm['medium'] ) ) {
182 + $query_args['utm_medium'] = $utm['medium'];
256 183 }
257 184
258 - if ( ! str_contains( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
185 + if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
259 186 $query_args['utm_content'] = $utm['content'];
260 187 }
261 188
262 - $query_args = self::maybe_add_utm_license( $query_args, $cta_link );
263 -
264 189 return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link;
265 190 }
266 191
267 192 /**
@@ -269,14 +194,12 @@
269 194 *
270 195 * @since 2.0
271 196 *
272 197 * @param array $args - May include the form id when values need translation.
273 - *
274 198 * @return FrmSettings $frm_settings
275 199 */
276 200 public static function get_settings( $args = array() ) {
277 201 global $frm_settings;
278 -
279 202 if ( empty( $frm_settings ) ) {
280 203 $frm_settings = new FrmSettings( $args );
281 204 } elseif ( isset( $args['current_form'] ) ) {
282 205 // If the global has already been set, allow strings to be filtered.
@@ -290,9 +213,10 @@
290 213 * @return string
291 214 */
292 215 public static function get_menu_name() {
293 216 $frm_settings = self::get_settings();
294 - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu;
217 +
218 + return FrmAddonsController::is_license_expired() ? 'Formidable' : $frm_settings->menu;
295 219 }
296 220
297 221 /**
298 222 * Determine if the current branding is set to 'formidable'.
@@ -307,9 +231,9 @@
307 231 return true;
308 232 }
309 233
310 234 $menu_icon = self::get_menu_icon_class();
311 - return str_contains( $menu_icon, 'frm_logo_icon' );
235 + return strpos( $menu_icon, 'frm_logo_icon' ) !== false;
312 236 }
313 237
314 238 /**
315 239 * @since 3.05
@@ -314,9 +238,8 @@
314 238 /**
315 239 * @since 3.05
316 240 *
317 241 * @param array $atts
318 - *
319 242 * @return string
320 243 */
321 244 public static function svg_logo( $atts = array() ) {
322 245 $defaults = array(
@@ -326,14 +249,12 @@
326 249 'orange' => '#f05a24',
327 250 );
328 251 $atts = array_merge( $defaults, $atts );
329 252
330 - // phpcs:disable SlevomatCodingStandard.Files.LineLength.LineTooLong
331 253 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 599.68 601.37" width="' . esc_attr( $atts['width'] ) . '" height="' . esc_attr( $atts['height'] ) . '">
332 254 <path fill="' . esc_attr( $atts['orange'] ) . '" d="M289.6 384h140v76h-140z"/>
333 255 <path fill="' . esc_attr( $atts['fill'] ) . '" d="M400.2 147h-200c-17 0-30.6 12.2-30.6 29.3V218h260v-71zM397.9 264H169.6v196h75V340H398a32.2 32.2 0 0 0 30.1-21.4 24.3 24.3 0 0 0 1.7-8.7V264zM299.8 601.4A300.3 300.3 0 0 1 0 300.7a299.8 299.8 0 1 1 511.9 212.6 297.4 297.4 0 0 1-212 88zm0-563A262 262 0 0 0 38.3 300.7a261.6 261.6 0 1 0 446.5-185.5 259.5 259.5 0 0 0-185-76.8z"/>
334 256 </svg>';
335 - // phpcs:enable SlevomatCodingStandard.Files.LineLength.LineTooLong
336 257 }
337 258
338 259 /**
339 260 * @since 4.0
@@ -338,13 +259,12 @@
338 259 /**
339 260 * @since 4.0
340 261 *
341 262 * @param array $atts
342 - *
343 263 * @return void
344 264 */
345 265 public static function show_logo( $atts = array() ) {
346 - self::kses_echo( self::svg_logo( $atts ), 'all' );
266 + echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
347 267 }
348 268
349 269 /**
350 270 * @since 4.03.02
@@ -359,11 +279,10 @@
359 279 )
360 280 );
361 281
362 282 $new_icon = apply_filters( 'frm_icon', $icon, true );
363 -
364 283 if ( $new_icon !== $icon ) {
365 - if ( str_starts_with( $new_icon, '<svg' ) ) {
284 + if ( strpos( $new_icon, '<svg' ) === 0 ) {
366 285 $icon = str_replace( 'viewBox="0 0 20', 'width="30" height="35" style="color:#929699" viewBox="0 0 20', $new_icon );
367 286 } else {
368 287 // Show nothing if it isn't an SVG.
369 288 $icon = '<div style="height:39px"></div>';
@@ -368,9 +287,9 @@
368 287 // Show nothing if it isn't an SVG.
369 288 $icon = '<div style="height:39px"></div>';
370 289 }
371 290 }
372 - self::kses_echo( $icon, 'all' );
291 + echo self::kses( $icon, 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
373 292 }
374 293
375 294 /**
376 295 * @since 2.02.04
@@ -420,13 +339,11 @@
420 339 */
421 340 public static function is_form_builder_page( $check_for_settings = true ) {
422 341 $action = self::simple_get( 'frm_action', 'sanitize_title' );
423 342 $check_actions = array( 'edit', 'duplicate' );
424 -
425 343 if ( $check_for_settings ) {
426 344 $check_actions[] = 'settings';
427 345 }
428 -
429 346 return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true );
430 347 }
431 348
432 349 /**
@@ -432,15 +349,15 @@
432 349 /**
433 350 * @return bool
434 351 */
435 352 public static function is_formidable_admin() {
436 - $page = self::simple_get( 'page', 'sanitize_title' );
437 -
438 - if ( ! $page ) {
439 - return self::is_view_builder_page();
353 + $page = self::simple_get( 'page', 'sanitize_title' );
354 + $is_formidable = strpos( $page, 'formidable' ) !== false;
355 + if ( empty( $page ) ) {
356 + $is_formidable = self::is_view_builder_page();
440 357 }
441 358
442 - return str_contains( $page, 'formidable' );
359 + return $is_formidable;
443 360 }
444 361
445 362 /**
446 363 * Checks if is a list page.
@@ -447,9 +364,8 @@
447 364 *
448 365 * @since 6.19
449 366 *
450 367 * @param string $page The name of the page to check.
451 - *
452 368 * @return bool
453 369 */
454 370 public static function is_admin_list_page( $page = 'formidable' ) {
455 371 if ( 'formidable' === $page ) {
@@ -461,9 +377,8 @@
461 377 }
462 378
463 379 if ( 'formidable-entries' === $page ) {
464 380 $action = self::simple_get( 'frm_action' );
465 -
466 381 if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) {
467 382 return true;
468 383 }
469 384 }
@@ -492,13 +407,11 @@
492 407 */
493 408 public static function is_admin_page( $page = 'formidable' ) {
494 409 global $pagenow;
495 410 $get_page = self::simple_get( 'page', 'sanitize_title' );
496 -
497 411 if ( $pagenow ) {
498 412 // allow this to be true during ajax load i.e. ajax form builder loading
499 413 $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
500 -
501 414 if ( $is_page ) {
502 415 return true;
503 416 }
504 417 }
@@ -516,15 +429,15 @@
516 429 */
517 430 public static function is_view_builder_page() {
518 431 global $pagenow;
519 432
520 - if ( ! in_array( $pagenow, array( 'post.php', 'post-new.php', 'edit.php' ), true ) ) {
433 + if ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'edit.php' ) {
521 434 return false;
522 435 }
523 436
524 437 $post_type = self::simple_get( 'post_type', 'sanitize_title' );
525 438
526 - if ( ! $post_type ) {
439 + if ( empty( $post_type ) ) {
527 440 $post_id = self::simple_get( 'post', 'absint' );
528 441 $post = get_post( $post_id );
529 442 $post_type = $post ? $post->post_type : '';
530 443 }
@@ -542,9 +455,9 @@
542 455 public static function is_preview_page() {
543 456 global $pagenow;
544 457 $action = self::simple_get( 'action', 'sanitize_title' );
545 458
546 - return $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
459 + return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
547 460 }
548 461
549 462 /**
550 463 * Check for ajax except the form preview page
@@ -565,9 +478,8 @@
565 478 }
566 479
567 480 /**
568 481 * @since 2.0.8
569 - *
570 482 * @return bool
571 483 */
572 484 public static function prevent_caching() {
573 485 global $frm_vars;
@@ -585,9 +497,8 @@
585 497 $is_admin = is_admin() && ! wp_doing_ajax();
586 498
587 499 /**
588 500 * @since 6.0
589 - *
590 501 * @param bool $is_admin
591 502 */
592 503 return apply_filters( 'frm_is_admin', $is_admin );
593 504 }
@@ -602,15 +513,14 @@
602 513 *
603 514 * @return bool
604 515 */
605 516 public static function is_empty_value( $value, $empty = '' ) {
606 - return $value === array() || $value === $empty;
517 + return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
607 518 }
608 519
609 520 /**
610 521 * @param mixed $value
611 522 * @param string $empty
612 - *
613 523 * @return bool
614 524 */
615 525 public static function is_not_empty_value( $value, $empty = '' ) {
616 526 return ! self::is_empty_value( $value, $empty );
@@ -664,9 +574,8 @@
664 574 continue;
665 575 }
666 576
667 577 $key = self::get_server_value( $key );
668 -
669 578 foreach ( explode( ',', $key ) as $ip ) {
670 579 // Just to be safe.
671 580 $ip = trim( $ip );
672 581
@@ -722,26 +631,16 @@
722 631 */
723 632 return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
724 633 }
725 634
726 - /**
727 - * @param string $param
728 - * @param mixed $default
729 - * @param string $src
730 - * @param callable|string $sanitize
731 - *
732 - * @return mixed
733 - */
734 635 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
735 - if ( str_contains( $param, '[' ) ) {
636 + if ( strpos( $param, '[' ) ) {
736 637 $params = explode( '[', $param );
737 638 $param = $params[0];
738 639 }
739 640
740 641 if ( $src === 'get' ) {
741 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
742 - $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default );
743 -
642 + $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
744 643 if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
745 644 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
746 645 $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
747 646 }
@@ -756,9 +655,9 @@
756 655 )
757 656 );
758 657 }
759 658
760 - if ( isset( $params ) && is_array( $value ) && $value ) {
659 + if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
761 660 foreach ( $params as $k => $p ) {
762 661 if ( ! $k || ! is_array( $value ) ) {
763 662 continue;
764 663 }
@@ -763,9 +662,9 @@
763 662 continue;
764 663 }
765 664
766 665 $p = trim( $p, ']' );
767 - $value = $value[ $p ] ?? $default;
666 + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
768 667 }
769 668 }
770 669
771 670 return $value;
@@ -777,9 +676,8 @@
777 676 * @param string $param The key we are trying to access data from in $_POST.
778 677 * @param mixed $default The default if nothing is being sent.
779 678 * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default.
780 679 * @param bool $serialized
781 - *
782 680 * @return mixed
783 681 */
784 682 public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
785 683 return self::get_simple_request(
@@ -830,10 +728,10 @@
830 728 'sanitize' => 'sanitize_text_field',
831 729 'serialized' => false,
832 730 );
833 731 $args = wp_parse_args( $args, $defaults );
834 - $value = $args['default'];
835 732
733 + $value = $args['default'];
836 734 if ( $args['type'] === 'get' ) {
837 735 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
838 736 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
839 737 $value = wp_unslash( $_GET[ $args['param'] ] );
@@ -841,9 +739,8 @@
841 739 } elseif ( $args['type'] === 'post' ) {
842 740 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
843 741 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
844 742 $value = wp_unslash( $_POST[ $args['param'] ] );
845 -
846 743 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
847 744 self::unserialize_or_decode( $value );
848 745 }
849 746 }
@@ -868,9 +765,9 @@
868 765 * @return string $value
869 766 */
870 767 public static function preserve_backslashes( $value ) {
871 768 // If backslashes have already been added, don't add them again
872 - if ( ! str_contains( $value, '\\\\' ) ) {
769 + if ( strpos( $value, '\\\\' ) === false ) {
873 770 $value = addslashes( $value );
874 771 }
875 772
876 773 return $value;
@@ -881,9 +778,8 @@
881 778 * If $value is an array, the sanitize function will get called for each item.
882 779 *
883 780 * @param callable $sanitize
884 781 * @param mixed $value
885 - *
886 782 * @return void
887 783 */
888 784 public static function sanitize_value( $sanitize, &$value ) {
889 785 if ( ! $sanitize ) {
@@ -896,13 +792,11 @@
896 792 }
897 793
898 794 if ( is_array( $value ) ) {
899 795 $temp_values = $value;
900 -
901 796 foreach ( $temp_values as $k => $v ) {
902 797 self::sanitize_value( $sanitize, $value[ $k ] );
903 798 }
904 -
905 799 return;
906 800 }
907 801
908 802 $value = call_user_func( $sanitize, $value );
@@ -907,17 +801,10 @@
907 801
908 802 $value = call_user_func( $sanitize, $value );
909 803 }
910 804
911 - /**
912 - * @param array $sanitize_method
913 - * @param array $values
914 - *
915 - * @return void
916 - */
917 805 public static function sanitize_request( $sanitize_method, &$values ) {
918 806 $temp_values = $values;
919 -
920 807 foreach ( $temp_values as $k => $val ) {
921 808 if ( isset( $sanitize_method[ $k ] ) ) {
922 809 $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
923 810 }
@@ -927,9 +814,8 @@
927 814 /**
928 815 * @since 4.0.04
929 816 *
930 817 * @param mixed $value
931 - *
932 818 * @return void
933 819 */
934 820 public static function sanitize_with_html( &$value ) {
935 821 if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) {
@@ -974,15 +860,12 @@
974 860 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&amp;'
975 861 * this MUST be done, else we'll be back to the '& entity' problem.
976 862 *
977 863 * @since 4.0.04
978 - *
979 - * @param mixed $value Value to decode, passed by reference.
980 864 */
981 865 public static function decode_specialchars( &$value ) {
982 866 if ( is_array( $value ) ) {
983 867 $temp_values = $value;
984 -
985 868 foreach ( $temp_values as $k => $v ) {
986 869 self::decode_specialchars( $value[ $k ] );
987 870 }
988 871 } else {
@@ -996,13 +879,13 @@
996 879 * Adapted from wp_specialchars_decode().
997 880 *
998 881 * @since 4.03.01
999 882 *
1000 - * @param string $string The string to prep, passed by reference.
883 + * @param string $string The string to prep.
1001 884 */
1002 885 private static function decode_amp( &$string ) {
1003 886 // Don't bother if there are no entities - saves a lot of processing
1004 - if ( ! $string || ! str_contains( $string, '&' ) ) {
887 + if ( empty( $string ) || strpos( $string, '&' ) === false ) {
1005 888 return;
1006 889 }
1007 890
1008 891 $translation = array(
@@ -1040,15 +923,16 @@
1040 923 * Sanitize the value, and allow some HTML
1041 924 *
1042 925 * @since 2.0
1043 926 *
1044 - * @param string $value The value to sanitize.
1045 - * @param array|string $allowed Allowed HTML tags and attributes, or 'all' for defaults.
927 + * @param string $value
928 + * @param array|string $allowed 'all' for everything included as defaults.
1046 929 *
1047 930 * @return string
1048 931 */
1049 932 public static function kses( $value, $allowed = array() ) {
1050 933 $allowed_html = self::allowed_html( $allowed );
934 +
1051 935 return wp_kses( $value, $allowed_html );
1052 936 }
1053 937
1054 938 /**
@@ -1057,9 +941,8 @@
1057 941 * @since 6.18
1058 942 *
1059 943 * @param string $value The value to sanitize and output.
1060 944 * @param array|string $allowed Allowed HTML tags and attributes.
1061 - *
1062 945 * @return void
1063 946 */
1064 947 public static function kses_echo( $value, $allowed = array() ) {
1065 948 echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -1070,23 +953,21 @@
1070 953 *
1071 954 * @since 5.0.13
1072 955 *
1073 956 * @param string $html
1074 - *
1075 957 * @return string
1076 958 */
1077 959 public static function kses_submit_button( $html ) {
1078 - $included_button_action = str_contains( $html, '[button_action]' );
1079 - $included_back_hook = str_contains( $html, '[back_hook]' );
1080 - $included_draft_hook = str_contains( $html, '[draft_hook]' );
960 + $included_button_action = false !== strpos( $html, '[button_action]' );
961 + $included_back_hook = false !== strpos( $html, '[back_hook]' );
962 + $included_draft_hook = false !== strpos( $html, '[draft_hook]' );
1081 963 add_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1082 964 add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1083 965 $html = self::kses( $html, 'all' );
1084 966 remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1085 967 remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1086 -
1087 968 if ( $included_button_action ) {
1088 - if ( str_contains( $html, '<input type="submit"' ) ) {
969 + if ( false !== strpos( $html, '<input type="submit"' ) ) {
1089 970 $pattern = '/(<input type="submit")([^>]*)(\/>)/';
1090 971 $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
1091 972 } else {
1092 973 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
@@ -1092,17 +973,14 @@
1092 973 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
1093 974 $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
1094 975 }
1095 976 }
1096 -
1097 977 if ( $included_back_hook ) {
1098 978 $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html );
1099 979 }
1100 -
1101 980 if ( $included_draft_hook ) {
1102 981 $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
1103 982 }
1104 -
1105 983 return $html;
1106 984 }
1107 985
1108 986 /**
@@ -1108,9 +986,8 @@
1108 986 /**
1109 987 * @since 5.0.13
1110 988 *
1111 989 * @param array $allowed_attr
1112 - *
1113 990 * @return array
1114 991 */
1115 992 public static function allow_visibility_style( $allowed_attr ) {
1116 993 $allowed_attr[] = 'visibility';
@@ -1120,9 +997,8 @@
1120 997 /**
1121 998 * @since 5.0.13
1122 999 *
1123 1000 * @param array $allowed_html
1124 - *
1125 1001 * @return array
1126 1002 */
1127 1003 public static function add_allowed_submit_button_tags( $allowed_html ) {
1128 1004 $allowed_html['input'] = array(
@@ -1139,22 +1015,17 @@
1139 1015 }
1140 1016
1141 1017 /**
1142 1018 * @since 2.05.03
1143 - *
1144 - * @param array|string $allowed
1145 - *
1146 - * @return array
1147 1019 */
1148 1020 private static function allowed_html( $allowed ) {
1149 1021 $html = self::safe_html();
1150 1022 $allowed_html = array();
1151 -
1152 1023 if ( $allowed === 'all' ) {
1153 1024 $allowed_html = $html;
1154 - } elseif ( $allowed ) {
1025 + } elseif ( ! empty( $allowed ) ) {
1155 1026 foreach ( (array) $allowed as $a ) {
1156 - $allowed_html[ $a ] = $html[ $a ] ?? array();
1027 + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
1157 1028 }
1158 1029 }
1159 1030
1160 1031 return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html );
@@ -1314,16 +1185,14 @@
1314 1185 return;
1315 1186 }
1316 1187
1317 1188 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
1318 -
1319 - if ( ! $action_name ) {
1189 + if ( empty( $action_name ) ) {
1320 1190 return;
1321 1191 }
1322 1192
1323 1193 $new_action = self::get_param( $action_name, '', 'get', 'sanitize_text_field' );
1324 -
1325 - if ( $new_action ) {
1194 + if ( ! empty( $new_action ) ) {
1326 1195 $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
1327 1196 }
1328 1197 }
1329 1198
@@ -1330,22 +1199,16 @@
1330 1199 /**
1331 1200 * Check the WP query for a parameter
1332 1201 *
1333 1202 * @since 2.0
1334 - *
1335 - * @param array|string $value
1336 - * @param string $param
1337 - *
1338 1203 * @return array|string
1339 1204 */
1340 1205 public static function get_query_var( $value, $param ) {
1341 - // phpcs:ignore Universal.Operators.StrictComparisons
1342 1206 if ( $value != '' ) {
1343 1207 return $value;
1344 1208 }
1345 1209
1346 1210 global $wp_query;
1347 -
1348 1211 if ( isset( $wp_query->query_vars[ $param ] ) ) {
1349 1212 $value = $wp_query->query_vars[ $param ];
1350 1213 }
1351 1214
@@ -1358,21 +1221,20 @@
1358 1221 * @since 4.0.02
1359 1222 *
1360 1223 * @param string $class
1361 1224 * @param array $atts
1362 - *
1363 1225 * @return string|null
1364 1226 */
1365 1227 public static function icon_by_class( $class, $atts = array() ) {
1366 1228 $echo = ! isset( $atts['echo'] ) || $atts['echo'];
1367 -
1368 1229 if ( isset( $atts['echo'] ) ) {
1369 1230 unset( $atts['echo'] );
1370 1231 }
1371 1232
1372 1233 $html_atts = self::array_to_html_params( $atts );
1373 - $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1374 1234
1235 + $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1236 +
1375 1237 // Replace icons that have been removed or renamed.
1376 1238 $deprecated = array(
1377 1239 'frm_clone_solid_icon' => 'frm_clone_icon',
1378 1240 'frm_keyalt_icon' => 'frm_key_icon',
@@ -1377,9 +1239,8 @@
1377 1239 'frm_clone_solid_icon' => 'frm_clone_icon',
1378 1240 'frm_keyalt_icon' => 'frm_key_icon',
1379 1241 'frm_keyalt_solid_icon' => 'frm_key_solid_icon',
1380 1242 );
1381 -
1382 1243 if ( isset( $deprecated[ $icon ] ) ) {
1383 1244 $icon = $deprecated[ $icon ];
1384 1245 $class = str_replace( $icon, $deprecated[ $icon ], $class );
1385 1246 }
@@ -1386,24 +1247,21 @@
1386 1247
1387 1248 if ( $icon === $class ) {
1388 1249 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
1389 1250 } else {
1390 - $class = ! str_contains( $icon, ' ' ) ? '' : ' ' . $icon;
1391 -
1392 - if ( str_contains( $icon, ' ' ) ) {
1251 + $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
1252 + if ( strpos( $icon, ' ' ) ) {
1393 1253 $icon = explode( ' ', $icon );
1394 1254 $icon = reset( $icon );
1395 1255 }
1396 -
1397 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use href="#' . esc_attr( $icon ) . '" /></svg>';
1256 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>';
1398 1257 }
1399 1258
1400 1259 if ( $echo ) {
1401 1260 echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1402 - return null;
1261 + } else {
1262 + return $icon;
1403 1263 }
1404 -
1405 - return $icon;
1406 1264 }
1407 1265
1408 1266 /**
1409 1267 * Run kses for icons. It needs to add a few filters first in order to preserve some custom style values.
@@ -1410,9 +1268,8 @@
1410 1268 *
1411 1269 * @since 5.0.13
1412 1270 *
1413 1271 * @param string $icon
1414 - *
1415 1272 * @return string
1416 1273 */
1417 1274 public static function kses_icon( $icon ) {
1418 1275 add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
@@ -1428,15 +1285,13 @@
1428 1285 /**
1429 1286 * @since 5.0.13.1
1430 1287 *
1431 1288 * @param array $allowed_html
1432 - *
1433 1289 * @return array
1434 1290 */
1435 1291 public static function add_allowed_icon_tags( $allowed_html ) {
1436 1292 $allowed_html['svg']['data-open'] = true;
1437 1293 $allowed_html['svg']['title'] = true;
1438 - $allowed_html['svg']['tabindex'] = true;
1439 1294 return $allowed_html;
1440 1295 }
1441 1296
1442 1297 /**
@@ -1442,9 +1297,8 @@
1442 1297 /**
1443 1298 * @since 5.0.13
1444 1299 *
1445 1300 * @param array $allowed_attr
1446 - *
1447 1301 * @return array
1448 1302 */
1449 1303 public static function allow_vars_in_styles( $allowed_attr ) {
1450 1304 $allowed_attr[] = '--primary-700';
@@ -1457,9 +1311,9 @@
1457 1311 * @param bool $allow_css
1458 1312 * @param string $css_string
1459 1313 */
1460 1314 public static function allow_style( $allow_css, $css_string ) {
1461 - if ( ! $allow_css && str_starts_with( $css_string, '--primary-700:' ) ) {
1315 + if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
1462 1316 $split = explode( ':', $css_string, 2 );
1463 1317 $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1464 1318 }
1465 1319 return $allow_css;
@@ -1468,22 +1322,19 @@
1468 1322 /**
1469 1323 * @since 5.0.13
1470 1324 *
1471 1325 * @param string $value
1472 - *
1473 1326 * @return bool
1474 1327 */
1475 1328 private static function is_a_valid_color( $value ) {
1476 1329 $match = 0;
1477 -
1478 - if ( str_starts_with( $value, 'rgba(' ) ) {
1330 + if ( 0 === strpos( $value, 'rgba(' ) ) {
1479 1331 $match = preg_match( '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/', $value );
1480 - } elseif ( str_starts_with( $value, 'rgb(' ) ) {
1332 + } elseif ( 0 === strpos( $value, 'rgb(' ) ) {
1481 1333 $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value );
1482 - } elseif ( str_starts_with( $value, '#' ) ) {
1334 + } elseif ( 0 === strpos( $value, '#' ) ) {
1483 1335 $match = preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})\b$/', $value );
1484 1336 }
1485 -
1486 1337 return (bool) $match;
1487 1338 }
1488 1339
1489 1340 /**
@@ -1489,9 +1340,8 @@
1489 1340 /**
1490 1341 * Include svg images.
1491 1342 *
1492 1343 * @since 4.0.02
1493 - *
1494 1344 * @return void
1495 1345 */
1496 1346 public static function include_svg() {
1497 1347 if ( self::$included_svg ) {
@@ -1510,9 +1360,8 @@
1510 1360 * @since 5.0.13 added $echo parameter.
1511 1361 *
1512 1362 * @param array $atts
1513 1363 * @param bool $echo
1514 - *
1515 1364 * @return string|void
1516 1365 */
1517 1366 public static function array_to_html_params( $atts, $echo = false ) {
1518 1367 $callback = function () use ( $atts ) {
@@ -1531,9 +1380,8 @@
1531 1380 * @since 5.0.13
1532 1381 *
1533 1382 * @param Closure $echo_function
1534 1383 * @param bool $echo
1535 - *
1536 1384 * @return string|null
1537 1385 */
1538 1386 public static function clip( $echo_function, $echo = false ) {
1539 1387 if ( ! $echo ) {
@@ -1543,9 +1391,13 @@
1543 1391 if ( is_callable( $echo_function ) ) {
1544 1392 $echo_function();
1545 1393 }
1546 1394
1547 - return $echo ? null : ob_get_clean();
1395 + if ( ! $echo ) {
1396 + $return = ob_get_contents();
1397 + ob_end_clean();
1398 + return $return;
1399 + }
1548 1400 }
1549 1401
1550 1402 /**
1551 1403 * @since 3.0
@@ -1550,18 +1402,15 @@
1550 1402 /**
1551 1403 * @since 3.0
1552 1404 *
1553 1405 * @param array $atts
1554 - *
1555 1406 * @return void
1556 1407 */
1557 1408 public static function get_admin_header( $atts ) {
1558 1409 $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] );
1559 -
1560 1410 if ( empty( $atts['close'] ) ) {
1561 1411 $atts['close'] = admin_url( 'admin.php?page=formidable' );
1562 1412 }
1563 -
1564 1413 if ( ! isset( $atts['import_link'] ) ) {
1565 1414 $atts['import_link'] = false;
1566 1415 }
1567 1416
@@ -1571,9 +1420,8 @@
1571 1420 /**
1572 1421 * @since 6.0
1573 1422 *
1574 1423 * @param string $type
1575 - *
1576 1424 * @return void
1577 1425 */
1578 1426 public static function import_link( $type = 'secondary' ) {
1579 1427 ?>
@@ -1588,9 +1436,8 @@
1588 1436 *
1589 1437 * @since 5.4.2
1590 1438 *
1591 1439 * @param bool $should_show_lite_upgrade
1592 - *
1593 1440 * @return void
1594 1441 */
1595 1442 public static function print_admin_banner( $should_show_lite_upgrade ) {
1596 1443 if ( ! current_user_can( 'administrator' ) ) {
@@ -1607,9 +1454,8 @@
1607 1454 <div class="frm-upgrade-bar">
1608 1455 <div class="frm-upgrade-bar-inner">
1609 1456 <?php
1610 1457 $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' );
1611 -
1612 1458 if ( ! $cta_text ) {
1613 1459 $cta_text = __( 'upgrading to PRO', 'formidable' );
1614 1460 }
1615 1461
@@ -1614,13 +1460,17 @@
1614 1460 }
1615 1461
1616 1462 $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' );
1617 1463 $utm = array(
1618 - 'campaign' => 'settings-license',
1619 - 'content' => 'lite-banner',
1464 + 'medium' => 'settings-license',
1465 + 'content' => 'lite-banner',
1620 1466 );
1621 1467
1622 - $upgrade_link = $upgrade_link ? self::maybe_add_missing_utm( $upgrade_link, $utm ) : self::admin_upgrade_link( $utm );
1468 + if ( $upgrade_link ) {
1469 + $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm );
1470 + } else {
1471 + $upgrade_link = self::admin_upgrade_link( $utm );
1472 + }
1623 1473
1624 1474 printf(
1625 1475 /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */
1626 1476 esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ),
@@ -1646,9 +1496,8 @@
1646 1496 /**
1647 1497 * Render a button for a new item (Form, Application, etc).
1648 1498 *
1649 1499 * @since 3.0
1650 - *
1651 1500 * @param array $atts {
1652 1501 * Details about the button.
1653 1502 *
1654 1503 * @type array $link_hook Custom link hook, calls do_action and exits early.
@@ -1655,9 +1504,8 @@
1655 1504 * @type string $new_link Href value, default #.
1656 1505 * @type string $class Custom class names, space separated.
1657 1506 * @type string $button_text Button text. Default "Add New".
1658 1507 * }
1659 - *
1660 1508 * @return void
1661 1509 */
1662 1510 public static function add_new_item_link( $atts ) {
1663 1511 if ( isset( $atts['link_hook'] ) ) {
@@ -1683,12 +1531,8 @@
1683 1531 }
1684 1532
1685 1533 /**
1686 1534 * @since 3.06
1687 - *
1688 - * @param array $atts
1689 - *
1690 - * @return void
1691 1535 */
1692 1536 public static function show_search_box( $atts ) {
1693 1537 $defaults = array(
1694 1538 'placeholder' => '',
@@ -1704,9 +1548,8 @@
1704 1548 $atts['tosearch'] = 'frm-card';
1705 1549 }
1706 1550
1707 1551 $class = 'frm-search-input';
1708 -
1709 1552 if ( ! empty( $atts['tosearch'] ) ) {
1710 1553 $class .= ' frm-auto-search';
1711 1554 }
1712 1555
@@ -1735,9 +1578,9 @@
1735 1578 <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>">
1736 1579 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
1737 1580 <?php echo esc_html( $atts['text'] ); ?>:
1738 1581 </label>
1739 - <?php self::icon_by_class( 'frmfont frm_search_icon frm_svg20' ); ?>
1582 + <?php self::icon_by_class( 'frm_icon_font frm_search_icon frm_svg20' ); ?>
1740 1583 <input <?php self::array_to_html_params( $input_atts, true ); ?> />
1741 1584 <?php
1742 1585 if ( empty( $atts['tosearch'] ) ) {
1743 1586 submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
@@ -1747,17 +1590,14 @@
1747 1590 <?php
1748 1591 }
1749 1592
1750 1593 /**
1751 - * @param string $type Hook type slug.
1752 - * @param object|null $object Optional related object.
1753 - *
1594 + * @param string $type
1754 1595 * @return void
1755 1596 */
1756 1597 public static function trigger_hook_load( $type, $object = null ) {
1757 1598 // Only load the form hooks once.
1758 1599 $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
1759 -
1760 1600 if ( ! $hooks_loaded ) {
1761 1601 do_action( 'frm_load_' . $type . '_hooks' );
1762 1602 }
1763 1603 }
@@ -1816,14 +1656,14 @@
1816 1656 * True when value is 1, true, 'true', 'yes'
1817 1657 *
1818 1658 * @since 1.07.10
1819 1659 *
1820 - * @param int|string $value The value to compare.
1660 + * @param string $value The value to compare.
1821 1661 *
1822 1662 * @return bool
1823 1663 */
1824 1664 public static function is_true( $value ) {
1825 - return true === $value || '1' === (string) $value || 'true' === $value || 'yes' === $value;
1665 + return true === $value || 1 == $value || 'true' === $value || 'yes' === $value;
1826 1666 }
1827 1667
1828 1668 /**
1829 1669 * Gets all post from a specific post type.
@@ -1831,9 +1671,8 @@
1831 1671 *
1832 1672 * @since 4.10.01 Add `$post_type` argument.
1833 1673 *
1834 1674 * @param string $post_type Post type to query. Default is `page`.
1835 - *
1836 1675 * @return WP_Post[]
1837 1676 */
1838 1677 public static function get_pages( $post_type = 'page' ) {
1839 1678 $query = array(
@@ -1852,9 +1691,8 @@
1852 1691 *
1853 1692 * @since 5.0.09
1854 1693 *
1855 1694 * @param string $post_type Post type to query. Default is `page`.
1856 - *
1857 1695 * @return array
1858 1696 */
1859 1697 public static function get_post_ids_and_titles( $post_type = 'page' ) {
1860 1698 return FrmDb::get_results(
@@ -1879,9 +1717,10 @@
1879 1717 *
1880 1718 * @param array $args Selection arguments.
1881 1719 */
1882 1720 public static function maybe_autocomplete_pages_options( $args ) {
1883 - $args = self::preformat_selection_args( $args );
1721 + $args = self::preformat_selection_args( $args );
1722 +
1884 1723 $pages_count = wp_count_posts( $args['post_type'] );
1885 1724
1886 1725 if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) {
1887 1726 self::wp_pages_dropdown( $args );
@@ -1928,11 +1767,11 @@
1928 1767 'value_key' => 'value',
1929 1768 'label_key' => 'label',
1930 1769 );
1931 1770
1932 - $args = wp_parse_args( $args, $defaults );
1771 + $args = wp_parse_args( $args, $defaults );
1772 +
1933 1773 $html_attrs = array();
1934 -
1935 1774 if ( ! empty( $args['name'] ) ) {
1936 1775 $html_attrs['name'] = $args['name'];
1937 1776 }
1938 1777
@@ -1946,14 +1785,13 @@
1946 1785 <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
1947 1786 <?php
1948 1787 foreach ( $args['source'] as $key => $source ) :
1949 1788 $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1950 -
1951 1789 if ( ! empty( $args['truncate'] ) ) {
1952 1790 $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] );
1953 1791 }
1954 1792 ?>
1955 - <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?>
1793 + <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option>
1956 1794 <?php endforeach; ?>
1957 1795 </select>
1958 1796 <?php
1959 1797 } else {
@@ -1958,9 +1796,8 @@
1958 1796 <?php
1959 1797 } else {
1960 1798 $options = array();
1961 1799 $autocomplete_value = '';
1962 -
1963 1800 foreach ( $args['source'] as $key => $source ) {
1964 1801 $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1965 1802
1966 1803 if ( $value_label['value'] === $args['selected'] ) {
@@ -1990,15 +1827,14 @@
1990 1827 *
1991 1828 * @param array|string $option Autocomplete option.
1992 1829 * @param string $key Array key of the option.
1993 1830 * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}.
1994 - *
1995 1831 * @return array
1996 1832 */
1997 1833 private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) {
1998 1834 if ( is_array( $option ) ) {
1999 - $value = $option[ $args['value_key'] ] ?? '';
2000 - $label = $option[ $args['label_key'] ] ?? '';
1835 + $value = isset( $option[ $args['value_key'] ] ) ? $option[ $args['value_key'] ] : '';
1836 + $label = isset( $option[ $args['label_key'] ] ) ? $option[ $args['label_key'] ] : '';
2001 1837 } else {
2002 1838 $value = $key;
2003 1839 $label = $option;
2004 1840 }
@@ -2032,14 +1868,8 @@
2032 1868 * Fill in missing parameters passed to wp_pages_dropdown().
2033 1869 * This is for reverse compatibility with switching 3 params to 1.
2034 1870 *
2035 1871 * @since 4.03.06
2036 - *
2037 - * @param string $page_id Deprecated.
2038 - * @param bool $truncate Deprecated.
2039 - * @param mixed $args
2040 - *
2041 - * @return void
2042 1872 */
2043 1873 private static function prep_page_dropdown_params( $page_id, $truncate, &$args ) {
2044 1874 if ( ! is_array( $args ) ) {
2045 1875 $args = array(
@@ -2056,12 +1886,8 @@
2056 1886 * Filter to format args for page dropdown or autocomplete
2057 1887 *
2058 1888 * @since 4.03.06
2059 1889 * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array.
2060 - *
2061 - * @param array $args
2062 - *
2063 - * @return array
2064 1890 */
2065 1891 private static function preformat_selection_args( $args ) {
2066 1892 $defaults = array(
2067 1893 'truncate' => false,
@@ -2074,18 +1900,13 @@
2074 1900
2075 1901 return array_merge( $defaults, $args );
2076 1902 }
2077 1903
2078 - /**
2079 - * @param int $post_id
2080 - *
2081 - * @return string
2082 - */
2083 1904 public static function post_edit_link( $post_id ) {
2084 1905 $post = get_post( $post_id );
2085 -
2086 1906 if ( $post ) {
2087 1907 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1908 +
2088 1909 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
2089 1910 }
2090 1911
2091 1912 return '';
@@ -2112,9 +1933,8 @@
2112 1933 * @since 5.5.3
2113 1934 * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
2114 1935 *
2115 1936 * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
2116 - *
2117 1937 * @return bool
2118 1938 */
2119 1939 public static function is_style_editor_page( $view = '' ) {
2120 1940 if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
@@ -2162,9 +1982,8 @@
2162 1982 }
2163 1983
2164 1984 /**
2165 1985 * @since 4.07
2166 - *
2167 1986 * @param array|string $selected
2168 1987 * @param string $current
2169 1988 */
2170 1989 private static function selected( $selected, $current ) {
@@ -2179,9 +1998,8 @@
2179 1998 * @param array|string $capability
2180 1999 */
2181 2000 public static function roles_options( $capability ) {
2182 2001 global $frm_vars;
2183 -
2184 2002 if ( isset( $frm_vars['editable_roles'] ) ) {
2185 2003 $editable_roles = $frm_vars['editable_roles'];
2186 2004 } else {
2187 2005 $editable_roles = get_editable_roles();
@@ -2190,9 +2008,9 @@
2190 2008
2191 2009 foreach ( $editable_roles as $role => $details ) {
2192 2010 $name = translate_user_role( $details['name'] );
2193 2011 ?>
2194 - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option>
2012 + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?> </option>
2195 2013 <?php
2196 2014 unset( $role, $details );
2197 2015 }
2198 2016 }
@@ -2202,9 +2020,8 @@
2202 2020 *
2203 2021 * @since 5.0 Parameter `$type` supports `pro_only` value.
2204 2022 *
2205 2023 * @param string $type Supports `auto`, `pro`, or `pro_only`.
2206 - *
2207 2024 * @return array
2208 2025 */
2209 2026 public static function frm_capabilities( $type = 'auto' ) {
2210 2027 if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
@@ -2222,8 +2039,14 @@
2222 2039 * @param array<string,string> $pro_cap
2223 2040 */
2224 2041 $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
2225 2042
2043 + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) {
2044 + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date.
2045 + // This was added in 6.5.4. Remove this in the future.
2046 + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
2047 + }
2048 +
2226 2049 if ( 'pro_only' === $type ) {
2227 2050 return $pro_cap;
2228 2051 }
2229 2052
@@ -2269,18 +2092,21 @@
2269 2092 if ( $role === 'loggedin' || ! $role ) {
2270 2093 return is_user_logged_in();
2271 2094 }
2272 2095
2273 - if ( (int) $role === 1 ) {
2096 + if ( $role == 1 ) {
2274 2097 $role = 'administrator';
2275 2098 }
2276 2099
2277 - return is_user_logged_in() ? current_user_can( $role ) : false;
2100 + if ( ! is_user_logged_in() ) {
2101 + return false;
2102 + }
2103 +
2104 + return current_user_can( $role );
2278 2105 }
2279 2106
2280 2107 /**
2281 2108 * @param array|string $needed_role
2282 - *
2283 2109 * @return bool
2284 2110 */
2285 2111 public static function user_has_permission( $needed_role ) {
2286 2112 if ( is_array( $needed_role ) ) {
@@ -2294,20 +2120,18 @@
2294 2120 }
2295 2121
2296 2122 $can = self::current_user_can( $needed_role );
2297 2123
2298 - if ( $can || in_array( $needed_role, array( '-1', 'loggedout' ), true ) ) {
2124 + if ( $can || in_array( $needed_role, array( '-1', 'loggedout' ) ) ) {
2299 2125 return $can;
2300 2126 }
2301 2127
2302 2128 $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
2303 -
2304 2129 foreach ( $roles as $role ) {
2305 2130 if ( current_user_can( $role ) ) {
2306 2131 return true;
2307 2132 }
2308 -
2309 - if ( $role === $needed_role ) {
2133 + if ( $role == $needed_role ) {
2310 2134 break;
2311 2135 }
2312 2136 }
2313 2137
@@ -2328,9 +2152,8 @@
2328 2152
2329 2153 $user_id = get_current_user_id();
2330 2154 $user = new WP_User( $user_id );
2331 2155 $frm_roles = self::frm_capabilities();
2332 -
2333 2156 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2334 2157 $user->add_cap( $frm_role );
2335 2158 unset( $frm_role, $frm_role_description );
2336 2159 }
@@ -2341,9 +2164,8 @@
2341 2164 *
2342 2165 * @since 2.0.6
2343 2166 *
2344 2167 * @param string $cap
2345 - *
2346 2168 * @return void
2347 2169 */
2348 2170 public static function force_capability( $cap = 'frm_change_settings' ) {
2349 2171 if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
@@ -2348,9 +2170,8 @@
2348 2170 public static function force_capability( $cap = 'frm_change_settings' ) {
2349 2171 if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
2350 2172 $role = get_role( 'administrator' );
2351 2173 $frm_roles = self::frm_capabilities();
2352 -
2353 2174 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2354 2175 $role->add_cap( $frm_role );
2355 2176 }
2356 2177 }
@@ -2362,18 +2183,15 @@
2362 2183 *
2363 2184 * @since 2.0
2364 2185 *
2365 2186 * @param string $permission
2366 - * @param string $show_message
2367 2187 */
2368 2188 public static function permission_check( $permission, $show_message = 'show' ) {
2369 2189 $permission_error = self::permission_nonce_error( $permission );
2370 -
2371 2190 if ( $permission_error !== false ) {
2372 - if ( 'hide' === $show_message ) {
2191 + if ( 'hide' == $show_message ) {
2373 2192 $permission_error = '';
2374 2193 }
2375 -
2376 2194 wp_die( esc_html( $permission_error ) );
2377 2195 }
2378 2196 }
2379 2197
@@ -2382,27 +2200,24 @@
2382 2200 *
2383 2201 * @since 2.0
2384 2202 *
2385 2203 * @param string $permission
2386 - * @param string $nonce_name
2387 - * @param string $nonce
2388 2204 *
2389 2205 * @return false|string The permission message or false if allowed
2390 2206 */
2391 2207 public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
2392 - if ( $permission && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
2208 + if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
2393 2209 $frm_settings = self::get_settings();
2210 +
2394 2211 return $frm_settings->admin_permission;
2395 2212 }
2396 2213
2397 2214 $error = false;
2398 -
2399 - if ( ! $nonce_name ) {
2215 + if ( empty( $nonce_name ) ) {
2400 2216 return $error;
2401 2217 }
2402 2218
2403 2219 $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2404 -
2405 2220 if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
2406 2221 $frm_settings = self::get_settings();
2407 2222 $error = $frm_settings->admin_permission;
2408 2223 }
@@ -2409,14 +2224,8 @@
2409 2224
2410 2225 return $error;
2411 2226 }
2412 2227
2413 - /**
2414 - * @param array|string $values
2415 - * @param string $current
2416 - *
2417 - * @return void
2418 - */
2419 2228 public static function checked( $values, $current ) {
2420 2229 if ( self::check_selected( $values, $current ) ) {
2421 2230 echo ' checked="checked"';
2422 2231 }
@@ -2421,34 +2230,25 @@
2421 2230 echo ' checked="checked"';
2422 2231 }
2423 2232 }
2424 2233
2425 - /**
2426 - * @param array|string $values
2427 - * @param string $current
2428 - *
2429 - * @return bool
2430 - */
2431 2234 public static function check_selected( $values, $current ) {
2432 - $values = self::recursive_function_map( $values, 'trim' );
2433 - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
2235 + $values = self::recursive_function_map( $values, 'trim' );
2236 + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
2237 +
2434 2238 $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) );
2435 2239
2436 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons
2437 2240 return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
2438 2241 }
2439 2242
2440 - /**
2441 - * @param array|string $value
2442 - * @param callable|string $function
2443 - *
2444 - * @return array|string
2445 - */
2446 2243 public static function recursive_function_map( $value, $function ) {
2447 2244 if ( is_array( $value ) ) {
2448 2245 $original_function = $function;
2449 - $function = count( $value ) ? explode( ', ', FrmDb::prepare_array_values( $value, $function ) ) : array( $function );
2450 -
2246 + if ( count( $value ) ) {
2247 + $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) );
2248 + } else {
2249 + $function = array( $function );
2250 + }
2451 2251 if ( ! self::is_assoc( $value ) ) {
2452 2252 $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function );
2453 2253 } else {
2454 2254 foreach ( $value as $k => $v ) {
@@ -2459,9 +2259,9 @@
2459 2259 }
2460 2260 } else {
2461 2261 $value = self::maybe_update_value_if_null( $value, $function );
2462 2262 $value = call_user_func( $function, $value );
2463 - }//end if
2263 + }
2464 2264
2465 2265 return $value;
2466 2266 }
2467 2267
@@ -2468,12 +2268,10 @@
2468 2268 /**
2469 2269 * Updates value to empty string if it is null and being passed to a string function.
2470 2270 *
2471 2271 * @since 6.8.4
2472 - *
2473 2272 * @param mixed $value
2474 2273 * @param string $function
2475 - *
2476 2274 * @return mixed
2477 2275 */
2478 2276 private static function maybe_update_value_if_null( $value, $function ) {
2479 2277 if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) {
@@ -2482,13 +2280,8 @@
2482 2280
2483 2281 return $value;
2484 2282 }
2485 2283
2486 - /**
2487 - * @param array $array
2488 - *
2489 - * @return bool
2490 - */
2491 2284 public static function is_assoc( $array ) {
2492 2285 return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
2493 2286 }
2494 2287
@@ -2493,17 +2286,11 @@
2493 2286 }
2494 2287
2495 2288 /**
2496 2289 * Flatten a multi-dimensional array
2497 - *
2498 - * @param array $array
2499 - * @param string $keys
2500 - *
2501 - * @return array
2502 2290 */
2503 2291 public static function array_flatten( $array, $keys = 'keep' ) {
2504 2292 $return = array();
2505 -
2506 2293 foreach ( $array as $key => $value ) {
2507 2294 if ( is_array( $value ) ) {
2508 2295 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
2509 2296 } elseif ( $keys === 'keep' ) {
@@ -2522,9 +2309,8 @@
2522 2309 * @since 6.16.1
2523 2310 *
2524 2311 * @param string $sep
2525 2312 * @param array $array
2526 - *
2527 2313 * @return string
2528 2314 */
2529 2315 public static function safe_implode( $sep, $array ) {
2530 2316 $array = self::array_flatten( $array );
@@ -2533,18 +2319,15 @@
2533 2319
2534 2320 /**
2535 2321 * @param string $text
2536 2322 * @param bool $is_rich_text
2537 - *
2538 2323 * @return string
2539 2324 */
2540 2325 public static function esc_textarea( $text, $is_rich_text = false ) {
2541 2326 $safe_text = str_replace( '&quot;', '"', $text );
2542 -
2543 2327 if ( ! $is_rich_text ) {
2544 2328 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
2545 2329 }
2546 -
2547 2330 $safe_text = str_replace( '&amp; ', '& ', $safe_text );
2548 2331
2549 2332 /**
2550 2333 * @param string $safe_text
@@ -2556,12 +2339,8 @@
2556 2339 /**
2557 2340 * Add auto paragraphs to text areas
2558 2341 *
2559 2342 * @since 2.0
2560 - *
2561 - * @param mixed $content
2562 - *
2563 - * @return mixed
2564 2343 */
2565 2344 public static function use_wpautop( $content ) {
2566 2345 if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) {
2567 2346 $content = wpautop( str_replace( '<br>', '<br />', $content ) );
@@ -2569,44 +2348,33 @@
2569 2348
2570 2349 return $content;
2571 2350 }
2572 2351
2573 - /**
2574 - * Replace quotes with their HTML entities.
2575 - *
2576 - * @param string $val
2577 - *
2578 - * @return string
2579 - */
2580 2352 public static function replace_quotes( $val ) {
2581 2353 // Replace double quotes.
2582 2354 $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
2583 2355
2584 2356 // Replace single quotes.
2585 - return str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
2357 + $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
2358 +
2359 + return $val;
2586 2360 }
2587 2361
2588 2362 /**
2589 - * @param string $handle
2590 - * @param int|string $default
2591 - *
2592 - * @return int|string
2363 + * @param string $handle
2593 2364 */
2594 2365 public static function script_version( $handle, $default = 0 ) {
2595 2366 global $wp_scripts;
2596 -
2597 2367 if ( ! $wp_scripts ) {
2598 2368 return $default;
2599 2369 }
2600 2370
2601 2371 $ver = $default;
2602 -
2603 2372 if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
2604 2373 return $ver;
2605 2374 }
2606 2375
2607 2376 $query = $wp_scripts->registered[ $handle ];
2608 -
2609 2377 if ( is_object( $query ) && ! empty( $query->ver ) ) {
2610 2378 $ver = $query->ver;
2611 2379 }
2612 2380
@@ -2617,9 +2385,8 @@
2617 2385 * @since 5.0.13 added $echo param.
2618 2386 *
2619 2387 * @param string $url
2620 2388 * @param bool $echo
2621 - *
2622 2389 * @return string|null
2623 2390 */
2624 2391 public static function js_redirect( $url, $echo = false ) {
2625 2392 $callback = function () use ( $url ) {
@@ -2627,13 +2394,8 @@
2627 2394 };
2628 2395 return self::clip( $callback, $echo );
2629 2396 }
2630 2397
2631 - /**
2632 - * @param int|string $user_id
2633 - *
2634 - * @return int|string
2635 - */
2636 2398 public static function get_user_id_param( $user_id ) {
2637 2399 if ( ! $user_id || is_numeric( $user_id ) ) {
2638 2400 return $user_id;
2639 2401 }
@@ -2638,13 +2400,16 @@
2638 2400 return $user_id;
2639 2401 }
2640 2402
2641 2403 $user_id = sanitize_text_field( $user_id );
2642 -
2643 2404 if ( $user_id === 'current' ) {
2644 2405 $user_id = get_current_user_id();
2645 2406 } else {
2646 - $user = is_email( $user_id ) ? get_user_by( 'email', $user_id ) : get_user_by( 'login', $user_id );
2407 + if ( is_email( $user_id ) ) {
2408 + $user = get_user_by( 'email', $user_id );
2409 + } else {
2410 + $user = get_user_by( 'login', $user_id );
2411 + }
2647 2412
2648 2413 if ( $user ) {
2649 2414 $user_id = $user->ID;
2650 2415 }
@@ -2656,9 +2421,8 @@
2656 2421
2657 2422 /**
2658 2423 * @param string $filename
2659 2424 * @param array $atts
2660 - *
2661 2425 * @return false|string
2662 2426 */
2663 2427 public static function get_file_contents( $filename, $atts = array() ) {
2664 2428 if ( ! is_file( $filename ) ) {
@@ -2667,9 +2431,12 @@
2667 2431
2668 2432 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
2669 2433 ob_start();
2670 2434 include $filename;
2671 - return ob_get_clean();
2435 + $contents = ob_get_contents();
2436 + ob_end_clean();
2437 +
2438 + return $contents;
2672 2439 }
2673 2440
2674 2441 /**
2675 2442 * @param string $name
@@ -2679,9 +2446,8 @@
2679 2446 * @param int $num_chars
2680 2447 */
2681 2448 public static function get_unique_key( $name, $table_name, $column, $id = 0, $num_chars = 5 ) {
2682 2449 $key = '';
2683 -
2684 2450 if ( $name ) {
2685 2451 $key = sanitize_key( $name );
2686 2452 $key = self::maybe_clear_long_key( $key, $column );
2687 2453 }
@@ -2732,24 +2498,20 @@
2732 2498 * The database limit is 100 for form and field keys so we want to avoid getting too close.
2733 2499 *
2734 2500 * @param string $column
2735 2501 * @param string $key
2736 - *
2737 2502 * @return string
2738 2503 */
2739 2504 private static function maybe_truncate_key_before_appending( $column, $key ) {
2740 2505 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2741 2506 $max_key_length_before_truncating = 60;
2742 -
2743 2507 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2744 2508 $key = substr( $key, 0, $max_key_length_before_truncating );
2745 -
2746 2509 if ( is_numeric( $key ) ) {
2747 2510 $key .= 'a';
2748 2511 }
2749 2512 }
2750 2513 }
2751 -
2752 2514 return $key;
2753 2515 }
2754 2516
2755 2517 /**
@@ -2756,9 +2518,8 @@
2756 2518 * Possibly reset a key to avoid conflicts with column size limits.
2757 2519 *
2758 2520 * @param string $key
2759 2521 * @param string $column
2760 - *
2761 2522 * @return string either the original key value, or an empty string if the key was too long.
2762 2523 */
2763 2524 private static function maybe_clear_long_key( $key, $column ) {
2764 2525 if ( 'field_key' === $column && strlen( $key ) >= 70 ) {
@@ -2770,22 +2531,20 @@
2770 2531 /**
2771 2532 * @since 6.21 This is changed from `private` to `public`.
2772 2533 *
2773 2534 * @param int $num_chars
2774 - *
2775 2535 * @return string
2776 2536 */
2777 2537 public static function generate_new_key( $num_chars ) {
2778 - $max_slug_value = 36 ** $num_chars;
2538 + $max_slug_value = pow( 36, $num_chars );
2779 2539
2780 2540 // We want to have at least 2 characters in the slug.
2781 2541 $min_slug_value = 37;
2782 - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
2542 + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2783 2543 }
2784 2544
2785 2545 /**
2786 2546 * @param string $key
2787 - *
2788 2547 * @return string
2789 2548 */
2790 2549 private static function prevent_numeric_and_reserved_keys( $key ) {
2791 2550 if ( is_numeric( $key ) ) {
@@ -2799,14 +2558,12 @@
2799 2558 'editlink',
2800 2559 'siteurl',
2801 2560 'evenodd',
2802 2561 );
2803 -
2804 2562 if ( in_array( $key, $not_allowed, true ) ) {
2805 2563 $key .= 'a';
2806 2564 }
2807 2565 }
2808 -
2809 2566 return $key;
2810 2567 }
2811 2568
2812 2569 /**
@@ -2825,9 +2582,9 @@
2825 2582 if ( ! $record ) {
2826 2583 return false;
2827 2584 }
2828 2585
2829 - if ( ! $post_values ) {
2586 + if ( empty( $post_values ) ) {
2830 2587 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
2831 2588 }
2832 2589
2833 2590 $values = array(
@@ -2835,9 +2592,9 @@
2835 2592 'fields' => array(),
2836 2593 );
2837 2594
2838 2595 foreach ( array( 'name', 'description' ) as $var ) {
2839 - $default_val = $record->{$var} ?? '';
2596 + $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
2840 2597 $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
2841 2598 unset( $var, $default_val );
2842 2599 }
2843 2600
@@ -2855,47 +2612,30 @@
2855 2612
2856 2613 return $values;
2857 2614 }
2858 2615
2859 - /**
2860 - * @param array|string $fields
2861 - * @param object $record
2862 - * @param array $values
2863 - * @param array $args
2864 - *
2865 - * @return void
2866 - */
2867 2616 private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
2868 - if ( $fields ) {
2617 + if ( ! empty( $fields ) ) {
2869 2618 foreach ( (array) $fields as $field ) {
2870 2619 if ( ! self::is_admin_page() ) {
2871 2620 // Don't prep default values on the form settings page.
2872 2621 $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2873 2622 }
2874 - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
2623 + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
2875 2624 self::fill_field_defaults( $field, $record, $values, $args );
2876 2625 }
2877 2626 }
2878 2627 }
2879 2628
2880 - /**
2881 - * @param object $field
2882 - * @param object $record
2883 - * @param array $values
2884 - * @param array $args
2885 - *
2886 - * @return void
2887 - */
2888 2629 private static function fill_field_defaults( $field, $record, array &$values, $args ) {
2889 2630 $post_values = $args['post_values'];
2890 2631
2891 2632 if ( $args['default'] ) {
2892 2633 $meta_value = $field->default_value;
2893 - } elseif ( $record->post_id && self::pro_is_installed() && ! empty( $field->field_options['post_field'] ) ) {
2634 + } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2894 2635 if ( ! isset( $field->field_options['custom_field'] ) ) {
2895 2636 $field->field_options['custom_field'] = '';
2896 2637 }
2897 -
2898 2638 $meta_value = FrmProEntryMetaHelper::get_post_value(
2899 2639 $record->post_id,
2900 2640 $field->field_options['post_field'],
2901 2641 $field->field_options['custom_field'],
@@ -2909,10 +2649,9 @@
2909 2649 } else {
2910 2650 $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2911 2651 }//end if
2912 2652
2913 - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type;
2914 -
2653 + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2915 2654 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2916 2655 $new_value = $post_values['item_meta'][ $field->id ];
2917 2656 self::unserialize_or_decode( $new_value );
2918 2657 } else {
@@ -2927,9 +2666,9 @@
2927 2666 $args['field_type'] = $field_type;
2928 2667
2929 2668 FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
2930 2669
2931 - if ( empty( $field_array['unique'] ) ) {
2670 + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
2932 2671 $field_array['unique_msg'] = '';
2933 2672 }
2934 2673
2935 2674 $field_array = array_merge( (array) $field->field_options, $field_array );
@@ -2996,21 +2735,15 @@
2996 2735 }
2997 2736
2998 2737 /**
2999 2738 * Set to POST value or default
3000 - *
3001 - * @param array $post_values
3002 - * @param array $values
3003 - *
3004 - * @return void
3005 2739 */
3006 2740 private static function fill_form_defaults( $post_values, array &$values ) {
3007 2741 $form_defaults = FrmFormsHelper::get_default_opts();
3008 2742
3009 2743 foreach ( $form_defaults as $opt => $default ) {
3010 - // phpcs:ignore Universal.Operators.StrictComparisons
3011 2744 if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
3012 - $values[ $opt ] = $post_values['options'][ $opt ] ?? $default;
2745 + $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default;
3013 2746 }
3014 2747
3015 2748 unset( $opt, $default );
3016 2749 }
@@ -3020,9 +2753,9 @@
3020 2753 }
3021 2754
3022 2755 foreach ( array( 'before', 'after', 'submit' ) as $h ) {
3023 2756 if ( ! isset( $values[ $h . '_html' ] ) ) {
3024 - $values[ $h . '_html' ] = $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h );
2757 + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
3025 2758 }
3026 2759 unset( $h );
3027 2760 }
3028 2761 }
@@ -3034,14 +2767,16 @@
3034 2767 *
3035 2768 * @return bool|int
3036 2769 */
3037 2770 public static function custom_style_value( $post_values ) {
3038 - if ( $post_values && isset( $post_values['options']['custom_style'] ) ) {
3039 - return absint( $post_values['options']['custom_style'] );
2771 + if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
2772 + $custom_style = absint( $post_values['options']['custom_style'] );
2773 + } else {
2774 + $frm_settings = self::get_settings();
2775 + $custom_style = ( $frm_settings->load_style !== 'none' );
3040 2776 }
3041 2777
3042 - $frm_settings = self::get_settings();
3043 - return $frm_settings->load_style !== 'none';
2778 + return $custom_style;
3044 2779 }
3045 2780
3046 2781 /**
3047 2782 * @param mixed $original_string
@@ -3047,9 +2782,8 @@
3047 2782 * @param mixed $original_string
3048 2783 * @param int|string $length
3049 2784 * @param int $minword
3050 2785 * @param string $continue
3051 - *
3052 2786 * @return string
3053 2787 */
3054 2788 public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) {
3055 2789 if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) {
@@ -3059,9 +2793,9 @@
3059 2793 $length = (int) $length;
3060 2794 $str = wp_strip_all_tags( (string) $original_string );
3061 2795 $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
3062 2796
3063 - if ( $length === 0 ) {
2797 + if ( $length == 0 ) {
3064 2798 return '';
3065 2799 }
3066 2800
3067 2801 if ( $length <= 10 ) {
@@ -3068,10 +2802,11 @@
3068 2802 $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3069 2803 return $sub . ( $length < $original_len ? $continue : '' );
3070 2804 }
3071 2805
3072 - $sub = '';
3073 - $len = 0;
2806 + $sub = '';
2807 + $len = 0;
2808 +
3074 2809 $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
3075 2810
3076 2811 if ( ! is_array( $words ) ) {
3077 2812 return $original_string;
@@ -3077,11 +2812,10 @@
3077 2812 return $original_string;
3078 2813 }
3079 2814
3080 2815 foreach ( $words as $word ) {
3081 - $part = ( $sub !== '' ? ' ' : '' ) . $word;
2816 + $part = ( $sub != '' ? ' ' : '' ) . $word;
3082 2817 $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
3083 -
3084 2818 if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
3085 2819 break;
3086 2820 }
3087 2821
@@ -3106,9 +2840,8 @@
3106 2840 * @since 6.5.4
3107 2841 *
3108 2842 * @param string $sub Current substring.
3109 2843 * @param int $length The length limit.
3110 - *
3111 2844 * @return string
3112 2845 */
3113 2846 private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
3114 2847 if ( strlen( $sub ) < $length + 50 ) {
@@ -3116,9 +2849,8 @@
3116 2849 return $sub;
3117 2850 }
3118 2851
3119 2852 $first_space = strpos( $sub, ' ', $length );
3120 -
3121 2853 if ( false !== $first_space ) {
3122 2854 // Ignore anything with spaces.
3123 2855 return $sub;
3124 2856 }
@@ -3125,18 +2857,11 @@
3125 2857
3126 2858 return substr( $sub, 0, $length + 10 );
3127 2859 }
3128 2860
3129 - /**
3130 - * @param array $function_names
3131 - * @param array $args
3132 - *
3133 - * @return mixed
3134 - */
3135 2861 public static function mb_function( $function_names, $args ) {
3136 2862 $mb_function_name = $function_names[0];
3137 2863 $function_name = $function_names[1];
3138 -
3139 2864 if ( function_exists( $mb_function_name ) ) {
3140 2865 $function_name = $mb_function_name;
3141 2866 }
3142 2867
@@ -3142,21 +2867,14 @@
3142 2867
3143 2868 return call_user_func_array( $function_name, $args );
3144 2869 }
3145 2870
3146 - /**
3147 - * @param string $date
3148 - * @param string $date_format
3149 - * @param string $time_format
3150 - *
3151 - * @return string
3152 - */
3153 2871 public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
3154 - if ( ! $date ) {
2872 + if ( empty( $date ) ) {
3155 2873 return $date;
3156 2874 }
3157 2875
3158 - if ( ! $date_format ) {
2876 + if ( empty( $date_format ) ) {
3159 2877 $date_format = get_option( 'date_format' );
3160 2878 }
3161 2879
3162 2880 if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
@@ -3164,10 +2882,10 @@
3164 2882 $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
3165 2883 }
3166 2884
3167 2885 $formatted = self::get_localized_date( $date_format, $date );
3168 - $do_time = gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00';
3169 2886
2887 + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) != '00:00:00' );
3170 2888 if ( $do_time ) {
3171 2889 $formatted .= self::add_time_to_date( $time_format, $date );
3172 2890 }
3173 2891
@@ -3176,35 +2894,30 @@
3176 2894
3177 2895 /**
3178 2896 * @param string $time_format
3179 2897 * @param string $date
3180 - *
3181 2898 * @return string
3182 2899 */
3183 2900 private static function add_time_to_date( $time_format, $date ) {
3184 - if ( ! $time_format ) {
2901 + if ( empty( $time_format ) ) {
3185 2902 $time_format = get_option( 'time_format' );
3186 2903 }
3187 2904
3188 2905 $trimmed_format = trim( $time_format );
3189 -
3190 - if ( $time_format && $trimmed_format ) {
3191 - return ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
2906 + $time = '';
2907 + if ( $time_format && ! empty( $trimmed_format ) ) {
2908 + $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
3192 2909 }
3193 2910
3194 - return '';
2911 + return $time;
3195 2912 }
3196 2913
3197 2914 /**
3198 2915 * @since 2.0.8
3199 - *
3200 - * @param string $date_format
3201 - * @param string $date
3202 - *
3203 - * @return string
3204 2916 */
3205 2917 public static function get_localized_date( $date_format, $date ) {
3206 2918 $date = get_date_from_gmt( $date );
2919 +
3207 2920 return date_i18n( $date_format, strtotime( $date ) );
3208 2921 }
3209 2922
3210 2923 /**
@@ -3209,16 +2922,19 @@
3209 2922
3210 2923 /**
3211 2924 * Gets the time ago in words.
3212 2925 *
3213 - * @param int $from In seconds.
3214 - * @param int|string $to In seconds.
3215 - * @param int|string $levels Number of time units to include or a specific unit.
2926 + * @param int $from In seconds.
2927 + * @param int|string $to In seconds.
3216 2928 *
3217 2929 * @return string $time_ago
3218 2930 */
3219 2931 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
3220 - $now = empty( $to ) && 0 !== $to ? new DateTime() : new DateTime( '@' . $to );
2932 + if ( empty( $to ) && 0 !== $to ) {
2933 + $now = new DateTime();
2934 + } else {
2935 + $now = new DateTime( '@' . $to );
2936 + }
3221 2937 $ago = new DateTime( '@' . $from );
3222 2938
3223 2939 // Get the time difference
3224 2940 $diff_object = $now->diff( $ago );
@@ -3232,9 +2948,8 @@
3232 2948
3233 2949 if ( ! is_numeric( $levels ) ) {
3234 2950 // Show time in specified unit.
3235 2951 $levels = self::get_unit( $levels );
3236 -
3237 2952 if ( isset( $time_strings[ $levels ] ) ) {
3238 2953 $diff = array(
3239 2954 $levels => self::time_format( $levels, $diff ),
3240 2955 );
@@ -3241,14 +2956,13 @@
3241 2956 $time_strings = array(
3242 2957 $levels => $time_strings[ $levels ],
3243 2958 );
3244 2959 }
3245 -
3246 2960 $levels = 1;
3247 2961 }
3248 2962
3249 2963 foreach ( $time_strings as $k => $v ) {
3250 - if ( ! empty( $diff[ $k ] ) ) {
2964 + if ( isset( $diff[ $k ] ) && $diff[ $k ] ) {
3251 2965 $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
3252 2966 } elseif ( isset( $diff[ $k ] ) && count( $time_strings ) === 1 ) {
3253 2967 // Account for 0.
3254 2968 $time_strings[ $k ] = $diff[ $k ] . ' ' . $v[1];
@@ -3256,21 +2970,17 @@
3256 2970 unset( $time_strings[ $k ] );
3257 2971 }
3258 2972 }
3259 2973
3260 - $levels_deep = apply_filters( 'frm_time_ago_levels', $levels, compact( 'time_strings', 'from', 'to' ) );
3261 - $time_strings = array_slice( $time_strings, 0, absint( $levels_deep ) );
2974 + $levels_deep = apply_filters( 'frm_time_ago_levels', $levels, compact( 'time_strings', 'from', 'to' ) );
2975 + $time_strings = array_slice( $time_strings, 0, absint( $levels_deep ) );
2976 + $time_ago_string = implode( ' ', $time_strings );
3262 2977
3263 - return implode( ' ', $time_strings );
2978 + return $time_ago_string;
3264 2979 }
3265 2980
3266 2981 /**
3267 2982 * @since 4.05.01
3268 - *
3269 - * @param string $unit
3270 - * @param array $diff
3271 - *
3272 - * @return int
3273 2983 */
3274 2984 private static function time_format( $unit, $diff ) {
3275 2985 $return = array(
3276 2986 'y' => 'y',
@@ -3275,14 +2985,14 @@
3275 2985 $return = array(
3276 2986 'y' => 'y',
3277 2987 'd' => 'days',
3278 2988 );
3279 -
3280 2989 if ( isset( $return[ $unit ] ) ) {
3281 2990 return $diff[ $return[ $unit ] ];
3282 2991 }
3283 2992
3284 2993 $total = $diff['days'] * self::convert_time( 'd', $unit );
2994 +
3285 2995 $times = array( 'h', 'i', 's' );
3286 2996
3287 2997 foreach ( $times as $time ) {
3288 2998 if ( ! isset( $diff[ $time ] ) ) {
@@ -3296,13 +3006,8 @@
3296 3006 }
3297 3007
3298 3008 /**
3299 3009 * @since 4.05.01
3300 - *
3301 - * @param string $from
3302 - * @param string $to
3303 - *
3304 - * @return int
3305 3010 */
3306 3011 private static function convert_time( $from, $to ) {
3307 3012 $convert = array(
3308 3013 's' => 1,
@@ -3318,26 +3023,20 @@
3318 3023 }
3319 3024
3320 3025 /**
3321 3026 * @since 4.05.01
3322 - *
3323 - * @param string $unit
3324 - *
3325 - * @return int|string
3326 3027 */
3327 3028 private static function get_unit( $unit ) {
3328 3029 $units = self::get_time_strings();
3329 -
3330 3030 if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) {
3331 3031 return $unit;
3332 3032 }
3333 3033
3334 3034 foreach ( $units as $u => $strings ) {
3335 - if ( in_array( $unit, $strings, true ) ) {
3035 + if ( in_array( $unit, $strings ) ) {
3336 3036 return $u;
3337 3037 }
3338 3038 }
3339 -
3340 3039 return 1;
3341 3040 }
3342 3041
3343 3042 /**
@@ -3344,9 +3043,8 @@
3344 3043 * Get the translatable time strings. The untranslated version is a failsafe
3345 3044 * in case languages are changing for the unit set in the shortcode.
3346 3045 *
3347 3046 * @since 2.0.20
3348 - *
3349 3047 * @return array
3350 3048 */
3351 3049 private static function get_time_strings() {
3352 3050 return array(
@@ -3393,9 +3091,8 @@
3393 3091 /**
3394 3092 * @param int $r_count
3395 3093 * @param int $current_p
3396 3094 * @param int $p_size
3397 - *
3398 3095 * @return int
3399 3096 */
3400 3097 public static function get_last_record_num( $r_count, $current_p, $p_size ) {
3401 3098 return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size );
@@ -3404,13 +3101,11 @@
3404 3101 /**
3405 3102 * @param int $r_count
3406 3103 * @param int $current_p
3407 3104 * @param int $p_size
3408 - *
3409 3105 * @return int
3410 3106 */
3411 3107 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
3412 - // phpcs:ignore Universal.Operators.StrictComparisons
3413 3108 if ( $current_p == 1 ) {
3414 3109 return 1;
3415 3110 }
3416 3111 return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
@@ -3416,22 +3111,17 @@
3416 3111 return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
3417 3112 }
3418 3113
3419 3114 /**
3420 - * @param array $json_vars
3421 - *
3422 3115 * @return array
3423 3116 */
3424 3117 public static function json_to_array( $json_vars ) {
3425 3118 $vars = array();
3426 -
3427 3119 foreach ( $json_vars as $jv ) {
3428 3120 $jv_name = explode( '[', $jv['name'] );
3429 3121 $last = count( $jv_name ) - 1;
3430 -
3431 3122 foreach ( $jv_name as $p => $n ) {
3432 3123 $name = trim( $n, ']' );
3433 -
3434 3124 if ( ! isset( $l1 ) ) {
3435 3125 $l1 = $name;
3436 3126 }
3437 3127
@@ -3442,9 +3132,9 @@
3442 3132 if ( ! isset( $l3 ) ) {
3443 3133 $l3 = $name;
3444 3134 }
3445 3135
3446 - $this_val = $p === $last ? $jv['value'] : array();
3136 + $this_val = $p == $last ? $jv['value'] : array();
3447 3137
3448 3138 switch ( $p ) {
3449 3139 case 0:
3450 3140 $l1 = $name;
@@ -3477,15 +3167,10 @@
3477 3167
3478 3168 /**
3479 3169 * @param string $name
3480 3170 * @param string $l1
3481 - * @param mixed $val
3482 - * @param array $vars
3483 - *
3484 - * @return void
3485 3171 */
3486 3172 public static function add_value_to_array( $name, $l1, $val, &$vars ) {
3487 - // phpcs:ignore Universal.Operators.StrictComparisons
3488 3173 if ( $name == '' ) {
3489 3174 $vars[] = $val;
3490 3175 } elseif ( ! isset( $vars[ $l1 ] ) ) {
3491 3176 $vars[ $l1 ] = $val;
@@ -3491,26 +3176,19 @@
3491 3176 $vars[ $l1 ] = $val;
3492 3177 }
3493 3178 }
3494 3179
3495 - /**
3496 - * @param string $name
3497 - * @param string $class
3498 - * @param string $form_name
3499 - *
3500 - * @return void
3501 - */
3502 3180 public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
3503 3181 $tooltips = array(
3504 3182 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
3505 - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3183 + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ),
3506 3184 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3507 3185 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3508 - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3186 + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3509 3187 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
3510 3188 /* translators: %1$s: Form name, %2$s: Date */
3511 - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3512 - 'new_tab' => __( 'This option will open the link in a new browser tab. Please note that some popup blockers may prevent this from happening, in which case the link will be displayed.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3189 + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
3190 + 'new_tab' => __( 'This option will open the link in a new browser tab. Please note that some popup blockers may prevent this from happening, in which case the link will be displayed.', 'formidable' ),
3513 3191 );
3514 3192
3515 3193 if ( ! isset( $tooltips[ $name ] ) ) {
3516 3194 return;
@@ -3515,9 +3193,9 @@
3515 3193 if ( ! isset( $tooltips[ $name ] ) ) {
3516 3194 return;
3517 3195 }
3518 3196
3519 - if ( 'open' === $class ) {
3197 + if ( 'open' == $class ) {
3520 3198 echo ' frm_help"';
3521 3199 } else {
3522 3200 echo ' class="frm_help"';
3523 3201 }
@@ -3523,9 +3201,9 @@
3523 3201 }
3524 3202
3525 3203 echo ' title="' . esc_attr( $tooltips[ $name ] );
3526 3204
3527 - if ( 'open' !== $class ) {
3205 + if ( 'open' != $class ) {
3528 3206 echo '"';
3529 3207 }
3530 3208 }
3531 3209
@@ -3530,28 +3208,20 @@
3530 3208 }
3531 3209
3532 3210 /**
3533 3211 * Add the current_page class to that page in the form nav
3534 - *
3535 - * @param int|string $page
3536 - * @param int|string $current_page
3537 - * @param array $action
3538 - *
3539 - * @return void
3540 3212 */
3541 3213 public static function select_current_page( $page, $current_page, $action = array() ) {
3542 - // phpcs:ignore Universal.Operators.StrictComparisons
3543 3214 if ( $current_page != $page ) {
3544 3215 return;
3545 3216 }
3546 3217
3547 3218 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
3548 -
3549 3219 if ( 'lite-reports' === $frm_action ) {
3550 3220 $frm_action = 'reports';
3551 3221 }
3552 3222
3553 - if ( ! $action || ( $frm_action && in_array( $frm_action, $action, true ) ) ) {
3223 + if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
3554 3224 echo ' class="current_page"';
3555 3225 }
3556 3226 }
3557 3227
@@ -3582,18 +3252,13 @@
3582 3252 // Add extra slashes for \r\n since WP strips them.
3583 3253 $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
3584 3254
3585 3255 // allow for &quot
3586 - return str_replace( '&quot;', '\\"', $post_content );
3256 + $post_content = str_replace( '&quot;', '\\"', $post_content );
3257 +
3258 + return $post_content;
3587 3259 }
3588 3260
3589 - /**
3590 - * @param array|string $val
3591 - * @param int|string $key
3592 - * @param array $post_content
3593 - *
3594 - * @return void
3595 - */
3596 3261 private static function prepare_action_slashes( $val, $key, &$post_content ) {
3597 3262 if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) {
3598 3263 return;
3599 3264 }
@@ -3618,9 +3283,8 @@
3618 3283 *
3619 3284 * @since 4.02.03
3620 3285 *
3621 3286 * @param array|string $value
3622 - *
3623 3287 * @return void
3624 3288 */
3625 3289 public static function unserialize_or_decode( &$value ) {
3626 3290 if ( is_array( $value ) ) {
@@ -3626,9 +3290,13 @@
3626 3290 if ( is_array( $value ) ) {
3627 3291 return;
3628 3292 }
3629 3293
3630 - $value = is_serialized( $value ) ? self::maybe_unserialize_array( $value ) : self::maybe_json_decode( $value, false );
3294 + if ( is_serialized( $value ) ) {
3295 + $value = self::maybe_unserialize_array( $value );
3296 + } else {
3297 + $value = self::maybe_json_decode( $value, false );
3298 + }
3631 3299 }
3632 3300
3633 3301 /**
3634 3302 * Safely unserialize an array if necessary.
@@ -3636,9 +3304,8 @@
3636 3304 *
3637 3305 * @since 6.2
3638 3306 *
3639 3307 * @param mixed $value
3640 - *
3641 3308 * @return mixed
3642 3309 */
3643 3310 public static function maybe_unserialize_array( $value ) {
3644 3311 if ( ! is_string( $value ) ) {
@@ -3645,14 +3312,13 @@
3645 3312 return $value;
3646 3313 }
3647 3314
3648 3315 // Since we only expect an array, skip anything that doesn't start with a:.
3649 - if ( ! is_serialized( $value ) || ! str_starts_with( $value, 'a:' ) ) {
3316 + if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
3650 3317 return $value;
3651 3318 }
3652 3319
3653 3320 $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
3654 -
3655 3321 if ( is_array( $parsed ) ) {
3656 3322 $value = $parsed;
3657 3323 }
3658 3324
@@ -3662,12 +3328,11 @@
3662 3328 /**
3663 3329 * Decode a JSON string.
3664 3330 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
3665 3331 *
3666 - * @param array|string|null $string
3667 - * @param bool $single_to_array
3668 - *
3669 - * @return array|string|null
3332 + * @param mixed $string
3333 + * @param bool $single_to_array
3334 + * @return mixed
3670 3335 */
3671 3336 public static function maybe_json_decode( $string, $single_to_array = true ) {
3672 3337 if ( is_array( $string ) || is_null( $string ) ) {
3673 3338 return $string;
@@ -3672,19 +3337,20 @@
3672 3337 if ( is_array( $string ) || is_null( $string ) ) {
3673 3338 return $string;
3674 3339 }
3675 3340
3676 - $new_string = json_decode( $string, true );
3677 - $single_value = false;
3678 -
3679 - if ( ! $single_to_array ) {
3680 - $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3341 + $new_string = json_decode( $string, true );
3342 + if ( function_exists( 'json_last_error' ) ) {
3343 + // php 5.3+
3344 + $single_value = false;
3345 + if ( ! $single_to_array ) {
3346 + $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3347 + }
3348 + if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3349 + $string = $new_string;
3350 + }
3681 3351 }
3682 3352
3683 - if ( json_last_error() === JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3684 - $string = $new_string;
3685 - }
3686 -
3687 3353 return $string;
3688 3354 }
3689 3355
3690 3356 /**
@@ -3690,9 +3356,8 @@
3690 3356 /**
3691 3357 * @since 6.2.3
3692 3358 *
3693 3359 * @param string $value
3694 - *
3695 3360 * @return string
3696 3361 */
3697 3362 public static function maybe_utf8_encode( $value ) {
3698 3363 $from_format = 'ISO-8859-1';
@@ -3701,15 +3366,13 @@
3701 3366 if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
3702 3367 if ( mb_check_encoding( $value, $from_format ) ) {
3703 3368 return mb_convert_encoding( $value, $to_format, $from_format );
3704 3369 }
3705 -
3706 3370 return $value;
3707 3371 }
3708 3372
3709 3373 if ( function_exists( 'iconv' ) ) {
3710 3374 $converted = iconv( $from_format, $to_format, $value );
3711 -
3712 3375 // Value is false if $value is not ISO-8859-1.
3713 3376 if ( false !== $converted ) {
3714 3377 return $converted;
3715 3378 }
@@ -3721,12 +3384,8 @@
3721 3384 /**
3722 3385 * Reformat the json serialized array in name => value array.
3723 3386 *
3724 3387 * @since 4.02.03
3725 - *
3726 - * @param array $form
3727 - *
3728 - * @return void
3729 3388 */
3730 3389 public static function format_form_data( &$form ) {
3731 3390 $formatted = array();
3732 3391
@@ -3733,11 +3392,9 @@
3733 3392 foreach ( $form as $input ) {
3734 3393 if ( ! isset( $input['name'] ) ) {
3735 3394 continue;
3736 3395 }
3737 -
3738 3396 $key = $input['name'];
3739 -
3740 3397 if ( isset( $formatted[ $key ] ) ) {
3741 3398 if ( is_array( $formatted[ $key ] ) ) {
3742 3399 $formatted[ $key ][] = $input['value'];
3743 3400 } else {
@@ -3754,9 +3411,8 @@
3754 3411 /**
3755 3412 * @since 4.02.03
3756 3413 *
3757 3414 * @param array|string $value
3758 - *
3759 3415 * @return string
3760 3416 */
3761 3417 public static function maybe_json_encode( $value ) {
3762 3418 if ( is_array( $value ) ) {
@@ -3770,19 +3426,18 @@
3770 3426 *
3771 3427 * @since 1.07.10
3772 3428 *
3773 3429 * @param string $post_type The name of the post type that may need to be highlighted.
3774 - *
3775 3430 * @return void
3776 3431 */
3777 3432 public static function maybe_highlight_menu( $post_type ) {
3778 3433 global $post;
3779 3434
3780 - if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] !== $post_type ) {
3435 + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
3781 3436 return;
3782 3437 }
3783 3438
3784 - if ( is_object( $post ) && $post->post_type !== $post_type ) {
3439 + if ( is_object( $post ) && $post->post_type != $post_type ) {
3785 3440 return;
3786 3441 }
3787 3442
3788 3443 self::load_admin_wide_js();
@@ -3794,9 +3449,8 @@
3794 3449 *
3795 3450 * @since 2.0
3796 3451 *
3797 3452 * @param bool $load
3798 - *
3799 3453 * @return void
3800 3454 */
3801 3455 public static function load_admin_wide_js( $load = true ) {
3802 3456 $version = self::plugin_version();
@@ -3807,9 +3461,9 @@
3807 3461 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
3808 3462 'url' => self::plugin_url(),
3809 3463 'app_url' => 'https://formidableforms.com/',
3810 3464 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
3811 - 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3465 + 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
3812 3466 'loading' => __( 'Loading&hellip;', 'formidable' ),
3813 3467 'nonce' => wp_create_nonce( 'frm_ajax' ),
3814 3468 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
3815 3469 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(),
@@ -3822,9 +3476,8 @@
3822 3476 }
3823 3477
3824 3478 /**
3825 3479 * @since 2.0.9
3826 - *
3827 3480 * @return void
3828 3481 */
3829 3482 public static function load_font_style() {
3830 3483 wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
@@ -3831,9 +3484,8 @@
3831 3484 }
3832 3485
3833 3486 /**
3834 3487 * @param string $location
3835 - *
3836 3488 * @return void
3837 3489 */
3838 3490 public static function localize_script( $location ) {
3839 3491 global $wp_scripts, $wp_version;
@@ -3856,9 +3508,8 @@
3856 3508 'include_resend_email' => false,
3857 3509 );
3858 3510
3859 3511 $data = $wp_scripts->get_data( 'formidable', 'data' );
3860 -
3861 3512 if ( ! $data ) {
3862 3513 wp_localize_script( 'formidable', 'frm_js', $script_strings );
3863 3514 }
3864 3515
@@ -3865,9 +3516,9 @@
3865 3516 if ( $location === 'admin' ) {
3866 3517 $admin_script_strings = array(
3867 3518 'desc' => __( '(Click to add description)', 'formidable' ),
3868 3519 'blank' => __( '(Blank)', 'formidable' ),
3869 - 'no_label' => self::get_no_label_text(),
3520 + 'no_label' => __( '(no label)', 'formidable' ),
3870 3521 'ok' => __( 'OK', 'formidable' ),
3871 3522 'cancel' => __( 'Cancel', 'formidable' ),
3872 3523 'default_label' => __( 'Default', 'formidable' ),
3873 3524 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
@@ -3875,9 +3526,9 @@
3875 3526 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3876 3527 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3877 3528 'confirm' => __( 'Are you sure?', 'formidable' ),
3878 3529 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3879 - 'conf_delete_sec' => __( 'All fields inside this Section will be deleted along with their data. Are you sure you want to delete this group of fields?', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3530 + 'conf_delete_sec' => __( 'All fields inside this Section will be deleted along with their data. Are you sure you want to delete this group of fields?', 'formidable' ),
3880 3531 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3881 3532 'default_unique' => FrmFieldsHelper::default_unique_msg(),
3882 3533 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3883 3534 'enter_email' => __( 'Enter Email', 'formidable' ),
@@ -3883,9 +3534,9 @@
3883 3534 'enter_email' => __( 'Enter Email', 'formidable' ),
3884 3535 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3885 3536 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3886 3537 'new_option' => __( 'New Option', 'formidable' ),
3887 - 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3538 + 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ),
3888 3539 'enter_password' => __( 'Enter Password', 'formidable' ),
3889 3540 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3890 3541 'import_complete' => __( 'Import Complete', 'formidable' ),
3891 3542 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
@@ -3901,11 +3552,11 @@
3901 3552 'only_one_action' => sprintf( __( 'This form action is limited to %d per form.', 'formidable' ), 1 ),
3902 3553 'edit_action_text' => __( 'Please edit the existing form action.', 'formidable' ),
3903 3554 'unsafe_params' => FrmFormsHelper::reserved_words(),
3904 3555 /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/
3905 - 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3556 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3906 3557 /* Translators: %s is the name of a parameter that is a reserved word. More than one word could be listed here, though that would not be common. */
3907 - 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3558 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3908 3559 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3909 3560 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3910 3561 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3911 3562 'install' => __( 'Install', 'formidable' ),
@@ -3935,9 +3586,8 @@
3935 3586 */
3936 3587 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3937 3588
3938 3589 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3939 -
3940 3590 if ( ! $data ) {
3941 3591 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3942 3592 }
3943 3593 }//end if
@@ -3943,19 +3593,8 @@
3943 3593 }//end if
3944 3594 }
3945 3595
3946 3596 /**
3947 - * Get the no label text.
3948 - *
3949 - * @since 6.25.1
3950 - *
3951 - * @return string
3952 - */
3953 - public static function get_no_label_text() {
3954 - return __( '(no label)', 'formidable' );
3955 - }
3956 -
3957 - /**
3958 3597 * @since 6.5
3959 3598 *
3960 3599 * @return string
3961 3600 */
@@ -3997,9 +3636,8 @@
3997 3636 *
3998 3637 * @since 1.07.10
3999 3638 *
4000 3639 * @param float $min_version The version the add-on requires.
4001 - *
4002 3640 * @return void
4003 3641 */
4004 3642 public static function min_version_notice( $min_version ) {
4005 3643 $frm_version = self::plugin_version();
@@ -4009,9 +3647,9 @@
4009 3647 return;
4010 3648 }
4011 3649
4012 3650 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
4013 - echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3651 + echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' .
4014 3652 esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
4015 3653 '</div></td></tr>';
4016 3654 }
4017 3655
@@ -4019,10 +3657,8 @@
4019 3657 * If Pro is far outdated, show a message.
4020 3658 *
4021 3659 * @since 4.0.01
4022 3660 *
4023 - * @param string $min_version
4024 - *
4025 3661 * @return void
4026 3662 */
4027 3663 public static function min_pro_version_notice( $min_version ) {
4028 3664 if ( ! self::is_formidable_admin() ) {
@@ -4032,14 +3668,25 @@
4032 3668
4033 3669 self::php_version_notice();
4034 3670
4035 3671 $is_pro = self::pro_is_installed() && class_exists( 'FrmProDb' );
4036 -
4037 3672 if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) {
4038 3673 return;
4039 3674 }
4040 3675
4041 - include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
3676 + $expired = FrmAddonsController::is_license_expired();
3677 + ?>
3678 + <div class="frm-banner-alert frm_error_style frm_previous_install">
3679 + <?php
3680 + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
3681 + if ( empty( $expired ) ) {
3682 + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
3683 + } else {
3684 + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
3685 + }
3686 + ?>
3687 + </div>
3688 + <?php
4042 3689 }
4043 3690
4044 3691 /**
4045 3692 * If Pro is installed, check the version number.
@@ -4046,9 +3693,8 @@
4046 3693 *
4047 3694 * @since 4.0.01
4048 3695 *
4049 3696 * @param string $min_version
4050 - *
4051 3697 * @return bool
4052 3698 */
4053 3699 public static function meets_min_pro_version( $min_version ) {
4054 3700 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
@@ -4057,16 +3703,14 @@
4057 3703 /**
4058 3704 * Show a message if the PHP version is below the recommendations.
4059 3705 *
4060 3706 * @since 4.0.02
4061 - *
4062 3707 * @return void
4063 3708 */
4064 3709 private static function php_version_notice() {
4065 3710 $message = array();
4066 -
4067 3711 if ( version_compare( phpversion(), '7.0', '<' ) ) {
4068 - $message[] = __( 'The version of PHP on your server is too low. If this is not corrected, you may see issues with Formidable Forms. Please contact your web host and ask to be updated to PHP 7.0+.', 'formidable' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3712 + $message[] = __( 'The version of PHP on your server is too low. If this is not corrected, you may see issues with Formidable Forms. Please contact your web host and ask to be updated to PHP 7.0+.', 'formidable' );
4069 3713 }
4070 3714
4071 3715 foreach ( $message as $m ) {
4072 3716 ?>
@@ -4078,9 +3722,8 @@
4078 3722 }
4079 3723
4080 3724 /**
4081 3725 * @param string $type
4082 - *
4083 3726 * @return array<string,string>
4084 3727 */
4085 3728 public static function locales( $type = 'date' ) {
4086 3729 $locales = array(
@@ -4190,13 +3833,14 @@
4190 3833 * @since 5.4.5 Added $args parameter with type.
4191 3834 *
4192 3835 * @param array<string,string> $locales
4193 3836 * @param array $args {
4194 - *
4195 3837 * @type string $type
4196 3838 * }
4197 3839 */
4198 - return apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3840 + $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3841 +
3842 + return $locales;
4199 3843 }
4200 3844
4201 3845 /**
4202 3846 * @return string
@@ -4203,14 +3847,12 @@
4203 3847 */
4204 3848 public static function get_menu_icon_class() {
4205 3849 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
4206 3850 $settings = FrmProAppHelper::get_settings();
4207 -
4208 3851 if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
4209 3852 return $settings->menu_icon;
4210 3853 }
4211 3854 }
4212 -
4213 3855 return 'frmfont frm_logo_icon';
4214 3856 }
4215 3857
4216 3858 /**
@@ -4228,9 +3870,10 @@
4228 3870 * @type array $input_attrs Attributes of value input.
4229 3871 * }
4230 3872 */
4231 3873 public static function images_dropdown( $args ) {
4232 - $args = self::fill_default_images_dropdown_args( $args );
3874 + $args = self::fill_default_images_dropdown_args( $args );
3875 +
4233 3876 $input_attrs_str = self::get_images_dropdown_input_attrs( $args );
4234 3877 ob_start();
4235 3878 include self::plugin_path() . '/classes/views/shared/images-dropdown.php';
4236 3879 $output = ob_get_clean();
@@ -4251,9 +3894,8 @@
4251 3894 *
4252 3895 * @since 5.0.04
4253 3896 *
4254 3897 * @param array $args The arguments.
4255 - *
4256 3898 * @return array
4257 3899 */
4258 3900 private static function fill_default_images_dropdown_args( $args ) {
4259 3901 $defaults = array(
@@ -4283,9 +3925,8 @@
4283 3925 *
4284 3926 * @since 5.0.04
4285 3927 *
4286 3928 * @param array $args The arguments.
4287 - *
4288 3929 * @return string
4289 3930 */
4290 3931 private static function get_images_dropdown_input_attrs( $args ) {
4291 3932 $input_attrs = $args['input_attrs'];
@@ -4292,9 +3933,8 @@
4292 3933 $input_attrs['type'] = 'radio';
4293 3934 $input_attrs['name'] = $args['name'];
4294 3935
4295 3936 $input_attrs_str = '';
4296 -
4297 3937 foreach ( $input_attrs as $key => $input_attr ) {
4298 3938 $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) );
4299 3939 }
4300 3940
@@ -4310,13 +3950,8 @@
4310 3950 }
4311 3951
4312 3952 /**
4313 3953 * @since 6.7.1
4314 - *
4315 - * @param array $option Option data.
4316 - * @param array $args The arguments of images_dropdown() method.
4317 - *
4318 - * @return array
4319 3954 */
4320 3955 public static function get_images_dropdown_atts( $option, $args ) {
4321 3956 $image = self::get_images_dropdown_option_image( $option, $args );
4322 3957 $classes = self::get_images_dropdown_option_classes( $option, $args );
@@ -4330,9 +3965,8 @@
4330 3965 * @since 5.0.04
4331 3966 *
4332 3967 * @param array $option Option data.
4333 3968 * @param array $args The arguments of images_dropdown() method.
4334 - *
4335 3969 * @return string
4336 3970 */
4337 3971 private static function get_images_dropdown_option_image( $option, $args ) {
4338 3972 $image = self::icon_by_class(
@@ -4361,9 +3995,8 @@
4361 3995 * @since 5.0.04
4362 3996 *
4363 3997 * @param array $option Option data.
4364 3998 * @param array $args The arguments of images_dropdown() method.
4365 - *
4366 3999 * @return string
4367 4000 */
4368 4001 private static function get_images_dropdown_option_classes( $option, $args ) {
4369 4002 $classes = '';
@@ -4391,19 +4024,17 @@
4391 4024 * @since 5.0.04
4392 4025 *
4393 4026 * @param array $option Option data.
4394 4027 * @param array $args The arguments of images_dropdown() method.
4395 - *
4396 4028 * @return string
4397 4029 */
4398 4030 private static function get_images_dropdown_option_html_attrs( $option, $args ) {
4399 4031 $html_attrs = '';
4400 -
4401 4032 if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) {
4402 4033 $html_attrs_arr = array();
4403 4034
4404 4035 foreach ( $option['custom_attrs'] as $key => $value ) {
4405 - if ( in_array( $key, array( 'type', 'class', 'data-value' ), true ) ) {
4036 + if ( in_array( $key, array( 'type', 'class', 'data-value' ) ) ) {
4406 4037 continue;
4407 4038 }
4408 4039
4409 4040 $html_attrs_arr[] = sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $value ) );
@@ -4461,9 +4092,8 @@
4461 4092 * @since 5.0.07
4462 4093 *
4463 4094 * @param array $values
4464 4095 * @param array $keys
4465 - *
4466 4096 * @return array
4467 4097 */
4468 4098 public static function maybe_filter_array( $values, $keys ) {
4469 4099 $allow_unfiltered_html = self::allow_unfiltered_html();
@@ -4488,9 +4118,8 @@
4488 4118 * @since 5.0.13
4489 4119 *
4490 4120 * @param string $value
4491 4121 * @param array|string $allowed 'all' for everything included as defaults.
4492 - *
4493 4122 * @return string
4494 4123 */
4495 4124 public static function maybe_kses( $value, $allowed = 'all' ) {
4496 4125 if ( self::should_never_allow_unfiltered_html() ) {
@@ -4505,18 +4134,17 @@
4505 4134 * @since 6.11.2
4506 4135 *
4507 4136 * @param string $key
4508 4137 * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed.
4509 - *
4510 4138 * @return bool
4511 4139 */
4512 4140 public static function input_key_is_safe( $key, $context = 'display' ) {
4513 4141 if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) {
4514 4142 $safe = true;
4515 - } elseif ( str_starts_with( $key, 'data-' ) ) {
4143 + } elseif ( 0 === strpos( $key, 'data-' ) ) {
4516 4144 // Allow all data attributes.
4517 4145 $safe = true;
4518 - } elseif ( str_starts_with( $key, 'aria-' ) ) {
4146 + } elseif ( 0 === strpos( $key, 'aria-' ) ) {
4519 4147 // Allow all aria attributes.
4520 4148 $safe = true;
4521 4149 } else {
4522 4150 $safe_keys = array(
@@ -4558,9 +4186,16 @@
4558 4186
4559 4187 /**
4560 4188 * @since 5.0.16
4561 4189 *
4562 - * @param string $medium
4190 + * @return bool
4191 + */
4192 + public static function show_landing_pages() {
4193 + return self::show_new_feature( 'landing' );
4194 + }
4195 +
4196 + /**
4197 + * @since 5.0.16
4563 4198 *
4564 4199 * @return array
4565 4200 */
4566 4201 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
@@ -4568,9 +4203,8 @@
4568 4203 'medium' => $medium,
4569 4204 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
4570 4205 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4571 4206 'screenshot' => 'landing.png',
4572 - 'learn-more' => self::get_doc_url( 'landing-page-forms', 'form-landing-page-settings', false ),
4573 4207 );
4574 4208 return self::get_upgrade_data_params( 'landing', $params );
4575 4209 }
4576 4210
@@ -4577,19 +4211,13 @@
4577 4211 /**
4578 4212 * @since 5.0.17
4579 4213 *
4580 4214 * @param string $feature
4581 - *
4582 4215 * @return bool
4583 4216 */
4584 4217 public static function show_new_feature( $feature ) {
4585 4218 $link = FrmAddonsController::install_link( $feature );
4586 -
4587 - if ( array_key_exists( 'status', $link ) || array_key_exists( 'class', $link ) ) {
4588 - return true;
4589 - }
4590 -
4591 - return 'coupons' === $feature && class_exists( 'FrmCouponsAppController' );
4219 + return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
4592 4220 }
4593 4221
4594 4222 /**
4595 4223 * Enhances upgrade data parameters with installation link and plan requirement information.
@@ -4598,14 +4226,12 @@
4598 4226 *
4599 4227 * @param string $plugin The plugin slug to get installation data for.
4600 4228 * @param array $params Initial parameters for the upgrade data.
4601 4229 * @param bool $detailed Whether to include detailed information.
4602 - *
4603 4230 * @return array Modified parameters with installation data.
4604 4231 */
4605 4232 public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) {
4606 4233 $link = FrmAddonsController::install_link( $plugin );
4607 -
4608 4234 if ( ! $link ) {
4609 4235 return $params;
4610 4236 }
4611 4237
@@ -4611,9 +4237,8 @@
4611 4237
4612 4238 if ( ! empty( $link['url'] ) && self::pro_is_installed() ) {
4613 4239 $params['oneclick'] = json_encode( $link );
4614 4240 unset( $params['message'] );
4615 -
4616 4241 if ( ! isset( $params['medium'] ) ) {
4617 4242 $params['medium'] = $plugin;
4618 4243 }
4619 4244 } else {
@@ -4633,9 +4258,8 @@
4633 4258 *
4634 4259 * @since 5.0.17
4635 4260 *
4636 4261 * @param string $text
4637 - *
4638 4262 * @return bool
4639 4263 */
4640 4264 public static function ctype_xdigit( $text ) {
4641 4265 if ( function_exists( 'ctype_xdigit' ) ) {
@@ -4650,14 +4274,12 @@
4650 4274 * @since 5.2.01
4651 4275 */
4652 4276 public static function set_current_screen_and_hook_suffix() {
4653 4277 global $hook_suffix;
4654 -
4655 4278 if ( is_null( $hook_suffix ) ) {
4656 4279 // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
4657 4280 $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
4658 4281 }
4659 -
4660 4282 set_current_screen();
4661 4283 }
4662 4284
4663 4285 /**
@@ -4679,9 +4301,8 @@
4679 4301 *
4680 4302 * @since 5.2.07
4681 4303 *
4682 4304 * @param mixed $num Number.
4683 - *
4684 4305 * @return false|int Returns `false` if the passed parameter is not number.
4685 4306 */
4686 4307 public static function count_decimals( $num ) {
4687 4308 if ( ! is_numeric( $num ) ) {
@@ -4689,9 +4310,8 @@
4689 4310 }
4690 4311
4691 4312 $num = (string) $num;
4692 4313 $parts = explode( '.', $num );
4693 -
4694 4314 if ( 1 === count( $parts ) ) {
4695 4315 return 0;
4696 4316 }
4697 4317
@@ -4773,20 +4393,17 @@
4773 4393 * @since 5.5.5
4774 4394 *
4775 4395 * @param string $url
4776 4396 * @param string $expected_extension
4777 - *
4778 4397 * @return bool
4779 4398 */
4780 4399 public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
4781 - $file_is_in_expected_s3_bucket = str_starts_with( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4782 -
4400 + $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4783 4401 if ( ! $file_is_in_expected_s3_bucket ) {
4784 4402 return false;
4785 4403 }
4786 4404
4787 4405 $parsed = parse_url( $url );
4788 -
4789 4406 if ( ! is_array( $parsed ) ) {
4790 4407 // URL is malformed.
4791 4408 return false;
4792 4409 }
@@ -4792,10 +4409,14 @@
4792 4409 }
4793 4410
4794 4411 $path = $parsed['path'];
4795 4412 $ext = pathinfo( $path, PATHINFO_EXTENSION );
4796 - // The URL isn't to an XML file.
4797 - return $expected_extension === $ext;
4413 + if ( $expected_extension !== $ext ) {
4414 + // The URL isn't to an XML file.
4415 + return false;
4416 + }
4417 +
4418 + return true;
4798 4419 }
4799 4420
4800 4421 /**
4801 4422 * Display a dismissable warning message and save its dismissal state.
@@ -4803,9 +4424,8 @@
4803 4424 * @since 6.3
4804 4425 *
4805 4426 * @param string $message The warning message to display.
4806 4427 * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
4807 - *
4808 4428 * @return void
4809 4429 */
4810 4430 public static function add_dismissable_warning_message( $message = '', $option = '' ) {
4811 4431 if ( ! $message || ! $option ) {
@@ -4848,9 +4468,8 @@
4848 4468 *
4849 4469 * @since 6.3
4850 4470 *
4851 4471 * @param string $option The unique identifier for the dismissal state of the message.
4852 - *
4853 4472 * @return void
4854 4473 */
4855 4474 public static function dismiss_warning_message( $option = '' ) {
4856 4475 self::permission_check( 'frm_change_settings' );
@@ -4872,8 +4491,17 @@
4872 4491 * @return string
4873 4492 */
4874 4493 public static function copy_for_lite_license() {
4875 4494 $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂';
4495 +
4496 + if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) {
4497 + // Manage PRO versions without PRO dashboard functionality.
4498 + $license_type = FrmProAddonsController::get_readable_license_type();
4499 + if ( 'lite' !== strtolower( $license_type ) ) {
4500 + $message = 'Formidable Pro ' . $license_type;
4501 + }
4502 + }
4503 +
4876 4504 return apply_filters( 'frm_license_type_text', $message );
4877 4505 }
4878 4506
4879 4507 /**
@@ -4879,9 +4507,8 @@
4879 4507 /**
4880 4508 * Removes scripts that are unnecessarily loaded across the pages!
4881 4509 *
4882 4510 * @since 6.9
4883 - *
4884 4511 * @return void
4885 4512 */
4886 4513 public static function dequeue_extra_global_scripts() {
4887 4514 wp_dequeue_script( 'frm-surveys-admin' );
@@ -4899,9 +4526,8 @@
4899 4526 * @return void
4900 4527 */
4901 4528 public static function tooltip_icon( $tooltip_text, $atts = array() ) {
4902 4529 $atts['title'] = $tooltip_text;
4903 -
4904 4530 if ( isset( $atts['class'] ) ) {
4905 4531 $atts['class'] .= ' frm_help';
4906 4532 } else {
4907 4533 $atts['class'] = 'frm_help';
@@ -4979,9 +4605,8 @@
4979 4605 *
4980 4606 * @since 6.24
4981 4607 *
4982 4608 * @param string $string The string to check.
4983 - *
4984 4609 * @return bool
4985 4610 */
4986 4611 public static function is_valid_utf8( $string ) {
4987 4612 // wp_is_valid_utf8 is added in WP 6.9.
@@ -4987,41 +4612,11 @@
4987 4612 // wp_is_valid_utf8 is added in WP 6.9.
4988 4613 if ( function_exists( 'wp_is_valid_utf8' ) ) {
4989 4614 return wp_is_valid_utf8( $string );
4990 4615 }
4991 -
4992 4616 // As of WP 6.9, seems_utf8 is deprecated.
4993 - return function_exists( 'seems_utf8' ) ? seems_utf8( $string ) : false;
4994 - }
4995 -
4996 - /**
4997 - * Get a documentation URL with UTM parameters and affiliate tracking.
4998 - *
4999 - * @since 6.26
5000 - *
5001 - * @param string $path The relative path to append to the base URL.
5002 - * @param string $campaign The campaign to use for UTM parameters.
5003 - * @param bool $add_kb_base Whether to prepend 'knowledgebase/' to the path. Default true.
5004 - *
5005 - * @return string The processed URL with UTM parameters and affiliate tracking.
5006 - */
5007 - public static function get_doc_url( $path, $campaign, $add_kb_base = true ) {
5008 - $path = trim( $path, '/' );
5009 -
5010 - if ( $add_kb_base ) {
5011 - $path = 'knowledgebase/' . $path;
4617 + if ( function_exists( 'seems_utf8' ) ) {
4618 + return seems_utf8( $string );
5012 4619 }
5013 -
5014 - return self::maybe_add_missing_utm( 'https://formidableforms.com/' . $path, array( 'campaign' => $campaign ) );
5015 - }
5016 -
5017 - /**
5018 - * @since 5.0.16
5019 - * @deprecated 6.26
5020 - *
5021 - * @return bool
5022 - */
5023 - public static function show_landing_pages() {
5024 - _deprecated_function( __METHOD__, '6.26' );
5025 - return true;
4620 + return false;
5026 4621 }
5027 4622 }