PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.3
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 +433 -1198 6.31 → 6.16.3 View file →
@@ -3,19 +3,23 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmAppHelper {
7 -
8 7 /**
9 8 * Version of the database we are moving to.
10 9 *
11 10 * @var int
12 11 */
13 - public static $db_version = 105;
12 + public static $db_version = 102;
14 13
15 14 /**
16 - * Used by the API add-on.
15 + * Deprecated.
17 16 *
17 + * @var int
18 + */
19 + public static $pro_db_version = 37;
20 +
21 + /**
18 22 * @var float
19 23 */
20 24 public static $font_version = 7;
21 25
@@ -28,9 +32,9 @@
28 32 * @since 2.0
29 33 *
30 34 * @var string
31 35 */
32 - public static $plug_version = '6.31';
36 + public static $plug_version = '6.16.3';
33 37
34 38 /**
35 39 * @var bool
36 40 */
@@ -55,9 +59,9 @@
55 59 /**
56 60 * @return string
57 61 */
58 62 public static function plugin_path() {
59 - return dirname( __DIR__, 2 );
63 + return dirname( dirname( __DIR__ ) );
60 64 }
61 65
62 66 /**
63 67 * @return string
@@ -85,9 +89,8 @@
85 89 * Get the name of this site
86 90 * Used for [sitename] shortcode
87 91 *
88 92 * @since 2.0
89 - *
90 93 * @return string
91 94 */
92 95 public static function site_name() {
93 96 return get_option( 'blogname' );
@@ -94,15 +97,13 @@
94 97 }
95 98
96 99 /**
97 100 * @param string $url
98 - *
99 101 * @return string
100 102 */
101 103 public static function make_affiliate_url( $url ) {
102 104 $affiliate_id = self::get_affiliate();
103 -
104 - if ( $affiliate_id ) {
105 + if ( ! empty( $affiliate_id ) ) {
105 106 $url = str_replace( array( 'http://', 'https://' ), '', $url );
106 107 $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url );
107 108 }
108 109
@@ -117,167 +118,65 @@
117 118 }
118 119
119 120 /**
120 121 * @since 3.04.02
121 - *
122 - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
122 + * @param array|string $args
123 123 * @param string $page
124 124 */
125 125 public static function admin_upgrade_link( $args, $page = '' ) {
126 - if ( $page ) {
126 + if ( empty( $page ) ) {
127 + $page = 'https://formidableforms.com/lite-upgrade/';
128 + } else {
127 129 $page = str_replace( 'https://formidableforms.com/', '', $page );
128 130 $page = 'https://formidableforms.com/' . $page;
131 + }
132 +
133 + $anchor = '';
134 + if ( is_array( $args ) ) {
135 + $medium = $args['medium'];
136 + if ( isset( $args['content'] ) ) {
137 + $content = $args['content'];
138 + }
139 + if ( isset( $args['anchor'] ) ) {
140 + $anchor = '#' . $args['anchor'];
141 + }
129 142 } else {
130 - $page = 'https://formidableforms.com/lite-upgrade/';
143 + $medium = $args;
131 144 }
132 145
133 - $args = is_array( $args ) ? self::adjust_legacy_utm_args( $args ) : array( 'campaign' => $args );
134 -
135 146 $query_args = array(
136 - 'utm_source' => 'plugin',
137 - 'utm_medium' => self::get_utm_medium(),
147 + 'utm_source' => 'WordPress',
148 + 'utm_medium' => $medium,
149 + 'utm_campaign' => 'liteplugin',
138 150 );
139 - $query_args = self::maybe_add_utm_license( $query_args );
140 151
141 - if ( isset( $args['campaign'] ) ) {
142 - $query_args['utm_campaign'] = $args['campaign'];
152 + if ( isset( $content ) ) {
153 + $query_args['utm_content'] = $content;
143 154 }
144 155
145 - if ( isset( $args['content'] ) ) {
146 - $query_args['utm_content'] = $args['content'];
147 - }
148 -
149 - if ( isset( $args['param'] ) ) {
156 + if ( is_array( $args ) && isset( $args['param'] ) ) {
150 157 $query_args['f'] = $args['param'];
151 158 }
152 159
153 - if ( ! empty( $args['plan'] ) ) {
160 + if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
154 161 $query_args['plan'] = $args['plan'];
155 162 }
156 163
157 - $link = add_query_arg( $query_args, $page );
158 -
159 - if ( isset( $args['anchor'] ) ) {
160 - $link .= '#' . $args['anchor'];
161 - }
162 -
164 + $link = add_query_arg( $query_args, $page ) . $anchor;
163 165 return self::make_affiliate_url( $link );
164 166 }
165 167
166 168 /**
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 - * @since 6.21
238 - *
239 - * @param string $cta_link
240 - * @param array $utm
241 - */
242 - public static function maybe_add_missing_utm( $cta_link, $utm ) {
243 - $utm = self::adjust_legacy_utm_args( $utm );
244 - $query_args = array();
245 -
246 - if ( ! str_contains( $cta_link, 'utm_source' ) ) {
247 - $query_args['utm_source'] = 'plugin';
248 - }
249 -
250 - if ( ! str_contains( $cta_link, 'utm_medium' ) ) {
251 - $query_args['utm_medium'] = self::get_utm_medium();
252 - }
253 -
254 - if ( ! str_contains( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) {
255 - $query_args['utm_campaign'] = $utm['campaign'];
256 - }
257 -
258 - if ( ! str_contains( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
259 - $query_args['utm_content'] = $utm['content'];
260 - }
261 -
262 - $query_args = self::maybe_add_utm_license( $query_args, $cta_link );
263 -
264 - return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link;
265 - }
266 -
267 - /**
268 169 * Get the Formidable settings
269 170 *
270 171 * @since 2.0
271 172 *
272 173 * @param array $args - May include the form id when values need translation.
273 - *
274 - * @return FrmSettings
174 + * @return FrmSettings $frm_settings
275 175 */
276 176 public static function get_settings( $args = array() ) {
277 177 global $frm_settings;
278 -
279 - if ( ! $frm_settings ) {
178 + if ( empty( $frm_settings ) ) {
280 179 $frm_settings = new FrmSettings( $args );
281 180 } elseif ( isset( $args['current_form'] ) ) {
282 181 // If the global has already been set, allow strings to be filtered.
283 182 $frm_settings->maybe_filter_for_form( $args );
@@ -289,13 +188,11 @@
289 188 /**
290 189 * @return string
291 190 */
292 191 public static function get_menu_name() {
293 - if ( ! self::pro_is_installed() || FrmAddonsController::is_license_expired() ) {
294 - return 'Formidable';
295 - }
192 + $frm_settings = self::get_settings();
296 193
297 - return self::get_settings()->menu;
194 + return FrmAddonsController::is_license_expired() ? 'Formidable' : $frm_settings->menu;
298 195 }
299 196
300 197 /**
301 198 * Determine if the current branding is set to 'formidable'.
@@ -309,9 +206,10 @@
309 206 if ( ! self::pro_is_installed() ) {
310 207 return true;
311 208 }
312 209
313 - return str_contains( self::get_menu_icon_class(), 'frm_logo_icon' );
210 + $menu_icon = self::get_menu_icon_class();
211 + return strpos( $menu_icon, 'frm_logo_icon' ) !== false;
314 212 }
315 213
316 214 /**
317 215 * @since 3.05
@@ -316,9 +214,8 @@
316 214 /**
317 215 * @since 3.05
318 216 *
319 217 * @param array $atts
320 - *
321 218 * @return string
322 219 */
323 220 public static function svg_logo( $atts = array() ) {
324 221 $defaults = array(
@@ -328,14 +225,12 @@
328 225 'orange' => '#f05a24',
329 226 );
330 227 $atts = array_merge( $defaults, $atts );
331 228
332 - // phpcs:disable SlevomatCodingStandard.Files.LineLength.LineTooLong
333 229 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'] ) . '">
334 230 <path fill="' . esc_attr( $atts['orange'] ) . '" d="M289.6 384h140v76h-140z"/>
335 231 <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"/>
336 232 </svg>';
337 - // phpcs:enable SlevomatCodingStandard.Files.LineLength.LineTooLong
338 233 }
339 234
340 235 /**
341 236 * @since 4.0
@@ -340,13 +235,12 @@
340 235 /**
341 236 * @since 4.0
342 237 *
343 238 * @param array $atts
344 - *
345 239 * @return void
346 240 */
347 241 public static function show_logo( $atts = array() ) {
348 - self::kses_echo( self::svg_logo( $atts ), 'all' );
242 + echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
349 243 }
350 244
351 245 /**
352 246 * @since 4.03.02
@@ -361,11 +255,10 @@
361 255 )
362 256 );
363 257
364 258 $new_icon = apply_filters( 'frm_icon', $icon, true );
365 -
366 259 if ( $new_icon !== $icon ) {
367 - if ( str_starts_with( $new_icon, '<svg' ) ) {
260 + if ( strpos( $new_icon, '<svg' ) === 0 ) {
368 261 $icon = str_replace( 'viewBox="0 0 20', 'width="30" height="35" style="color:#929699" viewBox="0 0 20', $new_icon );
369 262 } else {
370 263 // Show nothing if it isn't an SVG.
371 264 $icon = '<div style="height:39px"></div>';
@@ -370,9 +263,9 @@
370 263 // Show nothing if it isn't an SVG.
371 264 $icon = '<div style="height:39px"></div>';
372 265 }
373 266 }
374 - self::kses_echo( $icon, 'all' );
267 + echo self::kses( $icon, 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
375 268 }
376 269
377 270 /**
378 271 * @since 2.02.04
@@ -422,13 +315,11 @@
422 315 */
423 316 public static function is_form_builder_page( $check_for_settings = true ) {
424 317 $action = self::simple_get( 'frm_action', 'sanitize_title' );
425 318 $check_actions = array( 'edit', 'duplicate' );
426 -
427 319 if ( $check_for_settings ) {
428 320 $check_actions[] = 'settings';
429 321 }
430 -
431 322 return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true );
432 323 }
433 324
434 325 /**
@@ -434,57 +325,18 @@
434 325 /**
435 326 * @return bool
436 327 */
437 328 public static function is_formidable_admin() {
438 - $page = self::simple_get( 'page', 'sanitize_title' );
439 -
440 - if ( ! $page ) {
441 - return self::is_view_builder_page();
329 + $page = self::simple_get( 'page', 'sanitize_title' );
330 + $is_formidable = strpos( $page, 'formidable' ) !== false;
331 + if ( empty( $page ) ) {
332 + $is_formidable = self::is_view_builder_page();
442 333 }
443 334
444 - return str_contains( $page, 'formidable' );
335 + return $is_formidable;
445 336 }
446 337
447 338 /**
448 - * Checks if is a list page.
449 - *
450 - * @since 6.19
451 - *
452 - * @param string $page The name of the page to check.
453 - *
454 - * @return bool
455 - */
456 - public static function is_admin_list_page( $page = 'formidable' ) {
457 - if ( 'formidable' === $page ) {
458 - return self::on_form_listing_page();
459 - }
460 -
461 - if ( ! self::is_admin_page( $page ) ) {
462 - return false;
463 - }
464 -
465 - if ( 'formidable-entries' === $page ) {
466 - $action = self::simple_get( 'frm_action' );
467 -
468 - if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) {
469 - return true;
470 - }
471 - }
472 -
473 - // Check edit or settings page.
474 - return ! self::simple_get( 'frm_action' );
475 - }
476 -
477 - /**
478 - * @since 6.20
479 - *
480 - * @return array<string>
481 - */
482 - private static function get_entries_listing_page_form_actions() {
483 - return array( 'list', 'destroy' );
484 - }
485 -
486 - /**
487 339 * Check for certain page in Formidable settings
488 340 *
489 341 * @since 2.0
490 342 *
@@ -494,13 +346,11 @@
494 346 */
495 347 public static function is_admin_page( $page = 'formidable' ) {
496 348 global $pagenow;
497 349 $get_page = self::simple_get( 'page', 'sanitize_title' );
498 -
499 350 if ( $pagenow ) {
500 - // Allow this to be true during ajax load i.e. ajax form builder loading
351 + // allow this to be true during ajax load i.e. ajax form builder loading
501 352 $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
502 -
503 353 if ( $is_page ) {
504 354 return true;
505 355 }
506 356 }
@@ -518,15 +368,15 @@
518 368 */
519 369 public static function is_view_builder_page() {
520 370 global $pagenow;
521 371
522 - if ( ! in_array( $pagenow, array( 'post.php', 'post-new.php', 'edit.php' ), true ) ) {
372 + if ( $pagenow !== 'post.php' && $pagenow !== 'post-new.php' && $pagenow !== 'edit.php' ) {
523 373 return false;
524 374 }
525 375
526 376 $post_type = self::simple_get( 'post_type', 'sanitize_title' );
527 377
528 - if ( ! $post_type ) {
378 + if ( empty( $post_type ) ) {
529 379 $post_id = self::simple_get( 'post', 'absint' );
530 380 $post = get_post( $post_id );
531 381 $post_type = $post ? $post->post_type : '';
532 382 }
@@ -544,9 +394,9 @@
544 394 public static function is_preview_page() {
545 395 global $pagenow;
546 396 $action = self::simple_get( 'action', 'sanitize_title' );
547 397
548 - return $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
398 + return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
549 399 }
550 400
551 401 /**
552 402 * Check for ajax except the form preview page
@@ -567,9 +417,8 @@
567 417 }
568 418
569 419 /**
570 420 * @since 2.0.8
571 - *
572 421 * @return bool
573 422 */
574 423 public static function prevent_caching() {
575 424 global $frm_vars;
@@ -587,9 +436,8 @@
587 436 $is_admin = is_admin() && ! wp_doing_ajax();
588 437
589 438 /**
590 439 * @since 6.0
591 - *
592 440 * @param bool $is_admin
593 441 */
594 442 return apply_filters( 'frm_is_admin', $is_admin );
595 443 }
@@ -604,15 +452,14 @@
604 452 *
605 453 * @return bool
606 454 */
607 455 public static function is_empty_value( $value, $empty = '' ) {
608 - return $value === array() || $value === $empty;
456 + return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
609 457 }
610 458
611 459 /**
612 460 * @param mixed $value
613 461 * @param string $empty
614 - *
615 462 * @return bool
616 463 */
617 464 public static function is_not_empty_value( $value, $empty = '' ) {
618 465 return ! self::is_empty_value( $value, $empty );
@@ -666,9 +513,8 @@
666 513 continue;
667 514 }
668 515
669 516 $key = self::get_server_value( $key );
670 -
671 517 foreach ( explode( ',', $key ) as $ip ) {
672 518 // Just to be safe.
673 519 $ip = trim( $ip );
674 520
@@ -724,26 +570,16 @@
724 570 */
725 571 return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
726 572 }
727 573
728 - /**
729 - * @param string $param
730 - * @param mixed $default
731 - * @param string $src
732 - * @param callable|string $sanitize
733 - *
734 - * @return mixed
735 - */
736 574 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
737 - if ( str_contains( $param, '[' ) ) {
575 + if ( strpos( $param, '[' ) ) {
738 576 $params = explode( '[', $param );
739 577 $param = $params[0];
740 578 }
741 579
742 580 if ( $src === 'get' ) {
743 - // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
744 - $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default );
745 -
581 + $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
746 582 if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
747 583 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
748 584 $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
749 585 }
@@ -758,19 +594,17 @@
758 594 )
759 595 );
760 596 }
761 597
762 - if ( ! isset( $params ) || ! is_array( $value ) || ! $value ) {
763 - return $value;
764 - }
598 + if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) {
599 + foreach ( $params as $k => $p ) {
600 + if ( ! $k || ! is_array( $value ) ) {
601 + continue;
602 + }
765 603
766 - foreach ( $params as $k => $p ) {
767 - if ( ! $k || ! is_array( $value ) ) {
768 - continue;
604 + $p = trim( $p, ']' );
605 + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
769 606 }
770 -
771 - $p = trim( $p, ']' );
772 - $value = $value[ $p ] ?? $default;
773 607 }
774 608
775 609 return $value;
776 610 }
@@ -781,9 +615,8 @@
781 615 * @param string $param The key we are trying to access data from in $_POST.
782 616 * @param mixed $default The default if nothing is being sent.
783 617 * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default.
784 618 * @param bool $serialized
785 - *
786 619 * @return mixed
787 620 */
788 621 public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
789 622 return self::get_simple_request(
@@ -803,9 +636,9 @@
803 636 * @param string $param
804 637 * @param string $sanitize
805 638 * @param string $default
806 639 *
807 - * @return array|int|string
640 + * @return array|string
808 641 */
809 642 public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
810 643 return self::get_simple_request(
811 644 array(
@@ -834,10 +667,10 @@
834 667 'sanitize' => 'sanitize_text_field',
835 668 'serialized' => false,
836 669 );
837 670 $args = wp_parse_args( $args, $defaults );
838 - $value = $args['default'];
839 671
672 + $value = $args['default'];
840 673 if ( $args['type'] === 'get' ) {
841 674 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
842 675 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
843 676 $value = wp_unslash( $_GET[ $args['param'] ] );
@@ -845,16 +678,16 @@
845 678 } elseif ( $args['type'] === 'post' ) {
846 679 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
847 680 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
848 681 $value = wp_unslash( $_POST[ $args['param'] ] );
849 -
850 682 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
851 683 self::unserialize_or_decode( $value );
852 684 }
853 685 }
854 686 } elseif ( isset( $_REQUEST[ $args['param'] ] ) ) {
855 - // phpcs:ignore phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
856 - $value = wp_unslash( $_REQUEST[ $args['param'] ] );
687 + // phpcs:ignore WordPress.Security.NonceVerification.Missing
688 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
689 + $value = wp_unslash( $_REQUEST[ $args['param'] ] );
857 690 }
858 691
859 692 self::sanitize_value( $args['sanitize'], $value );
860 693
@@ -867,13 +700,17 @@
867 700 * @since 2.0.8
868 701 *
869 702 * @param string $value
870 703 *
871 - * @return string Value.
704 + * @return string $value
872 705 */
873 706 public static function preserve_backslashes( $value ) {
874 707 // If backslashes have already been added, don't add them again
875 - return str_contains( $value, '\\\\' ) ? $value : addslashes( $value );
708 + if ( strpos( $value, '\\\\' ) === false ) {
709 + $value = addslashes( $value );
710 + }
711 +
712 + return $value;
876 713 }
877 714
878 715 /**
879 716 * Sanitize a value in-place.
@@ -880,9 +717,8 @@
880 717 * If $value is an array, the sanitize function will get called for each item.
881 718 *
882 719 * @param callable $sanitize
883 720 * @param mixed $value
884 - *
885 721 * @return void
886 722 */
887 723 public static function sanitize_value( $sanitize, &$value ) {
888 724 if ( ! $sanitize ) {
@@ -895,13 +731,11 @@
895 731 }
896 732
897 733 if ( is_array( $value ) ) {
898 734 $temp_values = $value;
899 -
900 735 foreach ( $temp_values as $k => $v ) {
901 736 self::sanitize_value( $sanitize, $value[ $k ] );
902 737 }
903 -
904 738 return;
905 739 }
906 740
907 741 $value = call_user_func( $sanitize, $value );
@@ -906,17 +740,10 @@
906 740
907 741 $value = call_user_func( $sanitize, $value );
908 742 }
909 743
910 - /**
911 - * @param array $sanitize_method
912 - * @param array $values
913 - *
914 - * @return void
915 - */
916 744 public static function sanitize_request( $sanitize_method, &$values ) {
917 745 $temp_values = $values;
918 -
919 746 foreach ( $temp_values as $k => $val ) {
920 747 if ( isset( $sanitize_method[ $k ] ) ) {
921 748 $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
922 749 }
@@ -926,9 +753,8 @@
926 753 /**
927 754 * @since 4.0.04
928 755 *
929 756 * @param mixed $value
930 - *
931 757 * @return void
932 758 */
933 759 public static function sanitize_with_html( &$value ) {
934 760 if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) {
@@ -947,12 +773,8 @@
947 773 *
948 774 * @param string $value
949 775 */
950 776 public static function strip_most_html( $value ) {
951 - if ( '' === $value ) {
952 - return $value;
953 - }
954 -
955 777 $allowed_html = array(
956 778 'b' => array(),
957 779 'br' => array(),
958 780 'strong' => array(),
@@ -977,15 +799,12 @@
977 799 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&amp;'
978 800 * this MUST be done, else we'll be back to the '& entity' problem.
979 801 *
980 802 * @since 4.0.04
981 - *
982 - * @param mixed $value Value to decode, passed by reference.
983 803 */
984 804 public static function decode_specialchars( &$value ) {
985 805 if ( is_array( $value ) ) {
986 806 $temp_values = $value;
987 -
988 807 foreach ( $temp_values as $k => $v ) {
989 808 self::decode_specialchars( $value[ $k ] );
990 809 }
991 810 } else {
@@ -999,13 +818,13 @@
999 818 * Adapted from wp_specialchars_decode().
1000 819 *
1001 820 * @since 4.03.01
1002 821 *
1003 - * @param string $string The string to prep, passed by reference.
822 + * @param string $string The string to prep.
1004 823 */
1005 824 private static function decode_amp( &$string ) {
1006 825 // Don't bother if there are no entities - saves a lot of processing
1007 - if ( ! $string || ! str_contains( $string, '&' ) ) {
826 + if ( empty( $string ) || strpos( $string, '&' ) === false ) {
1008 827 return;
1009 828 }
1010 829
1011 830 $translation = array(
@@ -1043,29 +862,17 @@
1043 862 * Sanitize the value, and allow some HTML
1044 863 *
1045 864 * @since 2.0
1046 865 *
1047 - * @param string $value The value to sanitize.
1048 - * @param array|string $allowed Allowed HTML tags and attributes, or 'all' for defaults.
866 + * @param string $value
867 + * @param array|string $allowed 'all' for everything included as defaults.
1049 868 *
1050 869 * @return string
1051 870 */
1052 871 public static function kses( $value, $allowed = array() ) {
1053 - return wp_kses( $value, self::allowed_html( $allowed ) );
1054 - }
872 + $allowed_html = self::allowed_html( $allowed );
1055 873
1056 - /**
1057 - * Sanitizes and echoes a given value.
1058 - *
1059 - * @since 6.18
1060 - *
1061 - * @param string $value The value to sanitize and output.
1062 - * @param array|string $allowed Allowed HTML tags and attributes.
1063 - *
1064 - * @return void
1065 - */
1066 - public static function kses_echo( $value, $allowed = array() ) {
1067 - echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
874 + return wp_kses( $value, $allowed_html );
1068 875 }
1069 876
1070 877 /**
1071 878 * The regular kses function strips [button_action] from submit button HTML.
@@ -1072,23 +879,21 @@
1072 879 *
1073 880 * @since 5.0.13
1074 881 *
1075 882 * @param string $html
1076 - *
1077 883 * @return string
1078 884 */
1079 885 public static function kses_submit_button( $html ) {
1080 - $included_button_action = str_contains( $html, '[button_action]' );
1081 - $included_back_hook = str_contains( $html, '[back_hook]' );
1082 - $included_draft_hook = str_contains( $html, '[draft_hook]' );
886 + $included_button_action = false !== strpos( $html, '[button_action]' );
887 + $included_back_hook = false !== strpos( $html, '[back_hook]' );
888 + $included_draft_hook = false !== strpos( $html, '[draft_hook]' );
1083 889 add_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1084 890 add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1085 891 $html = self::kses( $html, 'all' );
1086 892 remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1087 893 remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1088 -
1089 894 if ( $included_button_action ) {
1090 - if ( str_contains( $html, '<input type="submit"' ) ) {
895 + if ( false !== strpos( $html, '<input type="submit"' ) ) {
1091 896 $pattern = '/(<input type="submit")([^>]*)(\/>)/';
1092 897 $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
1093 898 } else {
1094 899 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
@@ -1094,17 +899,14 @@
1094 899 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
1095 900 $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
1096 901 }
1097 902 }
1098 -
1099 903 if ( $included_back_hook ) {
1100 904 $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html );
1101 905 }
1102 -
1103 906 if ( $included_draft_hook ) {
1104 - return str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
907 + $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
1105 908 }
1106 -
1107 909 return $html;
1108 910 }
1109 911
1110 912 /**
@@ -1110,9 +912,8 @@
1110 912 /**
1111 913 * @since 5.0.13
1112 914 *
1113 915 * @param array $allowed_attr
1114 - *
1115 916 * @return array
1116 917 */
1117 918 public static function allow_visibility_style( $allowed_attr ) {
1118 919 $allowed_attr[] = 'visibility';
@@ -1122,9 +923,8 @@
1122 923 /**
1123 924 * @since 5.0.13
1124 925 *
1125 926 * @param array $allowed_html
1126 - *
1127 927 * @return array
1128 928 */
1129 929 public static function add_allowed_submit_button_tags( $allowed_html ) {
1130 930 $allowed_html['input'] = array(
@@ -1141,22 +941,17 @@
1141 941 }
1142 942
1143 943 /**
1144 944 * @since 2.05.03
1145 - *
1146 - * @param array|string $allowed
1147 - *
1148 - * @return array
1149 945 */
1150 946 private static function allowed_html( $allowed ) {
1151 947 $html = self::safe_html();
1152 948 $allowed_html = array();
1153 -
1154 949 if ( $allowed === 'all' ) {
1155 950 $allowed_html = $html;
1156 - } elseif ( $allowed ) {
951 + } elseif ( ! empty( $allowed ) ) {
1157 952 foreach ( (array) $allowed as $a ) {
1158 - $allowed_html[ $a ] = $html[ $a ] ?? array();
953 + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
1159 954 }
1160 955 }
1161 956
1162 957 return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html );
@@ -1163,10 +958,8 @@
1163 958 }
1164 959
1165 960 /**
1166 961 * @since 2.05.03
1167 - *
1168 - * @return array
1169 962 */
1170 963 private static function safe_html() {
1171 964 $allow_class = array(
1172 965 'class' => true,
@@ -1299,13 +1092,8 @@
1299 1092 ),
1300 1093 'legend' => array(
1301 1094 'class' => true,
1302 1095 ),
1303 - 'option' => array(
1304 - 'class' => true,
1305 - 'value' => true,
1306 - 'selected' => true,
1307 - ),
1308 1096 );
1309 1097 }
1310 1098
1311 1099 /**
@@ -1318,16 +1106,14 @@
1318 1106 return;
1319 1107 }
1320 1108
1321 1109 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
1322 -
1323 - if ( ! $action_name ) {
1110 + if ( empty( $action_name ) ) {
1324 1111 return;
1325 1112 }
1326 1113
1327 1114 $new_action = self::get_param( $action_name, '', 'get', 'sanitize_text_field' );
1328 -
1329 - if ( $new_action ) {
1115 + if ( ! empty( $new_action ) ) {
1330 1116 $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
1331 1117 }
1332 1118 }
1333 1119
@@ -1334,23 +1120,21 @@
1334 1120 /**
1335 1121 * Check the WP query for a parameter
1336 1122 *
1337 1123 * @since 2.0
1338 - *
1339 - * @param array|string $value
1340 - * @param string $param
1341 - *
1342 1124 * @return array|string
1343 1125 */
1344 1126 public static function get_query_var( $value, $param ) {
1345 - // phpcs:ignore Universal.Operators.StrictComparisons
1346 1127 if ( $value != '' ) {
1347 1128 return $value;
1348 1129 }
1349 1130
1350 1131 global $wp_query;
1132 + if ( isset( $wp_query->query_vars[ $param ] ) ) {
1133 + $value = $wp_query->query_vars[ $param ];
1134 + }
1351 1135
1352 - return $wp_query->query_vars[ $param ] ?? $value;
1136 + return $value;
1353 1137 }
1354 1138
1355 1139 /**
1356 1140 * Try to show the SVG if possible. Otherwise, use the font icon.
@@ -1358,21 +1142,20 @@
1358 1142 * @since 4.0.02
1359 1143 *
1360 1144 * @param string $class
1361 1145 * @param array $atts
1362 - *
1363 1146 * @return string|null
1364 1147 */
1365 1148 public static function icon_by_class( $class, $atts = array() ) {
1366 1149 $echo = ! isset( $atts['echo'] ) || $atts['echo'];
1367 -
1368 1150 if ( isset( $atts['echo'] ) ) {
1369 1151 unset( $atts['echo'] );
1370 1152 }
1371 1153
1372 1154 $html_atts = self::array_to_html_params( $atts );
1373 - $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1374 1155
1156 + $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1157 +
1375 1158 // Replace icons that have been removed or renamed.
1376 1159 $deprecated = array(
1377 1160 'frm_clone_solid_icon' => 'frm_clone_icon',
1378 1161 'frm_keyalt_icon' => 'frm_key_icon',
@@ -1377,9 +1160,8 @@
1377 1160 'frm_clone_solid_icon' => 'frm_clone_icon',
1378 1161 'frm_keyalt_icon' => 'frm_key_icon',
1379 1162 'frm_keyalt_solid_icon' => 'frm_key_solid_icon',
1380 1163 );
1381 -
1382 1164 if ( isset( $deprecated[ $icon ] ) ) {
1383 1165 $icon = $deprecated[ $icon ];
1384 1166 $class = str_replace( $icon, $deprecated[ $icon ], $class );
1385 1167 }
@@ -1386,24 +1168,21 @@
1386 1168
1387 1169 if ( $icon === $class ) {
1388 1170 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
1389 1171 } else {
1390 - $class = str_contains( $icon, ' ' ) ? ' ' . $icon : '';
1391 -
1392 - if ( str_contains( $icon, ' ' ) ) {
1172 + $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
1173 + if ( strpos( $icon, ' ' ) ) {
1393 1174 $icon = explode( ' ', $icon );
1394 1175 $icon = reset( $icon );
1395 1176 }
1396 -
1397 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use href="#' . esc_attr( $icon ) . '" /></svg>';
1177 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>';
1398 1178 }
1399 1179
1400 1180 if ( $echo ) {
1401 1181 echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1402 - return null;
1182 + } else {
1183 + return $icon;
1403 1184 }
1404 -
1405 - return $icon;
1406 1185 }
1407 1186
1408 1187 /**
1409 1188 * Run kses for icons. It needs to add a few filters first in order to preserve some custom style values.
@@ -1410,9 +1189,8 @@
1410 1189 *
1411 1190 * @since 5.0.13
1412 1191 *
1413 1192 * @param string $icon
1414 - *
1415 1193 * @return string
1416 1194 */
1417 1195 public static function kses_icon( $icon ) {
1418 1196 add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
@@ -1428,15 +1206,13 @@
1428 1206 /**
1429 1207 * @since 5.0.13.1
1430 1208 *
1431 1209 * @param array $allowed_html
1432 - *
1433 1210 * @return array
1434 1211 */
1435 1212 public static function add_allowed_icon_tags( $allowed_html ) {
1436 1213 $allowed_html['svg']['data-open'] = true;
1437 1214 $allowed_html['svg']['title'] = true;
1438 - $allowed_html['svg']['tabindex'] = true;
1439 1215 return $allowed_html;
1440 1216 }
1441 1217
1442 1218 /**
@@ -1442,9 +1218,8 @@
1442 1218 /**
1443 1219 * @since 5.0.13
1444 1220 *
1445 1221 * @param array $allowed_attr
1446 - *
1447 1222 * @return array
1448 1223 */
1449 1224 public static function allow_vars_in_styles( $allowed_attr ) {
1450 1225 $allowed_attr[] = '--primary-700';
@@ -1457,9 +1232,9 @@
1457 1232 * @param bool $allow_css
1458 1233 * @param string $css_string
1459 1234 */
1460 1235 public static function allow_style( $allow_css, $css_string ) {
1461 - if ( ! $allow_css && str_starts_with( $css_string, '--primary-700:' ) ) {
1236 + if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
1462 1237 $split = explode( ':', $css_string, 2 );
1463 1238 $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1464 1239 }
1465 1240 return $allow_css;
@@ -1468,22 +1243,19 @@
1468 1243 /**
1469 1244 * @since 5.0.13
1470 1245 *
1471 1246 * @param string $value
1472 - *
1473 1247 * @return bool
1474 1248 */
1475 1249 private static function is_a_valid_color( $value ) {
1476 1250 $match = 0;
1477 -
1478 - if ( str_starts_with( $value, 'rgba(' ) ) {
1251 + if ( 0 === strpos( $value, 'rgba(' ) ) {
1479 1252 $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(' ) ) {
1253 + } elseif ( 0 === strpos( $value, 'rgb(' ) ) {
1481 1254 $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value );
1482 - } elseif ( str_starts_with( $value, '#' ) ) {
1255 + } elseif ( 0 === strpos( $value, '#' ) ) {
1483 1256 $match = preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})\b$/', $value );
1484 1257 }
1485 -
1486 1258 return (bool) $match;
1487 1259 }
1488 1260
1489 1261 /**
@@ -1489,9 +1261,8 @@
1489 1261 /**
1490 1262 * Include svg images.
1491 1263 *
1492 1264 * @since 4.0.02
1493 - *
1494 1265 * @return void
1495 1266 */
1496 1267 public static function include_svg() {
1497 1268 if ( self::$included_svg ) {
@@ -1510,20 +1281,17 @@
1510 1281 * @since 5.0.13 added $echo parameter.
1511 1282 *
1512 1283 * @param array $atts
1513 1284 * @param bool $echo
1514 - *
1515 1285 * @return string|void
1516 1286 */
1517 1287 public static function array_to_html_params( $atts, $echo = false ) {
1518 1288 $callback = function () use ( $atts ) {
1519 - if ( ! $atts ) {
1520 - return;
1289 + if ( $atts ) {
1290 + foreach ( $atts as $key => $value ) {
1291 + echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1292 + }
1521 1293 }
1522 -
1523 - foreach ( $atts as $key => $value ) {
1524 - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1525 - }
1526 1294 };
1527 1295 return self::clip( $callback, $echo );
1528 1296 }
1529 1297
@@ -1533,9 +1301,8 @@
1533 1301 * @since 5.0.13
1534 1302 *
1535 1303 * @param Closure $echo_function
1536 1304 * @param bool $echo
1537 - *
1538 1305 * @return string|null
1539 1306 */
1540 1307 public static function clip( $echo_function, $echo = false ) {
1541 1308 if ( ! $echo ) {
@@ -1545,9 +1312,13 @@
1545 1312 if ( is_callable( $echo_function ) ) {
1546 1313 $echo_function();
1547 1314 }
1548 1315
1549 - return $echo ? null : ob_get_clean();
1316 + if ( ! $echo ) {
1317 + $return = ob_get_contents();
1318 + ob_end_clean();
1319 + return $return;
1320 + }
1550 1321 }
1551 1322
1552 1323 /**
1553 1324 * @since 3.0
@@ -1552,18 +1323,15 @@
1552 1323 /**
1553 1324 * @since 3.0
1554 1325 *
1555 1326 * @param array $atts
1556 - *
1557 1327 * @return void
1558 1328 */
1559 1329 public static function get_admin_header( $atts ) {
1560 1330 $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] );
1561 -
1562 1331 if ( empty( $atts['close'] ) ) {
1563 1332 $atts['close'] = admin_url( 'admin.php?page=formidable' );
1564 1333 }
1565 -
1566 1334 if ( ! isset( $atts['import_link'] ) ) {
1567 1335 $atts['import_link'] = false;
1568 1336 }
1569 1337
@@ -1573,19 +1341,16 @@
1573 1341 /**
1574 1342 * @since 6.0
1575 1343 *
1576 1344 * @param string $type
1577 - *
1578 1345 * @return void
1579 1346 */
1580 1347 public static function import_link( $type = 'secondary' ) {
1581 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1582 1348 ?>
1583 1349 <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-import' ) ); ?>" class="button frm-button-<?php echo esc_attr( $type ); ?> frm_animate_bg">
1584 1350 <?php esc_html_e( 'Import', 'formidable' ); ?>
1585 1351 </a>
1586 1352 <?php
1587 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1588 1353 }
1589 1354
1590 1355 /**
1591 1356 * Print applicable admin banner.
@@ -1592,9 +1357,8 @@
1592 1357 *
1593 1358 * @since 5.4.2
1594 1359 *
1595 1360 * @param bool $should_show_lite_upgrade
1596 - *
1597 1361 * @return void
1598 1362 */
1599 1363 public static function print_admin_banner( $should_show_lite_upgrade ) {
1600 1364 if ( ! current_user_can( 'administrator' ) ) {
@@ -1601,44 +1365,31 @@
1601 1365 FrmInbox::maybe_show_banner();
1602 1366 return;
1603 1367 }
1604 1368
1605 - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1369 + if ( self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1606 1370 // Print license warning or inbox banner and exit if either prints.
1607 1371 // And exit before printing the upgrade bar if it shouldn't be shown.
1608 1372 return;
1609 1373 }
1610 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1611 1374 ?>
1612 1375 <div class="frm-upgrade-bar">
1613 - <div class="frm-upgrade-bar-inner">
1614 1376 <?php
1615 - $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' );
1616 -
1617 - if ( ! $cta_text ) {
1618 - $cta_text = __( 'upgrading to PRO', 'formidable' );
1619 - }
1620 -
1621 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' );
1622 - $utm = array(
1623 - 'campaign' => 'settings-license',
1624 - 'content' => 'lite-banner',
1377 + $upgrade_link = self::admin_upgrade_link(
1378 + array(
1379 + 'medium' => 'settings-license',
1380 + 'content' => 'lite-banner',
1381 + )
1625 1382 );
1626 -
1627 - $upgrade_link = $upgrade_link ? self::maybe_add_missing_utm( $upgrade_link, $utm ) : self::admin_upgrade_link( $utm );
1628 -
1629 1383 printf(
1630 - /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */
1631 - esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ),
1384 + /* translators: %1$s: Start link HTML, %2$s: End link HTML */
1385 + esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$supgrading to PRO%2$s.', 'formidable' ),
1632 1386 '<a href="' . esc_url( $upgrade_link ) . '">',
1633 - esc_html( $cta_text ),
1634 1387 '</a>'
1635 1388 );
1636 1389 ?>
1637 - </div>
1638 1390 </div>
1639 1391 <?php
1640 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1641 1392 }
1642 1393
1643 1394 /**
1644 1395 * @since 5.4.2
@@ -1652,9 +1403,8 @@
1652 1403 /**
1653 1404 * Render a button for a new item (Form, Application, etc).
1654 1405 *
1655 1406 * @since 3.0
1656 - *
1657 1407 * @param array $atts {
1658 1408 * Details about the button.
1659 1409 *
1660 1410 * @type array $link_hook Custom link hook, calls do_action and exits early.
@@ -1661,9 +1411,8 @@
1661 1411 * @type string $new_link Href value, default #.
1662 1412 * @type string $class Custom class names, space separated.
1663 1413 * @type string $button_text Button text. Default "Add New".
1664 1414 * }
1665 - *
1666 1415 * @return void
1667 1416 */
1668 1417 public static function add_new_item_link( $atts ) {
1669 1418 if ( isset( $atts['link_hook'] ) ) {
@@ -1689,12 +1438,8 @@
1689 1438 }
1690 1439
1691 1440 /**
1692 1441 * @since 3.06
1693 - *
1694 - * @param array $atts
1695 - *
1696 - * @return void
1697 1442 */
1698 1443 public static function show_search_box( $atts ) {
1699 1444 $defaults = array(
1700 1445 'placeholder' => '',
@@ -1701,9 +1446,8 @@
1701 1446 'tosearch' => '',
1702 1447 'text' => __( 'Search', 'formidable' ),
1703 1448 'input_id' => '',
1704 1449 'value' => false,
1705 - 'class' => '',
1706 1450 );
1707 1451 $atts = array_merge( $defaults, $atts );
1708 1452
1709 1453 if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) {
@@ -1710,9 +1454,8 @@
1710 1454 $atts['tosearch'] = 'frm-card';
1711 1455 }
1712 1456
1713 1457 $class = 'frm-search-input';
1714 -
1715 1458 if ( ! empty( $atts['tosearch'] ) ) {
1716 1459 $class .= ' frm-auto-search';
1717 1460 }
1718 1461
@@ -1736,15 +1479,14 @@
1736 1479
1737 1480 if ( ! empty( $atts['tosearch'] ) ) {
1738 1481 $input_atts['autocomplete'] = 'off';
1739 1482 }
1740 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1741 1483 ?>
1742 - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>">
1484 + <p class="frm-search">
1743 1485 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
1744 1486 <?php echo esc_html( $atts['text'] ); ?>:
1745 1487 </label>
1746 - <?php self::icon_by_class( 'frmfont frm_search_icon frm_svg20' ); ?>
1488 + <span class="frmfont frm_search_icon"></span>
1747 1489 <input <?php self::array_to_html_params( $input_atts, true ); ?> />
1748 1490 <?php
1749 1491 if ( empty( $atts['tosearch'] ) ) {
1750 1492 submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
@@ -1751,21 +1493,17 @@
1751 1493 }
1752 1494 ?>
1753 1495 </p>
1754 1496 <?php
1755 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1756 1497 }
1757 1498
1758 1499 /**
1759 - * @param string $type Hook type slug.
1760 - * @param object|null $object Optional related object.
1761 - *
1500 + * @param string $type
1762 1501 * @return void
1763 1502 */
1764 1503 public static function trigger_hook_load( $type, $object = null ) {
1765 1504 // Only load the form hooks once.
1766 1505 $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
1767 -
1768 1506 if ( ! $hooks_loaded ) {
1769 1507 do_action( 'frm_load_' . $type . '_hooks' );
1770 1508 }
1771 1509 }
@@ -1824,14 +1562,14 @@
1824 1562 * True when value is 1, true, 'true', 'yes'
1825 1563 *
1826 1564 * @since 1.07.10
1827 1565 *
1828 - * @param bool|int|string $value The value to compare.
1566 + * @param string $value The value to compare.
1829 1567 *
1830 1568 * @return bool
1831 1569 */
1832 1570 public static function is_true( $value ) {
1833 - return true === $value || '1' === (string) $value || 'true' === $value || 'yes' === $value;
1571 + return true === $value || 1 == $value || 'true' === $value || 'yes' === $value;
1834 1572 }
1835 1573
1836 1574 /**
1837 1575 * Gets all post from a specific post type.
@@ -1839,9 +1577,8 @@
1839 1577 *
1840 1578 * @since 4.10.01 Add `$post_type` argument.
1841 1579 *
1842 1580 * @param string $post_type Post type to query. Default is `page`.
1843 - *
1844 1581 * @return WP_Post[]
1845 1582 */
1846 1583 public static function get_pages( $post_type = 'page' ) {
1847 1584 $query = array(
@@ -1860,9 +1597,8 @@
1860 1597 *
1861 1598 * @since 5.0.09
1862 1599 *
1863 1600 * @param string $post_type Post type to query. Default is `page`.
1864 - *
1865 1601 * @return array
1866 1602 */
1867 1603 public static function get_post_ids_and_titles( $post_type = 'page' ) {
1868 1604 return FrmDb::get_results(
@@ -1887,12 +1623,13 @@
1887 1623 *
1888 1624 * @param array $args Selection arguments.
1889 1625 */
1890 1626 public static function maybe_autocomplete_pages_options( $args ) {
1891 - $args = self::preformat_selection_args( $args );
1627 + $args = self::preformat_selection_args( $args );
1628 +
1892 1629 $pages_count = wp_count_posts( $args['post_type'] );
1893 1630
1894 - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) {
1631 + if ( $pages_count->publish <= 50 ) {
1895 1632 self::wp_pages_dropdown( $args );
1896 1633 return;
1897 1634 }
1898 1635
@@ -1916,109 +1653,8 @@
1916 1653 <?php
1917 1654 }
1918 1655
1919 1656 /**
1920 - * Maybe show an HTML select or autocomplete input based on the number of options.
1921 - *
1922 - * @since 6.21
1923 - *
1924 - * @param array $args Args. See the method for details.
1925 - */
1926 - public static function maybe_autocomplete_options( $args ) {
1927 - $defaults = array(
1928 - 'truncate' => false,
1929 - 'placeholder' => ' ',
1930 - 'name' => '',
1931 - 'id' => '',
1932 - 'selected' => '',
1933 - 'source' => array(),
1934 - 'dropdown_limit' => 50,
1935 - 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ),
1936 - 'value_key' => 'value',
1937 - 'label_key' => 'label',
1938 - );
1939 -
1940 - $args = wp_parse_args( $args, $defaults );
1941 - $html_attrs = array();
1942 -
1943 - if ( ! empty( $args['name'] ) ) {
1944 - $html_attrs['name'] = $args['name'];
1945 - }
1946 -
1947 - if ( ! empty( $args['id'] ) ) {
1948 - $html_attrs['id'] = $args['id'];
1949 - }
1950 -
1951 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1952 - if ( count( $args['source'] ) <= $args['dropdown_limit'] ) {
1953 - ?>
1954 - <select <?php self::array_to_html_params( $html_attrs, true ); ?>>
1955 - <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
1956 - <?php
1957 - foreach ( $args['source'] as $key => $source ) :
1958 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1959 -
1960 - if ( ! empty( $args['truncate'] ) ) {
1961 - $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] );
1962 - }
1963 - ?>
1964 - <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 ?>
1965 - <?php endforeach; ?>
1966 - </select>
1967 - <?php
1968 - return;
1969 - }
1970 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1971 -
1972 - $options = array();
1973 - $autocomplete_value = '';
1974 -
1975 - foreach ( $args['source'] as $key => $source ) {
1976 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1977 -
1978 - if ( $value_label['value'] === $args['selected'] ) {
1979 - $autocomplete_value = $value_label['label'];
1980 - }
1981 -
1982 - $options[] = $value_label;
1983 - }
1984 -
1985 - $html_attrs['type'] = 'hidden';
1986 - $html_attrs['class'] = 'frm_autocomplete_value_input';
1987 - $html_attrs['value'] = $args['selected'];
1988 - ?>
1989 - <input type="text" class="frm-custom-search"
1990 - data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>"
1991 - placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>"
1992 - value="<?php echo esc_attr( $autocomplete_value ); ?>" />
1993 - <input <?php self::array_to_html_params( $html_attrs, true ); ?> />
1994 - <?php
1995 - }
1996 -
1997 - /**
1998 - * Gets dropdown value and label from autodropdown option.
1999 - *
2000 - * @since 6.21
2001 - *
2002 - * @param array|string $option Autocomplete option.
2003 - * @param string $key Array key of the option.
2004 - * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}.
2005 - *
2006 - * @return array
2007 - */
2008 - private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) {
2009 - if ( is_array( $option ) ) {
2010 - $value = $option[ $args['value_key'] ] ?? '';
2011 - $label = $option[ $args['label_key'] ] ?? '';
2012 - } else {
2013 - $value = $key;
2014 - $label = $option;
2015 - }
2016 -
2017 - return compact( 'value', 'label' );
2018 - }
2019 -
2020 - /**
2021 1657 * @param array $args
2022 1658 * @param string $page_id Deprecated.
2023 1659 * @param bool $truncate Deprecated.
2024 1660 */
@@ -2026,9 +1662,9 @@
2026 1662 self::prep_page_dropdown_params( $page_id, $truncate, $args );
2027 1663
2028 1664 $pages = self::get_post_ids_and_titles( $args['post_type'] );
2029 1665 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
2030 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1666 +
2031 1667 ?>
2032 1668 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
2033 1669 <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
2034 1670 <?php foreach ( $pages as $page ) { ?>
@@ -2037,9 +1673,8 @@
2037 1673 </option>
2038 1674 <?php } ?>
2039 1675 </select>
2040 1676 <?php
2041 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
2042 1677 }
2043 1678
2044 1679 /**
2045 1680 * Fill in missing parameters passed to wp_pages_dropdown().
@@ -2045,14 +1680,8 @@
2045 1680 * Fill in missing parameters passed to wp_pages_dropdown().
2046 1681 * This is for reverse compatibility with switching 3 params to 1.
2047 1682 *
2048 1683 * @since 4.03.06
2049 - *
2050 - * @param string $page_id Deprecated.
2051 - * @param bool $truncate Deprecated.
2052 - * @param mixed $args
2053 - *
2054 - * @return void
2055 1684 */
2056 1685 private static function prep_page_dropdown_params( $page_id, $truncate, &$args ) {
2057 1686 if ( ! is_array( $args ) ) {
2058 1687 $args = array(
@@ -2069,12 +1698,8 @@
2069 1698 * Filter to format args for page dropdown or autocomplete
2070 1699 *
2071 1700 * @since 4.03.06
2072 1701 * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array.
2073 - *
2074 - * @param array $args
2075 - *
2076 - * @return array
2077 1702 */
2078 1703 private static function preformat_selection_args( $args ) {
2079 1704 $defaults = array(
2080 1705 'truncate' => false,
@@ -2087,18 +1712,13 @@
2087 1712
2088 1713 return array_merge( $defaults, $args );
2089 1714 }
2090 1715
2091 - /**
2092 - * @param int $post_id
2093 - *
2094 - * @return string
2095 - */
2096 1716 public static function post_edit_link( $post_id ) {
2097 1717 $post = get_post( $post_id );
2098 -
2099 1718 if ( $post ) {
2100 1719 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1720 +
2101 1721 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
2102 1722 }
2103 1723
2104 1724 return '';
@@ -2111,9 +1731,11 @@
2111 1731 *
2112 1732 * @return bool
2113 1733 */
2114 1734 public static function is_full_screen() {
2115 - return self::is_form_builder_page() || self::is_style_editor_page() || self::is_full_screen_view_builder_page();
1735 + return self::is_form_builder_page() ||
1736 + self::is_style_editor_page() ||
1737 + self::is_full_screen_view_builder_page();
2116 1738 }
2117 1739
2118 1740 /**
2119 1741 * Check if user is on the style editor or its alternative URL.
@@ -2123,9 +1745,8 @@
2123 1745 * @since 5.5.3
2124 1746 * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
2125 1747 *
2126 1748 * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
2127 - *
2128 1749 * @return bool
2129 1750 */
2130 1751 public static function is_style_editor_page( $view = '' ) {
2131 1752 if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
@@ -2162,9 +1783,8 @@
2162 1783 * @param array|string $capability
2163 1784 * @param string $multiple 'single' and 'multiple'.
2164 1785 */
2165 1786 public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
2166 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
2167 1787 ?>
2168 1788 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>"
2169 1789 <?php echo 'multiple' === $multiple ? 'multiple="multiple"' : ''; ?>
2170 1790 class="frm_multiselect">
@@ -2170,14 +1790,12 @@
2170 1790 class="frm_multiselect">
2171 1791 <?php self::roles_options( $capability ); ?>
2172 1792 </select>
2173 1793 <?php
2174 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
2175 1794 }
2176 1795
2177 1796 /**
2178 1797 * @since 4.07
2179 - *
2180 1798 * @param array|string $selected
2181 1799 * @param string $current
2182 1800 */
2183 1801 private static function selected( $selected, $current ) {
@@ -2192,9 +1810,8 @@
2192 1810 * @param array|string $capability
2193 1811 */
2194 1812 public static function roles_options( $capability ) {
2195 1813 global $frm_vars;
2196 -
2197 1814 if ( isset( $frm_vars['editable_roles'] ) ) {
2198 1815 $editable_roles = $frm_vars['editable_roles'];
2199 1816 } else {
2200 1817 $editable_roles = get_editable_roles();
@@ -2203,9 +1820,9 @@
2203 1820
2204 1821 foreach ( $editable_roles as $role => $details ) {
2205 1822 $name = translate_user_role( $details['name'] );
2206 1823 ?>
2207 - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option>
1824 + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?> </option>
2208 1825 <?php
2209 1826 unset( $role, $details );
2210 1827 }
2211 1828 }
@@ -2215,9 +1832,8 @@
2215 1832 *
2216 1833 * @since 5.0 Parameter `$type` supports `pro_only` value.
2217 1834 *
2218 1835 * @param string $type Supports `auto`, `pro`, or `pro_only`.
2219 - *
2220 1836 * @return array
2221 1837 */
2222 1838 public static function frm_capabilities( $type = 'auto' ) {
2223 1839 if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
@@ -2235,8 +1851,14 @@
2235 1851 * @param array<string,string> $pro_cap
2236 1852 */
2237 1853 $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
2238 1854
1855 + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) {
1856 + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date.
1857 + // This was added in 6.5.4. Remove this in the future.
1858 + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
1859 + }
1860 +
2239 1861 if ( 'pro_only' === $type ) {
2240 1862 return $pro_cap;
2241 1863 }
2242 1864
@@ -2282,18 +1904,21 @@
2282 1904 if ( $role === 'loggedin' || ! $role ) {
2283 1905 return is_user_logged_in();
2284 1906 }
2285 1907
2286 - if ( (int) $role === 1 ) {
1908 + if ( $role == 1 ) {
2287 1909 $role = 'administrator';
2288 1910 }
2289 1911
2290 - return is_user_logged_in() ? current_user_can( $role ) : false;
1912 + if ( ! is_user_logged_in() ) {
1913 + return false;
1914 + }
1915 +
1916 + return current_user_can( $role );
2291 1917 }
2292 1918
2293 1919 /**
2294 1920 * @param array|string $needed_role
2295 - *
2296 1921 * @return bool
2297 1922 */
2298 1923 public static function user_has_permission( $needed_role ) {
2299 1924 if ( is_array( $needed_role ) ) {
@@ -2307,20 +1932,18 @@
2307 1932 }
2308 1933
2309 1934 $can = self::current_user_can( $needed_role );
2310 1935
2311 - if ( $can || in_array( $needed_role, array( '-1', 'loggedout' ), true ) ) {
1936 + if ( $can || in_array( $needed_role, array( '-1', 'loggedout' ) ) ) {
2312 1937 return $can;
2313 1938 }
2314 1939
2315 1940 $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
2316 -
2317 1941 foreach ( $roles as $role ) {
2318 1942 if ( current_user_can( $role ) ) {
2319 1943 return true;
2320 1944 }
2321 -
2322 - if ( $role === $needed_role ) {
1945 + if ( $role == $needed_role ) {
2323 1946 break;
2324 1947 }
2325 1948 }
2326 1949
@@ -2338,11 +1961,11 @@
2338 1961 if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) {
2339 1962 return;
2340 1963 }
2341 1964
2342 - $user = new WP_User( get_current_user_id() );
1965 + $user_id = get_current_user_id();
1966 + $user = new WP_User( $user_id );
2343 1967 $frm_roles = self::frm_capabilities();
2344 -
2345 1968 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2346 1969 $user->add_cap( $frm_role );
2347 1970 unset( $frm_role, $frm_role_description );
2348 1971 }
@@ -2353,22 +1976,18 @@
2353 1976 *
2354 1977 * @since 2.0.6
2355 1978 *
2356 1979 * @param string $cap
2357 - *
2358 1980 * @return void
2359 1981 */
2360 1982 public static function force_capability( $cap = 'frm_change_settings' ) {
2361 - if ( ! current_user_can( 'administrator' ) || current_user_can( $cap ) ) {
2362 - return;
1983 + if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
1984 + $role = get_role( 'administrator' );
1985 + $frm_roles = self::frm_capabilities();
1986 + foreach ( $frm_roles as $frm_role => $frm_role_description ) {
1987 + $role->add_cap( $frm_role );
1988 + }
2363 1989 }
2364 -
2365 - $role = get_role( 'administrator' );
2366 - $frm_roles = self::frm_capabilities();
2367 -
2368 - foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2369 - $role->add_cap( $frm_role );
2370 - }
2371 1990 }
2372 1991
2373 1992 /**
2374 1993 * Check if the user has permission for action.
@@ -2376,22 +1995,17 @@
2376 1995 *
2377 1996 * @since 2.0
2378 1997 *
2379 1998 * @param string $permission
2380 - * @param string $show_message
2381 1999 */
2382 2000 public static function permission_check( $permission, $show_message = 'show' ) {
2383 2001 $permission_error = self::permission_nonce_error( $permission );
2384 -
2385 - if ( $permission_error === false ) {
2386 - return;
2002 + if ( $permission_error !== false ) {
2003 + if ( 'hide' == $show_message ) {
2004 + $permission_error = '';
2005 + }
2006 + wp_die( esc_html( $permission_error ) );
2387 2007 }
2388 -
2389 - if ( 'hide' === $show_message ) {
2390 - $permission_error = '';
2391 - }
2392 -
2393 - wp_die( esc_html( $permission_error ) );
2394 2008 }
2395 2009
2396 2010 /**
2397 2011 * Check user permission and nonce
@@ -2398,27 +2012,24 @@
2398 2012 *
2399 2013 * @since 2.0
2400 2014 *
2401 2015 * @param string $permission
2402 - * @param string $nonce_name
2403 - * @param string $nonce
2404 2016 *
2405 2017 * @return false|string The permission message or false if allowed
2406 2018 */
2407 2019 public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
2408 - if ( $permission && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
2020 + if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) {
2409 2021 $frm_settings = self::get_settings();
2022 +
2410 2023 return $frm_settings->admin_permission;
2411 2024 }
2412 2025
2413 2026 $error = false;
2414 -
2415 - if ( ! $nonce_name ) {
2027 + if ( empty( $nonce_name ) ) {
2416 2028 return $error;
2417 2029 }
2418 2030
2419 2031 $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2420 -
2421 2032 if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
2422 2033 $frm_settings = self::get_settings();
2423 2034 $error = $frm_settings->admin_permission;
2424 2035 }
@@ -2425,14 +2036,8 @@
2425 2036
2426 2037 return $error;
2427 2038 }
2428 2039
2429 - /**
2430 - * @param array|string $values
2431 - * @param string $current
2432 - *
2433 - * @return void
2434 - */
2435 2040 public static function checked( $values, $current ) {
2436 2041 if ( self::check_selected( $values, $current ) ) {
2437 2042 echo ' checked="checked"';
2438 2043 }
@@ -2437,47 +2042,38 @@
2437 2042 echo ' checked="checked"';
2438 2043 }
2439 2044 }
2440 2045
2441 - /**
2442 - * @param array|string $values
2443 - * @param string|null $current
2444 - *
2445 - * @return bool
2446 - */
2447 2046 public static function check_selected( $values, $current ) {
2448 - $values = self::recursive_function_map( $values, 'trim' );
2449 - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
2047 + $values = self::recursive_function_map( $values, 'trim' );
2048 + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
2049 +
2450 2050 $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) );
2451 2051
2452 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict, Universal.Operators.StrictComparisons
2453 - return is_array( $values ) ? in_array( $current, $values ) : $values == $current;
2052 + return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
2454 2053 }
2455 2054
2456 - /**
2457 - * @param array|string $value
2458 - * @param callable|string $function
2459 - *
2460 - * @return array|string
2461 - */
2462 2055 public static function recursive_function_map( $value, $function ) {
2463 2056 if ( is_array( $value ) ) {
2464 2057 $original_function = $function;
2465 - $function = count( $value ) ? explode( ', ', FrmDb::prepare_array_values( $value, $function ) ) : array( $function );
2466 -
2467 - if ( self::is_assoc( $value ) ) {
2058 + if ( count( $value ) ) {
2059 + $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) );
2060 + } else {
2061 + $function = array( $function );
2062 + }
2063 + if ( ! self::is_assoc( $value ) ) {
2064 + $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function );
2065 + } else {
2468 2066 foreach ( $value as $k => $v ) {
2469 2067 if ( ! is_array( $v ) ) {
2470 2068 $value[ $k ] = call_user_func( $original_function, $v );
2471 2069 }
2472 2070 }
2473 - } else {
2474 - $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function );
2475 2071 }
2476 2072 } else {
2477 2073 $value = self::maybe_update_value_if_null( $value, $function );
2478 2074 $value = call_user_func( $function, $value );
2479 - }//end if
2075 + }
2480 2076
2481 2077 return $value;
2482 2078 }
2483 2079
@@ -2484,27 +2080,20 @@
2484 2080 /**
2485 2081 * Updates value to empty string if it is null and being passed to a string function.
2486 2082 *
2487 2083 * @since 6.8.4
2488 - *
2489 2084 * @param mixed $value
2490 2085 * @param string $function
2491 - *
2492 2086 * @return mixed
2493 2087 */
2494 2088 private static function maybe_update_value_if_null( $value, $function ) {
2495 2089 if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) {
2496 - return '';
2090 + $value = '';
2497 2091 }
2498 2092
2499 2093 return $value;
2500 2094 }
2501 2095
2502 - /**
2503 - * @param array $array
2504 - *
2505 - * @return bool
2506 - */
2507 2096 public static function is_assoc( $array ) {
2508 2097 return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
2509 2098 }
2510 2099
@@ -2509,22 +2098,16 @@
2509 2098 }
2510 2099
2511 2100 /**
2512 2101 * Flatten a multi-dimensional array
2513 - *
2514 - * @param array $array
2515 - * @param string $keys
2516 - *
2517 - * @return array
2518 2102 */
2519 2103 public static function array_flatten( $array, $keys = 'keep' ) {
2520 2104 $return = array();
2521 -
2522 2105 foreach ( $array as $key => $value ) {
2523 2106 if ( is_array( $value ) ) {
2524 2107 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
2525 2108 } elseif ( $keys === 'keep' ) {
2526 - $return[ $key ] = $value;
2109 + $return[ $key ] = $value;
2527 2110 } else {
2528 2111 $return[] = $value;
2529 2112 }
2530 2113 }
@@ -2538,9 +2121,8 @@
2538 2121 * @since 6.16.1
2539 2122 *
2540 2123 * @param string $sep
2541 2124 * @param array $array
2542 - *
2543 2125 * @return string
2544 2126 */
2545 2127 public static function safe_implode( $sep, $array ) {
2546 2128 $array = self::array_flatten( $array );
@@ -2549,18 +2131,15 @@
2549 2131
2550 2132 /**
2551 2133 * @param string $text
2552 2134 * @param bool $is_rich_text
2553 - *
2554 2135 * @return string
2555 2136 */
2556 2137 public static function esc_textarea( $text, $is_rich_text = false ) {
2557 2138 $safe_text = str_replace( '&quot;', '"', $text );
2558 -
2559 2139 if ( ! $is_rich_text ) {
2560 2140 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
2561 2141 }
2562 -
2563 2142 $safe_text = str_replace( '&amp; ', '& ', $safe_text );
2564 2143
2565 2144 /**
2566 2145 * @param string $safe_text
@@ -2572,59 +2151,44 @@
2572 2151 /**
2573 2152 * Add auto paragraphs to text areas
2574 2153 *
2575 2154 * @since 2.0
2576 - *
2577 - * @param mixed $content
2578 - *
2579 - * @return mixed
2580 2155 */
2581 2156 public static function use_wpautop( $content ) {
2582 - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) {
2583 - return wpautop( str_replace( '<br>', '<br />', $content ) );
2157 + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) {
2158 + $content = wpautop( str_replace( '<br>', '<br />', $content ) );
2584 2159 }
2585 2160
2586 2161 return $content;
2587 2162 }
2588 2163
2589 - /**
2590 - * Replace quotes with their HTML entities.
2591 - *
2592 - * @param string $val
2593 - *
2594 - * @return string
2595 - */
2596 2164 public static function replace_quotes( $val ) {
2597 2165 // Replace double quotes.
2598 2166 $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
2599 2167
2600 2168 // Replace single quotes.
2601 - return str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
2169 + $val = str_replace( array( '&#8216;', '&#8217;', '&#8242;', '&prime;', '&rsquo;', '&lsquo;' ), "'", $val );
2170 +
2171 + return $val;
2602 2172 }
2603 2173
2604 2174 /**
2605 - * @param string $handle
2606 - * @param int|string $default
2607 - *
2608 - * @return int|string
2175 + * @param string $handle
2609 2176 */
2610 2177 public static function script_version( $handle, $default = 0 ) {
2611 2178 global $wp_scripts;
2612 -
2613 2179 if ( ! $wp_scripts ) {
2614 2180 return $default;
2615 2181 }
2616 2182
2617 2183 $ver = $default;
2618 -
2619 2184 if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
2620 2185 return $ver;
2621 2186 }
2622 2187
2623 2188 $query = $wp_scripts->registered[ $handle ];
2624 -
2625 2189 if ( is_object( $query ) && ! empty( $query->ver ) ) {
2626 - return $query->ver;
2190 + $ver = $query->ver;
2627 2191 }
2628 2192
2629 2193 return $ver;
2630 2194 }
@@ -2633,9 +2197,8 @@
2633 2197 * @since 5.0.13 added $echo param.
2634 2198 *
2635 2199 * @param string $url
2636 2200 * @param bool $echo
2637 - *
2638 2201 * @return string|null
2639 2202 */
2640 2203 public static function js_redirect( $url, $echo = false ) {
2641 2204 $callback = function () use ( $url ) {
@@ -2643,13 +2206,8 @@
2643 2206 };
2644 2207 return self::clip( $callback, $echo );
2645 2208 }
2646 2209
2647 - /**
2648 - * @param int|string $user_id
2649 - *
2650 - * @return int|string
2651 - */
2652 2210 public static function get_user_id_param( $user_id ) {
2653 2211 if ( ! $user_id || is_numeric( $user_id ) ) {
2654 2212 return $user_id;
2655 2213 }
@@ -2654,13 +2212,16 @@
2654 2212 return $user_id;
2655 2213 }
2656 2214
2657 2215 $user_id = sanitize_text_field( $user_id );
2658 -
2659 2216 if ( $user_id === 'current' ) {
2660 2217 $user_id = get_current_user_id();
2661 2218 } else {
2662 - $user = is_email( $user_id ) ? get_user_by( 'email', $user_id ) : get_user_by( 'login', $user_id );
2219 + if ( is_email( $user_id ) ) {
2220 + $user = get_user_by( 'email', $user_id );
2221 + } else {
2222 + $user = get_user_by( 'login', $user_id );
2223 + }
2663 2224
2664 2225 if ( $user ) {
2665 2226 $user_id = $user->ID;
2666 2227 }
@@ -2672,9 +2233,8 @@
2672 2233
2673 2234 /**
2674 2235 * @param string $filename
2675 2236 * @param array $atts
2676 - *
2677 2237 * @return false|string
2678 2238 */
2679 2239 public static function get_file_contents( $filename, $atts = array() ) {
2680 2240 if ( ! is_file( $filename ) ) {
@@ -2683,9 +2243,12 @@
2683 2243
2684 2244 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
2685 2245 ob_start();
2686 2246 include $filename;
2687 - return ob_get_clean();
2247 + $contents = ob_get_contents();
2248 + ob_end_clean();
2249 +
2250 + return $contents;
2688 2251 }
2689 2252
2690 2253 /**
2691 2254 * @param string $name
@@ -2695,9 +2258,8 @@
2695 2258 * @param int $num_chars
2696 2259 */
2697 2260 public static function get_unique_key( $name, $table_name, $column, $id = 0, $num_chars = 5 ) {
2698 2261 $key = '';
2699 -
2700 2262 if ( $name ) {
2701 2263 $key = sanitize_key( $name );
2702 2264 $key = self::maybe_clear_long_key( $key, $column );
2703 2265 }
@@ -2717,31 +2279,31 @@
2717 2279 $column
2718 2280 );
2719 2281
2720 2282 // Create a unique field id if it has already been used.
2721 - if ( ! in_array( $key, $similar_keys, true ) ) {
2722 - return $key;
2723 - }
2283 + if ( in_array( $key, $similar_keys, true ) ) {
2284 + $key = self::maybe_truncate_key_before_appending( $column, $key );
2724 2285
2725 - $key = self::maybe_truncate_key_before_appending( $column, $key );
2286 + /**
2287 + * Allow for a custom separator between the attempted key and the generated suffix.
2288 + *
2289 + * @since 5.2.03
2290 + *
2291 + * @param string $separator. Default empty.
2292 + * @param string $key the key without the added suffix.
2293 + */
2294 + $separator = apply_filters( 'frm_unique_' . $column . '_separator', '', $key );
2726 2295
2727 - /**
2728 - * Allow for a custom separator between the attempted key and the generated suffix.
2729 - *
2730 - * @since 5.2.03
2731 - *
2732 - * @param string $separator. Default empty.
2733 - * @param string $key the key without the added suffix.
2734 - */
2735 - $separator = apply_filters( 'frm_unique_' . $column . '_separator', '', $key );
2296 + $suffix = 2;
2297 + do {
2298 + $key_check = $key . $separator . $suffix;
2299 + ++$suffix;
2300 + } while ( in_array( $key_check, $similar_keys, true ) );
2736 2301
2737 - $suffix = 2;
2738 - do {
2739 - $key_check = $key . $separator . $suffix;
2740 - ++$suffix;
2741 - } while ( in_array( $key_check, $similar_keys, true ) );
2302 + $key = $key_check;
2303 + }//end if
2742 2304
2743 - return $key_check;
2305 + return $key;
2744 2306 }
2745 2307
2746 2308 /**
2747 2309 * Avoid trying to append to a really long key,
@@ -2748,26 +2310,20 @@
2748 2310 * The database limit is 100 for form and field keys so we want to avoid getting too close.
2749 2311 *
2750 2312 * @param string $column
2751 2313 * @param string $key
2752 - *
2753 2314 * @return string
2754 2315 */
2755 2316 private static function maybe_truncate_key_before_appending( $column, $key ) {
2756 - if ( ! in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2757 - return $key;
2758 - }
2759 -
2760 - $max_key_length_before_truncating = 60;
2761 -
2762 - if ( strlen( $key ) > $max_key_length_before_truncating ) {
2763 - $key = substr( $key, 0, $max_key_length_before_truncating );
2764 -
2765 - if ( is_numeric( $key ) ) {
2766 - $key .= 'a';
2317 + if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2318 + $max_key_length_before_truncating = 60;
2319 + if ( strlen( $key ) > $max_key_length_before_truncating ) {
2320 + $key = substr( $key, 0, $max_key_length_before_truncating );
2321 + if ( is_numeric( $key ) ) {
2322 + $key .= 'a';
2323 + }
2767 2324 }
2768 2325 }
2769 -
2770 2326 return $key;
2771 2327 }
2772 2328
2773 2329 /**
@@ -2774,36 +2330,31 @@
2774 2330 * Possibly reset a key to avoid conflicts with column size limits.
2775 2331 *
2776 2332 * @param string $key
2777 2333 * @param string $column
2778 - *
2779 2334 * @return string either the original key value, or an empty string if the key was too long.
2780 2335 */
2781 2336 private static function maybe_clear_long_key( $key, $column ) {
2782 2337 if ( 'field_key' === $column && strlen( $key ) >= 70 ) {
2783 - return '';
2338 + $key = '';
2784 2339 }
2785 2340 return $key;
2786 2341 }
2787 2342
2788 2343 /**
2789 - * @since 6.21 This is changed from `private` to `public`.
2790 - *
2791 2344 * @param int $num_chars
2792 - *
2793 2345 * @return string
2794 2346 */
2795 - public static function generate_new_key( $num_chars ) {
2796 - $max_slug_value = 36 ** $num_chars;
2347 + private static function generate_new_key( $num_chars ) {
2348 + $max_slug_value = pow( 36, $num_chars );
2797 2349
2798 2350 // We want to have at least 2 characters in the slug.
2799 2351 $min_slug_value = 37;
2800 - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
2352 + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2801 2353 }
2802 2354
2803 2355 /**
2804 2356 * @param string $key
2805 - *
2806 2357 * @return string
2807 2358 */
2808 2359 private static function prevent_numeric_and_reserved_keys( $key ) {
2809 2360 if ( is_numeric( $key ) ) {
@@ -2817,14 +2368,12 @@
2817 2368 'editlink',
2818 2369 'siteurl',
2819 2370 'evenodd',
2820 2371 );
2821 -
2822 2372 if ( in_array( $key, $not_allowed, true ) ) {
2823 2373 $key .= 'a';
2824 2374 }
2825 2375 }
2826 -
2827 2376 return $key;
2828 2377 }
2829 2378
2830 2379 /**
@@ -2843,9 +2392,9 @@
2843 2392 if ( ! $record ) {
2844 2393 return false;
2845 2394 }
2846 2395
2847 - if ( ! $post_values ) {
2396 + if ( empty( $post_values ) ) {
2848 2397 $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
2849 2398 }
2850 2399
2851 2400 $values = array(
@@ -2853,9 +2402,9 @@
2853 2402 'fields' => array(),
2854 2403 );
2855 2404
2856 2405 foreach ( array( 'name', 'description' ) as $var ) {
2857 - $default_val = $record->{$var} ?? '';
2406 + $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
2858 2407 $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
2859 2408 unset( $var, $default_val );
2860 2409 }
2861 2410
@@ -2873,67 +2422,46 @@
2873 2422
2874 2423 return $values;
2875 2424 }
2876 2425
2877 - /**
2878 - * @param array|string $fields
2879 - * @param object $record
2880 - * @param array $values
2881 - * @param array $args
2882 - *
2883 - * @return void
2884 - */
2885 2426 private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
2886 - if ( ! $fields ) {
2887 - return;
2888 - }
2889 -
2890 - foreach ( (array) $fields as $field ) {
2891 - if ( ! self::is_admin_page() ) {
2892 - // Don't prep default values on the form settings page.
2893 - $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2427 + if ( ! empty( $fields ) ) {
2428 + foreach ( (array) $fields as $field ) {
2429 + if ( ! self::is_admin_page() ) {
2430 + // Don't prep default values on the form settings page.
2431 + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2432 + }
2433 + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
2434 + self::fill_field_defaults( $field, $record, $values, $args );
2894 2435 }
2895 -
2896 - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
2897 - self::fill_field_defaults( $field, $record, $values, $args );
2898 2436 }
2899 2437 }
2900 2438
2901 - /**
2902 - * @param object $field
2903 - * @param object $record
2904 - * @param array $values
2905 - * @param array $args
2906 - *
2907 - * @return void
2908 - */
2909 2439 private static function fill_field_defaults( $field, $record, array &$values, $args ) {
2910 2440 $post_values = $args['post_values'];
2911 2441
2912 2442 if ( $args['default'] ) {
2913 2443 $meta_value = $field->default_value;
2914 - } elseif ( $record->post_id && self::pro_is_installed() && ! empty( $field->field_options['post_field'] ) ) {
2444 + } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2915 2445 if ( ! isset( $field->field_options['custom_field'] ) ) {
2916 2446 $field->field_options['custom_field'] = '';
2917 2447 }
2918 -
2919 - $meta_value = FrmProEntryMetaHelper::get_post_value(
2920 - $record->post_id,
2921 - $field->field_options['post_field'],
2922 - $field->field_options['custom_field'],
2923 - array(
2924 - 'truncate' => false,
2925 - 'type' => $field->type,
2926 - 'form_id' => $field->form_id,
2927 - 'field' => $field,
2928 - )
2929 - );
2448 + $meta_value = FrmProEntryMetaHelper::get_post_value(
2449 + $record->post_id,
2450 + $field->field_options['post_field'],
2451 + $field->field_options['custom_field'],
2452 + array(
2453 + 'truncate' => false,
2454 + 'type' => $field->type,
2455 + 'form_id' => $field->form_id,
2456 + 'field' => $field,
2457 + )
2458 + );
2930 2459 } else {
2931 2460 $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2932 2461 }//end if
2933 2462
2934 - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type;
2935 -
2463 + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2936 2464 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2937 2465 $new_value = $post_values['item_meta'][ $field->id ];
2938 2466 self::unserialize_or_decode( $new_value );
2939 2467 } else {
@@ -2948,9 +2476,9 @@
2948 2476 $args['field_type'] = $field_type;
2949 2477
2950 2478 FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args );
2951 2479
2952 - if ( empty( $field_array['unique'] ) ) {
2480 + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) {
2953 2481 $field_array['unique_msg'] = '';
2954 2482 }
2955 2483
2956 2484 $field_array = array_merge( (array) $field->field_options, $field_array );
@@ -3017,21 +2545,15 @@
3017 2545 }
3018 2546
3019 2547 /**
3020 2548 * Set to POST value or default
3021 - *
3022 - * @param array $post_values
3023 - * @param array $values
3024 - *
3025 - * @return void
3026 2549 */
3027 2550 private static function fill_form_defaults( $post_values, array &$values ) {
3028 2551 $form_defaults = FrmFormsHelper::get_default_opts();
3029 2552
3030 2553 foreach ( $form_defaults as $opt => $default ) {
3031 - // phpcs:ignore Universal.Operators.StrictComparisons
3032 2554 if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
3033 - $values[ $opt ] = $post_values['options'][ $opt ] ?? $default;
2555 + $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default;
3034 2556 }
3035 2557
3036 2558 unset( $opt, $default );
3037 2559 }
@@ -3041,9 +2563,9 @@
3041 2563 }
3042 2564
3043 2565 foreach ( array( 'before', 'after', 'submit' ) as $h ) {
3044 2566 if ( ! isset( $values[ $h . '_html' ] ) ) {
3045 - $values[ $h . '_html' ] = $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h );
2567 + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
3046 2568 }
3047 2569 unset( $h );
3048 2570 }
3049 2571 }
@@ -3055,57 +2577,46 @@
3055 2577 *
3056 2578 * @return bool|int
3057 2579 */
3058 2580 public static function custom_style_value( $post_values ) {
3059 - if ( $post_values && isset( $post_values['options']['custom_style'] ) ) {
3060 - return absint( $post_values['options']['custom_style'] );
2581 + if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
2582 + $custom_style = absint( $post_values['options']['custom_style'] );
2583 + } else {
2584 + $frm_settings = self::get_settings();
2585 + $custom_style = ( $frm_settings->load_style !== 'none' );
3061 2586 }
3062 2587
3063 - $frm_settings = self::get_settings();
3064 - return $frm_settings->load_style !== 'none';
2588 + return $custom_style;
3065 2589 }
3066 2590
3067 2591 /**
3068 - * Truncate a string.
3069 - *
3070 - * Note: By default, this function will allow for a few additional characters more than $length.
3071 - * If a string has no spaces, it allows up to 50 additional characters. To force a true length limit,
3072 - * use $force_length_limit = true.
3073 - *
3074 2592 * @param mixed $original_string
3075 2593 * @param int|string $length
3076 2594 * @param int $minword
3077 2595 * @param string $continue
3078 - * @param bool $force_length_limit Force the final string to never exceed the length limit.
3079 - *
3080 2596 * @return string
3081 2597 */
3082 - public static function truncate( $original_string, $length, $minword = 3, $continue = '...', $force_length_limit = false ) {
2598 + public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) {
3083 2599 if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) {
3084 2600 return '';
3085 2601 }
3086 2602
3087 - $length = (int) $length;
2603 + $length = (int) $length;
2604 + $str = wp_strip_all_tags( (string) $original_string );
2605 + $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
3088 2606
3089 - if ( $length === 0 ) {
2607 + if ( $length == 0 ) {
3090 2608 return '';
3091 2609 }
3092 2610
3093 - $str = wp_strip_all_tags( (string) $original_string );
3094 - $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
3095 -
3096 2611 if ( $length <= 10 ) {
3097 2612 $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3098 -
3099 - if ( $force_length_limit ) {
3100 - return $sub;
3101 - }
3102 -
3103 2613 return $sub . ( $length < $original_len ? $continue : '' );
3104 2614 }
3105 2615
3106 - $sub = '';
3107 - $len = 0;
2616 + $sub = '';
2617 + $len = 0;
2618 +
3108 2619 $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
3109 2620
3110 2621 if ( ! is_array( $words ) ) {
3111 2622 return $original_string;
@@ -3111,11 +2622,10 @@
3111 2622 return $original_string;
3112 2623 }
3113 2624
3114 2625 foreach ( $words as $word ) {
3115 - $part = ( $sub !== '' ? ' ' : '' ) . $word;
2626 + $part = ( $sub != '' ? ' ' : '' ) . $word;
3116 2627 $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
3117 -
3118 2628 if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
3119 2629 break;
3120 2630 }
3121 2631
@@ -3128,21 +2638,10 @@
3128 2638
3129 2639 unset( $total_len, $word );
3130 2640 }
3131 2641
3132 - $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length, $force_length_limit );
2642 + $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length );
3133 2643
3134 - if ( $force_length_limit ) {
3135 - // Ensure the final string doesn't exceed the length limit.
3136 - $final_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub ) );
3137 -
3138 - if ( $final_len > $length ) {
3139 - return self::mb_function( array( 'mb_substr', 'substr' ), array( $sub, 0, $length ) );
3140 - }
3141 -
3142 - return $sub;
3143 - }
3144 -
3145 2644 return $sub . ( $len < $original_len ? $continue : '' );
3146 2645 }
3147 2646
3148 2647 /**
@@ -3149,51 +2648,30 @@
3149 2648 * If the string is still too long because there may not have been any spaces, force truncate.
3150 2649 *
3151 2650 * @since 6.5.4
3152 2651 *
3153 - * @param string $sub Current substring.
3154 - * @param int $length The length limit.
3155 - * @param bool $force_length_limit Force the string to not exceed the length limit.
3156 - *
2652 + * @param string $sub Current substring.
2653 + * @param int $length The length limit.
3157 2654 * @return string
3158 2655 */
3159 - private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length, $force_length_limit = false ) {
3160 - if ( ! $force_length_limit ) {
3161 - if ( strlen( $sub ) < $length + 50 ) {
3162 - // If the string isn't way over the limit, leave it.
3163 - return $sub;
3164 - }
3165 -
3166 - $first_space = strpos( $sub, ' ', $length );
3167 -
3168 - if ( false !== $first_space ) {
3169 - // Ignore anything with spaces.
3170 - return $sub;
3171 - }
3172 -
3173 - return substr( $sub, 0, $length + 10 );
2656 + private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
2657 + if ( strlen( $sub ) < $length + 50 ) {
2658 + // If the string isn't way over the limit, leave it.
2659 + return $sub;
3174 2660 }
3175 2661
3176 - // When force_length_limit is true, ensure the string doesn't exceed the length.
3177 - $final_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub ) );
3178 -
3179 - if ( $final_len > $length ) {
3180 - return self::mb_function( array( 'mb_substr', 'substr' ), array( $sub, 0, $length ) );
2662 + $first_space = strpos( $sub, ' ', $length );
2663 + if ( false !== $first_space ) {
2664 + // Ignore anything with spaces.
2665 + return $sub;
3181 2666 }
3182 2667
3183 - return $sub;
2668 + return substr( $sub, 0, $length + 10 );
3184 2669 }
3185 2670
3186 - /**
3187 - * @param array $function_names
3188 - * @param array $args
3189 - *
3190 - * @return mixed
3191 - */
3192 2671 public static function mb_function( $function_names, $args ) {
3193 2672 $mb_function_name = $function_names[0];
3194 2673 $function_name = $function_names[1];
3195 -
3196 2674 if ( function_exists( $mb_function_name ) ) {
3197 2675 $function_name = $mb_function_name;
3198 2676 }
3199 2677
@@ -3199,21 +2677,14 @@
3199 2677
3200 2678 return call_user_func_array( $function_name, $args );
3201 2679 }
3202 2680
3203 - /**
3204 - * @param string $date
3205 - * @param string $date_format
3206 - * @param string $time_format
3207 - *
3208 - * @return string
3209 - */
3210 2681 public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
3211 - if ( ! $date ) {
2682 + if ( empty( $date ) ) {
3212 2683 return $date;
3213 2684 }
3214 2685
3215 - if ( ! $date_format ) {
2686 + if ( empty( $date_format ) ) {
3216 2687 $date_format = get_option( 'date_format' );
3217 2688 }
3218 2689
3219 2690 if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) {
@@ -3221,10 +2692,10 @@
3221 2692 $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' );
3222 2693 }
3223 2694
3224 2695 $formatted = self::get_localized_date( $date_format, $date );
3225 - $do_time = gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00';
3226 2696
2697 + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) != '00:00:00' );
3227 2698 if ( $do_time ) {
3228 2699 $formatted .= self::add_time_to_date( $time_format, $date );
3229 2700 }
3230 2701
@@ -3233,35 +2704,30 @@
3233 2704
3234 2705 /**
3235 2706 * @param string $time_format
3236 2707 * @param string $date
3237 - *
3238 2708 * @return string
3239 2709 */
3240 2710 private static function add_time_to_date( $time_format, $date ) {
3241 - if ( ! $time_format ) {
2711 + if ( empty( $time_format ) ) {
3242 2712 $time_format = get_option( 'time_format' );
3243 2713 }
3244 2714
3245 2715 $trimmed_format = trim( $time_format );
3246 -
3247 - if ( $time_format && $trimmed_format ) {
3248 - return ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
2716 + $time = '';
2717 + if ( $time_format && ! empty( $trimmed_format ) ) {
2718 + $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
3249 2719 }
3250 2720
3251 - return '';
2721 + return $time;
3252 2722 }
3253 2723
3254 2724 /**
3255 2725 * @since 2.0.8
3256 - *
3257 - * @param string $date_format
3258 - * @param string $date
3259 - *
3260 - * @return string
3261 2726 */
3262 2727 public static function get_localized_date( $date_format, $date ) {
3263 2728 $date = get_date_from_gmt( $date );
2729 +
3264 2730 return date_i18n( $date_format, strtotime( $date ) );
3265 2731 }
3266 2732
3267 2733 /**
@@ -3266,16 +2732,19 @@
3266 2732
3267 2733 /**
3268 2734 * Gets the time ago in words.
3269 2735 *
3270 - * @param int $from In seconds.
3271 - * @param int|string $to In seconds.
3272 - * @param int|string $levels Number of time units to include or a specific unit.
2736 + * @param int $from In seconds.
2737 + * @param int|string $to In seconds.
3273 2738 *
3274 - * @return string Time ago.
2739 + * @return string $time_ago
3275 2740 */
3276 2741 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
3277 - $now = ! $to && 0 !== $to ? new DateTime() : new DateTime( '@' . $to );
2742 + if ( empty( $to ) && 0 !== $to ) {
2743 + $now = new DateTime();
2744 + } else {
2745 + $now = new DateTime( '@' . $to );
2746 + }
3278 2747 $ago = new DateTime( '@' . $from );
3279 2748
3280 2749 // Get the time difference
3281 2750 $diff_object = $now->diff( $ago );
@@ -3289,9 +2758,8 @@
3289 2758
3290 2759 if ( ! is_numeric( $levels ) ) {
3291 2760 // Show time in specified unit.
3292 2761 $levels = self::get_unit( $levels );
3293 -
3294 2762 if ( isset( $time_strings[ $levels ] ) ) {
3295 2763 $diff = array(
3296 2764 $levels => self::time_format( $levels, $diff ),
3297 2765 );
@@ -3298,14 +2766,13 @@
3298 2766 $time_strings = array(
3299 2767 $levels => $time_strings[ $levels ],
3300 2768 );
3301 2769 }
3302 -
3303 2770 $levels = 1;
3304 2771 }
3305 2772
3306 2773 foreach ( $time_strings as $k => $v ) {
3307 - if ( ! empty( $diff[ $k ] ) ) {
2774 + if ( isset( $diff[ $k ] ) && $diff[ $k ] ) {
3308 2775 $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] );
3309 2776 } elseif ( isset( $diff[ $k ] ) && count( $time_strings ) === 1 ) {
3310 2777 // Account for 0.
3311 2778 $time_strings[ $k ] = $diff[ $k ] . ' ' . $v[1];
@@ -3313,21 +2780,17 @@
3313 2780 unset( $time_strings[ $k ] );
3314 2781 }
3315 2782 }
3316 2783
3317 - $levels_deep = apply_filters( 'frm_time_ago_levels', $levels, compact( 'time_strings', 'from', 'to' ) );
3318 - $time_strings = array_slice( $time_strings, 0, absint( $levels_deep ) );
2784 + $levels_deep = apply_filters( 'frm_time_ago_levels', $levels, compact( 'time_strings', 'from', 'to' ) );
2785 + $time_strings = array_slice( $time_strings, 0, absint( $levels_deep ) );
2786 + $time_ago_string = implode( ' ', $time_strings );
3319 2787
3320 - return implode( ' ', $time_strings );
2788 + return $time_ago_string;
3321 2789 }
3322 2790
3323 2791 /**
3324 2792 * @since 4.05.01
3325 - *
3326 - * @param string $unit
3327 - * @param array $diff
3328 - *
3329 - * @return int
3330 2793 */
3331 2794 private static function time_format( $unit, $diff ) {
3332 2795 $return = array(
3333 2796 'y' => 'y',
@@ -3332,14 +2795,14 @@
3332 2795 $return = array(
3333 2796 'y' => 'y',
3334 2797 'd' => 'days',
3335 2798 );
3336 -
3337 2799 if ( isset( $return[ $unit ] ) ) {
3338 2800 return $diff[ $return[ $unit ] ];
3339 2801 }
3340 2802
3341 2803 $total = $diff['days'] * self::convert_time( 'd', $unit );
2804 +
3342 2805 $times = array( 'h', 'i', 's' );
3343 2806
3344 2807 foreach ( $times as $time ) {
3345 2808 if ( ! isset( $diff[ $time ] ) ) {
@@ -3353,13 +2816,8 @@
3353 2816 }
3354 2817
3355 2818 /**
3356 2819 * @since 4.05.01
3357 - *
3358 - * @param string $from
3359 - * @param string $to
3360 - *
3361 - * @return int
3362 2820 */
3363 2821 private static function convert_time( $from, $to ) {
3364 2822 $convert = array(
3365 2823 's' => 1,
@@ -3375,26 +2833,20 @@
3375 2833 }
3376 2834
3377 2835 /**
3378 2836 * @since 4.05.01
3379 - *
3380 - * @param string $unit
3381 - *
3382 - * @return int|string
3383 2837 */
3384 2838 private static function get_unit( $unit ) {
3385 2839 $units = self::get_time_strings();
3386 -
3387 2840 if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) {
3388 2841 return $unit;
3389 2842 }
3390 2843
3391 2844 foreach ( $units as $u => $strings ) {
3392 - if ( in_array( $unit, $strings, true ) ) {
2845 + if ( in_array( $unit, $strings ) ) {
3393 2846 return $u;
3394 2847 }
3395 2848 }
3396 -
3397 2849 return 1;
3398 2850 }
3399 2851
3400 2852 /**
@@ -3401,9 +2853,8 @@
3401 2853 * Get the translatable time strings. The untranslated version is a failsafe
3402 2854 * in case languages are changing for the unit set in the shortcode.
3403 2855 *
3404 2856 * @since 2.0.20
3405 - *
3406 2857 * @return array
3407 2858 */
3408 2859 private static function get_time_strings() {
3409 2860 return array(
@@ -3450,13 +2901,12 @@
3450 2901 /**
3451 2902 * @param int $r_count
3452 2903 * @param int $current_p
3453 2904 * @param int $p_size
3454 - *
3455 2905 * @return int
3456 2906 */
3457 2907 public static function get_last_record_num( $r_count, $current_p, $p_size ) {
3458 - return $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size;
2908 + return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size );
3459 2909 }
3460 2910
3461 2911 /**
3462 2912 * @param int $r_count
@@ -3461,13 +2911,11 @@
3461 2911 /**
3462 2912 * @param int $r_count
3463 2913 * @param int $current_p
3464 2914 * @param int $p_size
3465 - *
3466 2915 * @return int
3467 2916 */
3468 2917 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
3469 - // phpcs:ignore Universal.Operators.StrictComparisons
3470 2918 if ( $current_p == 1 ) {
3471 2919 return 1;
3472 2920 }
3473 2921 return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
@@ -3473,22 +2921,17 @@
3473 2921 return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
3474 2922 }
3475 2923
3476 2924 /**
3477 - * @param array $json_vars
3478 - *
3479 2925 * @return array
3480 2926 */
3481 2927 public static function json_to_array( $json_vars ) {
3482 2928 $vars = array();
3483 -
3484 2929 foreach ( $json_vars as $jv ) {
3485 2930 $jv_name = explode( '[', $jv['name'] );
3486 2931 $last = count( $jv_name ) - 1;
3487 -
3488 2932 foreach ( $jv_name as $p => $n ) {
3489 2933 $name = trim( $n, ']' );
3490 -
3491 2934 if ( ! isset( $l1 ) ) {
3492 2935 $l1 = $name;
3493 2936 }
3494 2937
@@ -3499,9 +2942,9 @@
3499 2942 if ( ! isset( $l3 ) ) {
3500 2943 $l3 = $name;
3501 2944 }
3502 2945
3503 - $this_val = $p === $last ? $jv['value'] : array();
2946 + $this_val = $p == $last ? $jv['value'] : array();
3504 2947
3505 2948 switch ( $p ) {
3506 2949 case 0:
3507 2950 $l1 = $name;
@@ -3534,15 +2977,10 @@
3534 2977
3535 2978 /**
3536 2979 * @param string $name
3537 2980 * @param string $l1
3538 - * @param mixed $val
3539 - * @param array $vars
3540 - *
3541 - * @return void
3542 2981 */
3543 2982 public static function add_value_to_array( $name, $l1, $val, &$vars ) {
3544 - // phpcs:ignore Universal.Operators.StrictComparisons
3545 2983 if ( $name == '' ) {
3546 2984 $vars[] = $val;
3547 2985 } elseif ( ! isset( $vars[ $l1 ] ) ) {
3548 2986 $vars[ $l1 ] = $val;
@@ -3548,26 +2986,19 @@
3548 2986 $vars[ $l1 ] = $val;
3549 2987 }
3550 2988 }
3551 2989
3552 - /**
3553 - * @param string $name
3554 - * @param string $class
3555 - * @param string $form_name
3556 - *
3557 - * @return void
3558 - */
3559 2990 public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
3560 2991 $tooltips = array(
3561 2992 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
3562 - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
2993 + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ),
3563 2994 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3564 2995 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3565 - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
2996 + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3566 2997 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
3567 2998 /* translators: %1$s: Form name, %2$s: Date */
3568 - '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
3569 - '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
2999 + '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() ) ),
3000 + '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' ),
3570 3001 );
3571 3002
3572 3003 if ( ! isset( $tooltips[ $name ] ) ) {
3573 3004 return;
@@ -3572,9 +3003,9 @@
3572 3003 if ( ! isset( $tooltips[ $name ] ) ) {
3573 3004 return;
3574 3005 }
3575 3006
3576 - if ( 'open' === $class ) {
3007 + if ( 'open' == $class ) {
3577 3008 echo ' frm_help"';
3578 3009 } else {
3579 3010 echo ' class="frm_help"';
3580 3011 }
@@ -3580,9 +3011,9 @@
3580 3011 }
3581 3012
3582 3013 echo ' title="' . esc_attr( $tooltips[ $name ] );
3583 3014
3584 - if ( 'open' !== $class ) {
3015 + if ( 'open' != $class ) {
3585 3016 echo '"';
3586 3017 }
3587 3018 }
3588 3019
@@ -3587,28 +3018,20 @@
3587 3018 }
3588 3019
3589 3020 /**
3590 3021 * Add the current_page class to that page in the form nav
3591 - *
3592 - * @param int|string $page
3593 - * @param int|string $current_page
3594 - * @param array $action
3595 - *
3596 - * @return void
3597 3022 */
3598 3023 public static function select_current_page( $page, $current_page, $action = array() ) {
3599 - // phpcs:ignore Universal.Operators.StrictComparisons
3600 3024 if ( $current_page != $page ) {
3601 3025 return;
3602 3026 }
3603 3027
3604 3028 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
3605 -
3606 3029 if ( 'lite-reports' === $frm_action ) {
3607 3030 $frm_action = 'reports';
3608 3031 }
3609 3032
3610 - if ( ! $action || ( $frm_action && in_array( $frm_action, $action, true ) ) ) {
3033 + if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
3611 3034 echo ' class="current_page"';
3612 3035 }
3613 3036 }
3614 3037
@@ -3638,19 +3061,14 @@
3638 3061
3639 3062 // Add extra slashes for \r\n since WP strips them.
3640 3063 $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content );
3641 3064
3642 - // Allow for &quot
3643 - return str_replace( '&quot;', '\\"', $post_content );
3065 + // allow for &quot
3066 + $post_content = str_replace( '&quot;', '\\"', $post_content );
3067 +
3068 + return $post_content;
3644 3069 }
3645 3070
3646 - /**
3647 - * @param array|string $val
3648 - * @param int|string $key
3649 - * @param array $post_content
3650 - *
3651 - * @return void
3652 - */
3653 3071 private static function prepare_action_slashes( $val, $key, &$post_content ) {
3654 3072 if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) {
3655 3073 return;
3656 3074 }
@@ -3659,17 +3077,15 @@
3659 3077 foreach ( $val as $k1 => $v1 ) {
3660 3078 self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] );
3661 3079 unset( $k1, $v1 );
3662 3080 }
3081 + } else {
3082 + // Strip all slashes so everything is the same, no matter where the value is coming from
3083 + $val = stripslashes( $val );
3663 3084
3664 - return;
3085 + // Add backslashes before double quotes and forward slashes only
3086 + $post_content[ $key ] = addcslashes( $val, '"\\/' );
3665 3087 }
3666 -
3667 - // Strip all slashes so everything is the same, no matter where the value is coming from
3668 - $val = stripslashes( $val );
3669 -
3670 - // Add backslashes before double quotes and forward slashes only
3671 - $post_content[ $key ] = addcslashes( $val, '"\\/' );
3672 3088 }
3673 3089
3674 3090 /**
3675 3091 * Check for either json or serialized data. This is temporary while transitioning
@@ -3677,9 +3093,8 @@
3677 3093 *
3678 3094 * @since 4.02.03
3679 3095 *
3680 3096 * @param array|string $value
3681 - *
3682 3097 * @return void
3683 3098 */
3684 3099 public static function unserialize_or_decode( &$value ) {
3685 3100 if ( is_array( $value ) ) {
@@ -3685,9 +3100,13 @@
3685 3100 if ( is_array( $value ) ) {
3686 3101 return;
3687 3102 }
3688 3103
3689 - $value = is_serialized( $value ) ? self::maybe_unserialize_array( $value ) : self::maybe_json_decode( $value, false );
3104 + if ( is_serialized( $value ) ) {
3105 + $value = self::maybe_unserialize_array( $value );
3106 + } else {
3107 + $value = self::maybe_json_decode( $value, false );
3108 + }
3690 3109 }
3691 3110
3692 3111 /**
3693 3112 * Safely unserialize an array if necessary.
@@ -3695,9 +3114,8 @@
3695 3114 *
3696 3115 * @since 6.2
3697 3116 *
3698 3117 * @param mixed $value
3699 - *
3700 3118 * @return mixed
3701 3119 */
3702 3120 public static function maybe_unserialize_array( $value ) {
3703 3121 if ( ! is_string( $value ) ) {
@@ -3704,15 +3122,18 @@
3704 3122 return $value;
3705 3123 }
3706 3124
3707 3125 // Since we only expect an array, skip anything that doesn't start with a:.
3708 - if ( ! is_serialized( $value ) || ! str_starts_with( $value, 'a:' ) ) {
3126 + if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
3709 3127 return $value;
3710 3128 }
3711 3129
3712 3130 $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
3131 + if ( is_array( $parsed ) ) {
3132 + $value = $parsed;
3133 + }
3713 3134
3714 - return is_array( $parsed ) ? $parsed : $value;
3135 + return $value;
3715 3136 }
3716 3137
3717 3138 /**
3718 3139 * Decode a JSON string.
@@ -3717,12 +3138,11 @@
3717 3138 /**
3718 3139 * Decode a JSON string.
3719 3140 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
3720 3141 *
3721 - * @param array|string|null $string
3722 - * @param bool $single_to_array
3723 - *
3724 - * @return array|string|null
3142 + * @param mixed $string
3143 + * @param bool $single_to_array
3144 + * @return mixed
3725 3145 */
3726 3146 public static function maybe_json_decode( $string, $single_to_array = true ) {
3727 3147 if ( is_array( $string ) || is_null( $string ) ) {
3728 3148 return $string;
@@ -3727,19 +3147,20 @@
3727 3147 if ( is_array( $string ) || is_null( $string ) ) {
3728 3148 return $string;
3729 3149 }
3730 3150
3731 - $new_string = json_decode( $string, true );
3732 - $single_value = false;
3733 -
3734 - if ( ! $single_to_array ) {
3735 - $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3151 + $new_string = json_decode( $string, true );
3152 + if ( function_exists( 'json_last_error' ) ) {
3153 + // php 5.3+
3154 + $single_value = false;
3155 + if ( ! $single_to_array ) {
3156 + $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3157 + }
3158 + if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3159 + $string = $new_string;
3160 + }
3736 3161 }
3737 3162
3738 - if ( json_last_error() === JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3739 - return $new_string;
3740 - }
3741 -
3742 3163 return $string;
3743 3164 }
3744 3165
3745 3166 /**
@@ -3745,9 +3166,8 @@
3745 3166 /**
3746 3167 * @since 6.2.3
3747 3168 *
3748 3169 * @param string $value
3749 - *
3750 3170 * @return string
3751 3171 */
3752 3172 public static function maybe_utf8_encode( $value ) {
3753 3173 $from_format = 'ISO-8859-1';
@@ -3756,15 +3176,13 @@
3756 3176 if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
3757 3177 if ( mb_check_encoding( $value, $from_format ) ) {
3758 3178 return mb_convert_encoding( $value, $to_format, $from_format );
3759 3179 }
3760 -
3761 3180 return $value;
3762 3181 }
3763 3182
3764 3183 if ( function_exists( 'iconv' ) ) {
3765 3184 $converted = iconv( $from_format, $to_format, $value );
3766 -
3767 3185 // Value is false if $value is not ISO-8859-1.
3768 3186 if ( false !== $converted ) {
3769 3187 return $converted;
3770 3188 }
@@ -3776,12 +3194,8 @@
3776 3194 /**
3777 3195 * Reformat the json serialized array in name => value array.
3778 3196 *
3779 3197 * @since 4.02.03
3780 - *
3781 - * @param array $form
3782 - *
3783 - * @return void
3784 3198 */
3785 3199 public static function format_form_data( &$form ) {
3786 3200 $formatted = array();
3787 3201
@@ -3788,21 +3202,18 @@
3788 3202 foreach ( $form as $input ) {
3789 3203 if ( ! isset( $input['name'] ) ) {
3790 3204 continue;
3791 3205 }
3792 -
3793 3206 $key = $input['name'];
3794 -
3795 - if ( ! isset( $formatted[ $key ] ) ) {
3207 + if ( isset( $formatted[ $key ] ) ) {
3208 + if ( is_array( $formatted[ $key ] ) ) {
3209 + $formatted[ $key ][] = $input['value'];
3210 + } else {
3211 + $formatted[ $key ] = array( $formatted[ $key ], $input['value'] );
3212 + }
3213 + } else {
3796 3214 $formatted[ $key ] = $input['value'];
3797 - continue;
3798 3215 }
3799 -
3800 - if ( is_array( $formatted[ $key ] ) ) {
3801 - $formatted[ $key ][] = $input['value'];
3802 - } else {
3803 - $formatted[ $key ] = array( $formatted[ $key ], $input['value'] );
3804 - }
3805 3216 }
3806 3217
3807 3218 parse_str( http_build_query( $formatted ), $form );
3808 3219 }
@@ -3810,13 +3221,15 @@
3810 3221 /**
3811 3222 * @since 4.02.03
3812 3223 *
3813 3224 * @param array|string $value
3814 - *
3815 3225 * @return string
3816 3226 */
3817 3227 public static function maybe_json_encode( $value ) {
3818 - return is_array( $value ) ? wp_json_encode( $value ) : $value;
3228 + if ( is_array( $value ) ) {
3229 + $value = wp_json_encode( $value );
3230 + }
3231 + return $value;
3819 3232 }
3820 3233
3821 3234 /**
3822 3235 * Echo The javascript to open and highlight the Formidable menu
@@ -3823,19 +3236,18 @@
3823 3236 *
3824 3237 * @since 1.07.10
3825 3238 *
3826 3239 * @param string $post_type The name of the post type that may need to be highlighted.
3827 - *
3828 3240 * @return void
3829 3241 */
3830 3242 public static function maybe_highlight_menu( $post_type ) {
3831 3243 global $post;
3832 3244
3833 - if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] !== $post_type ) {
3245 + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) {
3834 3246 return;
3835 3247 }
3836 3248
3837 - if ( is_object( $post ) && $post->post_type !== $post_type ) {
3249 + if ( is_object( $post ) && $post->post_type != $post_type ) {
3838 3250 return;
3839 3251 }
3840 3252
3841 3253 self::load_admin_wide_js();
@@ -3847,13 +3259,13 @@
3847 3259 *
3848 3260 * @since 2.0
3849 3261 *
3850 3262 * @param bool $load
3851 - *
3852 3263 * @return void
3853 3264 */
3854 3265 public static function load_admin_wide_js( $load = true ) {
3855 - wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), self::plugin_version() );
3266 + $version = self::plugin_version();
3267 + wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
3856 3268
3857 3269 $global_strings = array(
3858 3270 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
3859 3271 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
@@ -3859,9 +3271,9 @@
3859 3271 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
3860 3272 'url' => self::plugin_url(),
3861 3273 'app_url' => 'https://formidableforms.com/',
3862 3274 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
3863 - '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
3275 + 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
3864 3276 'loading' => __( 'Loading&hellip;', 'formidable' ),
3865 3277 'nonce' => wp_create_nonce( 'frm_ajax' ),
3866 3278 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
3867 3279 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(),
@@ -3874,9 +3286,8 @@
3874 3286 }
3875 3287
3876 3288 /**
3877 3289 * @since 2.0.9
3878 - *
3879 3290 * @return void
3880 3291 */
3881 3292 public static function load_font_style() {
3882 3293 wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
@@ -3883,9 +3294,8 @@
3883 3294 }
3884 3295
3885 3296 /**
3886 3297 * @param string $location
3887 - *
3888 3298 * @return void
3889 3299 */
3890 3300 public static function localize_script( $location ) {
3891 3301 global $wp_scripts, $wp_version;
@@ -3908,9 +3318,8 @@
3908 3318 'include_resend_email' => false,
3909 3319 );
3910 3320
3911 3321 $data = $wp_scripts->get_data( 'formidable', 'data' );
3912 -
3913 3322 if ( ! $data ) {
3914 3323 wp_localize_script( 'formidable', 'frm_js', $script_strings );
3915 3324 }
3916 3325
@@ -3917,9 +3326,9 @@
3917 3326 if ( $location === 'admin' ) {
3918 3327 $admin_script_strings = array(
3919 3328 'desc' => __( '(Click to add description)', 'formidable' ),
3920 3329 'blank' => __( '(Blank)', 'formidable' ),
3921 - 'no_label' => self::get_no_label_text(),
3330 + 'no_label' => __( '(no label)', 'formidable' ),
3922 3331 'ok' => __( 'OK', 'formidable' ),
3923 3332 'cancel' => __( 'Cancel', 'formidable' ),
3924 3333 'default_label' => __( 'Default', 'formidable' ),
3925 3334 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
@@ -3927,9 +3336,9 @@
3927 3336 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3928 3337 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3929 3338 'confirm' => __( 'Are you sure?', 'formidable' ),
3930 3339 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3931 - '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
3340 + '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' ),
3932 3341 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3933 3342 'default_unique' => FrmFieldsHelper::default_unique_msg(),
3934 3343 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3935 3344 'enter_email' => __( 'Enter Email', 'formidable' ),
@@ -3935,9 +3344,9 @@
3935 3344 'enter_email' => __( 'Enter Email', 'formidable' ),
3936 3345 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3937 3346 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3938 3347 'new_option' => __( 'New Option', 'formidable' ),
3939 - '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
3348 + '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' ),
3940 3349 'enter_password' => __( 'Enter Password', 'formidable' ),
3941 3350 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3942 3351 'import_complete' => __( 'Import Complete', 'formidable' ),
3943 3352 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
@@ -3951,15 +3360,13 @@
3951 3360 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3952 3361 /* translators: %d is the number of allowed actions per form */
3953 3362 'only_one_action' => sprintf( __( 'This form action is limited to %d per form.', 'formidable' ), 1 ),
3954 3363 'edit_action_text' => __( 'Please edit the existing form action.', 'formidable' ),
3955 - 'only_one_payment_action' => __( 'This form already has a payment action, and is currently limited to a single payment action.', 'formidable' ),
3956 - 'only_one_stripe_action' => __( 'This form already has a payment action. Multiple Stripe actions are available when using the Stripe add-on, available for Formidable Business licenses and higher.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
3957 3364 'unsafe_params' => FrmFormsHelper::reserved_words(),
3958 3365 /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/
3959 - '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
3366 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3960 3367 /* 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. */
3961 - '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
3368 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3962 3369 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3963 3370 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3964 3371 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3965 3372 'install' => __( 'Install', 'formidable' ),
@@ -3980,14 +3387,11 @@
3980 3387 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ),
3981 3388 'noTitleText' => FrmFormsHelper::get_no_title_text(),
3982 3389
3983 3390 // In older versions this event listener causes the section to immediately close again
3984 - // When the h3 element is clicked. It's only required in WP 6.7+.
3391 + // when the h3 element is clicked. It's only required in WP 6.7+.
3985 3392 'requireAccordionTitleClickListener' => version_compare( $wp_version, '6.7', '>=' ),
3986 3393 );
3987 -
3988 - self::add_form_builder_modal_data( $admin_script_strings );
3989 -
3990 3394 /**
3991 3395 * @param array $admin_script_strings
3992 3396 */
3993 3397 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
@@ -3992,9 +3396,8 @@
3992 3396 */
3993 3397 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3994 3398
3995 3399 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3996 -
3997 3400 if ( ! $data ) {
3998 3401 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3999 3402 }
4000 3403 }//end if
@@ -4000,87 +3403,8 @@
4000 3403 }//end if
4001 3404 }
4002 3405
4003 3406 /**
4004 - * @param array $admin_script_strings
4005 - *
4006 - * @return void
4007 - */
4008 - private static function add_form_builder_modal_data( &$admin_script_strings ) {
4009 - if ( ! self::is_form_builder_page() || self::pro_is_installed() ) {
4010 - return;
4011 - }
4012 -
4013 - $stripe_connected = FrmStrpLiteConnectHelper::at_least_one_mode_is_setup();
4014 - $square_connected = FrmSquareLiteConnectHelper::at_least_one_mode_is_setup();
4015 - $paypal_connected = FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup();
4016 - $gateway_connected = $stripe_connected || $square_connected || $paypal_connected;
4017 - $payments_settings_url = FrmStrpLiteAppController::get_payments_settings_url();
4018 -
4019 - if ( ! $gateway_connected ) {
4020 - // This modal shows when user clicks on one of the pricing fields and no payment gateways configured.
4021 - $admin_script_strings['paymentsSettingsModal'] = array(
4022 - 'title' => __( 'Setup a Payment Gateway first', 'formidable' ),
4023 - 'msg' => __( 'To use the payment fields, please install and configure a payment gateway in your account settings.', 'formidable' ),
4024 - 'closeText' => __( 'Close', 'formidable' ),
4025 - 'actionUrl' => $payments_settings_url,
4026 - 'actionText' => __( 'Go to Payment Settings', 'formidable' ),
4027 - 'noCenter' => true,
4028 - );
4029 - }
4030 -
4031 - // This modal shows on load once after upgrading the plugin.
4032 - $show_pricing_fields_modal = get_option( 'frm_show_pricing_fields_modal' );
4033 -
4034 - if ( ! $show_pricing_fields_modal ) {
4035 - return;
4036 - }
4037 -
4038 - $admin_script_strings['pricingFieldsModal'] = array(
4039 - 'title' => esc_html__( 'Start Accepting Payments Today!', 'formidable' ),
4040 - 'img' => esc_url( self::plugin_url() . '/images/upsell/pricing-fields.png' ),
4041 - 'noCenter' => true,
4042 - );
4043 -
4044 - if ( $gateway_connected ) {
4045 - $gateway_texts = array();
4046 -
4047 - if ( $stripe_connected ) {
4048 - $gateway_texts['stripe'] = esc_html__( 'Stripe', 'formidable' );
4049 - }
4050 -
4051 - if ( $square_connected ) {
4052 - $gateway_texts['square'] = esc_html__( 'Square', 'formidable' );
4053 - }
4054 -
4055 - $admin_script_strings['pricingFieldsModal']['msg'] = sprintf(
4056 - // translators: %s: Stripe or Square.
4057 - esc_html__( 'You already have %s connected, so these have already been unlocked.', 'formidable' ),
4058 - esc_html( implode( ' ' . esc_html__( 'and', 'formidable' ) . ' ', $gateway_texts ) )
4059 - );
4060 - } else {
4061 - $admin_script_strings['pricingFieldsModal']['closeText'] = __( 'I\'ll do it later!', 'formidable' );
4062 - $admin_script_strings['pricingFieldsModal']['actionText'] = __( 'Setup Payments Now', 'formidable' );
4063 - $admin_script_strings['pricingFieldsModal']['actionUrl'] = $payments_settings_url;
4064 - // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
4065 - $admin_script_strings['pricingFieldsModal']['msg'] = __( 'We\'ve unlocked Product, Quantity, and Total fields for Lite users! You can now transform your forms into checkout pages. To start collecting revenue, simply connect your preferred payment gateway (Stripe, or Square) in your settings.', 'formidable' );
4066 - }//end if
4067 -
4068 - delete_option( 'frm_show_pricing_fields_modal' );
4069 - }
4070 -
4071 - /**
4072 - * Get the no label text.
4073 - *
4074 - * @since 6.25.1
4075 - *
4076 - * @return string
4077 - */
4078 - public static function get_no_label_text() {
4079 - return __( '(no label)', 'formidable' );
4080 - }
4081 -
4082 - /**
4083 3407 * @since 6.5
4084 3408 *
4085 3409 * @return string
4086 3410 */
@@ -4122,9 +3446,8 @@
4122 3446 *
4123 3447 * @since 1.07.10
4124 3448 *
4125 3449 * @param float $min_version The version the add-on requires.
4126 - *
4127 3450 * @return void
4128 3451 */
4129 3452 public static function min_version_notice( $min_version ) {
4130 3453 $frm_version = self::plugin_version();
@@ -4134,11 +3457,11 @@
4134 3457 return;
4135 3458 }
4136 3459
4137 3460 $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
4138 - 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
4139 - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
4140 - '</div></td></tr>';
3461 + 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">' .
3462 + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) .
3463 + '</div></td></tr>';
4141 3464 }
4142 3465
4143 3466 /**
4144 3467 * If Pro is far outdated, show a message.
@@ -4144,10 +3467,8 @@
4144 3467 * If Pro is far outdated, show a message.
4145 3468 *
4146 3469 * @since 4.0.01
4147 3470 *
4148 - * @param string $min_version
4149 - *
4150 3471 * @return void
4151 3472 */
4152 3473 public static function min_pro_version_notice( $min_version ) {
4153 3474 if ( ! self::is_formidable_admin() ) {
@@ -4157,14 +3478,25 @@
4157 3478
4158 3479 self::php_version_notice();
4159 3480
4160 3481 $is_pro = self::pro_is_installed() && class_exists( 'FrmProDb' );
4161 -
4162 3482 if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) {
4163 3483 return;
4164 3484 }
4165 3485
4166 - include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
3486 + $expired = FrmAddonsController::is_license_expired();
3487 + ?>
3488 + <div class="frm-banner-alert frm_error_style frm_previous_install">
3489 + <?php
3490 + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
3491 + if ( empty( $expired ) ) {
3492 + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
3493 + } else {
3494 + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
3495 + }
3496 + ?>
3497 + </div>
3498 + <?php
4167 3499 }
4168 3500
4169 3501 /**
4170 3502 * If Pro is installed, check the version number.
@@ -4171,9 +3503,8 @@
4171 3503 *
4172 3504 * @since 4.0.01
4173 3505 *
4174 3506 * @param string $min_version
4175 - *
4176 3507 * @return bool
4177 3508 */
4178 3509 public static function meets_min_pro_version( $min_version ) {
4179 3510 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
@@ -4182,19 +3513,16 @@
4182 3513 /**
4183 3514 * Show a message if the PHP version is below the recommendations.
4184 3515 *
4185 3516 * @since 4.0.02
4186 - *
4187 3517 * @return void
4188 3518 */
4189 3519 private static function php_version_notice() {
4190 3520 $message = array();
4191 -
4192 3521 if ( version_compare( phpversion(), '7.0', '<' ) ) {
4193 - $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
3522 + $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' );
4194 3523 }
4195 3524
4196 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
4197 3525 foreach ( $message as $m ) {
4198 3526 ?>
4199 3527 <div class="frm-banner-alert frm_error_style frm_previous_install">
4200 3528 <?php echo esc_html( $m ); ?>
@@ -4200,14 +3528,12 @@
4200 3528 <?php echo esc_html( $m ); ?>
4201 3529 </div>
4202 3530 <?php
4203 3531 }
4204 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
4205 3532 }
4206 3533
4207 3534 /**
4208 3535 * @param string $type
4209 - *
4210 3536 * @return array<string,string>
4211 3537 */
4212 3538 public static function locales( $type = 'date' ) {
4213 3539 $locales = array(
@@ -4301,12 +3627,12 @@
4301 3627 'zu' => __( 'Zulu', 'formidable' ),
4302 3628 );
4303 3629
4304 3630 if ( $type === 'captcha' ) {
4305 - // Remove the languages unavailable for the captcha
3631 + // remove the languages unavailable for the captcha
4306 3632 $unset = array( 'sq', 'bs', 'eo', 'fo', 'fr-CH', 'sr-SR', 'ar-DZ', 'be', 'cy-GB', 'kk', 'km', 'ky', 'lb', 'mk', 'nb', 'nn', 'rm', 'tj' );
4307 3633 } else {
4308 - // Remove the languages unavailable for the datepicker
3634 + // remove the languages unavailable for the datepicker
4309 3635 $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'mr', 'lo', 'kn', 'si', 'gu', 'bn', 'zu', 'ur', 'te', 'sw', 'am' );
4310 3636 }
4311 3637
4312 3638 $locales = array_diff_key( $locales, array_flip( $unset ) );
@@ -4317,13 +3643,14 @@
4317 3643 * @since 5.4.5 Added $args parameter with type.
4318 3644 *
4319 3645 * @param array<string,string> $locales
4320 3646 * @param array $args {
4321 - *
4322 3647 * @type string $type
4323 3648 * }
4324 3649 */
4325 - return apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3650 + $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3651 +
3652 + return $locales;
4326 3653 }
4327 3654
4328 3655 /**
4329 3656 * @return string
@@ -4330,14 +3657,12 @@
4330 3657 */
4331 3658 public static function get_menu_icon_class() {
4332 3659 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
4333 3660 $settings = FrmProAppHelper::get_settings();
4334 -
4335 3661 if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
4336 3662 return $settings->menu_icon;
4337 3663 }
4338 3664 }
4339 -
4340 3665 return 'frmfont frm_logo_icon';
4341 3666 }
4342 3667
4343 3668 /**
@@ -4355,9 +3680,10 @@
4355 3680 * @type array $input_attrs Attributes of value input.
4356 3681 * }
4357 3682 */
4358 3683 public static function images_dropdown( $args ) {
4359 - $args = self::fill_default_images_dropdown_args( $args );
3684 + $args = self::fill_default_images_dropdown_args( $args );
3685 +
4360 3686 $input_attrs_str = self::get_images_dropdown_input_attrs( $args );
4361 3687 ob_start();
4362 3688 include self::plugin_path() . '/classes/views/shared/images-dropdown.php';
4363 3689 $output = ob_get_clean();
@@ -4378,9 +3704,8 @@
4378 3704 *
4379 3705 * @since 5.0.04
4380 3706 *
4381 3707 * @param array $args The arguments.
4382 - *
4383 3708 * @return array
4384 3709 */
4385 3710 private static function fill_default_images_dropdown_args( $args ) {
4386 3711 $defaults = array(
@@ -4393,8 +3718,14 @@
4393 3718
4394 3719 $new_args['options'] = (array) $new_args['options'];
4395 3720 $new_args['input_attrs'] = (array) $new_args['input_attrs'];
4396 3721
3722 + // Set the number of columns.
3723 + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) );
3724 + if ( $new_args['col_class'] > 6 ) {
3725 + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 );
3726 + }
3727 +
4397 3728 /**
4398 3729 * Allows modifying the arguments of images_dropdown() method.
4399 3730 *
4400 3731 * @since 5.0.04
@@ -4410,9 +3741,8 @@
4410 3741 *
4411 3742 * @since 5.0.04
4412 3743 *
4413 3744 * @param array $args The arguments.
4414 - *
4415 3745 * @return string
4416 3746 */
4417 3747 private static function get_images_dropdown_input_attrs( $args ) {
4418 3748 $input_attrs = $args['input_attrs'];
@@ -4419,9 +3749,8 @@
4419 3749 $input_attrs['type'] = 'radio';
4420 3750 $input_attrs['name'] = $args['name'];
4421 3751
4422 3752 $input_attrs_str = '';
4423 -
4424 3753 foreach ( $input_attrs as $key => $input_attr ) {
4425 3754 $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) );
4426 3755 }
4427 3756
@@ -4437,13 +3766,8 @@
4437 3766 }
4438 3767
4439 3768 /**
4440 3769 * @since 6.7.1
4441 - *
4442 - * @param array $option Option data.
4443 - * @param array $args The arguments of images_dropdown() method.
4444 - *
4445 - * @return array
4446 3770 */
4447 3771 public static function get_images_dropdown_atts( $option, $args ) {
4448 3772 $image = self::get_images_dropdown_option_image( $option, $args );
4449 3773 $classes = self::get_images_dropdown_option_classes( $option, $args );
@@ -4457,9 +3781,8 @@
4457 3781 * @since 5.0.04
4458 3782 *
4459 3783 * @param array $option Option data.
4460 3784 * @param array $args The arguments of images_dropdown() method.
4461 - *
4462 3785 * @return string
4463 3786 */
4464 3787 private static function get_images_dropdown_option_image( $option, $args ) {
4465 3788 $image = self::icon_by_class(
@@ -4488,9 +3811,8 @@
4488 3811 * @since 5.0.04
4489 3812 *
4490 3813 * @param array $option Option data.
4491 3814 * @param array $args The arguments of images_dropdown() method.
4492 - *
4493 3815 * @return string
4494 3816 */
4495 3817 private static function get_images_dropdown_option_classes( $option, $args ) {
4496 3818 $classes = '';
@@ -4518,19 +3840,17 @@
4518 3840 * @since 5.0.04
4519 3841 *
4520 3842 * @param array $option Option data.
4521 3843 * @param array $args The arguments of images_dropdown() method.
4522 - *
4523 3844 * @return string
4524 3845 */
4525 3846 private static function get_images_dropdown_option_html_attrs( $option, $args ) {
4526 3847 $html_attrs = '';
4527 -
4528 3848 if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) {
4529 3849 $html_attrs_arr = array();
4530 3850
4531 3851 foreach ( $option['custom_attrs'] as $key => $value ) {
4532 - if ( in_array( $key, array( 'type', 'class', 'data-value' ), true ) ) {
3852 + if ( in_array( $key, array( 'type', 'class', 'data-value' ) ) ) {
4533 3853 continue;
4534 3854 }
4535 3855
4536 3856 $html_attrs_arr[] = sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $value ) );
@@ -4588,13 +3908,14 @@
4588 3908 * @since 5.0.07
4589 3909 *
4590 3910 * @param array $values
4591 3911 * @param array $keys
4592 - *
4593 3912 * @return array
4594 3913 */
4595 3914 public static function maybe_filter_array( $values, $keys ) {
4596 - if ( self::allow_unfiltered_html() ) {
3915 + $allow_unfiltered_html = self::allow_unfiltered_html();
3916 +
3917 + if ( $allow_unfiltered_html ) {
4597 3918 return $values;
4598 3919 }
4599 3920
4600 3921 foreach ( $keys as $key ) {
@@ -4613,14 +3934,13 @@
4613 3934 * @since 5.0.13
4614 3935 *
4615 3936 * @param string $value
4616 3937 * @param array|string $allowed 'all' for everything included as defaults.
4617 - *
4618 3938 * @return string
4619 3939 */
4620 3940 public static function maybe_kses( $value, $allowed = 'all' ) {
4621 3941 if ( self::should_never_allow_unfiltered_html() ) {
4622 - return self::kses( $value, $allowed );
3942 + $value = self::kses( $value, $allowed );
4623 3943 }
4624 3944 return $value;
4625 3945 }
4626 3946
@@ -4630,18 +3950,17 @@
4630 3950 * @since 6.11.2
4631 3951 *
4632 3952 * @param string $key
4633 3953 * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed.
4634 - *
4635 3954 * @return bool
4636 3955 */
4637 3956 public static function input_key_is_safe( $key, $context = 'display' ) {
4638 3957 if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) {
4639 3958 $safe = true;
4640 - } elseif ( str_starts_with( $key, 'data-' ) ) {
3959 + } elseif ( 0 === strpos( $key, 'data-' ) ) {
4641 3960 // Allow all data attributes.
4642 3961 $safe = true;
4643 - } elseif ( str_starts_with( $key, 'aria-' ) ) {
3962 + } elseif ( 0 === strpos( $key, 'aria-' ) ) {
4644 3963 // Allow all aria attributes.
4645 3964 $safe = true;
4646 3965 } else {
4647 3966 $safe_keys = array(
@@ -4683,9 +4002,16 @@
4683 4002
4684 4003 /**
4685 4004 * @since 5.0.16
4686 4005 *
4687 - * @param string $medium
4006 + * @return bool
4007 + */
4008 + public static function show_landing_pages() {
4009 + return self::show_new_feature( 'landing' );
4010 + }
4011 +
4012 + /**
4013 + * @since 5.0.16
4688 4014 *
4689 4015 * @return array
4690 4016 */
4691 4017 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
@@ -4693,9 +4019,8 @@
4693 4019 'medium' => $medium,
4694 4020 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
4695 4021 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4696 4022 'screenshot' => 'landing.png',
4697 - 'learn-more' => self::get_doc_url( 'landing-page-forms', 'form-landing-page-settings', false ),
4698 4023 );
4699 4024 return self::get_upgrade_data_params( 'landing', $params );
4700 4025 }
4701 4026
@@ -4702,9 +4027,8 @@
4702 4027 /**
4703 4028 * @since 5.0.17
4704 4029 *
4705 4030 * @param string $feature
4706 - *
4707 4031 * @return bool
4708 4032 */
4709 4033 public static function show_new_feature( $feature ) {
4710 4034 $link = FrmAddonsController::install_link( $feature );
@@ -4711,21 +4035,16 @@
4711 4035 return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
4712 4036 }
4713 4037
4714 4038 /**
4715 - * Enhances upgrade data parameters with installation link and plan requirement information.
4716 - *
4717 4039 * @since 5.0.17
4718 4040 *
4719 - * @param string $plugin The plugin slug to get installation data for.
4720 - * @param array $params Initial parameters for the upgrade data.
4721 - * @param bool $detailed Whether to include detailed information.
4722 - *
4723 - * @return array Modified parameters with installation data.
4041 + * @param string $plugin
4042 + * @param array $params
4043 + * @return array
4724 4044 */
4725 - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) {
4045 + public static function get_upgrade_data_params( $plugin, $params ) {
4726 4046 $link = FrmAddonsController::install_link( $plugin );
4727 -
4728 4047 if ( ! $link ) {
4729 4048 return $params;
4730 4049 }
4731 4050
@@ -4731,20 +4050,15 @@
4731 4050
4732 4051 if ( ! empty( $link['url'] ) && self::pro_is_installed() ) {
4733 4052 $params['oneclick'] = json_encode( $link );
4734 4053 unset( $params['message'] );
4735 -
4736 4054 if ( ! isset( $params['medium'] ) ) {
4737 4055 $params['medium'] = $plugin;
4738 4056 }
4739 4057 } else {
4740 - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link );
4058 + $params['requires'] = FrmFormsHelper::get_plan_required( $link );
4741 4059 }
4742 4060
4743 - if ( $detailed ) {
4744 - $params['plugin-status'] = $link['status'] ?? '';
4745 - }
4746 -
4747 4061 return $params;
4748 4062 }
4749 4063
4750 4064 /**
@@ -4753,9 +4067,8 @@
4753 4067 *
4754 4068 * @since 5.0.17
4755 4069 *
4756 4070 * @param string $text
4757 - *
4758 4071 * @return bool
4759 4072 */
4760 4073 public static function ctype_xdigit( $text ) {
4761 4074 if ( function_exists( 'ctype_xdigit' ) ) {
@@ -4770,14 +4083,12 @@
4770 4083 * @since 5.2.01
4771 4084 */
4772 4085 public static function set_current_screen_and_hook_suffix() {
4773 4086 global $hook_suffix;
4774 -
4775 4087 if ( is_null( $hook_suffix ) ) {
4776 4088 // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
4777 4089 $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
4778 4090 }
4779 -
4780 4091 set_current_screen();
4781 4092 }
4782 4093
4783 4094 /**
@@ -4784,9 +4095,9 @@
4784 4095 * Shows pill text.
4785 4096 *
4786 4097 * @since 5.2.02
4787 4098 *
4788 - * @param string|null $text Text in the pill. Default is NEW.
4099 + * @param string $text Text in the pill. Default is NEW.
4789 4100 */
4790 4101 public static function show_pill_text( $text = null ) {
4791 4102 if ( null === $text ) {
4792 4103 $text = __( 'NEW', 'formidable' );
@@ -4799,9 +4110,8 @@
4799 4110 *
4800 4111 * @since 5.2.07
4801 4112 *
4802 4113 * @param mixed $num Number.
4803 - *
4804 4114 * @return false|int Returns `false` if the passed parameter is not number.
4805 4115 */
4806 4116 public static function count_decimals( $num ) {
4807 4117 if ( ! is_numeric( $num ) ) {
@@ -4809,9 +4119,8 @@
4809 4119 }
4810 4120
4811 4121 $num = (string) $num;
4812 4122 $parts = explode( '.', $num );
4813 -
4814 4123 if ( 1 === count( $parts ) ) {
4815 4124 return 0;
4816 4125 }
4817 4126
@@ -4893,20 +4202,17 @@
4893 4202 * @since 5.5.5
4894 4203 *
4895 4204 * @param string $url
4896 4205 * @param string $expected_extension
4897 - *
4898 4206 * @return bool
4899 4207 */
4900 4208 public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
4901 - $file_is_in_expected_s3_bucket = str_starts_with( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4902 -
4209 + $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4903 4210 if ( ! $file_is_in_expected_s3_bucket ) {
4904 4211 return false;
4905 4212 }
4906 4213
4907 4214 $parsed = parse_url( $url );
4908 -
4909 4215 if ( ! is_array( $parsed ) ) {
4910 4216 // URL is malformed.
4911 4217 return false;
4912 4218 }
@@ -4912,10 +4218,14 @@
4912 4218 }
4913 4219
4914 4220 $path = $parsed['path'];
4915 4221 $ext = pathinfo( $path, PATHINFO_EXTENSION );
4916 - // The URL isn't to an XML file.
4917 - return $expected_extension === $ext;
4222 + if ( $expected_extension !== $ext ) {
4223 + // The URL isn't to an XML file.
4224 + return false;
4225 + }
4226 +
4227 + return true;
4918 4228 }
4919 4229
4920 4230 /**
4921 4231 * Display a dismissable warning message and save its dismissal state.
@@ -4923,9 +4233,8 @@
4923 4233 * @since 6.3
4924 4234 *
4925 4235 * @param string $message The warning message to display.
4926 4236 * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
4927 - *
4928 4237 * @return void
4929 4238 */
4930 4239 public static function add_dismissable_warning_message( $message = '', $option = '' ) {
4931 4240 if ( ! $message || ! $option ) {
@@ -4968,9 +4277,8 @@
4968 4277 *
4969 4278 * @since 6.3
4970 4279 *
4971 4280 * @param string $option The unique identifier for the dismissal state of the message.
4972 - *
4973 4281 * @return void
4974 4282 */
4975 4283 public static function dismiss_warning_message( $option = '' ) {
4976 4284 self::permission_check( 'frm_change_settings' );
@@ -4976,9 +4284,9 @@
4976 4284 self::permission_check( 'frm_change_settings' );
4977 4285 check_ajax_referer( 'frm_ajax', 'nonce' );
4978 4286
4979 4287 if ( $option ) {
4980 - update_option( $option, true, false );
4288 + update_option( $option, true, 'no' );
4981 4289 }
4982 4290
4983 4291 wp_send_json_success();
4984 4292 }
@@ -4992,8 +4300,17 @@
4992 4300 * @return string
4993 4301 */
4994 4302 public static function copy_for_lite_license() {
4995 4303 $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂';
4304 +
4305 + if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) {
4306 + // Manage PRO versions without PRO dashboard functionality.
4307 + $license_type = FrmProAddonsController::get_readable_license_type();
4308 + if ( 'lite' !== strtolower( $license_type ) ) {
4309 + $message = 'Formidable Pro ' . $license_type;
4310 + }
4311 + }
4312 +
4996 4313 return apply_filters( 'frm_license_type_text', $message );
4997 4314 }
4998 4315
4999 4316 /**
@@ -4999,9 +4316,8 @@
4999 4316 /**
5000 4317 * Removes scripts that are unnecessarily loaded across the pages!
5001 4318 *
5002 4319 * @since 6.9
5003 - *
5004 4320 * @return void
5005 4321 */
5006 4322 public static function dequeue_extra_global_scripts() {
5007 4323 wp_dequeue_script( 'frm-surveys-admin' );
@@ -5019,21 +4335,18 @@
5019 4335 * @return void
5020 4336 */
5021 4337 public static function tooltip_icon( $tooltip_text, $atts = array() ) {
5022 4338 $atts['title'] = $tooltip_text;
5023 -
5024 4339 if ( isset( $atts['class'] ) ) {
5025 4340 $atts['class'] .= ' frm_help';
5026 4341 } else {
5027 4342 $atts['class'] = 'frm_help';
5028 4343 }
5029 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
5030 4344 ?>
5031 4345 <span <?php self::array_to_html_params( $atts, true ); ?>>
5032 4346 <?php self::icon_by_class( 'frmfont frm_tooltip_icon' ); ?>
5033 4347 </span>
5034 4348 <?php
5035 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
5036 4349 }
5037 4350
5038 4351 /**
5039 4352 * Prints errors for settings in onboarding wizard or template settings.
@@ -5054,10 +4367,8 @@
5054 4367 )
5055 4368 );
5056 4369
5057 4370 $args['class'] .= ' frm-validation-error frm-mt-xs frm_hidden';
5058 -
5059 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
5060 4371 ?>
5061 4372 <span id="<?php echo esc_attr( $args['id'] ); ?>" class="<?php echo esc_attr( $args['class'] ); ?>">
5062 4373 <?php
5063 4374 if ( is_array( $args['errors'] ) ) {
@@ -5071,82 +4382,6 @@
5071 4382 }
5072 4383 ?>
5073 4384 </span>
5074 4385 <?php
5075 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
5076 - }
5077 -
5078 - /**
5079 - * Check if GDPR is enabled.
5080 - *
5081 - * @since 6.19
5082 - *
5083 - * @return bool
5084 - */
5085 - public static function is_gdpr_enabled() {
5086 - $frm_settings = self::get_settings();
5087 - return $frm_settings->enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies;
5088 - }
5089 -
5090 - /**
5091 - * Check if GDPR cookies are disabled.
5092 - *
5093 - * @since 6.19
5094 - *
5095 - * @return bool
5096 - */
5097 - public static function no_gdpr_cookies() {
5098 - $frm_settings = self::get_settings();
5099 - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies;
5100 - }
5101 -
5102 - /**
5103 - * Check if a string is valid UTF-8.
5104 - *
5105 - * @since 6.24
5106 - *
5107 - * @param string $string The string to check.
5108 - *
5109 - * @return bool
5110 - */
5111 - public static function is_valid_utf8( $string ) {
5112 - // wp_is_valid_utf8 is added in WP 6.9.
5113 - if ( function_exists( 'wp_is_valid_utf8' ) ) {
5114 - return wp_is_valid_utf8( $string );
5115 - }
5116 -
5117 - // As of WP 6.9, seems_utf8 is deprecated.
5118 - return function_exists( 'seems_utf8' ) ? seems_utf8( $string ) : false;
5119 - }
5120 -
5121 - /**
5122 - * Get a documentation URL with UTM parameters and affiliate tracking.
5123 - *
5124 - * @since 6.26
5125 - *
5126 - * @param string $path The relative path to append to the base URL.
5127 - * @param string $campaign The campaign to use for UTM parameters.
5128 - * @param bool $add_kb_base Whether to prepend 'knowledgebase/' to the path. Default true.
5129 - *
5130 - * @return string The processed URL with UTM parameters and affiliate tracking.
5131 - */
5132 - public static function get_doc_url( $path, $campaign, $add_kb_base = true ) {
5133 - $path = trim( $path, '/' );
5134 -
5135 - if ( $add_kb_base ) {
5136 - $path = 'knowledgebase/' . $path;
5137 - }
5138 -
5139 - return self::maybe_add_missing_utm( 'https://formidableforms.com/' . $path, array( 'campaign' => $campaign ) );
5140 - }
5141 -
5142 - /**
5143 - * @since 5.0.16
5144 - * @deprecated 6.26
5145 - *
5146 - * @return bool
5147 - */
5148 - public static function show_landing_pages() {
5149 - _deprecated_function( __METHOD__, '6.26' );
5150 - return true;
5151 4386 }
5152 4387 }