PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.2.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.2.06
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 +569 -1610 6.25.15.2.06 View file →
@@ -3,43 +3,22 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmAppHelper {
7 -
8 - /**
9 - * Version of the database we are moving to.
10 - *
11 - * @var int
12 - */
13 - public static $db_version = 104;
14 -
15 - /**
16 - * Used by the API add-on.
17 - *
18 - * @var float
19 - */
7 + public static $db_version = 98; // Version of the database we are moving to.
8 + public static $pro_db_version = 37; //deprecated
20 9 public static $font_version = 7;
21 10
22 11 /**
23 - * @var bool
24 - */
25 - private static $added_gmt_offset_filter = false;
26 -
27 - /**
28 12 * @since 2.0
29 - *
30 - * @var string
31 13 */
32 - public static $plug_version = '6.25.1';
14 + public static $plug_version = '5.2.06';
33 15
34 16 /**
35 - * @var bool
36 - */
37 - private static $included_svg = false;
38 -
39 - /**
40 17 * @since 1.07.02
41 18 *
19 + * @param none
20 + *
42 21 * @return string The version of this plugin
43 22 */
44 23 public static function plugin_version() {
45 24 return self::$plug_version;
@@ -44,33 +23,21 @@
44 23 public static function plugin_version() {
45 24 return self::$plug_version;
46 25 }
47 26
48 - /**
49 - * @return string
50 - */
51 27 public static function plugin_folder() {
52 28 return basename( self::plugin_path() );
53 29 }
54 30
55 - /**
56 - * @return string
57 - */
58 31 public static function plugin_path() {
59 - return dirname( __DIR__, 2 );
32 + return dirname( dirname( dirname( __FILE__ ) ) );
60 33 }
61 34
62 - /**
63 - * @return string
64 - */
65 35 public static function plugin_url() {
66 - // Previously FRM_URL constant.
36 + // Prevously FRM_URL constant.
67 37 return plugins_url( '', self::plugin_path() . '/formidable.php' );
68 38 }
69 39
70 - /**
71 - * @return string
72 - */
73 40 public static function relative_plugin_url() {
74 41 return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
75 42 }
76 43
@@ -91,12 +58,8 @@
91 58 public static function site_name() {
92 59 return get_option( 'blogname' );
93 60 }
94 61
95 - /**
96 - * @param string $url
97 - * @return string
98 - */
99 62 public static function make_affiliate_url( $url ) {
100 63 $affiliate_id = self::get_affiliate();
101 64 if ( ! empty( $affiliate_id ) ) {
102 65 $url = str_replace( array( 'http://', 'https://' ), '', $url );
@@ -105,11 +68,8 @@
105 68
106 69 return $url;
107 70 }
108 71
109 - /**
110 - * @return int
111 - */
112 72 public static function get_affiliate() {
113 73 return absint( apply_filters( 'frm_affiliate_id', 0 ) );
114 74 }
115 75
@@ -114,137 +74,61 @@
114 74 }
115 75
116 76 /**
117 77 * @since 3.04.02
118 - *
119 - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
78 + * @param array|string $args
120 79 * @param string $page
121 80 */
122 81 public static function admin_upgrade_link( $args, $page = '' ) {
123 - if ( $page ) {
82 + if ( empty( $page ) ) {
83 + $page = 'https://formidableforms.com/lite-upgrade/';
84 + } else {
124 85 $page = str_replace( 'https://formidableforms.com/', '', $page );
125 86 $page = 'https://formidableforms.com/' . $page;
126 - } else {
127 - $page = 'https://formidableforms.com/lite-upgrade/';
128 87 }
129 88
89 + $anchor = '';
130 90 if ( is_array( $args ) ) {
131 - $args = self::adjust_legacy_utm_args( $args );
91 + $medium = $args['medium'];
92 + if ( isset( $args['content'] ) ) {
93 + $content = $args['content'];
94 + }
95 + if ( isset( $args['anchor'] ) ) {
96 + $anchor = '#' . $args['anchor'];
97 + }
132 98 } else {
133 - $args = array( 'campaign' => $args );
99 + $medium = $args;
134 100 }
135 101
136 102 $query_args = array(
137 - 'utm_source' => 'plugin',
138 - 'utm_medium' => self::get_utm_medium(),
103 + 'utm_source' => 'WordPress',
104 + 'utm_medium' => $medium,
105 + 'utm_campaign' => 'liteplugin',
139 106 );
140 - $query_args = self::maybe_add_utm_license( $query_args );
141 107
142 - if ( isset( $args['campaign'] ) ) {
143 - $query_args['utm_campaign'] = $args['campaign'];
108 + if ( isset( $content ) ) {
109 + $query_args['utm_content'] = $content;
144 110 }
145 111
146 - if ( isset( $args['content'] ) ) {
147 - $query_args['utm_content'] = $args['content'];
148 - }
149 -
150 - if ( isset( $args['param'] ) ) {
112 + if ( is_array( $args ) && isset( $args['param'] ) ) {
151 113 $query_args['f'] = $args['param'];
152 114 }
153 115
154 - if ( ! empty( $args['plan'] ) ) {
116 + if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
155 117 $query_args['plan'] = $args['plan'];
156 118 }
157 119
158 - $link = add_query_arg( $query_args, $page );
159 -
160 - if ( isset( $args['anchor'] ) ) {
161 - $link .= '#' . $args['anchor'];
162 - }
163 -
120 + $link = add_query_arg( $query_args, $page ) . $anchor;
164 121 return self::make_affiliate_url( $link );
165 122 }
166 123
167 124 /**
168 - * If medium is "pro", add an additional utm_license param with their active license type.
169 - *
170 - * @since 6.25.1
171 - *
172 - * @param array $query_args
173 - * @return array
174 - */
175 - private static function maybe_add_utm_license( $query_args ) {
176 - if ( 'pro' === $query_args['utm_medium'] && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) {
177 - $query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() );
178 - }
179 -
180 - return $query_args;
181 - }
182 -
183 - /**
184 - * @since 6.25.1
185 - *
186 - * @return string
187 - */
188 - private static function get_utm_medium() {
189 - return self::pro_is_connected() ? 'pro' : 'lite';
190 - }
191 -
192 - /**
193 - * Change campaign from "liteplugin" to what we're currently using for medium.
194 - *
195 - * @since 6.25.1
196 - *
197 - * @param array $args
198 - * @return array
199 - */
200 - private static function adjust_legacy_utm_args( $args ) {
201 - if ( isset( $args['medium'] ) ) {
202 - $args['campaign'] = $args['medium'];
203 - unset( $args['medium'] );
204 - }
205 -
206 - return $args;
207 - }
208 -
209 - /**
210 - * @since 6.21
211 - *
212 - * @param string $cta_link
213 - * @param array $utm
214 - */
215 - public static function maybe_add_missing_utm( $cta_link, $utm ) {
216 - $utm = self::adjust_legacy_utm_args( $utm );
217 - $query_args = array();
218 -
219 - if ( false === strpos( $cta_link, 'utm_source' ) ) {
220 - $query_args['utm_source'] = 'plugin';
221 - }
222 -
223 - if ( false === strpos( $cta_link, 'utm_medium' ) ) {
224 - $query_args['utm_medium'] = self::get_utm_medium();
225 - }
226 -
227 - if ( false === strpos( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) {
228 - $query_args['utm_campaign'] = $utm['campaign'];
229 - }
230 -
231 - if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
232 - $query_args['utm_content'] = $utm['content'];
233 - }
234 -
235 - $query_args = self::maybe_add_utm_license( $query_args );
236 -
237 - return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link;
238 - }
239 -
240 - /**
241 125 * Get the Formidable settings
242 126 *
243 127 * @since 2.0
244 128 *
245 129 * @param array $args - May include the form id when values need translation.
246 - * @return FrmSettings $frm_settings
130 + * @return FrmSettings $frm_setings
247 131 */
248 132 public static function get_settings( $args = array() ) {
249 133 global $frm_settings;
250 134 if ( empty( $frm_settings ) ) {
@@ -256,39 +140,16 @@
256 140
257 141 return $frm_settings;
258 142 }
259 143
260 - /**
261 - * @return string
262 - */
263 144 public static function get_menu_name() {
264 145 $frm_settings = self::get_settings();
265 146
266 - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu;
147 + return $frm_settings->menu;
267 148 }
268 149
269 150 /**
270 - * Determine if the current branding is set to 'formidable'.
271 - * Checks the menu icon, and verifies if it matches the formidable branding.
272 - *
273 - * @since 6.4.2
274 - *
275 - * @return bool True if the menu icon is the logo, false otherwise.
276 - */
277 - public static function is_formidable_branding() {
278 - if ( ! self::pro_is_installed() ) {
279 - return true;
280 - }
281 -
282 - $menu_icon = self::get_menu_icon_class();
283 - return strpos( $menu_icon, 'frm_logo_icon' ) !== false;
284 - }
285 -
286 - /**
287 151 * @since 3.05
288 - *
289 - * @param array $atts
290 - * @return string
291 152 */
292 153 public static function svg_logo( $atts = array() ) {
293 154 $defaults = array(
294 155 'height' => 18,
@@ -305,11 +166,8 @@
305 166 }
306 167
307 168 /**
308 169 * @since 4.0
309 - *
310 - * @param array $atts
311 - * @return void
312 170 */
313 171 public static function show_logo( $atts = array() ) {
314 172 echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
315 173 }
@@ -315,10 +173,8 @@
315 173 }
316 174
317 175 /**
318 176 * @since 4.03.02
319 - *
320 - * @return void
321 177 */
322 178 public static function show_header_logo() {
323 179 $icon = self::svg_logo(
324 180 array(
@@ -340,38 +196,21 @@
340 196 }
341 197
342 198 /**
343 199 * @since 2.02.04
344 - *
345 - * @return bool
346 200 */
347 201 public static function ips_saved() {
348 202 $frm_settings = self::get_settings();
203 +
349 204 return ! $frm_settings->no_ips;
350 205 }
351 206
352 - /**
353 - * @return bool
354 - */
355 207 public static function pro_is_installed() {
356 - return (bool) apply_filters( 'frm_pro_installed', false );
208 + return apply_filters( 'frm_pro_installed', false );
357 209 }
358 210
359 211 /**
360 - * Check if the Pro plugin is installed, whether authorized or not.
361 - *
362 - * @since 6.8.3
363 - *
364 - * @return bool
365 - */
366 - public static function pro_is_included() {
367 - return function_exists( 'load_formidable_pro' );
368 - }
369 -
370 - /**
371 212 * @since 4.06.02
372 - *
373 - * @return bool
374 213 */
375 214 public static function pro_is_connected() {
376 215 global $frm_vars;
377 216 return self::pro_is_installed() && $frm_vars['pro_is_authorized'];
@@ -378,26 +217,14 @@
378 217 }
379 218
380 219 /**
381 220 * @since 4.06
382 - * @since 6.16.2 Added $check_for_settings parameter
383 - *
384 - * @param bool $check_for_settings
385 - *
386 - * @return bool
387 221 */
388 - public static function is_form_builder_page( $check_for_settings = true ) {
389 - $action = self::simple_get( 'frm_action', 'sanitize_title' );
390 - $check_actions = array( 'edit', 'duplicate' );
391 - if ( $check_for_settings ) {
392 - $check_actions[] = 'settings';
393 - }
394 - return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true );
222 + public static function is_form_builder_page() {
223 + $action = self::simple_get( 'frm_action', 'sanitize_title' );
224 + return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' );
395 225 }
396 226
397 - /**
398 - * @return bool
399 - */
400 227 public static function is_formidable_admin() {
401 228 $page = self::simple_get( 'page', 'sanitize_title' );
402 229 $is_formidable = strpos( $page, 'formidable' ) !== false;
403 230 if ( empty( $page ) ) {
@@ -407,52 +234,15 @@
407 234 return $is_formidable;
408 235 }
409 236
410 237 /**
411 - * Checks if is a list page.
412 - *
413 - * @since 6.19
414 - *
415 - * @param string $page The name of the page to check.
416 - * @return bool
417 - */
418 - public static function is_admin_list_page( $page = 'formidable' ) {
419 - if ( 'formidable' === $page ) {
420 - return self::on_form_listing_page();
421 - }
422 -
423 - if ( ! self::is_admin_page( $page ) ) {
424 - return false;
425 - }
426 -
427 - if ( 'formidable-entries' === $page ) {
428 - $action = self::simple_get( 'frm_action' );
429 - if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) {
430 - return true;
431 - }
432 - }
433 -
434 - // Check edit or settings page.
435 - return ! self::simple_get( 'frm_action' );
436 - }
437 -
438 - /**
439 - * @since 6.20
440 - *
441 - * @return array<string>
442 - */
443 - private static function get_entries_listing_page_form_actions() {
444 - return array( 'list', 'destroy' );
445 - }
446 -
447 - /**
448 238 * Check for certain page in Formidable settings
449 239 *
450 240 * @since 2.0
451 241 *
452 - * @param string $page The name of the page to check.
242 + * @param string $page The name of the page to check
453 243 *
454 - * @return bool
244 + * @return boolean
455 245 */
456 246 public static function is_admin_page( $page = 'formidable' ) {
457 247 global $pagenow;
458 248 $get_page = self::simple_get( 'page', 'sanitize_title' );
@@ -457,15 +247,15 @@
457 247 global $pagenow;
458 248 $get_page = self::simple_get( 'page', 'sanitize_title' );
459 249 if ( $pagenow ) {
460 250 // allow this to be true during ajax load i.e. ajax form builder loading
461 - $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
251 + $is_page = ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
462 252 if ( $is_page ) {
463 253 return true;
464 254 }
465 255 }
466 256
467 - return is_admin() && $get_page === $page;
257 + return is_admin() && $get_page == $page;
468 258 }
469 259
470 260 /**
471 261 * If the current page is for editing or creating a view.
@@ -471,10 +261,8 @@
471 261 * If the current page is for editing or creating a view.
472 262 * Returns false for the views listing page.
473 263 *
474 264 * @since 4.0
475 - *
476 - * @return bool
477 265 */
478 266 public static function is_view_builder_page() {
479 267 global $pagenow;
480 268
@@ -484,10 +272,10 @@
484 272
485 273 $post_type = self::simple_get( 'post_type', 'sanitize_title' );
486 274
487 275 if ( empty( $post_type ) ) {
488 - $post_id = self::simple_get( 'post', 'absint' );
489 - $post = get_post( $post_id );
276 + $post_id = self::simple_get( 'post', 'absint' );
277 + $post = get_post( $post_id );
490 278 $post_type = $post ? $post->post_type : '';
491 279 }
492 280
493 281 return $post_type === 'frm_display';
@@ -497,15 +285,17 @@
497 285 * Check for the form preview page
498 286 *
499 287 * @since 2.0
500 288 *
501 - * @return bool
289 + * @param None
290 + *
291 + * @return boolean
502 292 */
503 293 public static function is_preview_page() {
504 294 global $pagenow;
505 295 $action = self::simple_get( 'action', 'sanitize_title' );
506 296
507 - return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
297 + return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
508 298 }
509 299
510 300 /**
511 301 * Check for ajax except the form preview page
@@ -511,17 +301,16 @@
511 301 * Check for ajax except the form preview page
512 302 *
513 303 * @since 2.0
514 304 *
515 - * @return bool
305 + * @param None
306 + *
307 + * @return boolean
516 308 */
517 309 public static function doing_ajax() {
518 310 return wp_doing_ajax() && ! self::is_preview_page();
519 311 }
520 312
521 - /**
522 - * @return string
523 - */
524 313 public static function js_suffix() {
525 314 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
526 315 }
527 316
@@ -526,13 +315,13 @@
526 315 }
527 316
528 317 /**
529 318 * @since 2.0.8
530 - * @return bool
531 319 */
532 320 public static function prevent_caching() {
533 321 global $frm_vars;
534 - return ! empty( $frm_vars['prevent_caching'] );
322 +
323 + return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
535 324 }
536 325
537 326 /**
538 327 * Check if on an admin page
@@ -538,18 +327,14 @@
538 327 * Check if on an admin page
539 328 *
540 329 * @since 2.0
541 330 *
542 - * @return bool
331 + * @param None
332 + *
333 + * @return boolean
543 334 */
544 335 public static function is_admin() {
545 - $is_admin = is_admin() && ! wp_doing_ajax();
546 -
547 - /**
548 - * @since 6.0
549 - * @param bool $is_admin
550 - */
551 - return apply_filters( 'frm_is_admin', $is_admin );
336 + return is_admin() && ! wp_doing_ajax();
552 337 }
553 338
554 339 /**
555 340 * Check if value contains blank value or empty array
@@ -555,22 +340,17 @@
555 340 * Check if value contains blank value or empty array
556 341 *
557 342 * @since 2.0
558 343 *
559 - * @param mixed $value Value to check.
560 - * @param string $empty
344 + * @param mixed $value - value to check
345 + * @param string
561 346 *
562 - * @return bool
347 + * @return boolean
563 348 */
564 349 public static function is_empty_value( $value, $empty = '' ) {
565 350 return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
566 351 }
567 352
568 - /**
569 - * @param mixed $value
570 - * @param string $empty
571 - * @return bool
572 - */
573 353 public static function is_not_empty_value( $value, $empty = '' ) {
574 354 return ! self::is_empty_value( $value, $empty );
575 355 }
576 356
@@ -587,37 +367,26 @@
587 367 return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
588 368 }
589 369
590 370 /**
591 - * Get the server OS
371 + * Check for the IP address in several places
372 + * Used by [ip] shortcode
592 373 *
593 - * @since 6.4.2
594 - *
595 - * @return string
596 - */
597 - public static function get_server_os() {
598 - if ( function_exists( 'php_uname' ) ) {
599 - return php_uname( 's' );
600 - }
601 -
602 - if ( ! defined( 'PHP_OS' ) ) {
603 - return '';
604 - }
605 -
606 - // match the same response for Windows server as php_uname('s')
607 - return in_array( PHP_OS, array( 'WIN32', 'WINNT', 'Windows_NT' ), true ) ? 'Windows NT' : PHP_OS;
608 - }
609 -
610 - /**
611 - * Check for the IP address in several places (when custom headers are enabled).
612 - * Used by [ip] shortcode.
613 - *
614 374 * @return string The IP address of the current user
615 375 */
616 376 public static function get_ip_address() {
617 - $ip_options = self::should_use_custom_header_ip() ? self::get_custom_header_keys_for_ip() : array( 'REMOTE_ADDR' );
618 - $ip = '';
619 -
377 + $ip_options = array(
378 + 'HTTP_CLIENT_IP',
379 + 'HTTP_CF_CONNECTING_IP',
380 + 'HTTP_X_FORWARDED_FOR',
381 + 'HTTP_X_FORWARDED',
382 + 'HTTP_X_CLUSTER_CLIENT_IP',
383 + 'HTTP_X_REAL_IP',
384 + 'HTTP_FORWARDED_FOR',
385 + 'HTTP_FORWARDED',
386 + 'REMOTE_ADDR',
387 + );
388 + $ip = '';
620 389 foreach ( $ip_options as $key ) {
621 390 if ( ! isset( $_SERVER[ $key ] ) ) {
622 391 continue;
623 392 }
@@ -623,10 +392,9 @@
623 392 }
624 393
625 394 $key = self::get_server_value( $key );
626 395 foreach ( explode( ',', $key ) as $ip ) {
627 - // Just to be safe.
628 - $ip = trim( $ip );
396 + $ip = trim( $ip ); // just to be safe.
629 397
630 398 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
631 399 return sanitize_text_field( $ip );
632 400 }
@@ -635,52 +403,8 @@
635 403
636 404 return sanitize_text_field( $ip );
637 405 }
638 406
639 - /**
640 - * @since 6.1
641 - *
642 - * @return array
643 - */
644 - public static function get_custom_header_keys_for_ip() {
645 - return array(
646 - 'HTTP_CLIENT_IP',
647 - 'HTTP_CF_CONNECTING_IP',
648 - 'HTTP_X_FORWARDED_FOR',
649 - 'HTTP_X_FORWARDED',
650 - 'HTTP_X_CLUSTER_CLIENT_IP',
651 - 'HTTP_X_REAL_IP',
652 - 'HTTP_FORWARDED_FOR',
653 - 'HTTP_FORWARDED',
654 - 'REMOTE_ADDR',
655 - );
656 - }
657 -
658 - /**
659 - * Check if we should check every HTTP header or just $_SERVER['REMOTE_ADDR'].
660 - * The other HTTP headers can be spoofed so this isn't recommended.
661 - * But in some cases (like reverse proxies), the IP may be empty if you use $_SERVER['REMOTE_ADDR'].
662 - *
663 - * @since 6.1
664 - *
665 - * @return bool
666 - */
667 - private static function should_use_custom_header_ip() {
668 - $settings = self::get_settings();
669 - $should_use_custom_header_ip = ! $settings->no_ips && $settings->custom_header_ip;
670 -
671 - /**
672 - * Filter whether to check spoofable HTTP headers.
673 - * This uses the custom_header_ip setting, but it is hidden if the GDPR option is also on.
674 - * As the IP is still checked for blacklist checks, someone with the GDPR option may still want to enable this when behind a reverse proxy.
675 - *
676 - * @since 6.1
677 - *
678 - * @param bool $should_use_custom_header_ip
679 - */
680 - return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
681 - }
682 -
683 407 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
684 408 if ( strpos( $param, '[' ) ) {
685 409 $params = explode( '[', $param );
686 410 $param = $params[0];
@@ -710,9 +434,9 @@
710 434 continue;
711 435 }
712 436
713 437 $p = trim( $p, ']' );
714 - $value = $value[ $p ] ?? $default;
438 + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
715 439 }
716 440 }
717 441
718 442 return $value;
@@ -717,24 +441,15 @@
717 441
718 442 return $value;
719 443 }
720 444
721 - /**
722 - * Get a value from $_POST data.
723 - *
724 - * @param string $param The key we are trying to access data from in $_POST.
725 - * @param mixed $default The default if nothing is being sent.
726 - * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default.
727 - * @param bool $serialized
728 - * @return mixed
729 - */
730 445 public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
731 446 return self::get_simple_request(
732 447 array(
733 - 'type' => 'post',
734 - 'param' => $param,
735 - 'default' => $default,
736 - 'sanitize' => $sanitize,
448 + 'type' => 'post',
449 + 'param' => $param,
450 + 'default' => $default,
451 + 'sanitize' => $sanitize,
737 452 'serialized' => $serialized,
738 453 )
739 454 );
740 455 }
@@ -745,9 +460,9 @@
745 460 * @param string $param
746 461 * @param string $sanitize
747 462 * @param string $default
748 463 *
749 - * @return array|string
464 + * @return string|array
750 465 */
751 466 public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
752 467 return self::get_simple_request(
753 468 array(
@@ -765,27 +480,27 @@
765 480 * @since 2.0.6
766 481 *
767 482 * @param array $args
768 483 *
769 - * @return array|string
484 + * @return string|array
770 485 */
771 486 public static function get_simple_request( $args ) {
772 487 $defaults = array(
773 - 'param' => '',
774 - 'default' => '',
775 - 'type' => 'get',
776 - 'sanitize' => 'sanitize_text_field',
488 + 'param' => '',
489 + 'default' => '',
490 + 'type' => 'get',
491 + 'sanitize' => 'sanitize_text_field',
777 492 'serialized' => false,
778 493 );
779 494 $args = wp_parse_args( $args, $defaults );
780 495
781 496 $value = $args['default'];
782 - if ( $args['type'] === 'get' ) {
497 + if ( $args['type'] == 'get' ) {
783 498 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
784 499 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
785 500 $value = wp_unslash( $_GET[ $args['param'] ] );
786 501 }
787 - } elseif ( $args['type'] === 'post' ) {
502 + } elseif ( $args['type'] == 'post' ) {
788 503 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
789 504 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
790 505 $value = wp_unslash( $_POST[ $args['param'] ] );
791 506 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
@@ -791,12 +506,13 @@
791 506 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
792 507 self::unserialize_or_decode( $value );
793 508 }
794 509 }
795 - } elseif ( isset( $_REQUEST[ $args['param'] ] ) ) {
796 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
510 + } else {
511 + if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
797 512 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
798 513 $value = wp_unslash( $_REQUEST[ $args['param'] ] );
514 + }
799 515 }
800 516
801 517 self::sanitize_value( $args['sanitize'], $value );
802 518
@@ -820,35 +536,19 @@
820 536
821 537 return $value;
822 538 }
823 539
824 - /**
825 - * Sanitize a value in-place.
826 - * If $value is an array, the sanitize function will get called for each item.
827 - *
828 - * @param callable $sanitize
829 - * @param mixed $value
830 - * @return void
831 - */
832 540 public static function sanitize_value( $sanitize, &$value ) {
833 - if ( ! $sanitize ) {
834 - return;
835 - }
836 -
837 - if ( is_object( $value ) ) {
838 - $value = '';
839 - return;
840 - }
841 -
842 - if ( is_array( $value ) ) {
843 - $temp_values = $value;
844 - foreach ( $temp_values as $k => $v ) {
845 - self::sanitize_value( $sanitize, $value[ $k ] );
541 + if ( ! empty( $sanitize ) ) {
542 + if ( is_array( $value ) ) {
543 + $temp_values = $value;
544 + foreach ( $temp_values as $k => $v ) {
545 + self::sanitize_value( $sanitize, $value[ $k ] );
546 + }
547 + } else {
548 + $value = call_user_func( $sanitize, $value );
846 549 }
847 - return;
848 550 }
849 -
850 - $value = call_user_func( $sanitize, $value );
851 551 }
852 552
853 553 public static function sanitize_request( $sanitize_method, &$values ) {
854 554 $temp_values = $values;
@@ -860,52 +560,15 @@
860 560 }
861 561
862 562 /**
863 563 * @since 4.0.04
864 - *
865 - * @param mixed $value
866 - * @return void
867 564 */
868 565 public static function sanitize_with_html( &$value ) {
869 - if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) {
870 - // Only strip unsafe HTML like scripts for a privileged user submitting a form.
871 - self::sanitize_value( 'wp_kses_post', $value );
872 - } else {
873 - self::sanitize_value( self::class . '::strip_most_html', $value );
874 - }
566 + self::sanitize_value( 'wp_kses_post', $value );
875 567 self::decode_specialchars( $value );
876 568 }
877 569
878 570 /**
879 - * Allow only a small set of very basic HTML for unprivileged users.
880 - *
881 - * @since 6.7.1
882 - *
883 - * @param string $value
884 - */
885 - public static function strip_most_html( $value ) {
886 - $allowed_html = array(
887 - 'b' => array(),
888 - 'br' => array(),
889 - 'strong' => array(),
890 - 'p' => array(),
891 - 'i' => array(),
892 - 'ul' => array(),
893 - 'ol' => array(),
894 - 'li' => array(),
895 - );
896 -
897 - /**
898 - * @since 6.7.1
899 - *
900 - * @param array $allowed_html
901 - */
902 - $allowed_html = apply_filters( 'frm_allowed_form_input_html', $allowed_html );
903 -
904 - return wp_kses( $value, $allowed_html );
905 - }
906 -
907 - /**
908 571 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&amp;'
909 572 * this MUST be done, else we'll be back to the '& entity' problem.
910 573 *
911 574 * @since 4.0.04
@@ -939,12 +602,10 @@
939 602 $translation = array(
940 603 '&quot;' => '"',
941 604 '&#034;' => '"',
942 605 '&#x22;' => '"',
943 - // The space preserves the HTML.
944 - '&lt; ' => '< ',
945 - // The space preserves the HTML.
946 - '&#060; ' => '< ',
606 + '&lt; ' => '< ', // The space preserves the HTML.
607 + '&#060; ' => '< ', // The space preserves the HTML.
947 608 '&gt;' => '>',
948 609 '&#062;' => '>',
949 610 '&amp;' => '&',
950 611 '&#038;' => '&',
@@ -971,10 +632,10 @@
971 632 * Sanitize the value, and allow some HTML
972 633 *
973 634 * @since 2.0
974 635 *
975 - * @param string $value
976 - * @param array|string $allowed 'all' for everything included as defaults.
636 + * @param string $value
637 + * @param array|string $allowed 'all' for everything included as defaults
977 638 *
978 639 * @return string
979 640 */
980 641 public static function kses( $value, $allowed = array() ) {
@@ -983,21 +644,8 @@
983 644 return wp_kses( $value, $allowed_html );
984 645 }
985 646
986 647 /**
987 - * Sanitizes and echoes a given value.
988 - *
989 - * @since 6.18
990 - *
991 - * @param string $value The value to sanitize and output.
992 - * @param array|string $allowed Allowed HTML tags and attributes.
993 - * @return void
994 - */
995 - public static function kses_echo( $value, $allowed = array() ) {
996 - echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
997 - }
998 -
999 - /**
1000 648 * The regular kses function strips [button_action] from submit button HTML.
1001 649 *
1002 650 * @since 5.0.13
1003 651 *
@@ -1071,9 +719,9 @@
1071 719 if ( $allowed === 'all' ) {
1072 720 $allowed_html = $html;
1073 721 } elseif ( ! empty( $allowed ) ) {
1074 722 foreach ( (array) $allowed as $a ) {
1075 - $allowed_html[ $a ] = $html[ $a ] ?? array();
723 + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
1076 724 }
1077 725 }
1078 726
1079 727 return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html );
@@ -1088,9 +736,9 @@
1088 736 'id' => true,
1089 737 );
1090 738
1091 739 return array(
1092 - 'a' => array(
740 + 'a' => array(
1093 741 'class' => true,
1094 742 'href' => true,
1095 743 'id' => true,
1096 744 'rel' => true,
@@ -1159,16 +807,16 @@
1159 807 'cite' => true,
1160 808 'title' => true,
1161 809 ),
1162 810 'rect' => array(
1163 - 'class' => true,
1164 - 'fill' => true,
1165 - 'height' => true,
1166 - 'width' => true,
1167 - 'x' => true,
1168 - 'y' => true,
1169 - 'rx' => true,
1170 - 'stroke' => true,
811 + 'class' => true,
812 + 'fill' => true,
813 + 'height' => true,
814 + 'width' => true,
815 + 'x' => true,
816 + 'y' => true,
817 + 'rx' => true,
818 + 'stroke' => true,
1171 819 'stroke-opacity' => true,
1172 820 'stroke-width' => true,
1173 821 ),
1174 822 'section' => $allow_class,
@@ -1203,9 +851,9 @@
1203 851 'xlink:href' => true,
1204 852 ),
1205 853 'ul' => $allow_class,
1206 854 'label' => array(
1207 - 'for' => true,
855 + 'for' => true,
1208 856 'class' => true,
1209 857 'id' => true,
1210 858 ),
1211 859 'button' => array(
@@ -1214,13 +862,8 @@
1214 862 ),
1215 863 'legend' => array(
1216 864 'class' => true,
1217 865 ),
1218 - 'option' => array(
1219 - 'class' => true,
1220 - 'value' => true,
1221 - 'selected' => true,
1222 - ),
1223 866 );
1224 867 }
1225 868
1226 869 /**
@@ -1228,9 +871,9 @@
1228 871 *
1229 872 * @since 2.0
1230 873 */
1231 874 public static function remove_get_action() {
1232 - if ( empty( $_GET ) ) {
875 + if ( ! isset( $_GET ) ) {
1233 876 return;
1234 877 }
1235 878
1236 879 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
@@ -1247,9 +890,9 @@
1247 890 /**
1248 891 * Check the WP query for a parameter
1249 892 *
1250 893 * @since 2.0
1251 - * @return array|string
894 + * @return string|array
1252 895 */
1253 896 public static function get_query_var( $value, $param ) {
1254 897 if ( $value != '' ) {
1255 898 return $value;
@@ -1266,12 +909,10 @@
1266 909 /**
1267 910 * Try to show the SVG if possible. Otherwise, use the font icon.
1268 911 *
1269 912 * @since 4.0.02
1270 - *
1271 913 * @param string $class
1272 914 * @param array $atts
1273 - * @return string|null
1274 915 */
1275 916 public static function icon_by_class( $class, $atts = array() ) {
1276 917 $echo = ! isset( $atts['echo'] ) || $atts['echo'];
1277 918 if ( isset( $atts['echo'] ) ) {
@@ -1280,20 +921,8 @@
1280 921
1281 922 $html_atts = self::array_to_html_params( $atts );
1282 923
1283 924 $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1284 -
1285 - // Replace icons that have been removed or renamed.
1286 - $deprecated = array(
1287 - 'frm_clone_solid_icon' => 'frm_clone_icon',
1288 - 'frm_keyalt_icon' => 'frm_key_icon',
1289 - 'frm_keyalt_solid_icon' => 'frm_key_solid_icon',
1290 - );
1291 - if ( isset( $deprecated[ $icon ] ) ) {
1292 - $icon = $deprecated[ $icon ];
1293 - $class = str_replace( $icon, $deprecated[ $icon ], $class );
1294 - }
1295 -
1296 925 if ( $icon === $class ) {
1297 926 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
1298 927 } else {
1299 928 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
@@ -1300,9 +929,11 @@
1300 929 if ( strpos( $icon, ' ' ) ) {
1301 930 $icon = explode( ' ', $icon );
1302 931 $icon = reset( $icon );
1303 932 }
1304 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>';
933 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
934 + <use xlink:href="#' . esc_attr( $icon ) . '" />
935 + </svg>';
1305 936 }
1306 937
1307 938 if ( $echo ) {
1308 939 echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -1338,9 +969,8 @@
1338 969 */
1339 970 public static function add_allowed_icon_tags( $allowed_html ) {
1340 971 $allowed_html['svg']['data-open'] = true;
1341 972 $allowed_html['svg']['title'] = true;
1342 - $allowed_html['svg']['tabindex'] = true;
1343 973 return $allowed_html;
1344 974 }
1345 975
1346 976 /**
@@ -1349,9 +979,9 @@
1349 979 * @param array $allowed_attr
1350 980 * @return array
1351 981 */
1352 982 public static function allow_vars_in_styles( $allowed_attr ) {
1353 - $allowed_attr[] = '--primary-700';
983 + $allowed_attr[] = '--primary-hover';
1354 984 return $allowed_attr;
1355 985 }
1356 986
1357 987 /**
@@ -1360,9 +990,9 @@
1360 990 * @param bool $allow_css
1361 991 * @param string $css_string
1362 992 */
1363 993 public static function allow_style( $allow_css, $css_string ) {
1364 - if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
994 + if ( ! $allow_css && 0 === strpos( $css_string, '--primary-hover:' ) ) {
1365 995 $split = explode( ':', $css_string, 2 );
1366 996 $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1367 997 }
1368 998 return $allow_css;
@@ -1389,18 +1019,11 @@
1389 1019 /**
1390 1020 * Include svg images.
1391 1021 *
1392 1022 * @since 4.0.02
1393 - * @return void
1394 1023 */
1395 1024 public static function include_svg() {
1396 - if ( self::$included_svg ) {
1397 - return;
1398 - }
1399 -
1400 - // Use readfile instead of include_once because of a default security rule in Snuffleupagus.
1401 - readfile( self::plugin_path() . '/images/icons.svg' );
1402 - self::$included_svg = true;
1025 + include_once( self::plugin_path() . '/images/icons.svg' );
1403 1026 }
1404 1027
1405 1028 /**
1406 1029 * Convert an associative array to HTML values.
@@ -1412,9 +1035,9 @@
1412 1035 * @param bool $echo
1413 1036 * @return string|void
1414 1037 */
1415 1038 public static function array_to_html_params( $atts, $echo = false ) {
1416 - $callback = function () use ( $atts ) {
1039 + $callback = function() use ( $atts ) {
1417 1040 if ( $atts ) {
1418 1041 foreach ( $atts as $key => $value ) {
1419 1042 echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1420 1043 }
@@ -1429,9 +1052,9 @@
1429 1052 * @since 5.0.13
1430 1053 *
1431 1054 * @param Closure $echo_function
1432 1055 * @param bool $echo
1433 - * @return string|null
1056 + * @return string|void
1434 1057 */
1435 1058 public static function clip( $echo_function, $echo = false ) {
1436 1059 if ( ! $echo ) {
1437 1060 ob_start();
@@ -1436,11 +1059,9 @@
1436 1059 if ( ! $echo ) {
1437 1060 ob_start();
1438 1061 }
1439 1062
1440 - if ( is_callable( $echo_function ) ) {
1441 - $echo_function();
1442 - }
1063 + $echo_function();
1443 1064
1444 1065 if ( ! $echo ) {
1445 1066 $return = ob_get_contents();
1446 1067 ob_end_clean();
@@ -1449,15 +1070,12 @@
1449 1070 }
1450 1071
1451 1072 /**
1452 1073 * @since 3.0
1453 - *
1454 - * @param array $atts
1455 - * @return void
1456 1074 */
1457 1075 public static function get_admin_header( $atts ) {
1458 - $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] );
1459 - if ( empty( $atts['close'] ) ) {
1076 + $has_nav = ( isset( $atts['form'] ) && ! empty( $atts['form'] ) && ( ! isset( $atts['is_template'] ) || ! $atts['is_template'] ) );
1077 + if ( ! isset( $atts['close'] ) || empty( $atts['close'] ) ) {
1460 1078 $atts['close'] = admin_url( 'admin.php?page=formidable' );
1461 1079 }
1462 1080 if ( ! isset( $atts['import_link'] ) ) {
1463 1081 $atts['import_link'] = false;
@@ -1462,122 +1080,35 @@
1462 1080 if ( ! isset( $atts['import_link'] ) ) {
1463 1081 $atts['import_link'] = false;
1464 1082 }
1465 1083
1466 - include self::plugin_path() . '/classes/views/shared/admin-header.php';
1084 + include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1467 1085 }
1468 1086
1469 1087 /**
1470 - * @since 6.0
1471 - *
1472 - * @param string $type
1473 - * @return void
1088 + * @since 3.0
1089 + * @param array $atts
1474 1090 */
1475 - public static function import_link( $type = 'secondary' ) {
1476 - ?>
1477 - <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">
1478 - <?php esc_html_e( 'Import', 'formidable' ); ?>
1479 - </a>
1480 - <?php
1481 - }
1482 -
1483 - /**
1484 - * Print applicable admin banner.
1485 - *
1486 - * @since 5.4.2
1487 - *
1488 - * @param bool $should_show_lite_upgrade
1489 - * @return void
1490 - */
1491 - public static function print_admin_banner( $should_show_lite_upgrade ) {
1492 - if ( ! current_user_can( 'administrator' ) ) {
1493 - FrmInbox::maybe_show_banner();
1494 - return;
1495 - }
1496 -
1497 - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1498 - // Print license warning or inbox banner and exit if either prints.
1499 - // And exit before printing the upgrade bar if it shouldn't be shown.
1500 - return;
1501 - }
1502 - ?>
1503 - <div class="frm-upgrade-bar">
1504 - <div class="frm-upgrade-bar-inner">
1091 + public static function add_new_item_link( $atts ) {
1092 + if ( ! empty( $atts['new_link'] ) ) {
1093 + ?>
1094 + <a href="<?php echo esc_url( $atts['new_link'] ); ?>" class="button button-primary frm-button-primary frm-with-plus">
1095 + <?php self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' ); ?>
1096 + <?php esc_html_e( 'Add New', 'formidable' ); ?>
1097 + </a>
1098 + <?php
1099 + } elseif ( ! empty( $atts['trigger_new_form_modal'] ) ) {
1100 + ?>
1101 + <a href="#" class="button button-primary frm-button-primary frm-with-plus frm-trigger-new-form-modal">
1505 1102 <?php
1506 - $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' );
1507 - if ( ! $cta_text ) {
1508 - $cta_text = __( 'upgrading to PRO', 'formidable' );
1509 - }
1510 -
1511 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' );
1512 - $utm = array(
1513 - 'campaign' => 'settings-license',
1514 - 'content' => 'lite-banner',
1515 - );
1516 -
1517 - if ( $upgrade_link ) {
1518 - $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm );
1519 - } else {
1520 - $upgrade_link = self::admin_upgrade_link( $utm );
1521 - }
1522 -
1523 - printf(
1524 - /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */
1525 - esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ),
1526 - '<a href="' . esc_url( $upgrade_link ) . '">',
1527 - esc_html( $cta_text ),
1528 - '</a>'
1529 - );
1103 + self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' );
1104 + esc_html_e( 'Add New', 'formidable' );
1530 1105 ?>
1531 - </div>
1532 - </div>
1533 - <?php
1534 - }
1535 -
1536 - /**
1537 - * @since 5.4.2
1538 - *
1539 - * @return bool True if a banner is available and shown.
1540 - */
1541 - private static function maybe_show_license_warning() {
1542 - return is_callable( 'FrmProAddonsController::admin_banner' ) && FrmProAddonsController::admin_banner();
1543 - }
1544 -
1545 - /**
1546 - * Render a button for a new item (Form, Application, etc).
1547 - *
1548 - * @since 3.0
1549 - * @param array $atts {
1550 - * Details about the button.
1551 - *
1552 - * @type array $link_hook Custom link hook, calls do_action and exits early.
1553 - * @type string $new_link Href value, default #.
1554 - * @type string $class Custom class names, space separated.
1555 - * @type string $button_text Button text. Default "Add New".
1556 - * }
1557 - * @return void
1558 - */
1559 - public static function add_new_item_link( $atts ) {
1560 - if ( isset( $atts['link_hook'] ) ) {
1106 + </a>
1107 + <?php
1108 + } elseif ( isset( $atts['link_hook'] ) ) {
1561 1109 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1562 - return;
1563 1110 }
1564 -
1565 - if ( empty( $atts['new_link'] ) && empty( $atts['create_form'] ) && empty( $atts['class'] ) ) {
1566 - // Do not render a button if none of these attributes are set.
1567 - return;
1568 - }
1569 -
1570 - $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#';
1571 - $class = 'button button-primary frm-button-primary';
1572 -
1573 - if ( ! empty( $atts['class'] ) ) {
1574 - $class .= ' ' . $atts['class'];
1575 - }
1576 -
1577 - $button_text = ! empty( $atts['button_text'] ) ? $atts['button_text'] : __( 'Add New', 'formidable' );
1578 -
1579 - require self::plugin_path() . '/classes/views/shared/add-button.php';
1580 1111 }
1581 1112
1582 1113 /**
1583 1114 * @since 3.06
@@ -1587,12 +1118,10 @@
1587 1118 'placeholder' => '',
1588 1119 'tosearch' => '',
1589 1120 'text' => __( 'Search', 'formidable' ),
1590 1121 'input_id' => '',
1591 - 'value' => false,
1592 - 'class' => '',
1593 1122 );
1594 - $atts = array_merge( $defaults, $atts );
1123 + $atts = array_merge( $defaults, $atts );
1595 1124
1596 1125 if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) {
1597 1126 $atts['tosearch'] = 'frm-card';
1598 1127 }
@@ -1603,34 +1132,21 @@
1603 1132 }
1604 1133
1605 1134 $input_id = $atts['input_id'] . '-search-input';
1606 1135
1607 - $input_atts = array(
1608 - 'type' => 'search',
1609 - 'id' => $input_id,
1610 - 'name' => 's',
1611 - 'placeholder' => $atts['placeholder'],
1612 - 'class' => $class,
1613 - 'data-tosearch' => $atts['tosearch'],
1614 - );
1615 -
1616 - if ( is_string( $atts['value'] ) ) {
1617 - $input_atts['value'] = $atts['value'];
1618 - } elseif ( isset( $_REQUEST['s'] ) ) {
1619 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1620 - $input_atts['value'] = wp_unslash( $_REQUEST['s'] );
1621 - }
1622 -
1623 - if ( ! empty( $atts['tosearch'] ) ) {
1624 - $input_atts['autocomplete'] = 'off';
1625 - }
1626 1136 ?>
1627 - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>">
1137 + <p class="frm-search">
1628 1138 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
1629 1139 <?php echo esc_html( $atts['text'] ); ?>:
1630 1140 </label>
1631 - <?php self::icon_by_class( 'frm_icon_font frm_search_icon frm_svg20' ); ?>
1632 - <input <?php self::array_to_html_params( $input_atts, true ); ?> />
1141 + <span class="frmfont frm_search_icon"></span>
1142 + <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s"
1143 + value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( $atts['placeholder'] ); ?>"
1144 + class="<?php echo esc_attr( $class ); ?>" data-tosearch="<?php echo esc_attr( $atts['tosearch'] ); ?>"
1145 + <?php if ( ! empty( $atts['tosearch'] ) ) { ?>
1146 + autocomplete="off"
1147 + <?php } ?>
1148 + />
1633 1149 <?php
1634 1150 if ( empty( $atts['tosearch'] ) ) {
1635 1151 submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
1636 1152 }
@@ -1640,9 +1156,8 @@
1640 1156 }
1641 1157
1642 1158 /**
1643 1159 * @param string $type
1644 - * @return void
1645 1160 */
1646 1161 public static function trigger_hook_load( $type, $object = null ) {
1647 1162 // Only load the form hooks once.
1648 1163 $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
@@ -1651,14 +1166,11 @@
1651 1166 }
1652 1167 }
1653 1168
1654 1169 /**
1655 - * Save all front-end js scripts into a single file.
1656 - * And save an additional single file of all front-end Stripe JS scripts.
1170 + * Save all front-end js scripts into a single file
1657 1171 *
1658 1172 * @since 3.0
1659 - *
1660 - * @return void
1661 1173 */
1662 1174 public static function save_combined_js() {
1663 1175 $file_atts = apply_filters(
1664 1176 'frm_js_location',
@@ -1671,34 +1183,10 @@
1671 1183
1672 1184 $files = array(
1673 1185 self::plugin_path() . '/js/formidable.min.js',
1674 1186 );
1675 - /**
1676 - * @param array $files
1677 - */
1678 1187 $files = apply_filters( 'frm_combined_js_files', $files );
1679 1188 $new_file->combine_files( $files );
1680 -
1681 - // Create the minified Stripe Script.
1682 - $file_atts = apply_filters(
1683 - 'frm_stripe_js_location',
1684 - array(
1685 - 'file_name' => 'frmstrp.min.js',
1686 - 'new_file_path' => self::plugin_path() . '/js',
1687 - )
1688 - );
1689 - $new_file = new FrmCreateFile( $file_atts );
1690 - $files = array(
1691 - FrmStrpLiteAppHelper::plugin_path() . 'js/frmstrp.min.js',
1692 - );
1693 -
1694 - /**
1695 - * @since 6.5
1696 - *
1697 - * @param array $files
1698 - */
1699 - $files = apply_filters( 'frm_stripe_combined_js_files', $files );
1700 - $new_file->combine_files( $files );
1701 1189 }
1702 1190
1703 1191 /**
1704 1192 * Check a value from a shortcode to see if true or false.
@@ -1705,14 +1193,14 @@
1705 1193 * True when value is 1, true, 'true', 'yes'
1706 1194 *
1707 1195 * @since 1.07.10
1708 1196 *
1709 - * @param string $value The value to compare.
1197 + * @param string $value The value to compare
1710 1198 *
1711 - * @return bool
1199 + * @return boolean True or False
1712 1200 */
1713 1201 public static function is_true( $value ) {
1714 - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value;
1202 + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
1715 1203 }
1716 1204
1717 1205 /**
1718 1206 * Gets all post from a specific post type.
@@ -1770,9 +1258,9 @@
1770 1258 $args = self::preformat_selection_args( $args );
1771 1259
1772 1260 $pages_count = wp_count_posts( $args['post_type'] );
1773 1261
1774 - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) {
1262 + if ( $pages_count->publish <= 50 ) {
1775 1263 self::wp_pages_dropdown( $args );
1776 1264 return;
1777 1265 }
1778 1266
@@ -1778,9 +1266,9 @@
1778 1266
1779 1267 wp_enqueue_script( 'jquery-ui-autocomplete' );
1780 1268
1781 1269 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1782 - $title = '';
1270 + $title = '';
1783 1271
1784 1272 if ( $selected ) {
1785 1273 $title = get_the_title( $selected );
1786 1274 }
@@ -1796,112 +1284,18 @@
1796 1284 <?php
1797 1285 }
1798 1286
1799 1287 /**
1800 - * Maybe show an HTML select or autocomplete input based on the number of options.
1801 - *
1802 - * @since 6.21
1803 - *
1804 - * @param array $args Args. See the method for details.
1288 + * @param array $args
1289 + * @param string $page_id Deprecated.
1290 + * @param boolean $truncate Deprecated.
1805 1291 */
1806 - public static function maybe_autocomplete_options( $args ) {
1807 - $defaults = array(
1808 - 'truncate' => false,
1809 - 'placeholder' => ' ',
1810 - 'name' => '',
1811 - 'id' => '',
1812 - 'selected' => '',
1813 - 'source' => array(),
1814 - 'dropdown_limit' => 50,
1815 - 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ),
1816 - 'value_key' => 'value',
1817 - 'label_key' => 'label',
1818 - );
1819 -
1820 - $args = wp_parse_args( $args, $defaults );
1821 -
1822 - $html_attrs = array();
1823 - if ( ! empty( $args['name'] ) ) {
1824 - $html_attrs['name'] = $args['name'];
1825 - }
1826 -
1827 - if ( ! empty( $args['id'] ) ) {
1828 - $html_attrs['id'] = $args['id'];
1829 - }
1830 -
1831 - if ( count( $args['source'] ) <= $args['dropdown_limit'] ) {
1832 - ?>
1833 - <select <?php self::array_to_html_params( $html_attrs, true ); ?>>
1834 - <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
1835 - <?php
1836 - foreach ( $args['source'] as $key => $source ) :
1837 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1838 - if ( ! empty( $args['truncate'] ) ) {
1839 - $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] );
1840 - }
1841 - ?>
1842 - <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option>
1843 - <?php endforeach; ?>
1844 - </select>
1845 - <?php
1846 - } else {
1847 - $options = array();
1848 - $autocomplete_value = '';
1849 - foreach ( $args['source'] as $key => $source ) {
1850 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1851 -
1852 - if ( $value_label['value'] === $args['selected'] ) {
1853 - $autocomplete_value = $value_label['label'];
1854 - }
1855 -
1856 - $options[] = $value_label;
1857 - }
1858 -
1859 - $html_attrs['type'] = 'hidden';
1860 - $html_attrs['class'] = 'frm_autocomplete_value_input';
1861 - $html_attrs['value'] = $args['selected'];
1862 - ?>
1863 - <input type="text" class="frm-custom-search"
1864 - data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>"
1865 - placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>"
1866 - value="<?php echo esc_attr( $autocomplete_value ); ?>" />
1867 - <input <?php self::array_to_html_params( $html_attrs, true ); ?> />
1868 - <?php
1869 - }//end if
1870 - }
1871 -
1872 - /**
1873 - * Gets dropdown value and label from autodropdown option.
1874 - *
1875 - * @since 6.21
1876 - *
1877 - * @param array|string $option Autocomplete option.
1878 - * @param string $key Array key of the option.
1879 - * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}.
1880 - * @return array
1881 - */
1882 - private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) {
1883 - if ( is_array( $option ) ) {
1884 - $value = $option[ $args['value_key'] ] ?? '';
1885 - $label = $option[ $args['label_key'] ] ?? '';
1886 - } else {
1887 - $value = $key;
1888 - $label = $option;
1889 - }
1890 -
1891 - return compact( 'value', 'label' );
1892 - }
1893 -
1894 - /**
1895 - * @param array $args
1896 - * @param string $page_id Deprecated.
1897 - * @param bool $truncate Deprecated.
1898 - */
1899 1292 public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) {
1900 1293 self::prep_page_dropdown_params( $page_id, $truncate, $args );
1901 1294
1902 1295 $pages = self::get_post_ids_and_titles( $args['post_type'] );
1903 1296 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1297 +
1904 1298 ?>
1905 1299 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
1906 1300 <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
1907 1301 <?php foreach ( $pages as $page ) { ?>
@@ -1938,13 +1332,13 @@
1938 1332 * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array.
1939 1333 */
1940 1334 private static function preformat_selection_args( $args ) {
1941 1335 $defaults = array(
1942 - 'truncate' => false,
1943 - 'placeholder' => ' ',
1944 - 'field_name' => '',
1945 - 'page_id' => '',
1946 - 'post_type' => 'page',
1336 + 'truncate' => false,
1337 + 'placeholder' => ' ',
1338 + 'field_name' => '',
1339 + 'page_id' => '',
1340 + 'post_type' => 'page',
1947 1341 'autocomplete_placeholder' => __( 'Select a Page', 'formidable' ),
1948 1342 );
1949 1343
1950 1344 return array_merge( $defaults, $args );
@@ -1953,8 +1347,9 @@
1953 1347 public static function post_edit_link( $post_id ) {
1954 1348 $post = get_post( $post_id );
1955 1349 if ( $post ) {
1956 1350 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1351 + $post_url = self::maybe_full_screen_link( $post_url );
1957 1352
1958 1353 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
1959 1354 }
1960 1355
@@ -1964,67 +1359,37 @@
1964 1359 /**
1965 1360 * Hide the WordPress menus on some pages.
1966 1361 *
1967 1362 * @since 4.0
1968 - *
1969 - * @return bool
1970 1363 */
1971 1364 public static function is_full_screen() {
1972 - return self::is_form_builder_page() ||
1973 - self::is_style_editor_page() ||
1974 - self::is_full_screen_view_builder_page();
1365 + $full_builder = self::is_form_builder_page();
1366 + $styler = self::is_admin_page( 'formidable-styles' ) || self::is_admin_page( 'formidable-styles2' );
1367 + $full_entries = self::simple_get( 'frm-full', 'absint' );
1368 +
1369 + return $full_builder || $full_entries || $styler || self::is_view_builder_page();
1975 1370 }
1976 1371
1977 1372 /**
1978 - * Check if user is on the style editor or its alternative URL.
1979 - * The first URL is a submenu "Styles" in the Formidable menu /wp-admin/admin.php?page=formidable-styles.
1980 - * The alternative URL is linked as a submenu "Forms" item of the Appearance menu /wp-admin/themes.php?page=formidable-styles2.
1981 - *
1982 - * @since 5.5.3
1983 - * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
1984 - *
1985 - * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
1986 - * @return bool
1373 + * @since 4.0
1987 1374 */
1988 - public static function is_style_editor_page( $view = '' ) {
1989 - if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
1990 - return false;
1375 + public static function maybe_full_screen_link( $link ) {
1376 + $is_full = self::simple_get( 'frm-full', 'absint' );
1377 + if ( $is_full && ! empty( $link ) && $link !== '#' ) {
1378 + $link .= '&frm-full=1';
1991 1379 }
1992 -
1993 - if ( ! in_array( $view, array( 'list', 'edit' ), true ) ) {
1994 - return true;
1995 - }
1996 -
1997 - $action = self::simple_get( 'frm_action' );
1998 - $is_edit_mode = 'edit' === $action || ( ! $action && ! self::simple_get( 'id' ) && ! self::simple_get( 'form' ) );
1999 -
2000 - if ( ! $is_edit_mode && class_exists( 'FrmProStylesController' ) && in_array( $action, array( 'new_style', 'duplicate' ), true ) ) {
2001 - $is_edit_mode = true;
2002 - }
2003 -
2004 - $checking_for_edit_mode = 'edit' === $view;
2005 -
2006 - return $is_edit_mode === $checking_for_edit_mode;
1380 + return $link;
2007 1381 }
2008 1382
2009 1383 /**
2010 - * @since 5.5.3
2011 - *
2012 - * @return bool
1384 + * @param string $field_name
1385 + * @param string|array $capability
1386 + * @param string $multiple 'single' and 'multiple'
2013 1387 */
2014 - private static function is_full_screen_view_builder_page() {
2015 - return self::is_admin_page( 'formidable-views-editor' );
2016 - }
2017 -
2018 - /**
2019 - * @param string $field_name
2020 - * @param array|string $capability
2021 - * @param string $multiple 'single' and 'multiple'.
2022 - */
2023 1388 public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
2024 1389 ?>
2025 1390 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>"
2026 - <?php echo 'multiple' === $multiple ? 'multiple="multiple"' : ''; ?>
1391 + <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?>
2027 1392 class="frm_multiselect">
2028 1393 <?php self::roles_options( $capability ); ?>
2029 1394 </select>
2030 1395 <?php
@@ -2032,9 +1397,9 @@
2032 1397
2033 1398 /**
2034 1399 * @since 4.07
2035 1400 * @param array|string $selected
2036 - * @param string $current
1401 + * @param string $current
2037 1402 */
2038 1403 private static function selected( $selected, $current ) {
2039 1404 if ( is_callable( 'FrmProAppHelper::selected' ) ) {
2040 1405 FrmProAppHelper::selected( $selected, $current );
@@ -2043,9 +1408,9 @@
2043 1408 }
2044 1409 }
2045 1410
2046 1411 /**
2047 - * @param array|string $capability
1412 + * @param string|array $capability
2048 1413 */
2049 1414 public static function roles_options( $capability ) {
2050 1415 global $frm_vars;
2051 1416 if ( isset( $frm_vars['editable_roles'] ) ) {
@@ -2057,9 +1422,9 @@
2057 1422
2058 1423 foreach ( $editable_roles as $role => $details ) {
2059 1424 $name = translate_user_role( $details['name'] );
2060 1425 ?>
2061 - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option>
1426 + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_attr( $name ); ?> </option>
2062 1427 <?php
2063 1428 unset( $role, $details );
2064 1429 }
2065 1430 }
@@ -2072,10 +1437,19 @@
2072 1437 * @param string $type Supports `auto`, `pro`, or `pro_only`.
2073 1438 * @return array
2074 1439 */
2075 1440 public static function frm_capabilities( $type = 'auto' ) {
2076 - if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
2077 - return self::get_lite_capabilities();
1441 + $cap = array(
1442 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1443 + 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1444 + 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1445 + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1446 + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
1447 + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
1448 + );
1449 +
1450 + if ( ! self::pro_is_installed() && 'pro' !== $type && 'pro_only' !== $type ) {
1451 + return $cap;
2078 1452 }
2079 1453
2080 1454 $pro_cap = array(
2081 1455 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
@@ -2080,42 +1454,19 @@
2080 1454 $pro_cap = array(
2081 1455 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
2082 1456 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
2083 1457 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1458 + 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
2084 1459 );
2085 - /**
2086 - * @since 5.3.1
2087 - *
2088 - * @param array<string,string> $pro_cap
2089 - */
2090 - $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
2091 1460
2092 1461 if ( 'pro_only' === $type ) {
2093 1462 return $pro_cap;
2094 1463 }
2095 1464
2096 - return self::get_lite_capabilities() + $pro_cap;
1465 + return $cap + $pro_cap;
2097 1466 }
2098 1467
2099 1468 /**
2100 - * Get the list of lite plugin capabilities.
2101 - *
2102 - * @since 5.3.1
2103 - *
2104 - * @return array<string,string>
2105 - */
2106 - private static function get_lite_capabilities() {
2107 - return array(
2108 - 'frm_view_forms' => __( 'View Forms List', 'formidable' ),
2109 - 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
2110 - 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
2111 - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
2112 - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
2113 - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
2114 - );
2115 - }
2116 -
2117 - /**
2118 1469 * Call the WordPress current_user_can but also validate empty strings as true for any logged in user
2119 1470 *
2120 1471 * @since 4.06.03
2121 1472 *
@@ -2147,9 +1498,9 @@
2147 1498 return current_user_can( $role );
2148 1499 }
2149 1500
2150 1501 /**
2151 - * @param array|string $needed_role
1502 + * @param string|array $needed_role
2152 1503 * @return bool
2153 1504 */
2154 1505 public static function user_has_permission( $needed_role ) {
2155 1506 if ( is_array( $needed_role ) ) {
@@ -2205,11 +1556,8 @@
2205 1556 /**
2206 1557 * Make sure admins have permission to see the menu items
2207 1558 *
2208 1559 * @since 2.0.6
2209 - *
2210 - * @param string $cap
2211 - * @return void
2212 1560 */
2213 1561 public static function force_capability( $cap = 'frm_change_settings' ) {
2214 1562 if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
2215 1563 $role = get_role( 'administrator' );
@@ -2220,9 +1568,9 @@
2220 1568 }
2221 1569 }
2222 1570
2223 1571 /**
2224 - * Check if the user has permission for action.
1572 + * Check if the user has permision for action.
2225 1573 * Return permission message and stop the action if no permission
2226 1574 *
2227 1575 * @since 2.0
2228 1576 *
@@ -2258,9 +1606,9 @@
2258 1606 if ( empty( $nonce_name ) ) {
2259 1607 return $error;
2260 1608 }
2261 1609
2262 - $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
1610 + $nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2263 1611 if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
2264 1612 $frm_settings = self::get_settings();
2265 1613 $error = $frm_settings->admin_permission;
2266 1614 }
@@ -2274,13 +1622,12 @@
2274 1622 }
2275 1623 }
2276 1624
2277 1625 public static function check_selected( $values, $current ) {
2278 - $values = self::recursive_function_map( $values, 'trim' );
2279 - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1626 + $values = self::recursive_function_map( $values, 'trim' );
1627 + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1628 + $current = htmlspecialchars_decode( trim( $current ) );
2280 1629
2281 - $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) );
2282 -
2283 1630 return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
2284 1631 }
2285 1632
2286 1633 public static function recursive_function_map( $value, $function ) {
@@ -2300,9 +1647,8 @@
2300 1647 }
2301 1648 }
2302 1649 }
2303 1650 } else {
2304 - $value = self::maybe_update_value_if_null( $value, $function );
2305 1651 $value = call_user_func( $function, $value );
2306 1652 }
2307 1653
2308 1654 return $value;
@@ -2307,24 +1653,8 @@
2307 1653
2308 1654 return $value;
2309 1655 }
2310 1656
2311 - /**
2312 - * Updates value to empty string if it is null and being passed to a string function.
2313 - *
2314 - * @since 6.8.4
2315 - * @param mixed $value
2316 - * @param string $function
2317 - * @return mixed
2318 - */
2319 - private static function maybe_update_value_if_null( $value, $function ) {
2320 - if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) {
2321 - $value = '';
2322 - }
2323 -
2324 - return $value;
2325 - }
2326 -
2327 1657 public static function is_assoc( $array ) {
2328 1658 return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
2329 1659 }
2330 1660
@@ -2335,12 +1665,14 @@
2335 1665 $return = array();
2336 1666 foreach ( $array as $key => $value ) {
2337 1667 if ( is_array( $value ) ) {
2338 1668 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
2339 - } elseif ( $keys === 'keep' ) {
1669 + } else {
1670 + if ( $keys == 'keep' ) {
2340 1671 $return[ $key ] = $value;
2341 - } else {
2342 - $return[] = $value;
1672 + } else {
1673 + $return[] = $value;
1674 + }
2343 1675 }
2344 1676 }
2345 1677
2346 1678 return $return;
@@ -2345,27 +1677,8 @@
2345 1677
2346 1678 return $return;
2347 1679 }
2348 1680
2349 - /**
2350 - * Flatten an array before imploding it to avoid Array to string conversion warnings.
2351 - *
2352 - * @since 6.16.1
2353 - *
2354 - * @param string $sep
2355 - * @param array $array
2356 - * @return string
2357 - */
2358 - public static function safe_implode( $sep, $array ) {
2359 - $array = self::array_flatten( $array );
2360 - return implode( $sep, $array );
2361 - }
2362 -
2363 - /**
2364 - * @param string $text
2365 - * @param bool $is_rich_text
2366 - * @return string
2367 - */
2368 1681 public static function esc_textarea( $text, $is_rich_text = false ) {
2369 1682 $safe_text = str_replace( '&quot;', '"', $text );
2370 1683 if ( ! $is_rich_text ) {
2371 1684 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
@@ -2371,13 +1684,9 @@
2371 1684 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
2372 1685 }
2373 1686 $safe_text = str_replace( '&amp; ', '& ', $safe_text );
2374 1687
2375 - /**
2376 - * @param string $safe_text
2377 - * @param string $text
2378 - */
2379 - return (string) apply_filters( 'esc_textarea', $safe_text, $text );
1688 + return apply_filters( 'esc_textarea', $safe_text, $text );
2380 1689 }
2381 1690
2382 1691 /**
2383 1692 * Add auto paragraphs to text areas
@@ -2384,9 +1693,9 @@
2384 1693 *
2385 1694 * @since 2.0
2386 1695 */
2387 1696 public static function use_wpautop( $content ) {
2388 - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) {
1697 + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) {
2389 1698 $content = wpautop( str_replace( '<br>', '<br />', $content ) );
2390 1699 }
2391 1700
2392 1701 return $content;
@@ -2428,12 +1737,12 @@
2428 1737 * @since 5.0.13 added $echo param.
2429 1738 *
2430 1739 * @param string $url
2431 1740 * @param bool $echo
2432 - * @return string|null
1741 + * @return string|void
2433 1742 */
2434 1743 public static function js_redirect( $url, $echo = false ) {
2435 - $callback = function () use ( $url ) {
1744 + $callback = function() use ( $url ) {
2436 1745 echo '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
2437 1746 };
2438 1747 return self::clip( $callback, $echo );
2439 1748 }
@@ -2443,9 +1752,9 @@
2443 1752 return $user_id;
2444 1753 }
2445 1754
2446 1755 $user_id = sanitize_text_field( $user_id );
2447 - if ( $user_id === 'current' ) {
1756 + if ( $user_id == 'current' ) {
2448 1757 $user_id = get_current_user_id();
2449 1758 } else {
2450 1759 if ( is_email( $user_id ) ) {
2451 1760 $user = get_user_by( 'email', $user_id );
@@ -2461,13 +1770,8 @@
2461 1770
2462 1771 return $user_id;
2463 1772 }
2464 1773
2465 - /**
2466 - * @param string $filename
2467 - * @param array $atts
2468 - * @return false|string
2469 - */
2470 1774 public static function get_file_contents( $filename, $atts = array() ) {
2471 1775 if ( ! is_file( $filename ) ) {
2472 1776 return false;
2473 1777 }
@@ -2473,9 +1777,9 @@
2473 1777 }
2474 1778
2475 1779 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
2476 1780 ob_start();
2477 - include $filename;
1781 + include( $filename );
2478 1782 $contents = ob_get_contents();
2479 1783 ob_end_clean();
2480 1784
2481 1785 return $contents;
@@ -2530,9 +1834,9 @@
2530 1834 ++$suffix;
2531 1835 } while ( in_array( $key_check, $similar_keys, true ) );
2532 1836
2533 1837 $key = $key_check;
2534 - }//end if
1838 + }
2535 1839
2536 1840 return $key;
2537 1841 }
2538 1842
@@ -2571,19 +1875,15 @@
2571 1875 return $key;
2572 1876 }
2573 1877
2574 1878 /**
2575 - * @since 6.21 This is changed from `private` to `public`.
2576 - *
2577 1879 * @param int $num_chars
2578 1880 * @return string
2579 1881 */
2580 - public static function generate_new_key( $num_chars ) {
2581 - $max_slug_value = 36 ** $num_chars;
2582 -
2583 - // We want to have at least 2 characters in the slug.
2584 - $min_slug_value = 37;
2585 - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
1882 + private static function generate_new_key( $num_chars ) {
1883 + $max_slug_value = pow( 36, $num_chars );
1884 + $min_slug_value = 37; // we want to have at least 2 characters in the slug
1885 + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2586 1886 }
2587 1887
2588 1888 /**
2589 1889 * @param string $key
@@ -2611,16 +1911,11 @@
2611 1911
2612 1912 /**
2613 1913 * Editing a Form or Entry
2614 1914 *
2615 - * @param object $record
2616 - * @param string $table
2617 - * @param array|string $fields
2618 - * @param bool $default
2619 - * @param array $post_values
2620 - * @param array $args
1915 + * @param string $table
2621 1916 *
2622 - * @return array|bool
1917 + * @return bool|array
2623 1918 */
2624 1919 public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
2625 1920 if ( ! $record ) {
2626 1921 return false;
@@ -2635,9 +1930,9 @@
2635 1930 'fields' => array(),
2636 1931 );
2637 1932
2638 1933 foreach ( array( 'name', 'description' ) as $var ) {
2639 - $default_val = $record->{$var} ?? '';
1934 + $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
2640 1935 $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
2641 1936 unset( $var, $default_val );
2642 1937 }
2643 1938
@@ -2662,9 +1957,9 @@
2662 1957 if ( ! self::is_admin_page() ) {
2663 1958 // Don't prep default values on the form settings page.
2664 1959 $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2665 1960 }
2666 - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
1961 + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
2667 1962 self::fill_field_defaults( $field, $record, $values, $args );
2668 1963 }
2669 1964 }
2670 1965 }
@@ -2673,12 +1968,13 @@
2673 1968 $post_values = $args['post_values'];
2674 1969
2675 1970 if ( $args['default'] ) {
2676 1971 $meta_value = $field->default_value;
2677 - } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2678 - if ( ! isset( $field->field_options['custom_field'] ) ) {
2679 - $field->field_options['custom_field'] = '';
2680 - }
1972 + } else {
1973 + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
1974 + if ( ! isset( $field->field_options['custom_field'] ) ) {
1975 + $field->field_options['custom_field'] = '';
1976 + }
2681 1977 $meta_value = FrmProEntryMetaHelper::get_post_value(
2682 1978 $record->post_id,
2683 1979 $field->field_options['post_field'],
2684 1980 $field->field_options['custom_field'],
@@ -2688,13 +1984,14 @@
2688 1984 'form_id' => $field->form_id,
2689 1985 'field' => $field,
2690 1986 )
2691 1987 );
2692 - } else {
2693 - $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2694 - }//end if
1988 + } else {
1989 + $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
1990 + }
1991 + }
2695 1992
2696 - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type;
1993 + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2697 1994 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2698 1995 $new_value = $post_values['item_meta'][ $field->id ];
2699 1996 self::unserialize_or_decode( $new_value );
2700 1997 } else {
@@ -2740,15 +2037,12 @@
2740 2037 );
2741 2038 }
2742 2039
2743 2040 /**
2744 - * @param object $record
2745 2041 * @param string $table
2746 - * @param array $post_values
2747 - * @param array $values
2748 2042 */
2749 2043 private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
2750 - if ( $table === 'entries' ) {
2044 + if ( $table == 'entries' ) {
2751 2045 $form = $record->form_id;
2752 2046 FrmForm::maybe_get_form( $form );
2753 2047 } else {
2754 2048 $form = $record;
@@ -2784,9 +2078,9 @@
2784 2078 $form_defaults = FrmFormsHelper::get_default_opts();
2785 2079
2786 2080 foreach ( $form_defaults as $opt => $default ) {
2787 2081 if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
2788 - $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default;
2082 + $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
2789 2083 }
2790 2084
2791 2085 unset( $opt, $default );
2792 2086 }
@@ -2796,9 +2090,9 @@
2796 2090 }
2797 2091
2798 2092 foreach ( array( 'before', 'after', 'submit' ) as $h ) {
2799 2093 if ( ! isset( $values[ $h . '_html' ] ) ) {
2800 - $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) );
2094 + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
2801 2095 }
2802 2096 unset( $h );
2803 2097 }
2804 2098 }
@@ -2807,9 +2101,9 @@
2807 2101 * @since 2.2.10
2808 2102 *
2809 2103 * @param array $post_values
2810 2104 *
2811 - * @return bool|int
2105 + * @return boolean|int
2812 2106 */
2813 2107 public static function custom_style_value( $post_values ) {
2814 2108 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
2815 2109 $custom_style = absint( $post_values['options']['custom_style'] );
@@ -2814,37 +2108,29 @@
2814 2108 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
2815 2109 $custom_style = absint( $post_values['options']['custom_style'] );
2816 2110 } else {
2817 2111 $frm_settings = self::get_settings();
2818 - $custom_style = ( $frm_settings->load_style !== 'none' );
2112 + $custom_style = ( $frm_settings->load_style != 'none' );
2819 2113 }
2820 2114
2821 2115 return $custom_style;
2822 2116 }
2823 2117
2824 - /**
2825 - * @param mixed $original_string
2826 - * @param int|string $length
2827 - * @param int $minword
2828 - * @param string $continue
2829 - * @return string
2830 - */
2831 - public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) {
2832 - if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) {
2118 + public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
2119 + if ( is_array( $str ) ) {
2833 2120 return '';
2834 2121 }
2835 2122
2836 2123 $length = (int) $length;
2837 - $str = wp_strip_all_tags( (string) $original_string );
2124 + $str = wp_strip_all_tags( $str );
2838 2125 $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
2839 2126
2840 2127 if ( $length == 0 ) {
2841 2128 return '';
2842 - }
2129 + } elseif ( $length <= 10 ) {
2130 + $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
2843 2131
2844 - if ( $length <= 10 ) {
2845 - $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
2846 - return $sub . ( $length < $original_len ? $continue : '' );
2132 + return $sub . ( ( $length < $original_len ) ? $continue : '' );
2847 2133 }
2848 2134
2849 2135 $sub = '';
2850 2136 $len = 0;
@@ -2850,14 +2136,10 @@
2850 2136 $len = 0;
2851 2137
2852 2138 $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
2853 2139
2854 - if ( ! is_array( $words ) ) {
2855 - return $original_string;
2856 - }
2857 -
2858 2140 foreach ( $words as $word ) {
2859 - $part = ( $sub != '' ? ' ' : '' ) . $word;
2141 + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
2860 2142 $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
2861 2143 if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
2862 2144 break;
2863 2145 }
@@ -2871,37 +2153,11 @@
2871 2153
2872 2154 unset( $total_len, $word );
2873 2155 }
2874 2156
2875 - $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length );
2876 -
2877 - return $sub . ( $len < $original_len ? $continue : '' );
2157 + return $sub . ( ( $len < $original_len ) ? $continue : '' );
2878 2158 }
2879 2159
2880 - /**
2881 - * If the string is still too long because there may not have been any spaces, force truncate.
2882 - *
2883 - * @since 6.5.4
2884 - *
2885 - * @param string $sub Current substring.
2886 - * @param int $length The length limit.
2887 - * @return string
2888 - */
2889 - private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
2890 - if ( strlen( $sub ) < $length + 50 ) {
2891 - // If the string isn't way over the limit, leave it.
2892 - return $sub;
2893 - }
2894 -
2895 - $first_space = strpos( $sub, ' ', $length );
2896 - if ( false !== $first_space ) {
2897 - // Ignore anything with spaces.
2898 - return $sub;
2899 - }
2900 -
2901 - return substr( $sub, 0, $length + 10 );
2902 - }
2903 -
2904 2160 public static function mb_function( $function_names, $args ) {
2905 2161 $mb_function_name = $function_names[0];
2906 2162 $function_name = $function_names[1];
2907 2163 if ( function_exists( $mb_function_name ) ) {
@@ -2934,13 +2190,8 @@
2934 2190
2935 2191 return $formatted;
2936 2192 }
2937 2193
2938 - /**
2939 - * @param string $time_format
2940 - * @param string $date
2941 - * @return string
2942 - */
2943 2194 private static function add_time_to_date( $time_format, $date ) {
2944 2195 if ( empty( $time_format ) ) {
2945 2196 $time_format = get_option( 'time_format' );
2946 2197 }
@@ -2963,17 +2214,17 @@
2963 2214 return date_i18n( $date_format, strtotime( $date ) );
2964 2215 }
2965 2216
2966 2217 /**
2967 - * Gets the time ago in words.
2218 + * Gets the time ago in words
2968 2219 *
2969 - * @param int $from In seconds.
2970 - * @param int|string $to In seconds.
2220 + * @param int $from in seconds
2221 + * @param int|string $to in seconds
2971 2222 *
2972 2223 * @return string $time_ago
2973 2224 */
2974 2225 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
2975 - if ( empty( $to ) && 0 !== $to ) {
2226 + if ( empty( $to ) ) {
2976 2227 $now = new DateTime();
2977 2228 } else {
2978 2229 $now = new DateTime( '@' . $to );
2979 2230 }
@@ -2983,9 +2234,9 @@
2983 2234 $diff_object = $now->diff( $ago );
2984 2235 $diff = get_object_vars( $diff_object );
2985 2236
2986 2237 // Add week amount and update day amount
2987 - $diff['w'] = floor( $diff['d'] / 7 );
2238 + $diff['w'] = floor( $diff['d'] / 7 );
2988 2239 $diff['d'] -= $diff['w'] * 7;
2989 2240
2990 2241 $time_strings = self::get_time_strings();
2991 2242
@@ -2992,9 +2243,9 @@
2992 2243 if ( ! is_numeric( $levels ) ) {
2993 2244 // Show time in specified unit.
2994 2245 $levels = self::get_unit( $levels );
2995 2246 if ( isset( $time_strings[ $levels ] ) ) {
2996 - $diff = array(
2247 + $diff = array(
2997 2248 $levels => self::time_format( $levels, $diff ),
2998 2249 );
2999 2250 $time_strings = array(
3000 2251 $levels => $time_strings[ $levels ],
@@ -3083,9 +2334,9 @@
3083 2334 }
3084 2335
3085 2336 /**
3086 2337 * Get the translatable time strings. The untranslated version is a failsafe
3087 - * in case languages are changing for the unit set in the shortcode.
2338 + * in case langauges are changing for the unit set in the shortcode.
3088 2339 *
3089 2340 * @since 2.0.20
3090 2341 * @return array
3091 2342 */
@@ -3131,28 +2382,23 @@
3131 2382
3132 2383 // Pagination Methods.
3133 2384
3134 2385 /**
3135 - * @param int $r_count
3136 - * @param int $current_p
3137 - * @param int $p_size
3138 - * @return int
2386 + * @param integer $current_p
3139 2387 */
3140 2388 public static function get_last_record_num( $r_count, $current_p, $p_size ) {
3141 - return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size );
2389 + return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
3142 2390 }
3143 2391
3144 2392 /**
3145 - * @param int $r_count
3146 - * @param int $current_p
3147 - * @param int $p_size
3148 - * @return int
2393 + * @param integer $current_p
3149 2394 */
3150 2395 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
3151 2396 if ( $current_p == 1 ) {
3152 2397 return 1;
2398 + } else {
2399 + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
3153 2400 }
3154 - return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
3155 2401 }
3156 2402
3157 2403 /**
3158 2404 * @return array
@@ -3175,9 +2421,9 @@
3175 2421 if ( ! isset( $l3 ) ) {
3176 2422 $l3 = $name;
3177 2423 }
3178 2424
3179 - $this_val = $p == $last ? $jv['value'] : array();
2425 + $this_val = ( $p == $last ) ? $jv['value'] : array();
3180 2426
3181 2427 switch ( $p ) {
3182 2428 case 0:
3183 2429 $l1 = $name;
@@ -3199,12 +2445,12 @@
3199 2445 self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
3200 2446 }
3201 2447
3202 2448 unset( $this_val, $n );
3203 - }//end foreach
2449 + }
3204 2450
3205 2451 unset( $last, $jv );
3206 - }//end foreach
2452 + }
3207 2453
3208 2454 return $vars;
3209 2455 }
3210 2456
@@ -3222,9 +2468,9 @@
3222 2468
3223 2469 public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
3224 2470 $tooltips = array(
3225 2471 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
3226 - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ),
2472 + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [admin_email] is the address set in WP General Settings.', 'formidable' ),
3227 2473 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3228 2474 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3229 2475 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3230 2476 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
@@ -3229,9 +2475,8 @@
3229 2475 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3230 2476 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
3231 2477 /* translators: %1$s: Form name, %2$s: Date */
3232 2478 '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() ) ),
3233 - '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' ),
3234 2479 );
3235 2480
3236 2481 if ( ! isset( $tooltips[ $name ] ) ) {
3237 2482 return;
@@ -3258,12 +2503,8 @@
3258 2503 return;
3259 2504 }
3260 2505
3261 2506 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
3262 - if ( 'lite-reports' === $frm_action ) {
3263 - $frm_action = 'reports';
3264 - }
3265 -
3266 2507 if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
3267 2508 echo ' class="current_page"';
3268 2509 }
3269 2510 }
@@ -3320,15 +2561,12 @@
3320 2561 }
3321 2562 }
3322 2563
3323 2564 /**
3324 - * Check for either json or serialized data. This is temporary while transitioning
2565 + * Check for either json or serilized data. This is temporary while transitioning
3325 2566 * all data to json.
3326 2567 *
3327 2568 * @since 4.02.03
3328 - *
3329 - * @param array|string $value
3330 - * @return void
3331 2569 */
3332 2570 public static function unserialize_or_decode( &$value ) {
3333 2571 if ( is_array( $value ) ) {
3334 2572 return;
@@ -3334,9 +2572,9 @@
3334 2572 return;
3335 2573 }
3336 2574
3337 2575 if ( is_serialized( $value ) ) {
3338 - $value = self::maybe_unserialize_array( $value );
2576 + $value = maybe_unserialize( $value );
3339 2577 } else {
3340 2578 $value = self::maybe_json_decode( $value, false );
3341 2579 }
3342 2580 }
@@ -3341,35 +2579,8 @@
3341 2579 }
3342 2580 }
3343 2581
3344 2582 /**
3345 - * Safely unserialize an array if necessary.
3346 - * This function doesn't actually use unserialize. The string is parsed instead.
3347 - *
3348 - * @since 6.2
3349 - *
3350 - * @param mixed $value
3351 - * @return mixed
3352 - */
3353 - public static function maybe_unserialize_array( $value ) {
3354 - if ( ! is_string( $value ) ) {
3355 - return $value;
3356 - }
3357 -
3358 - // Since we only expect an array, skip anything that doesn't start with a:.
3359 - if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
3360 - return $value;
3361 - }
3362 -
3363 - $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
3364 - if ( is_array( $parsed ) ) {
3365 - $value = $parsed;
3366 - }
3367 -
3368 - return $value;
3369 - }
3370 -
3371 - /**
3372 2583 * Decode a JSON string.
3373 2584 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
3374 2585 *
3375 2586 * @param mixed $string
@@ -3396,36 +2607,8 @@
3396 2607 return $string;
3397 2608 }
3398 2609
3399 2610 /**
3400 - * @since 6.2.3
3401 - *
3402 - * @param string $value
3403 - * @return string
3404 - */
3405 - public static function maybe_utf8_encode( $value ) {
3406 - $from_format = 'ISO-8859-1';
3407 - $to_format = 'UTF-8';
3408 -
3409 - if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
3410 - if ( mb_check_encoding( $value, $from_format ) ) {
3411 - return mb_convert_encoding( $value, $to_format, $from_format );
3412 - }
3413 - return $value;
3414 - }
3415 -
3416 - if ( function_exists( 'iconv' ) ) {
3417 - $converted = iconv( $from_format, $to_format, $value );
3418 - // Value is false if $value is not ISO-8859-1.
3419 - if ( false !== $converted ) {
3420 - return $converted;
3421 - }
3422 - }
3423 -
3424 - return $value;
3425 - }
3426 -
3427 - /**
3428 2611 * Reformat the json serialized array in name => value array.
3429 2612 *
3430 2613 * @since 4.02.03
3431 2614 */
@@ -3452,11 +2635,8 @@
3452 2635 }
3453 2636
3454 2637 /**
3455 2638 * @since 4.02.03
3456 - *
3457 - * @param array|string $value
3458 - * @return string
3459 2639 */
3460 2640 public static function maybe_json_encode( $value ) {
3461 2641 if ( is_array( $value ) ) {
3462 2642 $value = wp_json_encode( $value );
@@ -3464,14 +2644,12 @@
3464 2644 return $value;
3465 2645 }
3466 2646
3467 2647 /**
3468 - * Echo The javascript to open and highlight the Formidable menu
3469 - *
3470 2648 * @since 1.07.10
3471 2649 *
3472 - * @param string $post_type The name of the post type that may need to be highlighted.
3473 - * @return void
2650 + * @param string $post_type The name of the post type that may need to be highlighted
2651 + * echo The javascript to open and highlight the Formidable menu
3474 2652 */
3475 2653 public static function maybe_highlight_menu( $post_type ) {
3476 2654 global $post;
3477 2655
@@ -3490,11 +2668,8 @@
3490 2668 /**
3491 2669 * Load the JS file on non-Formidable pages in the admin area
3492 2670 *
3493 2671 * @since 2.0
3494 - *
3495 - * @param bool $load
3496 - * @return void
3497 2672 */
3498 2673 public static function load_admin_wide_js( $load = true ) {
3499 2674 $version = self::plugin_version();
3500 2675 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
@@ -3499,18 +2674,14 @@
3499 2674 $version = self::plugin_version();
3500 2675 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
3501 2676
3502 2677 $global_strings = array(
3503 - 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
3504 - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
3505 - 'url' => self::plugin_url(),
3506 - 'app_url' => 'https://formidableforms.com/',
3507 - 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
3508 - 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
3509 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
3510 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
3511 - 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
3512 - 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(),
2678 + 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2679 + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2680 + 'url' => self::plugin_url(),
2681 + 'app_url' => 'https://formidableforms.com/',
2682 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2683 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
3513 2684 );
3514 2685 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
3515 2686
3516 2687 if ( $load ) {
@@ -3519,9 +2690,8 @@
3519 2690 }
3520 2691
3521 2692 /**
3522 2693 * @since 2.0.9
3523 - * @return void
3524 2694 */
3525 2695 public static function load_font_style() {
3526 2696 wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
3527 2697 }
@@ -3527,144 +2697,99 @@
3527 2697 }
3528 2698
3529 2699 /**
3530 2700 * @param string $location
3531 - * @return void
3532 2701 */
3533 2702 public static function localize_script( $location ) {
3534 - global $wp_scripts, $wp_version;
2703 + global $wp_scripts;
3535 2704
2705 + $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2706 + $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2707 +
3536 2708 $script_strings = array(
3537 - 'ajax_url' => esc_url_raw( self::get_ajax_url() ),
3538 - 'images_url' => self::plugin_url() . '/images',
3539 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
3540 - 'remove' => __( 'Remove', 'formidable' ),
3541 - 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
3542 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
3543 - 'id' => __( 'ID', 'formidable' ),
3544 - 'no_results' => __( 'No results match', 'formidable' ),
3545 - 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
3546 - 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
3547 - 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
3548 - 'focus_first_error' => self::should_focus_first_error(),
3549 - 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
3550 - // We need to keep this setting for a few versions because Pro checks for this.
3551 - 'include_resend_email' => false,
2709 + 'ajax_url' => $ajax_url,
2710 + 'images_url' => self::plugin_url() . '/images',
2711 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2712 + 'remove' => __( 'Remove', 'formidable' ),
2713 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2714 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2715 + 'id' => __( 'ID', 'formidable' ),
2716 + 'no_results' => __( 'No results match', 'formidable' ),
2717 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2718 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2719 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2720 + 'focus_first_error' => self::should_focus_first_error(),
2721 + 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
3552 2722 );
3553 2723
3554 2724 $data = $wp_scripts->get_data( 'formidable', 'data' );
3555 - if ( ! $data ) {
2725 + if ( empty( $data ) ) {
3556 2726 wp_localize_script( 'formidable', 'frm_js', $script_strings );
3557 2727 }
3558 2728
3559 - if ( $location === 'admin' ) {
2729 + if ( $location == 'admin' ) {
2730 + $frm_settings = self::get_settings();
3560 2731 $admin_script_strings = array(
3561 - 'desc' => __( '(Click to add description)', 'formidable' ),
3562 - 'blank' => __( '(Blank)', 'formidable' ),
3563 - 'no_label' => self::get_no_label_text(),
3564 - 'ok' => __( 'OK', 'formidable' ),
3565 - 'cancel' => __( 'Cancel', 'formidable' ),
3566 - 'default_label' => __( 'Default', 'formidable' ),
3567 - 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
3568 - 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
3569 - 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3570 - 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3571 - 'confirm' => __( 'Are you sure?', 'formidable' ),
3572 - 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3573 - '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' ),
3574 - 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3575 - 'default_unique' => FrmFieldsHelper::default_unique_msg(),
3576 - 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3577 - 'enter_email' => __( 'Enter Email', 'formidable' ),
3578 - 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3579 - 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3580 - 'new_option' => __( 'New Option', 'formidable' ),
3581 - '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' ),
3582 - 'enter_password' => __( 'Enter Password', 'formidable' ),
3583 - 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3584 - 'import_complete' => __( 'Import Complete', 'formidable' ),
3585 - 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
3586 - 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
3587 - 'private_label' => __( 'Private', 'formidable' ),
3588 - 'jquery_ui_url' => '',
3589 - 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3590 - 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3591 - 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3592 - 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
3593 - 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3594 - /* translators: %d is the number of allowed actions per form */
3595 - 'only_one_action' => sprintf( __( 'This form action is limited to %d per form.', 'formidable' ), 1 ),
3596 - 'edit_action_text' => __( 'Please edit the existing form action.', 'formidable' ),
3597 - 'unsafe_params' => FrmFormsHelper::reserved_words(),
2732 + 'desc' => __( '(Click to add description)', 'formidable' ),
2733 + 'blank' => __( '(Blank)', 'formidable' ),
2734 + 'no_label' => __( '(no label)', 'formidable' ),
2735 + 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
2736 + 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2737 + 'ok' => __( 'OK', 'formidable' ),
2738 + 'cancel' => __( 'Cancel', 'formidable' ),
2739 + 'default_label' => __( 'Default', 'formidable' ),
2740 + 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2741 + 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2742 + 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2743 + 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2744 + 'caution' => __( 'Heads up', 'formidable' ),
2745 + 'confirm' => __( 'Are you sure?', 'formidable' ),
2746 + 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2747 + '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' ),
2748 + 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
2749 + 'default_unique' => $frm_settings->unique_msg,
2750 + 'default_conf' => __( 'The entered values do not match', 'formidable' ),
2751 + 'enter_email' => __( 'Enter Email', 'formidable' ),
2752 + 'confirm_email' => __( 'Confirm Email', 'formidable' ),
2753 + 'conditional_text' => __( 'Conditional content here', 'formidable' ),
2754 + 'new_option' => __( 'New Option', 'formidable' ),
2755 + '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' ),
2756 + 'enter_password' => __( 'Enter Password', 'formidable' ),
2757 + 'confirm_password' => __( 'Confirm Password', 'formidable' ),
2758 + 'import_complete' => __( 'Import Complete', 'formidable' ),
2759 + 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2760 + 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2761 + 'private_label' => __( 'Private', 'formidable' ),
2762 + 'jquery_ui_url' => '',
2763 + 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
2764 + 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
2765 + 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
2766 + 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
2767 + 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
2768 + 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ),
2769 + 'unsafe_params' => FrmFormsHelper::reserved_words(),
3598 2770 /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/
3599 - 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
2771 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3600 2772 /* 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. */
3601 - 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3602 - 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3603 - 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3604 - 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3605 - 'install' => __( 'Install', 'formidable' ),
3606 - 'active' => __( 'Active', 'formidable' ),
3607 - 'installed' => __( 'Installed', 'formidable' ),
3608 - 'not_installed' => __( 'Not Installed', 'formidable' ),
3609 - 'select_a_field' => __( 'Select a Field', 'formidable' ),
3610 - 'no_items_found' => __( 'No items found.', 'formidable' ),
3611 - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3612 -
3613 - // Deprecated in 6.0.
3614 - 'saving' => '',
3615 -
3616 - // Deprecated in 6.0.
3617 - 'saved' => '',
3618 -
3619 - // translators: %1$s: HTML open tag, %2$s: HTML end tag.
3620 - 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ),
3621 - 'noTitleText' => FrmFormsHelper::get_no_title_text(),
3622 -
3623 - // In older versions this event listener causes the section to immediately close again
3624 - // when the h3 element is clicked. It's only required in WP 6.7+.
3625 - 'requireAccordionTitleClickListener' => version_compare( $wp_version, '6.7', '>=' ),
2773 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
2774 + 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
2775 + 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
2776 + 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
2777 + 'install' => __( 'Install', 'formidable' ),
2778 + 'active' => __( 'Active', 'formidable' ),
2779 + 'select_a_field' => __( 'Select a Field', 'formidable' ),
2780 + 'no_items_found' => __( 'No items found.', 'formidable' ),
3626 2781 );
3627 - /**
3628 - * @param array $admin_script_strings
3629 - */
3630 2782 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3631 2783
3632 2784 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3633 - if ( ! $data ) {
2785 + if ( empty( $data ) ) {
3634 2786 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3635 2787 }
3636 - }//end if
2788 + }
3637 2789 }
3638 2790
3639 2791 /**
3640 - * Get the no label text.
3641 - *
3642 - * @since 6.25.1
3643 - *
3644 - * @return string
3645 - */
3646 - public static function get_no_label_text() {
3647 - return __( '(no label)', 'formidable' );
3648 - }
3649 -
3650 - /**
3651 - * @since 6.5
3652 - *
3653 - * @return string
3654 - */
3655 - public static function get_ajax_url() {
3656 - $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
3657 -
3658 - /**
3659 - * @since 2.0.13
3660 - *
3661 - * @param string $ajax_url
3662 - */
3663 - return apply_filters( 'frm_ajax_url', $ajax_url );
3664 - }
3665 -
3666 - /**
3667 2792 * Returns whether or not the first errored input should be auto-focused (default true).
3668 2793 *
3669 2794 * @since 5.2.05
3670 2795 *
@@ -3689,10 +2814,9 @@
3689 2814 * Echo the message on the plugins listing page
3690 2815 *
3691 2816 * @since 1.07.10
3692 2817 *
3693 - * @param float $min_version The version the add-on requires.
3694 - * @return void
2818 + * @param float $min_version The version the add-on requires
3695 2819 */
3696 2820 public static function min_version_notice( $min_version ) {
3697 2821 $frm_version = self::plugin_version();
3698 2822
@@ -3710,10 +2834,8 @@
3710 2834 /**
3711 2835 * If Pro is far outdated, show a message.
3712 2836 *
3713 2837 * @since 4.0.01
3714 - *
3715 - * @return void
3716 2838 */
3717 2839 public static function min_pro_version_notice( $min_version ) {
3718 2840 if ( ! self::is_formidable_admin() ) {
3719 2841 // Don't show admin-wide.
@@ -3726,9 +2848,22 @@
3726 2848 if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) {
3727 2849 return;
3728 2850 }
3729 2851
3730 - include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
2852 + $pro_version = FrmProDb::$plug_version;
2853 + $expired = FrmAddonsController::is_license_expired();
2854 + ?>
2855 + <div class="error frm_previous_install">
2856 + <?php
2857 + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
2858 + if ( empty( $expired ) ) {
2859 + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
2860 + } else {
2861 + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
2862 + }
2863 + ?>
2864 + </div>
2865 + <?php
3731 2866 }
3732 2867
3733 2868 /**
3734 2869 * If Pro is installed, check the version number.
@@ -3733,11 +2868,8 @@
3733 2868 /**
3734 2869 * If Pro is installed, check the version number.
3735 2870 *
3736 2871 * @since 4.0.01
3737 - *
3738 - * @param string $min_version
3739 - * @return bool
3740 2872 */
3741 2873 public static function meets_min_pro_version( $min_version ) {
3742 2874 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
3743 2875 }
@@ -3742,22 +2874,27 @@
3742 2874 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
3743 2875 }
3744 2876
3745 2877 /**
3746 - * Show a message if the PHP version is below the recommendations.
2878 + * Show a message if the browser or PHP version is below the recommendations.
3747 2879 *
3748 2880 * @since 4.0.02
3749 - * @return void
3750 2881 */
3751 2882 private static function php_version_notice() {
3752 2883 $message = array();
3753 - if ( version_compare( phpversion(), '7.0', '<' ) ) {
2884 + if ( version_compare( phpversion(), '5.6', '<' ) ) {
3754 2885 $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' );
3755 2886 }
3756 2887
2888 + $browser = self::get_server_value( 'HTTP_USER_AGENT' );
2889 + $is_ie = strpos( $browser, 'MSIE' ) !== false;
2890 + if ( $is_ie ) {
2891 + $message[] = __( 'You are using an outdated browser that is not compatible with Formidable Forms. Please update to a more current browser (we recommend Chrome).', 'formidable' );
2892 + }
2893 +
3757 2894 foreach ( $message as $m ) {
3758 2895 ?>
3759 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2896 + <div class="error frm_previous_install">
3760 2897 <?php echo esc_html( $m ); ?>
3761 2898 </div>
3762 2899 <?php
3763 2900 }
@@ -3762,25 +2899,17 @@
3762 2899 <?php
3763 2900 }
3764 2901 }
3765 2902
3766 - /**
3767 - * @param string $type
3768 - * @return array<string,string>
3769 - */
3770 2903 public static function locales( $type = 'date' ) {
3771 2904 $locales = array(
3772 2905 'en' => __( 'English', 'formidable' ),
3773 2906 'af' => __( 'Afrikaans', 'formidable' ),
3774 2907 'sq' => __( 'Albanian', 'formidable' ),
3775 - 'ar-DZ' => __( 'Algerian Arabic', 'formidable' ),
3776 - 'am' => __( 'Amharic', 'formidable' ),
3777 2908 'ar' => __( 'Arabic', 'formidable' ),
3778 2909 'hy' => __( 'Armenian', 'formidable' ),
3779 2910 'az' => __( 'Azerbaijani', 'formidable' ),
3780 2911 'eu' => __( 'Basque', 'formidable' ),
3781 - 'be' => __( 'Belarusian', 'formidable' ),
3782 - 'bn' => __( 'Bengali', 'formidable' ),
3783 2912 'bs' => __( 'Bosnian', 'formidable' ),
3784 2913 'bg' => __( 'Bulgarian', 'formidable' ),
3785 2914 'ca' => __( 'Catalan', 'formidable' ),
3786 2915 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
@@ -3799,15 +2928,12 @@
3799 2928 'fi' => __( 'Finnish', 'formidable' ),
3800 2929 'fr' => __( 'French', 'formidable' ),
3801 2930 'fr-CA' => __( 'French/Canadian', 'formidable' ),
3802 2931 'fr-CH' => __( 'French/Swiss', 'formidable' ),
3803 - 'gl' => __( 'Galician', 'formidable' ),
3804 - 'ka' => __( 'Georgian', 'formidable' ),
3805 2932 'de' => __( 'German', 'formidable' ),
3806 2933 'de-AT' => __( 'German/Austria', 'formidable' ),
3807 2934 'de-CH' => __( 'German/Switzerland', 'formidable' ),
3808 2935 'el' => __( 'Greek', 'formidable' ),
3809 - 'gu' => __( 'Gujarati', 'formidable' ),
3810 2936 'he' => __( 'Hebrew', 'formidable' ),
3811 2937 'iw' => __( 'Hebrew', 'formidable' ),
3812 2938 'hi' => __( 'Hindi', 'formidable' ),
3813 2939 'hu' => __( 'Hungarian', 'formidable' ),
@@ -3814,80 +2940,56 @@
3814 2940 'is' => __( 'Icelandic', 'formidable' ),
3815 2941 'id' => __( 'Indonesian', 'formidable' ),
3816 2942 'it' => __( 'Italian', 'formidable' ),
3817 2943 'ja' => __( 'Japanese', 'formidable' ),
3818 - 'kn' => __( 'Kannada', 'formidable' ),
3819 - 'kk' => __( 'Kazakh', 'formidable' ),
3820 - 'km' => __( 'Khmer', 'formidable' ),
3821 2944 'ko' => __( 'Korean', 'formidable' ),
3822 - 'ky' => __( 'Kyrgyz', 'formidable' ),
3823 - 'lo' => __( 'Laothian', 'formidable' ),
3824 2945 'lv' => __( 'Latvian', 'formidable' ),
3825 2946 'lt' => __( 'Lithuanian', 'formidable' ),
3826 - 'lb' => __( 'Luxembourgish', 'formidable' ),
3827 - 'mk' => __( 'Macedonian', 'formidable' ),
3828 - 'ml' => __( 'Malayalam', 'formidable' ),
3829 2947 'ms' => __( 'Malaysian', 'formidable' ),
3830 - 'mr' => __( 'Marathi', 'formidable' ),
3831 2948 'no' => __( 'Norwegian', 'formidable' ),
3832 - 'nb' => __( 'Norwegian Bokmål', 'formidable' ),
3833 - 'nn' => __( 'Norwegian Nynorsk', 'formidable' ),
3834 2949 'pl' => __( 'Polish', 'formidable' ),
3835 2950 'pt' => __( 'Portuguese', 'formidable' ),
3836 2951 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
3837 2952 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ),
3838 - 'rm' => __( 'Romansh', 'formidable' ),
3839 2953 'ro' => __( 'Romanian', 'formidable' ),
3840 2954 'ru' => __( 'Russian', 'formidable' ),
3841 2955 'sr' => __( 'Serbian', 'formidable' ),
3842 2956 'sr-SR' => __( 'Serbian', 'formidable' ),
3843 - 'si' => __( 'Sinhalese', 'formidable' ),
3844 2957 'sk' => __( 'Slovak', 'formidable' ),
3845 2958 'sl' => __( 'Slovenian', 'formidable' ),
3846 2959 'es' => __( 'Spanish', 'formidable' ),
3847 2960 'es-419' => __( 'Spanish/Latin America', 'formidable' ),
3848 - 'sw' => __( 'Swahili', 'formidable' ),
3849 2961 'sv' => __( 'Swedish', 'formidable' ),
3850 2962 'ta' => __( 'Tamil', 'formidable' ),
3851 - 'te' => __( 'Telugu', 'formidable' ),
3852 2963 'th' => __( 'Thai', 'formidable' ),
3853 - 'tj' => __( 'Tajiki', 'formidable' ),
3854 2964 'tr' => __( 'Turkish', 'formidable' ),
3855 2965 'uk' => __( 'Ukrainian', 'formidable' ),
3856 - 'ur' => __( 'Urdu', 'formidable' ),
3857 2966 'vi' => __( 'Vietnamese', 'formidable' ),
3858 - 'cy-GB' => __( 'Welsh', 'formidable' ),
3859 - 'zu' => __( 'Zulu', 'formidable' ),
3860 2967 );
3861 2968
3862 2969 if ( $type === 'captcha' ) {
3863 2970 // remove the languages unavailable for the captcha
3864 - $unset = array( 'sq', 'bs', 'eo', 'fo', 'fr-CH', 'sr-SR', 'ar-DZ', 'be', 'cy-GB', 'kk', 'km', 'ky', 'lb', 'mk', 'nb', 'nn', 'rm', 'tj' );
2971 + $unset = array( 'af', 'sq', 'hy', 'az', 'eu', 'bs', 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', 'he', 'is', 'ms', 'sr-SR', 'ta' );
3865 2972 } else {
3866 2973 // remove the languages unavailable for the datepicker
3867 - $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' );
2974 + $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419' );
3868 2975 }
3869 2976
3870 2977 $locales = array_diff_key( $locales, array_flip( $unset ) );
2978 + $locales = apply_filters( 'frm_locales', $locales );
3871 2979
3872 - /**
3873 - * Filter available locale options.
3874 - *
3875 - * @since 5.4.5 Added $args parameter with type.
3876 - *
3877 - * @param array<string,string> $locales
3878 - * @param array $args {
3879 - * @type string $type
3880 - * }
3881 - */
3882 - $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3883 -
3884 2980 return $locales;
3885 2981 }
3886 2982
3887 2983 /**
3888 - * @return string
2984 + * Output HTML containing reference text for accessibility
2985 + *
2986 + * @deprecated 5.1
3889 2987 */
2988 + public static function multiselect_accessibility() {
2989 + _deprecated_function( __METHOD__, '5.1' );
2990 + }
2991 +
3890 2992 public static function get_menu_icon_class() {
3891 2993 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
3892 2994 $settings = FrmProAppHelper::get_settings();
3893 2995 if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
@@ -3950,8 +3052,14 @@
3950 3052
3951 3053 $new_args['options'] = (array) $new_args['options'];
3952 3054 $new_args['input_attrs'] = (array) $new_args['input_attrs'];
3953 3055
3056 + // Set the number of columns.
3057 + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) );
3058 + if ( $new_args['col_class'] > 6 ) {
3059 + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 );
3060 + }
3061 +
3954 3062 /**
3955 3063 * Allows modifying the arguments of images_dropdown() method.
3956 3064 *
3957 3065 * @since 5.0.04
@@ -3991,18 +3099,8 @@
3991 3099 return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args );
3992 3100 }
3993 3101
3994 3102 /**
3995 - * @since 6.7.1
3996 - */
3997 - public static function get_images_dropdown_atts( $option, $args ) {
3998 - $image = self::get_images_dropdown_option_image( $option, $args );
3999 - $classes = self::get_images_dropdown_option_classes( $option, $args );
4000 - $custom_attrs = self::get_images_dropdown_option_html_attrs( $option, $args );
4001 - return compact( 'image', 'classes', 'custom_attrs' );
4002 - }
4003 -
4004 - /**
4005 3103 * Gets the image of each option in images_dropdown() method.
4006 3104 *
4007 3105 * @since 5.0.04
4008 3106 *
@@ -4013,9 +3111,9 @@
4013 3111 private static function get_images_dropdown_option_image( $option, $args ) {
4014 3112 $image = self::icon_by_class(
4015 3113 'frmfont ' . $option['svg'],
4016 3114 array(
4017 - 'echo' => false,
3115 + 'echo' => false,
4018 3116 )
4019 3117 );
4020 3118
4021 3119 $args['option'] = $option;
@@ -4153,15 +3251,15 @@
4153 3251 return $values;
4154 3252 }
4155 3253
4156 3254 /**
4157 - * Some back end fields allow privileged users to add scripts.
3255 + * Some back end fields allow privleged users to add scripts.
4158 3256 * A site that uses the DISALLOW_UNFILTERED_HTML always remove scripts on echo.
4159 3257 *
4160 3258 * @since 5.0.13
4161 3259 *
4162 3260 * @param string $value
4163 - * @param array|string $allowed 'all' for everything included as defaults.
3261 + * @param array|string $allowed 'all' for everything included as defaults
4164 3262 * @return string
4165 3263 */
4166 3264 public static function maybe_kses( $value, $allowed = 'all' ) {
4167 3265 if ( self::should_never_allow_unfiltered_html() ) {
@@ -4170,64 +3268,8 @@
4170 3268 return $value;
4171 3269 }
4172 3270
4173 3271 /**
4174 - * Check if an option attribute used in an [input] shortcode is safe.
4175 - *
4176 - * @since 6.11.2
4177 - *
4178 - * @param string $key
4179 - * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed.
4180 - * @return bool
4181 - */
4182 - public static function input_key_is_safe( $key, $context = 'display' ) {
4183 - if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) {
4184 - $safe = true;
4185 - } elseif ( 0 === strpos( $key, 'data-' ) ) {
4186 - // Allow all data attributes.
4187 - $safe = true;
4188 - } elseif ( 0 === strpos( $key, 'aria-' ) ) {
4189 - // Allow all aria attributes.
4190 - $safe = true;
4191 - } else {
4192 - $safe_keys = array(
4193 - 'class',
4194 - 'required',
4195 - 'title',
4196 - 'placeholder',
4197 - 'value',
4198 - 'readonly',
4199 - 'disabled',
4200 - 'size',
4201 - 'maxlength',
4202 - 'min',
4203 - 'max',
4204 - 'pattern',
4205 - 'step',
4206 - 'autofocus',
4207 - 'width',
4208 - 'height',
4209 - 'autocomplete',
4210 - 'tabindex',
4211 - 'role',
4212 - 'style',
4213 - );
4214 - $safe = in_array( $key, $safe_keys, true );
4215 - }//end if
4216 -
4217 - /**
4218 - * Filter the $safe value so additional keys can be allowed or disallowed.
4219 - *
4220 - * @since 6.11.2
4221 - *
4222 - * @param bool $safe True if the key is considered safe.
4223 - * @param string $key
4224 - * @param string $context Either 'display' or 'update'.
4225 - */
4226 - return (bool) apply_filters( 'frm_input_key_is_safe', $safe, $key, $context );
4227 - }
4228 -
4229 - /**
4230 3272 * @since 5.0.16
4231 3273 *
4232 3274 * @return bool
4233 3275 */
@@ -4241,12 +3283,11 @@
4241 3283 * @return array
4242 3284 */
4243 3285 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
4244 3286 $params = array(
4245 - 'medium' => $medium,
4246 - 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
4247 - 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4248 - 'screenshot' => 'landing.png',
3287 + 'medium' => $medium,
3288 + 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
3289 + 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4249 3290 );
4250 3291 return self::get_upgrade_data_params( 'landing', $params );
4251 3292 }
4252 3293
@@ -4252,9 +3293,20 @@
4252 3293
4253 3294 /**
4254 3295 * @since 5.0.17
4255 3296 *
4256 - * @param string $feature
3297 + * @param string $plugin
3298 + * @return string|false
3299 + */
3300 + private static function get_plan_required( $plugin ) {
3301 + $link = FrmAddonsController::install_link( $plugin );
3302 + return FrmFormsHelper::get_plan_required( $link );
3303 + }
3304 +
3305 + /**
3306 + * @since 5.0.17
3307 + *
3308 + * @param string
4257 3309 * @return bool
4258 3310 */
4259 3311 public static function show_new_feature( $feature ) {
4260 3312 $link = FrmAddonsController::install_link( $feature );
@@ -4261,18 +3313,15 @@
4261 3313 return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
4262 3314 }
4263 3315
4264 3316 /**
4265 - * Enhances upgrade data parameters with installation link and plan requirement information.
4266 - *
4267 3317 * @since 5.0.17
4268 3318 *
4269 - * @param string $plugin The plugin slug to get installation data for.
4270 - * @param array $params Initial parameters for the upgrade data.
4271 - * @param bool $detailed Whether to include detailed information.
4272 - * @return array Modified parameters with installation data.
3319 + * @param string $plugin
3320 + * @param array $params
3321 + * @return array
4273 3322 */
4274 - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) {
3323 + public static function get_upgrade_data_params( $plugin, $params ) {
4275 3324 $link = FrmAddonsController::install_link( $plugin );
4276 3325 if ( ! $link ) {
4277 3326 return $params;
4278 3327 }
@@ -4283,15 +3332,11 @@
4283 3332 if ( ! isset( $params['medium'] ) ) {
4284 3333 $params['medium'] = $plugin;
4285 3334 }
4286 3335 } else {
4287 - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link );
3336 + $params['requires'] = FrmFormsHelper::get_plan_required( $link );
4288 3337 }
4289 3338
4290 - if ( $detailed ) {
4291 - $params['plugin-status'] = $link['status'] ?? '';
4292 - }
4293 -
4294 3339 return $params;
4295 3340 }
4296 3341
4297 3342 /**
@@ -4324,8 +3369,36 @@
4324 3369 set_current_screen();
4325 3370 }
4326 3371
4327 3372 /**
3373 + * @since 4.07
3374 + * @deprecated 4.09.01
3375 + */
3376 + public static function renewal_message() {
3377 + if ( is_callable( 'FrmProAddonsController::renewal_message' ) ) {
3378 + FrmProAddonsController::renewal_message();
3379 + return;
3380 + }
3381 +
3382 + if ( ! FrmAddonsController::is_license_expired() ) {
3383 + return;
3384 + }
3385 +
3386 + ?>
3387 + <div class="frm_error_style" style="text-align:left">
3388 + <?php self::icon_by_class( 'frmfont frm_alert_icon' ); ?>
3389 + &nbsp;
3390 + <?php esc_html_e( 'Your account has expired', 'formidable' ); ?>
3391 + <div style="float:right">
3392 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'form-expired', 'account/downloads/' ) ); ?>">
3393 + <?php esc_html_e( 'Renew Now', 'formidable' ); ?>
3394 + </a>
3395 + </div>
3396 + </div>
3397 + <?php
3398 + }
3399 +
3400 + /**
4328 3401 * Shows pill text.
4329 3402 *
4330 3403 * @since 5.2.02
4331 3404 *
@@ -4334,331 +3407,217 @@
4334 3407 public static function show_pill_text( $text = null ) {
4335 3408 if ( null === $text ) {
4336 3409 $text = __( 'NEW', 'formidable' );
4337 3410 }
4338 - echo '<span class="frm-meta-tag frm-new-pill">' . esc_html( $text ) . '</span>';
3411 + echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>';
4339 3412 }
4340 3413
4341 3414 /**
4342 - * Count the number of decimals digits.
4343 - *
4344 - * @since 5.2.07
4345 - *
4346 - * @param mixed $num Number.
4347 - * @return false|int Returns `false` if the passed parameter is not number.
3415 + * @since 4.08
3416 + * @deprecated 4.09.01
4348 3417 */
4349 - public static function count_decimals( $num ) {
4350 - if ( ! is_numeric( $num ) ) {
4351 - return false;
3418 + public static function expiring_message() {
3419 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3420 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3421 + FrmProAddonsController::expiring_message();
4352 3422 }
3423 + }
4353 3424
4354 - $num = (string) $num;
4355 - $parts = explode( '.', $num );
4356 - if ( 1 === count( $parts ) ) {
4357 - return 0;
4358 - }
3425 + /**
3426 + * Use the WP 4.7 wp_doing_ajax function
3427 + *
3428 + * @since 2.05.07
3429 + * @deprecated 4.04.04
3430 + */
3431 + public static function wp_doing_ajax() {
3432 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3433 + return wp_doing_ajax();
3434 + }
4359 3435
4360 - return strlen( $parts[ count( $parts ) - 1 ] );
3436 + /**
3437 + * @deprecated 4.0
3438 + */
3439 + public static function insert_opt_html( $args ) {
3440 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3441 + FrmFormsHelper::insert_opt_html( $args );
4361 3442 }
4362 3443
4363 3444 /**
4364 - * Prevent a fatal error in PHP8 if gmt_offset happens to be set an empty string.
4365 - * This is a bug in WordPress. It isn't safe to call current_time( 'timestamp' ) without this with an empty string offset.
4366 - * In the future this might be safe to remove. Keep an eye on the current_time function in functions.php.
3445 + * Used to filter shortcode in text widgets
4367 3446 *
4368 - * @since 5.3.1
4369 - *
4370 - * @return void
3447 + * @deprecated 2.5.4
3448 + * @codeCoverageIgnore
4371 3449 */
4372 - public static function filter_gmt_offset() {
4373 - if ( self::$added_gmt_offset_filter ) {
4374 - // Avoid adding twice.
4375 - return;
4376 - }
3450 + public static function widget_text_filter_callback( $matches ) {
3451 + return FrmDeprecated::widget_text_filter_callback( $matches );
3452 + }
4377 3453
4378 - add_filter(
4379 - 'option_gmt_offset',
4380 - function ( $offset ) {
4381 - if ( ! is_string( $offset ) || is_numeric( $offset ) ) {
4382 - // Leave a valid value alone.
4383 - return $offset;
4384 - }
4385 -
4386 - return 0;
4387 - }
4388 - );
4389 - self::$added_gmt_offset_filter = true;
3454 + /**
3455 + * @deprecated 3.01
3456 + * @codeCoverageIgnore
3457 + */
3458 + public static function sanitize_array( &$values ) {
3459 + FrmDeprecated::sanitize_array( $values );
4390 3460 }
4391 3461
4392 3462 /**
4393 - * @since 5.3.1
3463 + * @param array $settings
3464 + * @param string $group
4394 3465 *
4395 - * @return bool
3466 + * @since 2.0.6
3467 + * @deprecated 2.05.06
3468 + * @codeCoverageIgnore
4396 3469 */
4397 - public static function on_form_listing_page() {
4398 - if ( ! self::is_admin_page( 'formidable' ) ) {
4399 - return false;
4400 - }
3470 + public static function save_settings( $settings, $group ) {
3471 + return FrmDeprecated::save_settings( $settings, $group );
3472 + }
4401 3473
4402 - $action = self::simple_get( 'frm_action', 'sanitize_title' );
4403 - return ! $action || in_array( $action, self::get_form_listing_page_actions(), true );
3474 + /**
3475 + * @since 2.0.4
3476 + * @deprecated 2.05.06
3477 + * @codeCoverageIgnore
3478 + */
3479 + public static function save_json_post( $settings ) {
3480 + return FrmDeprecated::save_json_post( $settings );
4404 3481 }
4405 3482
4406 3483 /**
4407 - * Get all actions that also display the forms list.
3484 + * @since 2.0
3485 + * @deprecated 2.05.06
3486 + * @codeCoverageIgnore
4408 3487 *
4409 - * @since 5.3.1
3488 + * @param string $cache_key The unique name for this cache
3489 + * @param string $group The name of the cache group
3490 + * @param string $query If blank, don't run a db call
3491 + * @param string $type The wpdb function to use with this query
4410 3492 *
4411 - * @return array<string>
3493 + * @return mixed $results The cache or query results
4412 3494 */
4413 - private static function get_form_listing_page_actions() {
4414 - return array( 'list', 'trash', 'untrash', 'destroy' );
3495 + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
3496 + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time );
4415 3497 }
4416 3498
4417 3499 /**
4418 - * Safely call get_plugins, importing the required files if they are not yet loaded.
4419 - *
4420 - * @since 5.5
4421 - *
4422 - * @return array
3500 + * @deprecated 2.05.06
3501 + * @codeCoverageIgnore
4423 3502 */
4424 - public static function get_plugins() {
4425 - if ( ! function_exists( 'get_plugins' ) ) {
4426 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
4427 - }
4428 - return get_plugins();
3503 + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
3504 + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time );
4429 3505 }
4430 3506
4431 3507 /**
4432 - * Make sure that the file we're trying to load is in fact the expected file type, and that it's coming from our S3 bucket.
4433 - * This is to make sure that the URL can't be exploited for a SSRF attack.
4434 - *
4435 - * @since 5.5.5
4436 - *
4437 - * @param string $url
4438 - * @param string $expected_extension
4439 - * @return bool
3508 + * @deprecated 2.05.06
3509 + * @codeCoverageIgnore
4440 3510 */
4441 - public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
4442 - $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4443 - if ( ! $file_is_in_expected_s3_bucket ) {
4444 - return false;
4445 - }
3511 + public static function add_key_to_group_cache( $key, $group ) {
3512 + FrmDeprecated::add_key_to_group_cache( $key, $group );
3513 + }
4446 3514
4447 - $parsed = parse_url( $url );
4448 - if ( ! is_array( $parsed ) ) {
4449 - // URL is malformed.
4450 - return false;
4451 - }
3515 + /**
3516 + * @deprecated 2.05.06
3517 + * @codeCoverageIgnore
3518 + */
3519 + public static function get_group_cached_keys( $group ) {
3520 + return FrmDeprecated::get_group_cached_keys( $group );
3521 + }
4452 3522
4453 - $path = $parsed['path'];
4454 - $ext = pathinfo( $path, PATHINFO_EXTENSION );
4455 - if ( $expected_extension !== $ext ) {
4456 - // The URL isn't to an XML file.
4457 - return false;
4458 - }
4459 -
4460 - return true;
3523 + /**
3524 + * @since 2.0
3525 + * @deprecated 2.05.06
3526 + * @codeCoverageIgnore
3527 + * @return mixed The cached value or false
3528 + */
3529 + public static function check_cache_and_transient( $cache_key ) {
3530 + return FrmDeprecated::check_cache( $cache_key );
4461 3531 }
4462 3532
4463 3533 /**
4464 - * Display a dismissable warning message and save its dismissal state.
3534 + * @since 2.0
3535 + * @deprecated 2.05.06
3536 + * @codeCoverageIgnore
4465 3537 *
4466 - * @since 6.3
4467 - *
4468 - * @param string $message The warning message to display.
4469 - * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
4470 - * @return void
3538 + * @param string $cache_key
4471 3539 */
4472 - public static function add_dismissable_warning_message( $message = '', $option = '' ) {
4473 - if ( ! $message || ! $option ) {
4474 - return;
4475 - }
4476 -
4477 - $ajax_callback = function () use ( $option ) {
4478 - self::dismiss_warning_message( $option );
4479 - };
4480 -
4481 - // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action.
4482 - // To prevent any issues, we add 'frm_' from the beginning of the action.
4483 - add_action( 'wp_ajax_frm_' . $option, $ajax_callback );
4484 -
4485 - add_filter(
4486 - 'frm_message_list',
4487 - function ( $show_messages ) use ( $message, $option ) {
4488 - if ( get_option( $option, false ) ) {
4489 - return $show_messages;
4490 - }
4491 -
4492 - $dismiss_icon = self::icon_by_class(
4493 - 'frmfont frm_close_icon',
4494 - array(
4495 - 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ),
4496 - 'echo' => false,
4497 - )
4498 - );
4499 -
4500 - $show_messages[] = $message;
4501 - $show_messages[] = '<span class="frm-warning-dismiss frmsvg" data-action="' . esc_attr( $option ) . '">' . $dismiss_icon . '</span>';
4502 -
4503 - return $show_messages;
4504 - }
4505 - );
3540 + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
3541 + FrmDeprecated::delete_cache_and_transient( $cache_key, $group );
4506 3542 }
4507 3543
4508 3544 /**
4509 - * Dismiss a warning message and update the dismissal state.
3545 + * @since 2.0
3546 + * @deprecated 2.05.06
3547 + * @codeCoverageIgnore
4510 3548 *
4511 - * @since 6.3
4512 - *
4513 - * @param string $option The unique identifier for the dismissal state of the message.
4514 - * @return void
3549 + * @param string $group The name of the cache group
4515 3550 */
4516 - public static function dismiss_warning_message( $option = '' ) {
4517 - self::permission_check( 'frm_change_settings' );
4518 - check_ajax_referer( 'frm_ajax', 'nonce' );
4519 -
4520 - if ( $option ) {
4521 - update_option( $option, true, 'no' );
4522 - }
4523 -
4524 - wp_send_json_success();
3551 + public static function cache_delete_group( $group ) {
3552 + FrmDeprecated::cache_delete_group( $group );
4525 3553 }
4526 3554
4527 3555 /**
4528 - * Lite license copy.
4529 - * Used in FrmDashboardController & FrmSettingsController
3556 + * @since 1.07.10
3557 + * @deprecated 2.05.06
3558 + * @codeCoverageIgnore
4530 3559 *
4531 - * @since 6.8
3560 + * @param string $term The value to escape
4532 3561 *
4533 - * @return string
3562 + * @return string The escaped value
4534 3563 */
4535 - public static function copy_for_lite_license() {
4536 - $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂';
4537 -
4538 - if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) {
4539 - // Manage PRO versions without PRO dashboard functionality.
4540 - $license_type = FrmProAddonsController::get_readable_license_type();
4541 - if ( 'lite' !== strtolower( $license_type ) ) {
4542 - $message = 'Formidable Pro ' . $license_type;
4543 - }
4544 - }
4545 -
4546 - return apply_filters( 'frm_license_type_text', $message );
3564 + public static function esc_like( $term ) {
3565 + return FrmDeprecated::esc_like( $term );
4547 3566 }
4548 3567
4549 3568 /**
4550 - * Removes scripts that are unnecessarily loaded across the pages!
3569 + * @param string $order_query
4551 3570 *
4552 - * @since 6.9
4553 - * @return void
3571 + * @deprecated 2.05.06
3572 + * @codeCoverageIgnore
4554 3573 */
4555 - public static function dequeue_extra_global_scripts() {
4556 - wp_dequeue_script( 'frm-surveys-admin' );
4557 - wp_dequeue_script( 'frm-quizzes-form-action' );
3574 + public static function esc_order( $order_query ) {
3575 + return FrmDeprecated::esc_order( $order_query );
4558 3576 }
4559 3577
4560 3578 /**
4561 - * Shows tooltip icon.
4562 - *
4563 - * @since 6.12
4564 - *
4565 - * @param string $tooltip_text Tooltip text.
4566 - * @param array $atts Tooltip wrapper HTML attributes.
4567 - *
4568 - * @return void
3579 + * @deprecated 2.05.06
3580 + * @codeCoverageIgnore
4569 3581 */
4570 - public static function tooltip_icon( $tooltip_text, $atts = array() ) {
4571 - $atts['title'] = $tooltip_text;
4572 - if ( isset( $atts['class'] ) ) {
4573 - $atts['class'] .= ' frm_help';
4574 - } else {
4575 - $atts['class'] = 'frm_help';
4576 - }
4577 - ?>
4578 - <span <?php self::array_to_html_params( $atts, true ); ?>>
4579 - <?php self::icon_by_class( 'frmfont frm_tooltip_icon' ); ?>
4580 - </span>
4581 - <?php
3582 + public static function esc_order_by( &$order_by ) {
3583 + FrmDeprecated::esc_order_by( $order_by );
4582 3584 }
4583 3585
4584 3586 /**
4585 - * Prints errors for settings in onboarding wizard or template settings.
3587 + * @param string $limit
4586 3588 *
4587 - * @since 6.15
4588 - *
4589 - * @param array $args Args.
4590 - *
4591 - * @return void
3589 + * @deprecated 2.05.06
3590 + * @codeCoverageIgnore
4592 3591 */
4593 - public static function print_setting_error( $args ) {
4594 - $args = wp_parse_args(
4595 - $args,
4596 - array(
4597 - 'id' => '',
4598 - 'errors' => array(),
4599 - 'class' => '',
4600 - )
4601 - );
4602 -
4603 - $args['class'] .= ' frm-validation-error frm-mt-xs frm_hidden';
4604 - ?>
4605 - <span id="<?php echo esc_attr( $args['id'] ); ?>" class="<?php echo esc_attr( $args['class'] ); ?>">
4606 - <?php
4607 - if ( is_array( $args['errors'] ) ) {
4608 - foreach ( $args['errors'] as $key => $msg ) {
4609 - ?>
4610 - <span frm-error="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $msg ); ?></span>
4611 - <?php
4612 - }
4613 - } else {
4614 - echo '<span>' . esc_html( $args['errors'] ) . '</span>';
4615 - }
4616 - ?>
4617 - </span>
4618 - <?php
3592 + public static function esc_limit( $limit ) {
3593 + return FrmDeprecated::esc_limit( $limit );
4619 3594 }
4620 3595
4621 3596 /**
4622 - * Check if GDPR is enabled.
4623 - *
4624 - * @since 6.19
4625 - *
4626 - * @return bool
3597 + * @since 2.0
3598 + * @deprecated 2.05.06
3599 + * @codeCoverageIgnore
4627 3600 */
4628 - public static function is_gdpr_enabled() {
4629 - $frm_settings = self::get_settings();
4630 - return $frm_settings->enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies;
3601 + public static function prepare_array_values( $array, $type = '%s' ) {
3602 + return FrmDeprecated::prepare_array_values( $array, $type );
4631 3603 }
4632 3604
4633 3605 /**
4634 - * Check if GDPR cookies are disabled.
4635 - *
4636 - * @since 6.19
4637 - *
4638 - * @return bool
3606 + * @deprecated 2.05.06
3607 + * @codeCoverageIgnore
4639 3608 */
4640 - public static function no_gdpr_cookies() {
4641 - $frm_settings = self::get_settings();
4642 - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies;
3609 + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
3610 + return FrmDeprecated::prepend_and_or_where( $starts_with, $where );
4643 3611 }
4644 3612
4645 3613 /**
4646 - * Check if a string is valid UTF-8.
3614 + * @since 2.0
3615 + * @deprecated 5.0.13
4647 3616 *
4648 - * @since 6.24
4649 - *
4650 - * @param string $string The string to check.
4651 - * @return bool
3617 + * @return string The base Google APIS url for the current version of jQuery UI
4652 3618 */
4653 - public static function is_valid_utf8( $string ) {
4654 - // wp_is_valid_utf8 is added in WP 6.9.
4655 - if ( function_exists( 'wp_is_valid_utf8' ) ) {
4656 - return wp_is_valid_utf8( $string );
4657 - }
4658 - // As of WP 6.9, seems_utf8 is deprecated.
4659 - if ( function_exists( 'seems_utf8' ) ) {
4660 - return seems_utf8( $string );
4661 - }
4662 - return false;
3619 + public static function jquery_ui_base_url() {
3620 + _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3621 + return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
4663 3622 }
4664 3623 }