PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.3.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.3.2
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 +554 -1902 6.26.15.3.2 View file →
@@ -3,43 +3,27 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmAppHelper {
7 + public static $db_version = 98; // Version of the database we are moving to.
8 + public static $pro_db_version = 37; //deprecated
9 + public static $font_version = 7;
7 10
8 11 /**
9 - * Version of the database we are moving to.
10 - *
11 - * @var int
12 + * @var bool $added_gmt_offset_filter
12 13 */
13 - public static $db_version = 104;
14 -
15 - /**
16 - * Used by the API add-on.
17 - *
18 - * @var float
19 - */
20 - public static $font_version = 7;
21 -
22 - /**
23 - * @var bool
24 - */
25 14 private static $added_gmt_offset_filter = false;
26 15
27 16 /**
28 17 * @since 2.0
29 - *
30 - * @var string
31 18 */
32 - public static $plug_version = '6.26.1';
19 + public static $plug_version = '5.3.2';
33 20
34 21 /**
35 - * @var bool
36 - */
37 - private static $included_svg = false;
38 -
39 - /**
40 22 * @since 1.07.02
41 23 *
24 + * @param none
25 + *
42 26 * @return string The version of this plugin
43 27 */
44 28 public static function plugin_version() {
45 29 return self::$plug_version;
@@ -44,33 +28,21 @@
44 28 public static function plugin_version() {
45 29 return self::$plug_version;
46 30 }
47 31
48 - /**
49 - * @return string
50 - */
51 32 public static function plugin_folder() {
52 33 return basename( self::plugin_path() );
53 34 }
54 35
55 - /**
56 - * @return string
57 - */
58 36 public static function plugin_path() {
59 - return dirname( __DIR__, 2 );
37 + return dirname( dirname( dirname( __FILE__ ) ) );
60 38 }
61 39
62 - /**
63 - * @return string
64 - */
65 40 public static function plugin_url() {
66 - // Previously FRM_URL constant.
41 + // Prevously FRM_URL constant.
67 42 return plugins_url( '', self::plugin_path() . '/formidable.php' );
68 43 }
69 44
70 - /**
71 - * @return string
72 - */
73 45 public static function relative_plugin_url() {
74 46 return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
75 47 }
76 48
@@ -85,9 +57,8 @@
85 57 * Get the name of this site
86 58 * Used for [sitename] shortcode
87 59 *
88 60 * @since 2.0
89 - *
90 61 * @return string
91 62 */
92 63 public static function site_name() {
93 64 return get_option( 'blogname' );
@@ -92,16 +63,10 @@
92 63 public static function site_name() {
93 64 return get_option( 'blogname' );
94 65 }
95 66
96 - /**
97 - * @param string $url
98 - *
99 - * @return string
100 - */
101 67 public static function make_affiliate_url( $url ) {
102 68 $affiliate_id = self::get_affiliate();
103 -
104 69 if ( ! empty( $affiliate_id ) ) {
105 70 $url = str_replace( array( 'http://', 'https://' ), '', $url );
106 71 $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url );
107 72 }
@@ -108,11 +73,8 @@
108 73
109 74 return $url;
110 75 }
111 76
112 - /**
113 - * @return int
114 - */
115 77 public static function get_affiliate() {
116 78 return absint( apply_filters( 'frm_affiliate_id', 0 ) );
117 79 }
118 80
@@ -117,178 +79,64 @@
117 79 }
118 80
119 81 /**
120 82 * @since 3.04.02
121 - *
122 - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
83 + * @param array|string $args
123 84 * @param string $page
124 85 */
125 86 public static function admin_upgrade_link( $args, $page = '' ) {
126 - if ( $page ) {
87 + if ( empty( $page ) ) {
88 + $page = 'https://formidableforms.com/lite-upgrade/';
89 + } else {
127 90 $page = str_replace( 'https://formidableforms.com/', '', $page );
128 91 $page = 'https://formidableforms.com/' . $page;
129 - } else {
130 - $page = 'https://formidableforms.com/lite-upgrade/';
131 92 }
132 93
94 + $anchor = '';
133 95 if ( is_array( $args ) ) {
134 - $args = self::adjust_legacy_utm_args( $args );
96 + $medium = $args['medium'];
97 + if ( isset( $args['content'] ) ) {
98 + $content = $args['content'];
99 + }
100 + if ( isset( $args['anchor'] ) ) {
101 + $anchor = '#' . $args['anchor'];
102 + }
135 103 } else {
136 - $args = array( 'campaign' => $args );
104 + $medium = $args;
137 105 }
138 106
139 107 $query_args = array(
140 - 'utm_source' => 'plugin',
141 - 'utm_medium' => self::get_utm_medium(),
108 + 'utm_source' => 'WordPress',
109 + 'utm_medium' => $medium,
110 + 'utm_campaign' => 'liteplugin',
142 111 );
143 - $query_args = self::maybe_add_utm_license( $query_args );
144 112
145 - if ( isset( $args['campaign'] ) ) {
146 - $query_args['utm_campaign'] = $args['campaign'];
113 + if ( isset( $content ) ) {
114 + $query_args['utm_content'] = $content;
147 115 }
148 116
149 - if ( isset( $args['content'] ) ) {
150 - $query_args['utm_content'] = $args['content'];
151 - }
152 -
153 - if ( isset( $args['param'] ) ) {
117 + if ( is_array( $args ) && isset( $args['param'] ) ) {
154 118 $query_args['f'] = $args['param'];
155 119 }
156 120
157 - if ( ! empty( $args['plan'] ) ) {
121 + if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
158 122 $query_args['plan'] = $args['plan'];
159 123 }
160 124
161 - $link = add_query_arg( $query_args, $page );
162 -
163 - if ( isset( $args['anchor'] ) ) {
164 - $link .= '#' . $args['anchor'];
165 - }
166 -
125 + $link = add_query_arg( $query_args, $page ) . $anchor;
167 126 return self::make_affiliate_url( $link );
168 127 }
169 128
170 129 /**
171 - * If medium is "pro", add an additional utm_license param with their active license type.
172 - *
173 - * @since 6.25.1
174 - *
175 - * @param array $query_args
176 - * @param string $link
177 - *
178 - * @return array
179 - */
180 - private static function maybe_add_utm_license( $query_args, $link = '' ) {
181 - if ( isset( $query_args['utm_medium'] ) ) {
182 - $medium = $query_args['utm_medium'];
183 - } else {
184 - $medium = self::pull_medium_from_link( $link );
185 - }
186 -
187 - if ( 'pro' === $medium && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) {
188 - $query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() );
189 - }
190 -
191 - return $query_args;
192 - }
193 -
194 - /**
195 - * @since 6.26
196 - *
197 - * @param string $link
198 - *
199 - * @return string
200 - */
201 - private static function pull_medium_from_link( $link ) {
202 - if ( ! $link ) {
203 - return '';
204 - }
205 -
206 - $parsed = parse_url( $link );
207 -
208 - if ( ! is_array( $parsed ) || ! isset( $parsed['query'] ) ) {
209 - return '';
210 - }
211 -
212 - $query_args = wp_parse_args( $parsed['query'] );
213 -
214 - if ( empty( $query_args['utm_medium'] ) ) {
215 - return '';
216 - }
217 -
218 - return $query_args['utm_medium'];
219 - }
220 -
221 - /**
222 - * @since 6.25.1
223 - *
224 - * @return string
225 - */
226 - private static function get_utm_medium() {
227 - return self::pro_is_connected() ? 'pro' : 'lite';
228 - }
229 -
230 - /**
231 - * Change campaign from "liteplugin" to what we're currently using for medium.
232 - *
233 - * @since 6.25.1
234 - *
235 - * @param array $args
236 - *
237 - * @return array
238 - */
239 - private static function adjust_legacy_utm_args( $args ) {
240 - if ( isset( $args['medium'] ) ) {
241 - $args['campaign'] = $args['medium'];
242 - unset( $args['medium'] );
243 - }
244 -
245 - return $args;
246 - }
247 -
248 - /**
249 - * @since 6.21
250 - *
251 - * @param string $cta_link
252 - * @param array $utm
253 - */
254 - public static function maybe_add_missing_utm( $cta_link, $utm ) {
255 - $utm = self::adjust_legacy_utm_args( $utm );
256 - $query_args = array();
257 -
258 - if ( false === strpos( $cta_link, 'utm_source' ) ) {
259 - $query_args['utm_source'] = 'plugin';
260 - }
261 -
262 - if ( false === strpos( $cta_link, 'utm_medium' ) ) {
263 - $query_args['utm_medium'] = self::get_utm_medium();
264 - }
265 -
266 - if ( false === strpos( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) {
267 - $query_args['utm_campaign'] = $utm['campaign'];
268 - }
269 -
270 - if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) {
271 - $query_args['utm_content'] = $utm['content'];
272 - }
273 -
274 - $query_args = self::maybe_add_utm_license( $query_args, $cta_link );
275 -
276 - return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link;
277 - }
278 -
279 - /**
280 130 * Get the Formidable settings
281 131 *
282 132 * @since 2.0
283 133 *
284 134 * @param array $args - May include the form id when values need translation.
285 - *
286 - * @return FrmSettings $frm_settings
135 + * @return FrmSettings $frm_setings
287 136 */
288 137 public static function get_settings( $args = array() ) {
289 138 global $frm_settings;
290 -
291 139 if ( empty( $frm_settings ) ) {
292 140 $frm_settings = new FrmSettings( $args );
293 141 } elseif ( isset( $args['current_form'] ) ) {
294 142 // If the global has already been set, allow strings to be filtered.
@@ -297,40 +145,16 @@
297 145
298 146 return $frm_settings;
299 147 }
300 148
301 - /**
302 - * @return string
303 - */
304 149 public static function get_menu_name() {
305 150 $frm_settings = self::get_settings();
306 151
307 - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu;
152 + return $frm_settings->menu;
308 153 }
309 154
310 155 /**
311 - * Determine if the current branding is set to 'formidable'.
312 - * Checks the menu icon, and verifies if it matches the formidable branding.
313 - *
314 - * @since 6.4.2
315 - *
316 - * @return bool True if the menu icon is the logo, false otherwise.
317 - */
318 - public static function is_formidable_branding() {
319 - if ( ! self::pro_is_installed() ) {
320 - return true;
321 - }
322 -
323 - $menu_icon = self::get_menu_icon_class();
324 - return strpos( $menu_icon, 'frm_logo_icon' ) !== false;
325 - }
326 -
327 - /**
328 156 * @since 3.05
329 - *
330 - * @param array $atts
331 - *
332 - * @return string
333 157 */
334 158 public static function svg_logo( $atts = array() ) {
335 159 $defaults = array(
336 160 'height' => 18,
@@ -347,12 +171,8 @@
347 171 }
348 172
349 173 /**
350 174 * @since 4.0
351 - *
352 - * @param array $atts
353 - *
354 - * @return void
355 175 */
356 176 public static function show_logo( $atts = array() ) {
357 177 echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
358 178 }
@@ -358,10 +178,8 @@
358 178 }
359 179
360 180 /**
361 181 * @since 4.03.02
362 - *
363 - * @return void
364 182 */
365 183 public static function show_header_logo() {
366 184 $icon = self::svg_logo(
367 185 array(
@@ -370,9 +188,8 @@
370 188 )
371 189 );
372 190
373 191 $new_icon = apply_filters( 'frm_icon', $icon, true );
374 -
375 192 if ( $new_icon !== $icon ) {
376 193 if ( strpos( $new_icon, '<svg' ) === 0 ) {
377 194 $icon = str_replace( 'viewBox="0 0 20', 'width="30" height="35" style="color:#929699" viewBox="0 0 20', $new_icon );
378 195 } else {
@@ -384,38 +201,21 @@
384 201 }
385 202
386 203 /**
387 204 * @since 2.02.04
388 - *
389 - * @return bool
390 205 */
391 206 public static function ips_saved() {
392 207 $frm_settings = self::get_settings();
208 +
393 209 return ! $frm_settings->no_ips;
394 210 }
395 211
396 - /**
397 - * @return bool
398 - */
399 212 public static function pro_is_installed() {
400 - return (bool) apply_filters( 'frm_pro_installed', false );
213 + return apply_filters( 'frm_pro_installed', false );
401 214 }
402 215
403 216 /**
404 - * Check if the Pro plugin is installed, whether authorized or not.
405 - *
406 - * @since 6.8.3
407 - *
408 - * @return bool
409 - */
410 - public static function pro_is_included() {
411 - return function_exists( 'load_formidable_pro' );
412 - }
413 -
414 - /**
415 217 * @since 4.06.02
416 - *
417 - * @return bool
418 218 */
419 219 public static function pro_is_connected() {
420 220 global $frm_vars;
421 221 return self::pro_is_installed() && $frm_vars['pro_is_authorized'];
@@ -422,31 +222,17 @@
422 222 }
423 223
424 224 /**
425 225 * @since 4.06
426 - * @since 6.16.2 Added $check_for_settings parameter
427 - *
428 - * @param bool $check_for_settings
429 - *
430 - * @return bool
431 226 */
432 - public static function is_form_builder_page( $check_for_settings = true ) {
433 - $action = self::simple_get( 'frm_action', 'sanitize_title' );
434 - $check_actions = array( 'edit', 'duplicate' );
435 -
436 - if ( $check_for_settings ) {
437 - $check_actions[] = 'settings';
438 - }
439 - return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true );
227 + public static function is_form_builder_page() {
228 + $action = self::simple_get( 'frm_action', 'sanitize_title' );
229 + return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' );
440 230 }
441 231
442 - /**
443 - * @return bool
444 - */
445 232 public static function is_formidable_admin() {
446 233 $page = self::simple_get( 'page', 'sanitize_title' );
447 234 $is_formidable = strpos( $page, 'formidable' ) !== false;
448 -
449 235 if ( empty( $page ) ) {
450 236 $is_formidable = self::is_view_builder_page();
451 237 }
452 238
@@ -453,69 +239,28 @@
453 239 return $is_formidable;
454 240 }
455 241
456 242 /**
457 - * Checks if is a list page.
458 - *
459 - * @since 6.19
460 - *
461 - * @param string $page The name of the page to check.
462 - *
463 - * @return bool
464 - */
465 - public static function is_admin_list_page( $page = 'formidable' ) {
466 - if ( 'formidable' === $page ) {
467 - return self::on_form_listing_page();
468 - }
469 -
470 - if ( ! self::is_admin_page( $page ) ) {
471 - return false;
472 - }
473 -
474 - if ( 'formidable-entries' === $page ) {
475 - $action = self::simple_get( 'frm_action' );
476 -
477 - if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) {
478 - return true;
479 - }
480 - }
481 -
482 - // Check edit or settings page.
483 - return ! self::simple_get( 'frm_action' );
484 - }
485 -
486 - /**
487 - * @since 6.20
488 - *
489 - * @return array<string>
490 - */
491 - private static function get_entries_listing_page_form_actions() {
492 - return array( 'list', 'destroy' );
493 - }
494 -
495 - /**
496 243 * Check for certain page in Formidable settings
497 244 *
498 245 * @since 2.0
499 246 *
500 - * @param string $page The name of the page to check.
247 + * @param string $page The name of the page to check
501 248 *
502 - * @return bool
249 + * @return boolean
503 250 */
504 251 public static function is_admin_page( $page = 'formidable' ) {
505 252 global $pagenow;
506 253 $get_page = self::simple_get( 'page', 'sanitize_title' );
507 -
508 254 if ( $pagenow ) {
509 255 // allow this to be true during ajax load i.e. ajax form builder loading
510 - $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
511 -
256 + $is_page = ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
512 257 if ( $is_page ) {
513 258 return true;
514 259 }
515 260 }
516 261
517 - return is_admin() && $get_page === $page;
262 + return is_admin() && $get_page == $page;
518 263 }
519 264
520 265 /**
521 266 * If the current page is for editing or creating a view.
@@ -521,10 +266,8 @@
521 266 * If the current page is for editing or creating a view.
522 267 * Returns false for the views listing page.
523 268 *
524 269 * @since 4.0
525 - *
526 - * @return bool
527 270 */
528 271 public static function is_view_builder_page() {
529 272 global $pagenow;
530 273
@@ -534,10 +277,10 @@
534 277
535 278 $post_type = self::simple_get( 'post_type', 'sanitize_title' );
536 279
537 280 if ( empty( $post_type ) ) {
538 - $post_id = self::simple_get( 'post', 'absint' );
539 - $post = get_post( $post_id );
281 + $post_id = self::simple_get( 'post', 'absint' );
282 + $post = get_post( $post_id );
540 283 $post_type = $post ? $post->post_type : '';
541 284 }
542 285
543 286 return $post_type === 'frm_display';
@@ -547,15 +290,17 @@
547 290 * Check for the form preview page
548 291 *
549 292 * @since 2.0
550 293 *
551 - * @return bool
294 + * @param None
295 + *
296 + * @return boolean
552 297 */
553 298 public static function is_preview_page() {
554 299 global $pagenow;
555 300 $action = self::simple_get( 'action', 'sanitize_title' );
556 301
557 - return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
302 + return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
558 303 }
559 304
560 305 /**
561 306 * Check for ajax except the form preview page
@@ -561,17 +306,16 @@
561 306 * Check for ajax except the form preview page
562 307 *
563 308 * @since 2.0
564 309 *
565 - * @return bool
310 + * @param None
311 + *
312 + * @return boolean
566 313 */
567 314 public static function doing_ajax() {
568 315 return wp_doing_ajax() && ! self::is_preview_page();
569 316 }
570 317
571 - /**
572 - * @return string
573 - */
574 318 public static function js_suffix() {
575 319 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
576 320 }
577 321
@@ -576,14 +320,13 @@
576 320 }
577 321
578 322 /**
579 323 * @since 2.0.8
580 - *
581 - * @return bool
582 324 */
583 325 public static function prevent_caching() {
584 326 global $frm_vars;
585 - return ! empty( $frm_vars['prevent_caching'] );
327 +
328 + return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
586 329 }
587 330
588 331 /**
589 332 * Check if on an admin page
@@ -589,19 +332,14 @@
589 332 * Check if on an admin page
590 333 *
591 334 * @since 2.0
592 335 *
593 - * @return bool
336 + * @param None
337 + *
338 + * @return boolean
594 339 */
595 340 public static function is_admin() {
596 - $is_admin = is_admin() && ! wp_doing_ajax();
597 -
598 - /**
599 - * @since 6.0
600 - *
601 - * @param bool $is_admin
602 - */
603 - return apply_filters( 'frm_is_admin', $is_admin );
341 + return is_admin() && ! wp_doing_ajax();
604 342 }
605 343
606 344 /**
607 345 * Check if value contains blank value or empty array
@@ -607,23 +345,17 @@
607 345 * Check if value contains blank value or empty array
608 346 *
609 347 * @since 2.0
610 348 *
611 - * @param mixed $value Value to check.
612 - * @param string $empty
349 + * @param mixed $value - value to check
350 + * @param string
613 351 *
614 - * @return bool
352 + * @return boolean
615 353 */
616 354 public static function is_empty_value( $value, $empty = '' ) {
617 355 return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
618 356 }
619 357
620 - /**
621 - * @param mixed $value
622 - * @param string $empty
623 - *
624 - * @return bool
625 - */
626 358 public static function is_not_empty_value( $value, $empty = '' ) {
627 359 return ! self::is_empty_value( $value, $empty );
628 360 }
629 361
@@ -640,37 +372,26 @@
640 372 return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
641 373 }
642 374
643 375 /**
644 - * Get the server OS
376 + * Check for the IP address in several places
377 + * Used by [ip] shortcode
645 378 *
646 - * @since 6.4.2
647 - *
648 - * @return string
649 - */
650 - public static function get_server_os() {
651 - if ( function_exists( 'php_uname' ) ) {
652 - return php_uname( 's' );
653 - }
654 -
655 - if ( ! defined( 'PHP_OS' ) ) {
656 - return '';
657 - }
658 -
659 - // match the same response for Windows server as php_uname('s')
660 - return in_array( PHP_OS, array( 'WIN32', 'WINNT', 'Windows_NT' ), true ) ? 'Windows NT' : PHP_OS;
661 - }
662 -
663 - /**
664 - * Check for the IP address in several places (when custom headers are enabled).
665 - * Used by [ip] shortcode.
666 - *
667 379 * @return string The IP address of the current user
668 380 */
669 381 public static function get_ip_address() {
670 - $ip_options = self::should_use_custom_header_ip() ? self::get_custom_header_keys_for_ip() : array( 'REMOTE_ADDR' );
671 - $ip = '';
672 -
382 + $ip_options = array(
383 + 'HTTP_CLIENT_IP',
384 + 'HTTP_CF_CONNECTING_IP',
385 + 'HTTP_X_FORWARDED_FOR',
386 + 'HTTP_X_FORWARDED',
387 + 'HTTP_X_CLUSTER_CLIENT_IP',
388 + 'HTTP_X_REAL_IP',
389 + 'HTTP_FORWARDED_FOR',
390 + 'HTTP_FORWARDED',
391 + 'REMOTE_ADDR',
392 + );
393 + $ip = '';
673 394 foreach ( $ip_options as $key ) {
674 395 if ( ! isset( $_SERVER[ $key ] ) ) {
675 396 continue;
676 397 }
@@ -675,12 +396,10 @@
675 396 continue;
676 397 }
677 398
678 399 $key = self::get_server_value( $key );
679 -
680 400 foreach ( explode( ',', $key ) as $ip ) {
681 - // Just to be safe.
682 - $ip = trim( $ip );
401 + $ip = trim( $ip ); // just to be safe.
683 402
684 403 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
685 404 return sanitize_text_field( $ip );
686 405 }
@@ -689,60 +408,8 @@
689 408
690 409 return sanitize_text_field( $ip );
691 410 }
692 411
693 - /**
694 - * @since 6.1
695 - *
696 - * @return array
697 - */
698 - public static function get_custom_header_keys_for_ip() {
699 - return array(
700 - 'HTTP_CLIENT_IP',
701 - 'HTTP_CF_CONNECTING_IP',
702 - 'HTTP_X_FORWARDED_FOR',
703 - 'HTTP_X_FORWARDED',
704 - 'HTTP_X_CLUSTER_CLIENT_IP',
705 - 'HTTP_X_REAL_IP',
706 - 'HTTP_FORWARDED_FOR',
707 - 'HTTP_FORWARDED',
708 - 'REMOTE_ADDR',
709 - );
710 - }
711 -
712 - /**
713 - * Check if we should check every HTTP header or just $_SERVER['REMOTE_ADDR'].
714 - * The other HTTP headers can be spoofed so this isn't recommended.
715 - * But in some cases (like reverse proxies), the IP may be empty if you use $_SERVER['REMOTE_ADDR'].
716 - *
717 - * @since 6.1
718 - *
719 - * @return bool
720 - */
721 - private static function should_use_custom_header_ip() {
722 - $settings = self::get_settings();
723 - $should_use_custom_header_ip = ! $settings->no_ips && $settings->custom_header_ip;
724 -
725 - /**
726 - * Filter whether to check spoofable HTTP headers.
727 - * This uses the custom_header_ip setting, but it is hidden if the GDPR option is also on.
728 - * 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.
729 - *
730 - * @since 6.1
731 - *
732 - * @param bool $should_use_custom_header_ip
733 - */
734 - return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
735 - }
736 -
737 - /**
738 - * @param string $param
739 - * @param mixed $default
740 - * @param string $src
741 - * @param callable|string $sanitize
742 - *
743 - * @return mixed
744 - */
745 412 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
746 413 if ( strpos( $param, '[' ) ) {
747 414 $params = explode( '[', $param );
748 415 $param = $params[0];
@@ -749,9 +416,8 @@
749 416 }
750 417
751 418 if ( $src === 'get' ) {
752 419 $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
753 -
754 420 if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
755 421 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
756 422 $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
757 423 }
@@ -773,9 +439,9 @@
773 439 continue;
774 440 }
775 441
776 442 $p = trim( $p, ']' );
777 - $value = $value[ $p ] ?? $default;
443 + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
778 444 }
779 445 }
780 446
781 447 return $value;
@@ -780,25 +446,15 @@
780 446
781 447 return $value;
782 448 }
783 449
784 - /**
785 - * Get a value from $_POST data.
786 - *
787 - * @param string $param The key we are trying to access data from in $_POST.
788 - * @param mixed $default The default if nothing is being sent.
789 - * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default.
790 - * @param bool $serialized
791 - *
792 - * @return mixed
793 - */
794 450 public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
795 451 return self::get_simple_request(
796 452 array(
797 - 'type' => 'post',
798 - 'param' => $param,
799 - 'default' => $default,
800 - 'sanitize' => $sanitize,
453 + 'type' => 'post',
454 + 'param' => $param,
455 + 'default' => $default,
456 + 'sanitize' => $sanitize,
801 457 'serialized' => $serialized,
802 458 )
803 459 );
804 460 }
@@ -809,9 +465,9 @@
809 465 * @param string $param
810 466 * @param string $sanitize
811 467 * @param string $default
812 468 *
813 - * @return array|string
469 + * @return string|array
814 470 */
815 471 public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
816 472 return self::get_simple_request(
817 473 array(
@@ -829,40 +485,39 @@
829 485 * @since 2.0.6
830 486 *
831 487 * @param array $args
832 488 *
833 - * @return array|string
489 + * @return string|array
834 490 */
835 491 public static function get_simple_request( $args ) {
836 492 $defaults = array(
837 - 'param' => '',
838 - 'default' => '',
839 - 'type' => 'get',
840 - 'sanitize' => 'sanitize_text_field',
493 + 'param' => '',
494 + 'default' => '',
495 + 'type' => 'get',
496 + 'sanitize' => 'sanitize_text_field',
841 497 'serialized' => false,
842 498 );
843 499 $args = wp_parse_args( $args, $defaults );
844 500
845 501 $value = $args['default'];
846 -
847 - if ( $args['type'] === 'get' ) {
502 + if ( $args['type'] == 'get' ) {
848 503 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
849 504 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
850 505 $value = wp_unslash( $_GET[ $args['param'] ] );
851 506 }
852 - } elseif ( $args['type'] === 'post' ) {
507 + } elseif ( $args['type'] == 'post' ) {
853 508 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
854 509 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
855 510 $value = wp_unslash( $_POST[ $args['param'] ] );
856 -
857 511 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
858 512 self::unserialize_or_decode( $value );
859 513 }
860 514 }
861 - } elseif ( isset( $_REQUEST[ $args['param'] ] ) ) {
862 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
515 + } else {
516 + if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
863 517 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
864 518 $value = wp_unslash( $_REQUEST[ $args['param'] ] );
519 + }
865 520 }
866 521
867 522 self::sanitize_value( $args['sanitize'], $value );
868 523
@@ -886,48 +541,23 @@
886 541
887 542 return $value;
888 543 }
889 544
890 - /**
891 - * Sanitize a value in-place.
892 - * If $value is an array, the sanitize function will get called for each item.
893 - *
894 - * @param callable $sanitize
895 - * @param mixed $value
896 - *
897 - * @return void
898 - */
899 545 public static function sanitize_value( $sanitize, &$value ) {
900 - if ( ! $sanitize ) {
901 - return;
902 - }
903 -
904 - if ( is_object( $value ) ) {
905 - $value = '';
906 - return;
907 - }
908 -
909 - if ( is_array( $value ) ) {
910 - $temp_values = $value;
911 -
912 - foreach ( $temp_values as $k => $v ) {
913 - self::sanitize_value( $sanitize, $value[ $k ] );
546 + if ( ! empty( $sanitize ) ) {
547 + if ( is_array( $value ) ) {
548 + $temp_values = $value;
549 + foreach ( $temp_values as $k => $v ) {
550 + self::sanitize_value( $sanitize, $value[ $k ] );
551 + }
552 + } else {
553 + $value = call_user_func( $sanitize, $value );
914 554 }
915 - return;
916 555 }
917 -
918 - $value = call_user_func( $sanitize, $value );
919 556 }
920 557
921 - /**
922 - * @param array $sanitize_method
923 - * @param array $values
924 - *
925 - * @return void
926 - */
927 558 public static function sanitize_request( $sanitize_method, &$values ) {
928 559 $temp_values = $values;
929 -
930 560 foreach ( $temp_values as $k => $val ) {
931 561 if ( isset( $sanitize_method[ $k ] ) ) {
932 562 $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
933 563 }
@@ -935,64 +565,23 @@
935 565 }
936 566
937 567 /**
938 568 * @since 4.0.04
939 - *
940 - * @param mixed $value
941 - *
942 - * @return void
943 569 */
944 570 public static function sanitize_with_html( &$value ) {
945 - if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) {
946 - // Only strip unsafe HTML like scripts for a privileged user submitting a form.
947 - self::sanitize_value( 'wp_kses_post', $value );
948 - } else {
949 - self::sanitize_value( self::class . '::strip_most_html', $value );
950 - }
571 + self::sanitize_value( 'wp_kses_post', $value );
951 572 self::decode_specialchars( $value );
952 573 }
953 574
954 575 /**
955 - * Allow only a small set of very basic HTML for unprivileged users.
956 - *
957 - * @since 6.7.1
958 - *
959 - * @param string $value
960 - */
961 - public static function strip_most_html( $value ) {
962 - $allowed_html = array(
963 - 'b' => array(),
964 - 'br' => array(),
965 - 'strong' => array(),
966 - 'p' => array(),
967 - 'i' => array(),
968 - 'ul' => array(),
969 - 'ol' => array(),
970 - 'li' => array(),
971 - );
972 -
973 - /**
974 - * @since 6.7.1
975 - *
976 - * @param array $allowed_html
977 - */
978 - $allowed_html = apply_filters( 'frm_allowed_form_input_html', $allowed_html );
979 -
980 - return wp_kses( $value, $allowed_html );
981 - }
982 -
983 - /**
984 576 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&amp;'
985 577 * this MUST be done, else we'll be back to the '& entity' problem.
986 578 *
987 579 * @since 4.0.04
988 - *
989 - * @param mixed $value Value to decode, passed by reference.
990 580 */
991 581 public static function decode_specialchars( &$value ) {
992 582 if ( is_array( $value ) ) {
993 583 $temp_values = $value;
994 -
995 584 foreach ( $temp_values as $k => $v ) {
996 585 self::decode_specialchars( $value[ $k ] );
997 586 }
998 587 } else {
@@ -1006,9 +595,9 @@
1006 595 * Adapted from wp_specialchars_decode().
1007 596 *
1008 597 * @since 4.03.01
1009 598 *
1010 - * @param string $string The string to prep, passed by reference.
599 + * @param string $string The string to prep.
1011 600 */
1012 601 private static function decode_amp( &$string ) {
1013 602 // Don't bother if there are no entities - saves a lot of processing
1014 603 if ( empty( $string ) || strpos( $string, '&' ) === false ) {
@@ -1018,12 +607,10 @@
1018 607 $translation = array(
1019 608 '&quot;' => '"',
1020 609 '&#034;' => '"',
1021 610 '&#x22;' => '"',
1022 - // The space preserves the HTML.
1023 - '&lt; ' => '< ',
1024 - // The space preserves the HTML.
1025 - '&#060; ' => '< ',
611 + '&lt; ' => '< ', // The space preserves the HTML.
612 + '&#060; ' => '< ', // The space preserves the HTML.
1026 613 '&gt;' => '>',
1027 614 '&#062;' => '>',
1028 615 '&amp;' => '&',
1029 616 '&#038;' => '&',
@@ -1050,10 +637,10 @@
1050 637 * Sanitize the value, and allow some HTML
1051 638 *
1052 639 * @since 2.0
1053 640 *
1054 - * @param string $value The value to sanitize.
1055 - * @param array|string $allowed Allowed HTML tags and attributes, or 'all' for defaults.
641 + * @param string $value
642 + * @param array|string $allowed 'all' for everything included as defaults
1056 643 *
1057 644 * @return string
1058 645 */
1059 646 public static function kses( $value, $allowed = array() ) {
@@ -1062,28 +649,13 @@
1062 649 return wp_kses( $value, $allowed_html );
1063 650 }
1064 651
1065 652 /**
1066 - * Sanitizes and echoes a given value.
1067 - *
1068 - * @since 6.18
1069 - *
1070 - * @param string $value The value to sanitize and output.
1071 - * @param array|string $allowed Allowed HTML tags and attributes.
1072 - *
1073 - * @return void
1074 - */
1075 - public static function kses_echo( $value, $allowed = array() ) {
1076 - echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1077 - }
1078 -
1079 - /**
1080 653 * The regular kses function strips [button_action] from submit button HTML.
1081 654 *
1082 655 * @since 5.0.13
1083 656 *
1084 657 * @param string $html
1085 - *
1086 658 * @return string
1087 659 */
1088 660 public static function kses_submit_button( $html ) {
1089 661 $included_button_action = false !== strpos( $html, '[button_action]' );
@@ -1093,9 +665,8 @@
1093 665 add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1094 666 $html = self::kses( $html, 'all' );
1095 667 remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1096 668 remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1097 -
1098 669 if ( $included_button_action ) {
1099 670 if ( false !== strpos( $html, '<input type="submit"' ) ) {
1100 671 $pattern = '/(<input type="submit")([^>]*)(\/>)/';
1101 672 $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
@@ -1103,13 +674,11 @@
1103 674 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
1104 675 $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
1105 676 }
1106 677 }
1107 -
1108 678 if ( $included_back_hook ) {
1109 679 $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html );
1110 680 }
1111 -
1112 681 if ( $included_draft_hook ) {
1113 682 $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
1114 683 }
1115 684 return $html;
@@ -1118,9 +687,8 @@
1118 687 /**
1119 688 * @since 5.0.13
1120 689 *
1121 690 * @param array $allowed_attr
1122 - *
1123 691 * @return array
1124 692 */
1125 693 public static function allow_visibility_style( $allowed_attr ) {
1126 694 $allowed_attr[] = 'visibility';
@@ -1130,9 +698,8 @@
1130 698 /**
1131 699 * @since 5.0.13
1132 700 *
1133 701 * @param array $allowed_html
1134 - *
1135 702 * @return array
1136 703 */
1137 704 public static function add_allowed_submit_button_tags( $allowed_html ) {
1138 705 $allowed_html['input'] = array(
@@ -1149,22 +716,17 @@
1149 716 }
1150 717
1151 718 /**
1152 719 * @since 2.05.03
1153 - *
1154 - * @param array|string $allowed
1155 - *
1156 - * @return array
1157 720 */
1158 721 private static function allowed_html( $allowed ) {
1159 722 $html = self::safe_html();
1160 723 $allowed_html = array();
1161 -
1162 724 if ( $allowed === 'all' ) {
1163 725 $allowed_html = $html;
1164 726 } elseif ( ! empty( $allowed ) ) {
1165 727 foreach ( (array) $allowed as $a ) {
1166 - $allowed_html[ $a ] = $html[ $a ] ?? array();
728 + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
1167 729 }
1168 730 }
1169 731
1170 732 return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html );
@@ -1179,9 +741,9 @@
1179 741 'id' => true,
1180 742 );
1181 743
1182 744 return array(
1183 - 'a' => array(
745 + 'a' => array(
1184 746 'class' => true,
1185 747 'href' => true,
1186 748 'id' => true,
1187 749 'rel' => true,
@@ -1250,16 +812,16 @@
1250 812 'cite' => true,
1251 813 'title' => true,
1252 814 ),
1253 815 'rect' => array(
1254 - 'class' => true,
1255 - 'fill' => true,
1256 - 'height' => true,
1257 - 'width' => true,
1258 - 'x' => true,
1259 - 'y' => true,
1260 - 'rx' => true,
1261 - 'stroke' => true,
816 + 'class' => true,
817 + 'fill' => true,
818 + 'height' => true,
819 + 'width' => true,
820 + 'x' => true,
821 + 'y' => true,
822 + 'rx' => true,
823 + 'stroke' => true,
1262 824 'stroke-opacity' => true,
1263 825 'stroke-width' => true,
1264 826 ),
1265 827 'section' => $allow_class,
@@ -1294,9 +856,9 @@
1294 856 'xlink:href' => true,
1295 857 ),
1296 858 'ul' => $allow_class,
1297 859 'label' => array(
1298 - 'for' => true,
860 + 'for' => true,
1299 861 'class' => true,
1300 862 'id' => true,
1301 863 ),
1302 864 'button' => array(
@@ -1305,13 +867,8 @@
1305 867 ),
1306 868 'legend' => array(
1307 869 'class' => true,
1308 870 ),
1309 - 'option' => array(
1310 - 'class' => true,
1311 - 'value' => true,
1312 - 'selected' => true,
1313 - ),
1314 871 );
1315 872 }
1316 873
1317 874 /**
@@ -1319,20 +876,18 @@
1319 876 *
1320 877 * @since 2.0
1321 878 */
1322 879 public static function remove_get_action() {
1323 - if ( empty( $_GET ) ) {
880 + if ( ! isset( $_GET ) ) {
1324 881 return;
1325 882 }
1326 883
1327 884 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
1328 -
1329 885 if ( empty( $action_name ) ) {
1330 886 return;
1331 887 }
1332 888
1333 889 $new_action = self::get_param( $action_name, '', 'get', 'sanitize_text_field' );
1334 -
1335 890 if ( ! empty( $new_action ) ) {
1336 891 $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
1337 892 }
1338 893 }
@@ -1340,13 +895,9 @@
1340 895 /**
1341 896 * Check the WP query for a parameter
1342 897 *
1343 898 * @since 2.0
1344 - *
1345 - * @param array|string $value
1346 - * @param string $param
1347 - *
1348 - * @return array|string
899 + * @return string|array
1349 900 */
1350 901 public static function get_query_var( $value, $param ) {
1351 902 if ( $value != '' ) {
1352 903 return $value;
@@ -1352,9 +903,8 @@
1352 903 return $value;
1353 904 }
1354 905
1355 906 global $wp_query;
1356 -
1357 907 if ( isset( $wp_query->query_vars[ $param ] ) ) {
1358 908 $value = $wp_query->query_vars[ $param ];
1359 909 }
1360 910
@@ -1364,17 +914,13 @@
1364 914 /**
1365 915 * Try to show the SVG if possible. Otherwise, use the font icon.
1366 916 *
1367 917 * @since 4.0.02
1368 - *
1369 918 * @param string $class
1370 919 * @param array $atts
1371 - *
1372 - * @return string|null
1373 920 */
1374 921 public static function icon_by_class( $class, $atts = array() ) {
1375 922 $echo = ! isset( $atts['echo'] ) || $atts['echo'];
1376 -
1377 923 if ( isset( $atts['echo'] ) ) {
1378 924 unset( $atts['echo'] );
1379 925 }
1380 926
@@ -1380,32 +926,19 @@
1380 926
1381 927 $html_atts = self::array_to_html_params( $atts );
1382 928
1383 929 $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1384 -
1385 - // Replace icons that have been removed or renamed.
1386 - $deprecated = array(
1387 - 'frm_clone_solid_icon' => 'frm_clone_icon',
1388 - 'frm_keyalt_icon' => 'frm_key_icon',
1389 - 'frm_keyalt_solid_icon' => 'frm_key_solid_icon',
1390 - );
1391 -
1392 - if ( isset( $deprecated[ $icon ] ) ) {
1393 - $icon = $deprecated[ $icon ];
1394 - $class = str_replace( $icon, $deprecated[ $icon ], $class );
1395 - }
1396 -
1397 930 if ( $icon === $class ) {
1398 931 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
1399 932 } else {
1400 933 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
1401 -
1402 934 if ( strpos( $icon, ' ' ) ) {
1403 935 $icon = explode( ' ', $icon );
1404 936 $icon = reset( $icon );
1405 937 }
1406 -
1407 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use href="#' . esc_attr( $icon ) . '" /></svg>';
938 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
939 + <use xlink:href="#' . esc_attr( $icon ) . '" />
940 + </svg>';
1408 941 }
1409 942
1410 943 if ( $echo ) {
1411 944 echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -1419,9 +952,8 @@
1419 952 *
1420 953 * @since 5.0.13
1421 954 *
1422 955 * @param string $icon
1423 - *
1424 956 * @return string
1425 957 */
1426 958 public static function kses_icon( $icon ) {
1427 959 add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
@@ -1437,15 +969,13 @@
1437 969 /**
1438 970 * @since 5.0.13.1
1439 971 *
1440 972 * @param array $allowed_html
1441 - *
1442 973 * @return array
1443 974 */
1444 975 public static function add_allowed_icon_tags( $allowed_html ) {
1445 976 $allowed_html['svg']['data-open'] = true;
1446 977 $allowed_html['svg']['title'] = true;
1447 - $allowed_html['svg']['tabindex'] = true;
1448 978 return $allowed_html;
1449 979 }
1450 980
1451 981 /**
@@ -1451,13 +981,12 @@
1451 981 /**
1452 982 * @since 5.0.13
1453 983 *
1454 984 * @param array $allowed_attr
1455 - *
1456 985 * @return array
1457 986 */
1458 987 public static function allow_vars_in_styles( $allowed_attr ) {
1459 - $allowed_attr[] = '--primary-700';
988 + $allowed_attr[] = '--primary-hover';
1460 989 return $allowed_attr;
1461 990 }
1462 991
1463 992 /**
@@ -1466,9 +995,9 @@
1466 995 * @param bool $allow_css
1467 996 * @param string $css_string
1468 997 */
1469 998 public static function allow_style( $allow_css, $css_string ) {
1470 - if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
999 + if ( ! $allow_css && 0 === strpos( $css_string, '--primary-hover:' ) ) {
1471 1000 $split = explode( ':', $css_string, 2 );
1472 1001 $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1473 1002 }
1474 1003 return $allow_css;
@@ -1477,14 +1006,12 @@
1477 1006 /**
1478 1007 * @since 5.0.13
1479 1008 *
1480 1009 * @param string $value
1481 - *
1482 1010 * @return bool
1483 1011 */
1484 1012 private static function is_a_valid_color( $value ) {
1485 1013 $match = 0;
1486 -
1487 1014 if ( 0 === strpos( $value, 'rgba(' ) ) {
1488 1015 $match = preg_match( '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/', $value );
1489 1016 } elseif ( 0 === strpos( $value, 'rgb(' ) ) {
1490 1017 $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value );
@@ -1497,19 +1024,11 @@
1497 1024 /**
1498 1025 * Include svg images.
1499 1026 *
1500 1027 * @since 4.0.02
1501 - *
1502 - * @return void
1503 1028 */
1504 1029 public static function include_svg() {
1505 - if ( self::$included_svg ) {
1506 - return;
1507 - }
1508 -
1509 - // Use readfile instead of include_once because of a default security rule in Snuffleupagus.
1510 - readfile( self::plugin_path() . '/images/icons.svg' );
1511 - self::$included_svg = true;
1030 + include_once self::plugin_path() . '/images/icons.svg';
1512 1031 }
1513 1032
1514 1033 /**
1515 1034 * Convert an associative array to HTML values.
@@ -1518,13 +1037,12 @@
1518 1037 * @since 5.0.13 added $echo parameter.
1519 1038 *
1520 1039 * @param array $atts
1521 1040 * @param bool $echo
1522 - *
1523 1041 * @return string|void
1524 1042 */
1525 1043 public static function array_to_html_params( $atts, $echo = false ) {
1526 - $callback = function () use ( $atts ) {
1044 + $callback = function() use ( $atts ) {
1527 1045 if ( $atts ) {
1528 1046 foreach ( $atts as $key => $value ) {
1529 1047 echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1530 1048 }
@@ -1539,10 +1057,9 @@
1539 1057 * @since 5.0.13
1540 1058 *
1541 1059 * @param Closure $echo_function
1542 1060 * @param bool $echo
1543 - *
1544 - * @return string|null
1061 + * @return string|void
1545 1062 */
1546 1063 public static function clip( $echo_function, $echo = false ) {
1547 1064 if ( ! $echo ) {
1548 1065 ob_start();
@@ -1547,11 +1064,9 @@
1547 1064 if ( ! $echo ) {
1548 1065 ob_start();
1549 1066 }
1550 1067
1551 - if ( is_callable( $echo_function ) ) {
1552 - $echo_function();
1553 - }
1068 + $echo_function();
1554 1069
1555 1070 if ( ! $echo ) {
1556 1071 $return = ob_get_contents();
1557 1072 ob_end_clean();
@@ -1560,120 +1075,31 @@
1560 1075 }
1561 1076
1562 1077 /**
1563 1078 * @since 3.0
1564 - *
1565 - * @param array $atts
1566 - *
1567 - * @return void
1568 1079 */
1569 1080 public static function get_admin_header( $atts ) {
1570 - $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] );
1571 -
1572 - if ( empty( $atts['close'] ) ) {
1081 + $has_nav = ( isset( $atts['form'] ) && ! empty( $atts['form'] ) && ( ! isset( $atts['is_template'] ) || ! $atts['is_template'] ) );
1082 + if ( ! isset( $atts['close'] ) || empty( $atts['close'] ) ) {
1573 1083 $atts['close'] = admin_url( 'admin.php?page=formidable' );
1574 1084 }
1575 -
1576 1085 if ( ! isset( $atts['import_link'] ) ) {
1577 1086 $atts['import_link'] = false;
1578 1087 }
1579 1088
1580 - include self::plugin_path() . '/classes/views/shared/admin-header.php';
1089 + include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1581 1090 }
1582 1091
1583 1092 /**
1584 - * @since 6.0
1585 - *
1586 - * @param string $type
1587 - *
1588 - * @return void
1589 - */
1590 - public static function import_link( $type = 'secondary' ) {
1591 - ?>
1592 - <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">
1593 - <?php esc_html_e( 'Import', 'formidable' ); ?>
1594 - </a>
1595 - <?php
1596 - }
1597 -
1598 - /**
1599 - * Print applicable admin banner.
1600 - *
1601 - * @since 5.4.2
1602 - *
1603 - * @param bool $should_show_lite_upgrade
1604 - *
1605 - * @return void
1606 - */
1607 - public static function print_admin_banner( $should_show_lite_upgrade ) {
1608 - if ( ! current_user_can( 'administrator' ) ) {
1609 - FrmInbox::maybe_show_banner();
1610 - return;
1611 - }
1612 -
1613 - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1614 - // Print license warning or inbox banner and exit if either prints.
1615 - // And exit before printing the upgrade bar if it shouldn't be shown.
1616 - return;
1617 - }
1618 - ?>
1619 - <div class="frm-upgrade-bar">
1620 - <div class="frm-upgrade-bar-inner">
1621 - <?php
1622 - $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' );
1623 -
1624 - if ( ! $cta_text ) {
1625 - $cta_text = __( 'upgrading to PRO', 'formidable' );
1626 - }
1627 -
1628 - $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' );
1629 - $utm = array(
1630 - 'campaign' => 'settings-license',
1631 - 'content' => 'lite-banner',
1632 - );
1633 -
1634 - if ( $upgrade_link ) {
1635 - $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm );
1636 - } else {
1637 - $upgrade_link = self::admin_upgrade_link( $utm );
1638 - }
1639 -
1640 - printf(
1641 - /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */
1642 - esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ),
1643 - '<a href="' . esc_url( $upgrade_link ) . '">',
1644 - esc_html( $cta_text ),
1645 - '</a>'
1646 - );
1647 - ?>
1648 - </div>
1649 - </div>
1650 - <?php
1651 - }
1652 -
1653 - /**
1654 - * @since 5.4.2
1655 - *
1656 - * @return bool True if a banner is available and shown.
1657 - */
1658 - private static function maybe_show_license_warning() {
1659 - return is_callable( 'FrmProAddonsController::admin_banner' ) && FrmProAddonsController::admin_banner();
1660 - }
1661 -
1662 - /**
1663 1093 * Render a button for a new item (Form, Application, etc).
1664 1094 *
1665 1095 * @since 3.0
1666 - *
1667 1096 * @param array $atts {
1668 - * Details about the button.
1669 - *
1670 1097 * @type array $link_hook Custom link hook, calls do_action and exits early.
1671 1098 * @type string $new_link Href value, default #.
1672 1099 * @type string $class Custom class names, space separated.
1673 1100 * @type string $button_text Button text. Default "Add New".
1674 1101 * }
1675 - *
1676 1102 * @return void
1677 1103 */
1678 1104 public static function add_new_item_link( $atts ) {
1679 1105 if ( isset( $atts['link_hook'] ) ) {
@@ -1680,16 +1106,20 @@
1680 1106 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1681 1107 return;
1682 1108 }
1683 1109
1684 - if ( empty( $atts['new_link'] ) && empty( $atts['create_form'] ) && empty( $atts['class'] ) ) {
1110 + if ( empty( $atts['new_link'] ) && empty( $atts['trigger_new_form_modal'] ) && empty( $atts['class'] ) ) {
1685 1111 // Do not render a button if none of these attributes are set.
1686 1112 return;
1687 1113 }
1688 1114
1689 1115 $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#';
1690 - $class = 'button button-primary frm-button-primary';
1116 + $class = 'button button-primary frm-button-primary frm-with-plus';
1691 1117
1118 + if ( ! empty( $atts['trigger_new_form_modal'] ) ) {
1119 + $class .= ' frm-trigger-new-form-modal';
1120 + }
1121 +
1692 1122 if ( ! empty( $atts['class'] ) ) {
1693 1123 $class .= ' ' . $atts['class'];
1694 1124 }
1695 1125
@@ -1699,12 +1129,8 @@
1699 1129 }
1700 1130
1701 1131 /**
1702 1132 * @since 3.06
1703 - *
1704 - * @param array $atts
1705 - *
1706 - * @return void
1707 1133 */
1708 1134 public static function show_search_box( $atts ) {
1709 1135 $defaults = array(
1710 1136 'placeholder' => '',
@@ -1710,12 +1136,10 @@
1710 1136 'placeholder' => '',
1711 1137 'tosearch' => '',
1712 1138 'text' => __( 'Search', 'formidable' ),
1713 1139 'input_id' => '',
1714 - 'value' => false,
1715 - 'class' => '',
1716 1140 );
1717 - $atts = array_merge( $defaults, $atts );
1141 + $atts = array_merge( $defaults, $atts );
1718 1142
1719 1143 if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) {
1720 1144 $atts['tosearch'] = 'frm-card';
1721 1145 }
@@ -1720,9 +1144,8 @@
1720 1144 $atts['tosearch'] = 'frm-card';
1721 1145 }
1722 1146
1723 1147 $class = 'frm-search-input';
1724 -
1725 1148 if ( ! empty( $atts['tosearch'] ) ) {
1726 1149 $class .= ' frm-auto-search';
1727 1150 }
1728 1151
@@ -1727,34 +1150,21 @@
1727 1150 }
1728 1151
1729 1152 $input_id = $atts['input_id'] . '-search-input';
1730 1153
1731 - $input_atts = array(
1732 - 'type' => 'search',
1733 - 'id' => $input_id,
1734 - 'name' => 's',
1735 - 'placeholder' => $atts['placeholder'],
1736 - 'class' => $class,
1737 - 'data-tosearch' => $atts['tosearch'],
1738 - );
1739 -
1740 - if ( is_string( $atts['value'] ) ) {
1741 - $input_atts['value'] = $atts['value'];
1742 - } elseif ( isset( $_REQUEST['s'] ) ) {
1743 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1744 - $input_atts['value'] = wp_unslash( $_REQUEST['s'] );
1745 - }
1746 -
1747 - if ( ! empty( $atts['tosearch'] ) ) {
1748 - $input_atts['autocomplete'] = 'off';
1749 - }
1750 1154 ?>
1751 - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>">
1155 + <p class="frm-search">
1752 1156 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
1753 1157 <?php echo esc_html( $atts['text'] ); ?>:
1754 1158 </label>
1755 - <?php self::icon_by_class( 'frm_icon_font frm_search_icon frm_svg20' ); ?>
1756 - <input <?php self::array_to_html_params( $input_atts, true ); ?> />
1159 + <span class="frmfont frm_search_icon"></span>
1160 + <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s"
1161 + value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( $atts['placeholder'] ); ?>"
1162 + class="<?php echo esc_attr( $class ); ?>" data-tosearch="<?php echo esc_attr( $atts['tosearch'] ); ?>"
1163 + <?php if ( ! empty( $atts['tosearch'] ) ) { ?>
1164 + autocomplete="off"
1165 + <?php } ?>
1166 + />
1757 1167 <?php
1758 1168 if ( empty( $atts['tosearch'] ) ) {
1759 1169 submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
1760 1170 }
@@ -1763,17 +1173,13 @@
1763 1173 <?php
1764 1174 }
1765 1175
1766 1176 /**
1767 - * @param string $type Hook type slug.
1768 - * @param object|null $object Optional related object.
1769 - *
1770 - * @return void
1177 + * @param string $type
1771 1178 */
1772 1179 public static function trigger_hook_load( $type, $object = null ) {
1773 1180 // Only load the form hooks once.
1774 1181 $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
1775 -
1776 1182 if ( ! $hooks_loaded ) {
1777 1183 do_action( 'frm_load_' . $type . '_hooks' );
1778 1184 }
1779 1185 }
@@ -1778,14 +1184,11 @@
1778 1184 }
1779 1185 }
1780 1186
1781 1187 /**
1782 - * Save all front-end js scripts into a single file.
1783 - * And save an additional single file of all front-end Stripe JS scripts.
1188 + * Save all front-end js scripts into a single file
1784 1189 *
1785 1190 * @since 3.0
1786 - *
1787 - * @return void
1788 1191 */
1789 1192 public static function save_combined_js() {
1790 1193 $file_atts = apply_filters(
1791 1194 'frm_js_location',
@@ -1798,34 +1201,10 @@
1798 1201
1799 1202 $files = array(
1800 1203 self::plugin_path() . '/js/formidable.min.js',
1801 1204 );
1802 - /**
1803 - * @param array $files
1804 - */
1805 1205 $files = apply_filters( 'frm_combined_js_files', $files );
1806 1206 $new_file->combine_files( $files );
1807 -
1808 - // Create the minified Stripe Script.
1809 - $file_atts = apply_filters(
1810 - 'frm_stripe_js_location',
1811 - array(
1812 - 'file_name' => 'frmstrp.min.js',
1813 - 'new_file_path' => self::plugin_path() . '/js',
1814 - )
1815 - );
1816 - $new_file = new FrmCreateFile( $file_atts );
1817 - $files = array(
1818 - FrmStrpLiteAppHelper::plugin_path() . 'js/frmstrp.min.js',
1819 - );
1820 -
1821 - /**
1822 - * @since 6.5
1823 - *
1824 - * @param array $files
1825 - */
1826 - $files = apply_filters( 'frm_stripe_combined_js_files', $files );
1827 - $new_file->combine_files( $files );
1828 1207 }
1829 1208
1830 1209 /**
1831 1210 * Check a value from a shortcode to see if true or false.
@@ -1832,14 +1211,14 @@
1832 1211 * True when value is 1, true, 'true', 'yes'
1833 1212 *
1834 1213 * @since 1.07.10
1835 1214 *
1836 - * @param string $value The value to compare.
1215 + * @param string $value The value to compare
1837 1216 *
1838 - * @return bool
1217 + * @return boolean True or False
1839 1218 */
1840 1219 public static function is_true( $value ) {
1841 - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value;
1220 + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
1842 1221 }
1843 1222
1844 1223 /**
1845 1224 * Gets all post from a specific post type.
@@ -1847,9 +1226,8 @@
1847 1226 *
1848 1227 * @since 4.10.01 Add `$post_type` argument.
1849 1228 *
1850 1229 * @param string $post_type Post type to query. Default is `page`.
1851 - *
1852 1230 * @return WP_Post[]
1853 1231 */
1854 1232 public static function get_pages( $post_type = 'page' ) {
1855 1233 $query = array(
@@ -1868,9 +1246,8 @@
1868 1246 *
1869 1247 * @since 5.0.09
1870 1248 *
1871 1249 * @param string $post_type Post type to query. Default is `page`.
1872 - *
1873 1250 * @return array
1874 1251 */
1875 1252 public static function get_post_ids_and_titles( $post_type = 'page' ) {
1876 1253 return FrmDb::get_results(
@@ -1899,9 +1276,9 @@
1899 1276 $args = self::preformat_selection_args( $args );
1900 1277
1901 1278 $pages_count = wp_count_posts( $args['post_type'] );
1902 1279
1903 - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) {
1280 + if ( $pages_count->publish <= 50 ) {
1904 1281 self::wp_pages_dropdown( $args );
1905 1282 return;
1906 1283 }
1907 1284
@@ -1907,9 +1284,9 @@
1907 1284
1908 1285 wp_enqueue_script( 'jquery-ui-autocomplete' );
1909 1286
1910 1287 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1911 - $title = '';
1288 + $title = '';
1912 1289
1913 1290 if ( $selected ) {
1914 1291 $title = get_the_title( $selected );
1915 1292 }
@@ -1925,116 +1302,18 @@
1925 1302 <?php
1926 1303 }
1927 1304
1928 1305 /**
1929 - * Maybe show an HTML select or autocomplete input based on the number of options.
1930 - *
1931 - * @since 6.21
1932 - *
1933 - * @param array $args Args. See the method for details.
1306 + * @param array $args
1307 + * @param string $page_id Deprecated.
1308 + * @param boolean $truncate Deprecated.
1934 1309 */
1935 - public static function maybe_autocomplete_options( $args ) {
1936 - $defaults = array(
1937 - 'truncate' => false,
1938 - 'placeholder' => ' ',
1939 - 'name' => '',
1940 - 'id' => '',
1941 - 'selected' => '',
1942 - 'source' => array(),
1943 - 'dropdown_limit' => 50,
1944 - 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ),
1945 - 'value_key' => 'value',
1946 - 'label_key' => 'label',
1947 - );
1948 -
1949 - $args = wp_parse_args( $args, $defaults );
1950 -
1951 - $html_attrs = array();
1952 -
1953 - if ( ! empty( $args['name'] ) ) {
1954 - $html_attrs['name'] = $args['name'];
1955 - }
1956 -
1957 - if ( ! empty( $args['id'] ) ) {
1958 - $html_attrs['id'] = $args['id'];
1959 - }
1960 -
1961 - if ( count( $args['source'] ) <= $args['dropdown_limit'] ) {
1962 - ?>
1963 - <select <?php self::array_to_html_params( $html_attrs, true ); ?>>
1964 - <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
1965 - <?php
1966 - foreach ( $args['source'] as $key => $source ) :
1967 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1968 -
1969 - if ( ! empty( $args['truncate'] ) ) {
1970 - $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] );
1971 - }
1972 - ?>
1973 - <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option>
1974 - <?php endforeach; ?>
1975 - </select>
1976 - <?php
1977 - } else {
1978 - $options = array();
1979 - $autocomplete_value = '';
1980 -
1981 - foreach ( $args['source'] as $key => $source ) {
1982 - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args );
1983 -
1984 - if ( $value_label['value'] === $args['selected'] ) {
1985 - $autocomplete_value = $value_label['label'];
1986 - }
1987 -
1988 - $options[] = $value_label;
1989 - }
1990 -
1991 - $html_attrs['type'] = 'hidden';
1992 - $html_attrs['class'] = 'frm_autocomplete_value_input';
1993 - $html_attrs['value'] = $args['selected'];
1994 - ?>
1995 - <input type="text" class="frm-custom-search"
1996 - data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>"
1997 - placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>"
1998 - value="<?php echo esc_attr( $autocomplete_value ); ?>" />
1999 - <input <?php self::array_to_html_params( $html_attrs, true ); ?> />
2000 - <?php
2001 - }//end if
2002 - }
2003 -
2004 - /**
2005 - * Gets dropdown value and label from autodropdown option.
2006 - *
2007 - * @since 6.21
2008 - *
2009 - * @param array|string $option Autocomplete option.
2010 - * @param string $key Array key of the option.
2011 - * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}.
2012 - *
2013 - * @return array
2014 - */
2015 - private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) {
2016 - if ( is_array( $option ) ) {
2017 - $value = $option[ $args['value_key'] ] ?? '';
2018 - $label = $option[ $args['label_key'] ] ?? '';
2019 - } else {
2020 - $value = $key;
2021 - $label = $option;
2022 - }
2023 -
2024 - return compact( 'value', 'label' );
2025 - }
2026 -
2027 - /**
2028 - * @param array $args
2029 - * @param string $page_id Deprecated.
2030 - * @param bool $truncate Deprecated.
2031 - */
2032 1310 public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) {
2033 1311 self::prep_page_dropdown_params( $page_id, $truncate, $args );
2034 1312
2035 1313 $pages = self::get_post_ids_and_titles( $args['post_type'] );
2036 1314 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1315 +
2037 1316 ?>
2038 1317 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
2039 1318 <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
2040 1319 <?php foreach ( $pages as $page ) { ?>
@@ -2050,14 +1329,8 @@
2050 1329 * Fill in missing parameters passed to wp_pages_dropdown().
2051 1330 * This is for reverse compatibility with switching 3 params to 1.
2052 1331 *
2053 1332 * @since 4.03.06
2054 - *
2055 - * @param string $page_id Deprecated.
2056 - * @param bool $truncate Deprecated.
2057 - * @param mixed $args
2058 - *
2059 - * @return void
2060 1333 */
2061 1334 private static function prep_page_dropdown_params( $page_id, $truncate, &$args ) {
2062 1335 if ( ! is_array( $args ) ) {
2063 1336 $args = array(
@@ -2074,20 +1347,16 @@
2074 1347 * Filter to format args for page dropdown or autocomplete
2075 1348 *
2076 1349 * @since 4.03.06
2077 1350 * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array.
2078 - *
2079 - * @param array $args
2080 - *
2081 - * @return array
2082 1351 */
2083 1352 private static function preformat_selection_args( $args ) {
2084 1353 $defaults = array(
2085 - 'truncate' => false,
2086 - 'placeholder' => ' ',
2087 - 'field_name' => '',
2088 - 'page_id' => '',
2089 - 'post_type' => 'page',
1354 + 'truncate' => false,
1355 + 'placeholder' => ' ',
1356 + 'field_name' => '',
1357 + 'page_id' => '',
1358 + 'post_type' => 'page',
2090 1359 'autocomplete_placeholder' => __( 'Select a Page', 'formidable' ),
2091 1360 );
2092 1361
2093 1362 return array_merge( $defaults, $args );
@@ -2092,18 +1361,13 @@
2092 1361
2093 1362 return array_merge( $defaults, $args );
2094 1363 }
2095 1364
2096 - /**
2097 - * @param int $post_id
2098 - *
2099 - * @return string
2100 - */
2101 1365 public static function post_edit_link( $post_id ) {
2102 1366 $post = get_post( $post_id );
2103 -
2104 1367 if ( $post ) {
2105 1368 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1369 + $post_url = self::maybe_full_screen_link( $post_url );
2106 1370
2107 1371 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
2108 1372 }
2109 1373
@@ -2118,63 +1382,34 @@
2118 1382 * @return bool
2119 1383 */
2120 1384 public static function is_full_screen() {
2121 1385 return self::is_form_builder_page() ||
2122 - self::is_style_editor_page() ||
2123 - self::is_full_screen_view_builder_page();
1386 + self::is_admin_page( 'formidable-styles' ) ||
1387 + self::is_admin_page( 'formidable-styles2' ) ||
1388 + self::simple_get( 'frm-full', 'absint' ) ||
1389 + self::is_view_builder_page();
2124 1390 }
2125 1391
2126 1392 /**
2127 - * Check if user is on the style editor or its alternative URL.
2128 - * The first URL is a submenu "Styles" in the Formidable menu /wp-admin/admin.php?page=formidable-styles.
2129 - * The alternative URL is linked as a submenu "Forms" item of the Appearance menu /wp-admin/themes.php?page=formidable-styles2.
2130 - *
2131 - * @since 5.5.3
2132 - * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
2133 - *
2134 - * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
2135 - *
2136 - * @return bool
1393 + * @since 4.0
2137 1394 */
2138 - public static function is_style_editor_page( $view = '' ) {
2139 - if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
2140 - return false;
1395 + public static function maybe_full_screen_link( $link ) {
1396 + $is_full = self::simple_get( 'frm-full', 'absint' );
1397 + if ( $is_full && ! empty( $link ) && $link !== '#' ) {
1398 + $link .= '&frm-full=1';
2141 1399 }
2142 -
2143 - if ( ! in_array( $view, array( 'list', 'edit' ), true ) ) {
2144 - return true;
2145 - }
2146 -
2147 - $action = self::simple_get( 'frm_action' );
2148 - $is_edit_mode = 'edit' === $action || ( ! $action && ! self::simple_get( 'id' ) && ! self::simple_get( 'form' ) );
2149 -
2150 - if ( ! $is_edit_mode && class_exists( 'FrmProStylesController' ) && in_array( $action, array( 'new_style', 'duplicate' ), true ) ) {
2151 - $is_edit_mode = true;
2152 - }
2153 -
2154 - $checking_for_edit_mode = 'edit' === $view;
2155 -
2156 - return $is_edit_mode === $checking_for_edit_mode;
1400 + return $link;
2157 1401 }
2158 1402
2159 1403 /**
2160 - * @since 5.5.3
2161 - *
2162 - * @return bool
1404 + * @param string $field_name
1405 + * @param string|array $capability
1406 + * @param string $multiple 'single' and 'multiple'
2163 1407 */
2164 - private static function is_full_screen_view_builder_page() {
2165 - return self::is_admin_page( 'formidable-views-editor' );
2166 - }
2167 -
2168 - /**
2169 - * @param string $field_name
2170 - * @param array|string $capability
2171 - * @param string $multiple 'single' and 'multiple'.
2172 - */
2173 1408 public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
2174 1409 ?>
2175 1410 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>"
2176 - <?php echo 'multiple' === $multiple ? 'multiple="multiple"' : ''; ?>
1411 + <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?>
2177 1412 class="frm_multiselect">
2178 1413 <?php self::roles_options( $capability ); ?>
2179 1414 </select>
2180 1415 <?php
@@ -2181,11 +1416,10 @@
2181 1416 }
2182 1417
2183 1418 /**
2184 1419 * @since 4.07
2185 - *
2186 1420 * @param array|string $selected
2187 - * @param string $current
1421 + * @param string $current
2188 1422 */
2189 1423 private static function selected( $selected, $current ) {
2190 1424 if ( is_callable( 'FrmProAppHelper::selected' ) ) {
2191 1425 FrmProAppHelper::selected( $selected, $current );
@@ -2194,13 +1428,12 @@
2194 1428 }
2195 1429 }
2196 1430
2197 1431 /**
2198 - * @param array|string $capability
1432 + * @param string|array $capability
2199 1433 */
2200 1434 public static function roles_options( $capability ) {
2201 1435 global $frm_vars;
2202 -
2203 1436 if ( isset( $frm_vars['editable_roles'] ) ) {
2204 1437 $editable_roles = $frm_vars['editable_roles'];
2205 1438 } else {
2206 1439 $editable_roles = get_editable_roles();
@@ -2209,9 +1442,9 @@
2209 1442
2210 1443 foreach ( $editable_roles as $role => $details ) {
2211 1444 $name = translate_user_role( $details['name'] );
2212 1445 ?>
2213 - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option>
1446 + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_attr( $name ); ?> </option>
2214 1447 <?php
2215 1448 unset( $role, $details );
2216 1449 }
2217 1450 }
@@ -2221,9 +1454,8 @@
2221 1454 *
2222 1455 * @since 5.0 Parameter `$type` supports `pro_only` value.
2223 1456 *
2224 1457 * @param string $type Supports `auto`, `pro`, or `pro_only`.
2225 - *
2226 1458 * @return array
2227 1459 */
2228 1460 public static function frm_capabilities( $type = 'auto' ) {
2229 1461 if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
@@ -2233,8 +1465,9 @@
2233 1465 $pro_cap = array(
2234 1466 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
2235 1467 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
2236 1468 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1469 + 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
2237 1470 );
2238 1471 /**
2239 1472 * @since 5.3.1
2240 1473 *
@@ -2257,9 +1490,9 @@
2257 1490 * @return array<string,string>
2258 1491 */
2259 1492 private static function get_lite_capabilities() {
2260 1493 return array(
2261 - 'frm_view_forms' => __( 'View Forms List', 'formidable' ),
1494 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
2262 1495 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
2263 1496 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
2264 1497 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
2265 1498 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
@@ -2300,10 +1533,9 @@
2300 1533 return current_user_can( $role );
2301 1534 }
2302 1535
2303 1536 /**
2304 - * @param array|string $needed_role
2305 - *
1537 + * @param string|array $needed_role
2306 1538 * @return bool
2307 1539 */
2308 1540 public static function user_has_permission( $needed_role ) {
2309 1541 if ( is_array( $needed_role ) ) {
@@ -2322,14 +1554,12 @@
2322 1554 return $can;
2323 1555 }
2324 1556
2325 1557 $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
2326 -
2327 1558 foreach ( $roles as $role ) {
2328 1559 if ( current_user_can( $role ) ) {
2329 1560 return true;
2330 1561 }
2331 -
2332 1562 if ( $role == $needed_role ) {
2333 1563 break;
2334 1564 }
2335 1565 }
@@ -2351,9 +1581,8 @@
2351 1581
2352 1582 $user_id = get_current_user_id();
2353 1583 $user = new WP_User( $user_id );
2354 1584 $frm_roles = self::frm_capabilities();
2355 -
2356 1585 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2357 1586 $user->add_cap( $frm_role );
2358 1587 unset( $frm_role, $frm_role_description );
2359 1588 }
@@ -2362,18 +1591,13 @@
2362 1591 /**
2363 1592 * Make sure admins have permission to see the menu items
2364 1593 *
2365 1594 * @since 2.0.6
2366 - *
2367 - * @param string $cap
2368 - *
2369 - * @return void
2370 1595 */
2371 1596 public static function force_capability( $cap = 'frm_change_settings' ) {
2372 1597 if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
2373 1598 $role = get_role( 'administrator' );
2374 1599 $frm_roles = self::frm_capabilities();
2375 -
2376 1600 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2377 1601 $role->add_cap( $frm_role );
2378 1602 }
2379 1603 }
@@ -2379,19 +1603,17 @@
2379 1603 }
2380 1604 }
2381 1605
2382 1606 /**
2383 - * Check if the user has permission for action.
1607 + * Check if the user has permision for action.
2384 1608 * Return permission message and stop the action if no permission
2385 1609 *
2386 1610 * @since 2.0
2387 1611 *
2388 1612 * @param string $permission
2389 - * @param string $show_message
2390 1613 */
2391 1614 public static function permission_check( $permission, $show_message = 'show' ) {
2392 1615 $permission_error = self::permission_nonce_error( $permission );
2393 -
2394 1616 if ( $permission_error !== false ) {
2395 1617 if ( 'hide' == $show_message ) {
2396 1618 $permission_error = '';
2397 1619 }
@@ -2404,10 +1626,8 @@
2404 1626 *
2405 1627 * @since 2.0
2406 1628 *
2407 1629 * @param string $permission
2408 - * @param string $nonce_name
2409 - * @param string $nonce
2410 1630 *
2411 1631 * @return false|string The permission message or false if allowed
2412 1632 */
2413 1633 public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
@@ -2417,15 +1637,13 @@
2417 1637 return $frm_settings->admin_permission;
2418 1638 }
2419 1639
2420 1640 $error = false;
2421 -
2422 1641 if ( empty( $nonce_name ) ) {
2423 1642 return $error;
2424 1643 }
2425 1644
2426 - $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2427 -
1645 + $nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2428 1646 if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
2429 1647 $frm_settings = self::get_settings();
2430 1648 $error = $frm_settings->admin_permission;
2431 1649 }
@@ -2432,14 +1650,8 @@
2432 1650
2433 1651 return $error;
2434 1652 }
2435 1653
2436 - /**
2437 - * @param array|string $values
2438 - * @param string $current
2439 - *
2440 - * @return void
2441 - */
2442 1654 public static function checked( $values, $current ) {
2443 1655 if ( self::check_selected( $values, $current ) ) {
2444 1656 echo ' checked="checked"';
2445 1657 }
@@ -2444,39 +1656,24 @@
2444 1656 echo ' checked="checked"';
2445 1657 }
2446 1658 }
2447 1659
2448 - /**
2449 - * @param array|string $values
2450 - * @param string $current
2451 - *
2452 - * @return bool
2453 - */
2454 1660 public static function check_selected( $values, $current ) {
2455 - $values = self::recursive_function_map( $values, 'trim' );
2456 - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1661 + $values = self::recursive_function_map( $values, 'trim' );
1662 + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1663 + $current = htmlspecialchars_decode( trim( $current ) );
2457 1664
2458 - $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) );
2459 -
2460 1665 return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
2461 1666 }
2462 1667
2463 - /**
2464 - * @param array|string $value
2465 - * @param callable|string $function
2466 - *
2467 - * @return array|string
2468 - */
2469 1668 public static function recursive_function_map( $value, $function ) {
2470 1669 if ( is_array( $value ) ) {
2471 1670 $original_function = $function;
2472 -
2473 1671 if ( count( $value ) ) {
2474 1672 $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) );
2475 1673 } else {
2476 1674 $function = array( $function );
2477 1675 }
2478 -
2479 1676 if ( ! self::is_assoc( $value ) ) {
2480 1677 $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function );
2481 1678 } else {
2482 1679 foreach ( $value as $k => $v ) {
@@ -2485,38 +1682,14 @@
2485 1682 }
2486 1683 }
2487 1684 }
2488 1685 } else {
2489 - $value = self::maybe_update_value_if_null( $value, $function );
2490 1686 $value = call_user_func( $function, $value );
2491 - }//end if
2492 -
2493 - return $value;
2494 - }
2495 -
2496 - /**
2497 - * Updates value to empty string if it is null and being passed to a string function.
2498 - *
2499 - * @since 6.8.4
2500 - *
2501 - * @param mixed $value
2502 - * @param string $function
2503 - *
2504 - * @return mixed
2505 - */
2506 - private static function maybe_update_value_if_null( $value, $function ) {
2507 - if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) {
2508 - $value = '';
2509 1687 }
2510 1688
2511 1689 return $value;
2512 1690 }
2513 1691
2514 - /**
2515 - * @param array $array
2516 - *
2517 - * @return bool
2518 - */
2519 1692 public static function is_assoc( $array ) {
2520 1693 return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
2521 1694 }
2522 1695
@@ -2521,24 +1694,20 @@
2521 1694 }
2522 1695
2523 1696 /**
2524 1697 * Flatten a multi-dimensional array
2525 - *
2526 - * @param array $array
2527 - * @param string $keys
2528 - *
2529 - * @return array
2530 1698 */
2531 1699 public static function array_flatten( $array, $keys = 'keep' ) {
2532 1700 $return = array();
2533 -
2534 1701 foreach ( $array as $key => $value ) {
2535 1702 if ( is_array( $value ) ) {
2536 1703 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
2537 - } elseif ( $keys === 'keep' ) {
1704 + } else {
1705 + if ( $keys == 'keep' ) {
2538 1706 $return[ $key ] = $value;
2539 - } else {
2540 - $return[] = $value;
1707 + } else {
1708 + $return[] = $value;
1709 + }
2541 1710 }
2542 1711 }
2543 1712
2544 1713 return $return;
@@ -2543,43 +1712,16 @@
2543 1712
2544 1713 return $return;
2545 1714 }
2546 1715
2547 - /**
2548 - * Flatten an array before imploding it to avoid Array to string conversion warnings.
2549 - *
2550 - * @since 6.16.1
2551 - *
2552 - * @param string $sep
2553 - * @param array $array
2554 - *
2555 - * @return string
2556 - */
2557 - public static function safe_implode( $sep, $array ) {
2558 - $array = self::array_flatten( $array );
2559 - return implode( $sep, $array );
2560 - }
2561 -
2562 - /**
2563 - * @param string $text
2564 - * @param bool $is_rich_text
2565 - *
2566 - * @return string
2567 - */
2568 1716 public static function esc_textarea( $text, $is_rich_text = false ) {
2569 1717 $safe_text = str_replace( '&quot;', '"', $text );
2570 -
2571 1718 if ( ! $is_rich_text ) {
2572 1719 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
2573 1720 }
2574 -
2575 1721 $safe_text = str_replace( '&amp; ', '& ', $safe_text );
2576 1722
2577 - /**
2578 - * @param string $safe_text
2579 - * @param string $text
2580 - */
2581 - return (string) apply_filters( 'esc_textarea', $safe_text, $text );
1723 + return apply_filters( 'esc_textarea', $safe_text, $text );
2582 1724 }
2583 1725
2584 1726 /**
2585 1727 * Add auto paragraphs to text areas
@@ -2584,15 +1726,11 @@
2584 1726 /**
2585 1727 * Add auto paragraphs to text areas
2586 1728 *
2587 1729 * @since 2.0
2588 - *
2589 - * @param mixed $content
2590 - *
2591 - * @return mixed
2592 1730 */
2593 1731 public static function use_wpautop( $content ) {
2594 - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) {
1732 + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) {
2595 1733 $content = wpautop( str_replace( '<br>', '<br />', $content ) );
2596 1734 }
2597 1735
2598 1736 return $content;
@@ -2597,15 +1735,8 @@
2597 1735
2598 1736 return $content;
2599 1737 }
2600 1738
2601 - /**
2602 - * Replace quotes with their HTML entities.
2603 - *
2604 - * @param string $val
2605 - *
2606 - * @return string
2607 - */
2608 1739 public static function replace_quotes( $val ) {
2609 1740 // Replace double quotes.
2610 1741 $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
2611 1742
@@ -2615,28 +1746,22 @@
2615 1746 return $val;
2616 1747 }
2617 1748
2618 1749 /**
2619 - * @param string $handle
2620 - * @param int|string $default
2621 - *
2622 - * @return int|string
1750 + * @param string $handle
2623 1751 */
2624 1752 public static function script_version( $handle, $default = 0 ) {
2625 1753 global $wp_scripts;
2626 -
2627 1754 if ( ! $wp_scripts ) {
2628 1755 return $default;
2629 1756 }
2630 1757
2631 1758 $ver = $default;
2632 -
2633 1759 if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
2634 1760 return $ver;
2635 1761 }
2636 1762
2637 1763 $query = $wp_scripts->registered[ $handle ];
2638 -
2639 1764 if ( is_object( $query ) && ! empty( $query->ver ) ) {
2640 1765 $ver = $query->ver;
2641 1766 }
2642 1767
@@ -2647,23 +1772,17 @@
2647 1772 * @since 5.0.13 added $echo param.
2648 1773 *
2649 1774 * @param string $url
2650 1775 * @param bool $echo
2651 - *
2652 - * @return string|null
1776 + * @return string|void
2653 1777 */
2654 1778 public static function js_redirect( $url, $echo = false ) {
2655 - $callback = function () use ( $url ) {
1779 + $callback = function() use ( $url ) {
2656 1780 echo '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
2657 1781 };
2658 1782 return self::clip( $callback, $echo );
2659 1783 }
2660 1784
2661 - /**
2662 - * @param int|string $user_id
2663 - *
2664 - * @return int|string
2665 - */
2666 1785 public static function get_user_id_param( $user_id ) {
2667 1786 if ( ! $user_id || is_numeric( $user_id ) ) {
2668 1787 return $user_id;
2669 1788 }
@@ -2668,10 +1787,9 @@
2668 1787 return $user_id;
2669 1788 }
2670 1789
2671 1790 $user_id = sanitize_text_field( $user_id );
2672 -
2673 - if ( $user_id === 'current' ) {
1791 + if ( $user_id == 'current' ) {
2674 1792 $user_id = get_current_user_id();
2675 1793 } else {
2676 1794 if ( is_email( $user_id ) ) {
2677 1795 $user = get_user_by( 'email', $user_id );
@@ -2687,14 +1805,8 @@
2687 1805
2688 1806 return $user_id;
2689 1807 }
2690 1808
2691 - /**
2692 - * @param string $filename
2693 - * @param array $atts
2694 - *
2695 - * @return false|string
2696 - */
2697 1809 public static function get_file_contents( $filename, $atts = array() ) {
2698 1810 if ( ! is_file( $filename ) ) {
2699 1811 return false;
2700 1812 }
@@ -2700,9 +1812,9 @@
2700 1812 }
2701 1813
2702 1814 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
2703 1815 ob_start();
2704 - include $filename;
1816 + include( $filename );
2705 1817 $contents = ob_get_contents();
2706 1818 ob_end_clean();
2707 1819
2708 1820 return $contents;
@@ -2716,9 +1828,8 @@
2716 1828 * @param int $num_chars
2717 1829 */
2718 1830 public static function get_unique_key( $name, $table_name, $column, $id = 0, $num_chars = 5 ) {
2719 1831 $key = '';
2720 -
2721 1832 if ( $name ) {
2722 1833 $key = sanitize_key( $name );
2723 1834 $key = self::maybe_clear_long_key( $key, $column );
2724 1835 }
@@ -2758,9 +1869,9 @@
2758 1869 ++$suffix;
2759 1870 } while ( in_array( $key_check, $similar_keys, true ) );
2760 1871
2761 1872 $key = $key_check;
2762 - }//end if
1873 + }
2763 1874
2764 1875 return $key;
2765 1876 }
2766 1877
@@ -2769,18 +1880,15 @@
2769 1880 * The database limit is 100 for form and field keys so we want to avoid getting too close.
2770 1881 *
2771 1882 * @param string $column
2772 1883 * @param string $key
2773 - *
2774 1884 * @return string
2775 1885 */
2776 1886 private static function maybe_truncate_key_before_appending( $column, $key ) {
2777 1887 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2778 1888 $max_key_length_before_truncating = 60;
2779 -
2780 1889 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2781 1890 $key = substr( $key, 0, $max_key_length_before_truncating );
2782 -
2783 1891 if ( is_numeric( $key ) ) {
2784 1892 $key .= 'a';
2785 1893 }
2786 1894 }
@@ -2792,9 +1900,8 @@
2792 1900 * Possibly reset a key to avoid conflicts with column size limits.
2793 1901 *
2794 1902 * @param string $key
2795 1903 * @param string $column
2796 - *
2797 1904 * @return string either the original key value, or an empty string if the key was too long.
2798 1905 */
2799 1906 private static function maybe_clear_long_key( $key, $column ) {
2800 1907 if ( 'field_key' === $column && strlen( $key ) >= 70 ) {
@@ -2803,25 +1910,19 @@
2803 1910 return $key;
2804 1911 }
2805 1912
2806 1913 /**
2807 - * @since 6.21 This is changed from `private` to `public`.
2808 - *
2809 1914 * @param int $num_chars
2810 - *
2811 1915 * @return string
2812 1916 */
2813 - public static function generate_new_key( $num_chars ) {
2814 - $max_slug_value = 36 ** $num_chars;
2815 -
2816 - // We want to have at least 2 characters in the slug.
2817 - $min_slug_value = 37;
2818 - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 );
1917 + private static function generate_new_key( $num_chars ) {
1918 + $max_slug_value = pow( 36, $num_chars );
1919 + $min_slug_value = 37; // we want to have at least 2 characters in the slug
1920 + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2819 1921 }
2820 1922
2821 1923 /**
2822 1924 * @param string $key
2823 - *
2824 1925 * @return string
2825 1926 */
2826 1927 private static function prevent_numeric_and_reserved_keys( $key ) {
2827 1928 if ( is_numeric( $key ) ) {
@@ -2835,9 +1936,8 @@
2835 1936 'editlink',
2836 1937 'siteurl',
2837 1938 'evenodd',
2838 1939 );
2839 -
2840 1940 if ( in_array( $key, $not_allowed, true ) ) {
2841 1941 $key .= 'a';
2842 1942 }
2843 1943 }
@@ -2846,16 +1946,11 @@
2846 1946
2847 1947 /**
2848 1948 * Editing a Form or Entry
2849 1949 *
2850 - * @param object $record
2851 - * @param string $table
2852 - * @param array|string $fields
2853 - * @param bool $default
2854 - * @param array $post_values
2855 - * @param array $args
1950 + * @param string $table
2856 1951 *
2857 - * @return array|bool
1952 + * @return bool|array
2858 1953 */
2859 1954 public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
2860 1955 if ( ! $record ) {
2861 1956 return false;
@@ -2870,9 +1965,9 @@
2870 1965 'fields' => array(),
2871 1966 );
2872 1967
2873 1968 foreach ( array( 'name', 'description' ) as $var ) {
2874 - $default_val = $record->{$var} ?? '';
1969 + $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
2875 1970 $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
2876 1971 unset( $var, $default_val );
2877 1972 }
2878 1973
@@ -2890,16 +1985,8 @@
2890 1985
2891 1986 return $values;
2892 1987 }
2893 1988
2894 - /**
2895 - * @param array|string $fields
2896 - * @param object $record
2897 - * @param array $values
2898 - * @param array $args
2899 - *
2900 - * @return void
2901 - */
2902 1989 private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
2903 1990 if ( ! empty( $fields ) ) {
2904 1991 foreach ( (array) $fields as $field ) {
2905 1992 if ( ! self::is_admin_page() ) {
@@ -2905,32 +1992,24 @@
2905 1992 if ( ! self::is_admin_page() ) {
2906 1993 // Don't prep default values on the form settings page.
2907 1994 $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2908 1995 }
2909 - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
1996 + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
2910 1997 self::fill_field_defaults( $field, $record, $values, $args );
2911 1998 }
2912 1999 }
2913 2000 }
2914 2001
2915 - /**
2916 - * @param object $field
2917 - * @param object $record
2918 - * @param array $values
2919 - * @param array $args
2920 - *
2921 - * @return void
2922 - */
2923 2002 private static function fill_field_defaults( $field, $record, array &$values, $args ) {
2924 2003 $post_values = $args['post_values'];
2925 2004
2926 2005 if ( $args['default'] ) {
2927 2006 $meta_value = $field->default_value;
2928 - } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2929 - if ( ! isset( $field->field_options['custom_field'] ) ) {
2930 - $field->field_options['custom_field'] = '';
2931 - }
2932 -
2007 + } else {
2008 + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2009 + if ( ! isset( $field->field_options['custom_field'] ) ) {
2010 + $field->field_options['custom_field'] = '';
2011 + }
2933 2012 $meta_value = FrmProEntryMetaHelper::get_post_value(
2934 2013 $record->post_id,
2935 2014 $field->field_options['post_field'],
2936 2015 $field->field_options['custom_field'],
@@ -2940,14 +2019,14 @@
2940 2019 'form_id' => $field->form_id,
2941 2020 'field' => $field,
2942 2021 )
2943 2022 );
2944 - } else {
2945 - $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2946 - }//end if
2023 + } else {
2024 + $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2025 + }
2026 + }
2947 2027
2948 - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type;
2949 -
2028 + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2950 2029 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2951 2030 $new_value = $post_values['item_meta'][ $field->id ];
2952 2031 self::unserialize_or_decode( $new_value );
2953 2032 } else {
@@ -2993,15 +2072,12 @@
2993 2072 );
2994 2073 }
2995 2074
2996 2075 /**
2997 - * @param object $record
2998 2076 * @param string $table
2999 - * @param array $post_values
3000 - * @param array $values
3001 2077 */
3002 2078 private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
3003 - if ( $table === 'entries' ) {
2079 + if ( $table == 'entries' ) {
3004 2080 $form = $record->form_id;
3005 2081 FrmForm::maybe_get_form( $form );
3006 2082 } else {
3007 2083 $form = $record;
@@ -3031,13 +2107,8 @@
3031 2107 }
3032 2108
3033 2109 /**
3034 2110 * Set to POST value or default
3035 - *
3036 - * @param array $post_values
3037 - * @param array $values
3038 - *
3039 - * @return void
3040 2111 */
3041 2112 private static function fill_form_defaults( $post_values, array &$values ) {
3042 2113 $form_defaults = FrmFormsHelper::get_default_opts();
3043 2114
@@ -3042,9 +2113,9 @@
3042 2113 $form_defaults = FrmFormsHelper::get_default_opts();
3043 2114
3044 2115 foreach ( $form_defaults as $opt => $default ) {
3045 2116 if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
3046 - $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default;
2117 + $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
3047 2118 }
3048 2119
3049 2120 unset( $opt, $default );
3050 2121 }
@@ -3054,9 +2125,9 @@
3054 2125 }
3055 2126
3056 2127 foreach ( array( 'before', 'after', 'submit' ) as $h ) {
3057 2128 if ( ! isset( $values[ $h . '_html' ] ) ) {
3058 - $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) );
2129 + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
3059 2130 }
3060 2131 unset( $h );
3061 2132 }
3062 2133 }
@@ -3065,9 +2136,9 @@
3065 2136 * @since 2.2.10
3066 2137 *
3067 2138 * @param array $post_values
3068 2139 *
3069 - * @return bool|int
2140 + * @return boolean|int
3070 2141 */
3071 2142 public static function custom_style_value( $post_values ) {
3072 2143 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
3073 2144 $custom_style = absint( $post_values['options']['custom_style'] );
@@ -3072,38 +2143,29 @@
3072 2143 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
3073 2144 $custom_style = absint( $post_values['options']['custom_style'] );
3074 2145 } else {
3075 2146 $frm_settings = self::get_settings();
3076 - $custom_style = ( $frm_settings->load_style !== 'none' );
2147 + $custom_style = ( $frm_settings->load_style != 'none' );
3077 2148 }
3078 2149
3079 2150 return $custom_style;
3080 2151 }
3081 2152
3082 - /**
3083 - * @param mixed $original_string
3084 - * @param int|string $length
3085 - * @param int $minword
3086 - * @param string $continue
3087 - *
3088 - * @return string
3089 - */
3090 - public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) {
3091 - if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) {
2153 + public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
2154 + if ( is_array( $str ) ) {
3092 2155 return '';
3093 2156 }
3094 2157
3095 2158 $length = (int) $length;
3096 - $str = wp_strip_all_tags( (string) $original_string );
2159 + $str = wp_strip_all_tags( $str );
3097 2160 $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
3098 2161
3099 2162 if ( $length == 0 ) {
3100 2163 return '';
3101 - }
2164 + } elseif ( $length <= 10 ) {
2165 + $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3102 2166
3103 - if ( $length <= 10 ) {
3104 - $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3105 - return $sub . ( $length < $original_len ? $continue : '' );
2167 + return $sub . ( ( $length < $original_len ) ? $continue : '' );
3106 2168 }
3107 2169
3108 2170 $sub = '';
3109 2171 $len = 0;
@@ -3109,16 +2171,11 @@
3109 2171 $len = 0;
3110 2172
3111 2173 $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
3112 2174
3113 - if ( ! is_array( $words ) ) {
3114 - return $original_string;
3115 - }
3116 -
3117 2175 foreach ( $words as $word ) {
3118 - $part = ( $sub !== '' ? ' ' : '' ) . $word;
2176 + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
3119 2177 $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
3120 -
3121 2178 if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
3122 2179 break;
3123 2180 }
3124 2181
@@ -3131,49 +2188,14 @@
3131 2188
3132 2189 unset( $total_len, $word );
3133 2190 }
3134 2191
3135 - $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length );
3136 -
3137 - return $sub . ( $len < $original_len ? $continue : '' );
2192 + return $sub . ( ( $len < $original_len ) ? $continue : '' );
3138 2193 }
3139 2194
3140 - /**
3141 - * If the string is still too long because there may not have been any spaces, force truncate.
3142 - *
3143 - * @since 6.5.4
3144 - *
3145 - * @param string $sub Current substring.
3146 - * @param int $length The length limit.
3147 - *
3148 - * @return string
3149 - */
3150 - private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
3151 - if ( strlen( $sub ) < $length + 50 ) {
3152 - // If the string isn't way over the limit, leave it.
3153 - return $sub;
3154 - }
3155 -
3156 - $first_space = strpos( $sub, ' ', $length );
3157 -
3158 - if ( false !== $first_space ) {
3159 - // Ignore anything with spaces.
3160 - return $sub;
3161 - }
3162 -
3163 - return substr( $sub, 0, $length + 10 );
3164 - }
3165 -
3166 - /**
3167 - * @param array $function_names
3168 - * @param array $args
3169 - *
3170 - * @return mixed
3171 - */
3172 2195 public static function mb_function( $function_names, $args ) {
3173 2196 $mb_function_name = $function_names[0];
3174 2197 $function_name = $function_names[1];
3175 -
3176 2198 if ( function_exists( $mb_function_name ) ) {
3177 2199 $function_name = $mb_function_name;
3178 2200 }
3179 2201
@@ -3179,15 +2201,8 @@
3179 2201
3180 2202 return call_user_func_array( $function_name, $args );
3181 2203 }
3182 2204
3183 - /**
3184 - * @param string $date
3185 - * @param string $date_format
3186 - * @param string $time_format
3187 - *
3188 - * @return string
3189 - */
3190 2205 public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
3191 2206 if ( empty( $date ) ) {
3192 2207 return $date;
3193 2208 }
@@ -3202,10 +2217,9 @@
3202 2217 }
3203 2218
3204 2219 $formatted = self::get_localized_date( $date_format, $date );
3205 2220
3206 - $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00' );
3207 -
2221 + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) != '00:00:00' );
3208 2222 if ( $do_time ) {
3209 2223 $formatted .= self::add_time_to_date( $time_format, $date );
3210 2224 }
3211 2225
@@ -3211,14 +2225,8 @@
3211 2225
3212 2226 return $formatted;
3213 2227 }
3214 2228
3215 - /**
3216 - * @param string $time_format
3217 - * @param string $date
3218 - *
3219 - * @return string
3220 - */
3221 2229 private static function add_time_to_date( $time_format, $date ) {
3222 2230 if ( empty( $time_format ) ) {
3223 2231 $time_format = get_option( 'time_format' );
3224 2232 }
@@ -3224,9 +2232,8 @@
3224 2232 }
3225 2233
3226 2234 $trimmed_format = trim( $time_format );
3227 2235 $time = '';
3228 -
3229 2236 if ( $time_format && ! empty( $trimmed_format ) ) {
3230 2237 $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
3231 2238 }
3232 2239
@@ -3234,13 +2241,8 @@
3234 2241 }
3235 2242
3236 2243 /**
3237 2244 * @since 2.0.8
3238 - *
3239 - * @param string $date_format
3240 - * @param string $date
3241 - *
3242 - * @return string
3243 2245 */
3244 2246 public static function get_localized_date( $date_format, $date ) {
3245 2247 $date = get_date_from_gmt( $date );
3246 2248
@@ -3247,23 +2249,21 @@
3247 2249 return date_i18n( $date_format, strtotime( $date ) );
3248 2250 }
3249 2251
3250 2252 /**
3251 - * Gets the time ago in words.
2253 + * Gets the time ago in words
3252 2254 *
3253 - * @param int $from In seconds.
3254 - * @param int|string $to In seconds.
3255 - * @param int|string $levels Number of time units to include or a specific unit.
2255 + * @param int $from in seconds
2256 + * @param int|string $to in seconds
3256 2257 *
3257 2258 * @return string $time_ago
3258 2259 */
3259 2260 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
3260 - if ( empty( $to ) && 0 !== $to ) {
2261 + if ( empty( $to ) ) {
3261 2262 $now = new DateTime();
3262 2263 } else {
3263 2264 $now = new DateTime( '@' . $to );
3264 2265 }
3265 -
3266 2266 $ago = new DateTime( '@' . $from );
3267 2267
3268 2268 // Get the time difference
3269 2269 $diff_object = $now->diff( $ago );
@@ -3269,9 +2269,9 @@
3269 2269 $diff_object = $now->diff( $ago );
3270 2270 $diff = get_object_vars( $diff_object );
3271 2271
3272 2272 // Add week amount and update day amount
3273 - $diff['w'] = floor( $diff['d'] / 7 );
2273 + $diff['w'] = floor( $diff['d'] / 7 );
3274 2274 $diff['d'] -= $diff['w'] * 7;
3275 2275
3276 2276 $time_strings = self::get_time_strings();
3277 2277
@@ -3277,11 +2277,10 @@
3277 2277
3278 2278 if ( ! is_numeric( $levels ) ) {
3279 2279 // Show time in specified unit.
3280 2280 $levels = self::get_unit( $levels );
3281 -
3282 2281 if ( isset( $time_strings[ $levels ] ) ) {
3283 - $diff = array(
2282 + $diff = array(
3284 2283 $levels => self::time_format( $levels, $diff ),
3285 2284 );
3286 2285 $time_strings = array(
3287 2286 $levels => $time_strings[ $levels ],
@@ -3286,9 +2285,8 @@
3286 2285 $time_strings = array(
3287 2286 $levels => $time_strings[ $levels ],
3288 2287 );
3289 2288 }
3290 -
3291 2289 $levels = 1;
3292 2290 }
3293 2291
3294 2292 foreach ( $time_strings as $k => $v ) {
@@ -3310,13 +2308,8 @@
3310 2308 }
3311 2309
3312 2310 /**
3313 2311 * @since 4.05.01
3314 - *
3315 - * @param string $unit
3316 - * @param array $diff
3317 - *
3318 - * @return int
3319 2312 */
3320 2313 private static function time_format( $unit, $diff ) {
3321 2314 $return = array(
3322 2315 'y' => 'y',
@@ -3321,9 +2314,8 @@
3321 2314 $return = array(
3322 2315 'y' => 'y',
3323 2316 'd' => 'days',
3324 2317 );
3325 -
3326 2318 if ( isset( $return[ $unit ] ) ) {
3327 2319 return $diff[ $return[ $unit ] ];
3328 2320 }
3329 2321
@@ -3343,13 +2335,8 @@
3343 2335 }
3344 2336
3345 2337 /**
3346 2338 * @since 4.05.01
3347 - *
3348 - * @param string $from
3349 - * @param string $to
3350 - *
3351 - * @return int
3352 2339 */
3353 2340 private static function convert_time( $from, $to ) {
3354 2341 $convert = array(
3355 2342 's' => 1,
@@ -3365,16 +2352,11 @@
3365 2352 }
3366 2353
3367 2354 /**
3368 2355 * @since 4.05.01
3369 - *
3370 - * @param string $unit
3371 - *
3372 - * @return int|string
3373 2356 */
3374 2357 private static function get_unit( $unit ) {
3375 2358 $units = self::get_time_strings();
3376 -
3377 2359 if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) {
3378 2360 return $unit;
3379 2361 }
3380 2362
@@ -3387,12 +2369,11 @@
3387 2369 }
3388 2370
3389 2371 /**
3390 2372 * Get the translatable time strings. The untranslated version is a failsafe
3391 - * in case languages are changing for the unit set in the shortcode.
2373 + * in case langauges are changing for the unit set in the shortcode.
3392 2374 *
3393 2375 * @since 2.0.20
3394 - *
3395 2376 * @return array
3396 2377 */
3397 2378 private static function get_time_strings() {
3398 2379 return array(
@@ -3436,47 +2417,35 @@
3436 2417
3437 2418 // Pagination Methods.
3438 2419
3439 2420 /**
3440 - * @param int $r_count
3441 - * @param int $current_p
3442 - * @param int $p_size
3443 - *
3444 - * @return int
2421 + * @param integer $current_p
3445 2422 */
3446 2423 public static function get_last_record_num( $r_count, $current_p, $p_size ) {
3447 - return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size );
2424 + return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
3448 2425 }
3449 2426
3450 2427 /**
3451 - * @param int $r_count
3452 - * @param int $current_p
3453 - * @param int $p_size
3454 - *
3455 - * @return int
2428 + * @param integer $current_p
3456 2429 */
3457 2430 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
3458 2431 if ( $current_p == 1 ) {
3459 2432 return 1;
2433 + } else {
2434 + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
3460 2435 }
3461 - return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
3462 2436 }
3463 2437
3464 2438 /**
3465 - * @param array $json_vars
3466 - *
3467 2439 * @return array
3468 2440 */
3469 2441 public static function json_to_array( $json_vars ) {
3470 2442 $vars = array();
3471 -
3472 2443 foreach ( $json_vars as $jv ) {
3473 2444 $jv_name = explode( '[', $jv['name'] );
3474 2445 $last = count( $jv_name ) - 1;
3475 -
3476 2446 foreach ( $jv_name as $p => $n ) {
3477 2447 $name = trim( $n, ']' );
3478 -
3479 2448 if ( ! isset( $l1 ) ) {
3480 2449 $l1 = $name;
3481 2450 }
3482 2451
@@ -3487,9 +2456,9 @@
3487 2456 if ( ! isset( $l3 ) ) {
3488 2457 $l3 = $name;
3489 2458 }
3490 2459
3491 - $this_val = $p == $last ? $jv['value'] : array();
2460 + $this_val = ( $p == $last ) ? $jv['value'] : array();
3492 2461
3493 2462 switch ( $p ) {
3494 2463 case 0:
3495 2464 $l1 = $name;
@@ -3511,12 +2480,12 @@
3511 2480 self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
3512 2481 }
3513 2482
3514 2483 unset( $this_val, $n );
3515 - }//end foreach
2484 + }
3516 2485
3517 2486 unset( $last, $jv );
3518 - }//end foreach
2487 + }
3519 2488
3520 2489 return $vars;
3521 2490 }
3522 2491
@@ -3522,12 +2491,8 @@
3522 2491
3523 2492 /**
3524 2493 * @param string $name
3525 2494 * @param string $l1
3526 - * @param mixed $val
3527 - * @param array $vars
3528 - *
3529 - * @return void
3530 2495 */
3531 2496 public static function add_value_to_array( $name, $l1, $val, &$vars ) {
3532 2497 if ( $name == '' ) {
3533 2498 $vars[] = $val;
@@ -3535,19 +2500,12 @@
3535 2500 $vars[ $l1 ] = $val;
3536 2501 }
3537 2502 }
3538 2503
3539 - /**
3540 - * @param string $name
3541 - * @param string $class
3542 - * @param string $form_name
3543 - *
3544 - * @return void
3545 - */
3546 2504 public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
3547 2505 $tooltips = array(
3548 2506 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ),
3549 - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ),
2507 + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ),
3550 2508 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3551 2509 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3552 2510 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3553 2511 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
@@ -3552,9 +2510,8 @@
3552 2510 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ),
3553 2511 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ),
3554 2512 /* translators: %1$s: Form name, %2$s: Date */
3555 2513 '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() ) ),
3556 - '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' ),
3557 2514 );
3558 2515
3559 2516 if ( ! isset( $tooltips[ $name ] ) ) {
3560 2517 return;
@@ -3574,14 +2531,8 @@
3574 2531 }
3575 2532
3576 2533 /**
3577 2534 * Add the current_page class to that page in the form nav
3578 - *
3579 - * @param int|string $page
3580 - * @param int|string $current_page
3581 - * @param array $action
3582 - *
3583 - * @return void
3584 2535 */
3585 2536 public static function select_current_page( $page, $current_page, $action = array() ) {
3586 2537 if ( $current_page != $page ) {
3587 2538 return;
@@ -3587,13 +2538,8 @@
3587 2538 return;
3588 2539 }
3589 2540
3590 2541 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
3591 -
3592 - if ( 'lite-reports' === $frm_action ) {
3593 - $frm_action = 'reports';
3594 - }
3595 -
3596 2542 if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
3597 2543 echo ' class="current_page"';
3598 2544 }
3599 2545 }
@@ -3630,15 +2576,8 @@
3630 2576
3631 2577 return $post_content;
3632 2578 }
3633 2579
3634 - /**
3635 - * @param array|string $val
3636 - * @param int|string $key
3637 - * @param array $post_content
3638 - *
3639 - * @return void
3640 - */
3641 2580 private static function prepare_action_slashes( $val, $key, &$post_content ) {
3642 2581 if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) {
3643 2582 return;
3644 2583 }
@@ -3657,16 +2596,12 @@
3657 2596 }
3658 2597 }
3659 2598
3660 2599 /**
3661 - * Check for either json or serialized data. This is temporary while transitioning
2600 + * Check for either json or serilized data. This is temporary while transitioning
3662 2601 * all data to json.
3663 2602 *
3664 2603 * @since 4.02.03
3665 - *
3666 - * @param array|string $value
3667 - *
3668 - * @return void
3669 2604 */
3670 2605 public static function unserialize_or_decode( &$value ) {
3671 2606 if ( is_array( $value ) ) {
3672 2607 return;
@@ -3672,9 +2607,9 @@
3672 2607 return;
3673 2608 }
3674 2609
3675 2610 if ( is_serialized( $value ) ) {
3676 - $value = self::maybe_unserialize_array( $value );
2611 + $value = maybe_unserialize( $value );
3677 2612 } else {
3678 2613 $value = self::maybe_json_decode( $value, false );
3679 2614 }
3680 2615 }
@@ -3679,43 +2614,13 @@
3679 2614 }
3680 2615 }
3681 2616
3682 2617 /**
3683 - * Safely unserialize an array if necessary.
3684 - * This function doesn't actually use unserialize. The string is parsed instead.
3685 - *
3686 - * @since 6.2
3687 - *
3688 - * @param mixed $value
3689 - *
3690 - * @return mixed
3691 - */
3692 - public static function maybe_unserialize_array( $value ) {
3693 - if ( ! is_string( $value ) ) {
3694 - return $value;
3695 - }
3696 -
3697 - // Since we only expect an array, skip anything that doesn't start with a:.
3698 - if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
3699 - return $value;
3700 - }
3701 -
3702 - $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
3703 -
3704 - if ( is_array( $parsed ) ) {
3705 - $value = $parsed;
3706 - }
3707 -
3708 - return $value;
3709 - }
3710 -
3711 - /**
3712 2618 * Decode a JSON string.
3713 2619 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
3714 2620 *
3715 2621 * @param mixed $string
3716 2622 * @param bool $single_to_array
3717 - *
3718 2623 * @return mixed
3719 2624 */
3720 2625 public static function maybe_json_decode( $string, $single_to_array = true ) {
3721 2626 if ( is_array( $string ) || is_null( $string ) ) {
@@ -3722,17 +2627,14 @@
3722 2627 return $string;
3723 2628 }
3724 2629
3725 2630 $new_string = json_decode( $string, true );
3726 -
3727 2631 if ( function_exists( 'json_last_error' ) ) {
3728 2632 // php 5.3+
3729 2633 $single_value = false;
3730 -
3731 2634 if ( ! $single_to_array ) {
3732 2635 $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3733 2636 }
3734 -
3735 2637 if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3736 2638 $string = $new_string;
3737 2639 }
3738 2640 }
@@ -3740,45 +2642,11 @@
3740 2642 return $string;
3741 2643 }
3742 2644
3743 2645 /**
3744 - * @since 6.2.3
3745 - *
3746 - * @param string $value
3747 - *
3748 - * @return string
3749 - */
3750 - public static function maybe_utf8_encode( $value ) {
3751 - $from_format = 'ISO-8859-1';
3752 - $to_format = 'UTF-8';
3753 -
3754 - if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
3755 - if ( mb_check_encoding( $value, $from_format ) ) {
3756 - return mb_convert_encoding( $value, $to_format, $from_format );
3757 - }
3758 - return $value;
3759 - }
3760 -
3761 - if ( function_exists( 'iconv' ) ) {
3762 - $converted = iconv( $from_format, $to_format, $value );
3763 -
3764 - // Value is false if $value is not ISO-8859-1.
3765 - if ( false !== $converted ) {
3766 - return $converted;
3767 - }
3768 - }
3769 -
3770 - return $value;
3771 - }
3772 -
3773 - /**
3774 2646 * Reformat the json serialized array in name => value array.
3775 2647 *
3776 2648 * @since 4.02.03
3777 - *
3778 - * @param array $form
3779 - *
3780 - * @return void
3781 2649 */
3782 2650 public static function format_form_data( &$form ) {
3783 2651 $formatted = array();
3784 2652
@@ -3785,11 +2653,9 @@
3785 2653 foreach ( $form as $input ) {
3786 2654 if ( ! isset( $input['name'] ) ) {
3787 2655 continue;
3788 2656 }
3789 -
3790 2657 $key = $input['name'];
3791 -
3792 2658 if ( isset( $formatted[ $key ] ) ) {
3793 2659 if ( is_array( $formatted[ $key ] ) ) {
3794 2660 $formatted[ $key ][] = $input['value'];
3795 2661 } else {
@@ -3804,12 +2670,8 @@
3804 2670 }
3805 2671
3806 2672 /**
3807 2673 * @since 4.02.03
3808 - *
3809 - * @param array|string $value
3810 - *
3811 - * @return string
3812 2674 */
3813 2675 public static function maybe_json_encode( $value ) {
3814 2676 if ( is_array( $value ) ) {
3815 2677 $value = wp_json_encode( $value );
@@ -3817,15 +2679,12 @@
3817 2679 return $value;
3818 2680 }
3819 2681
3820 2682 /**
3821 - * Echo The javascript to open and highlight the Formidable menu
3822 - *
3823 2683 * @since 1.07.10
3824 2684 *
3825 - * @param string $post_type The name of the post type that may need to be highlighted.
3826 - *
3827 - * @return void
2685 + * @param string $post_type The name of the post type that may need to be highlighted
2686 + * echo The javascript to open and highlight the Formidable menu
3828 2687 */
3829 2688 public static function maybe_highlight_menu( $post_type ) {
3830 2689 global $post;
3831 2690
@@ -3844,12 +2703,8 @@
3844 2703 /**
3845 2704 * Load the JS file on non-Formidable pages in the admin area
3846 2705 *
3847 2706 * @since 2.0
3848 - *
3849 - * @param bool $load
3850 - *
3851 - * @return void
3852 2707 */
3853 2708 public static function load_admin_wide_js( $load = true ) {
3854 2709 $version = self::plugin_version();
3855 2710 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
@@ -3862,10 +2717,8 @@
3862 2717 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
3863 2718 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
3864 2719 'loading' => __( 'Loading&hellip;', 'formidable' ),
3865 2720 'nonce' => wp_create_nonce( 'frm_ajax' ),
3866 - 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
3867 - 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(),
3868 2721 );
3869 2722 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
3870 2723
3871 2724 if ( $load ) {
@@ -3874,10 +2727,8 @@
3874 2727 }
3875 2728
3876 2729 /**
3877 2730 * @since 2.0.9
3878 - *
3879 - * @return void
3880 2731 */
3881 2732 public static function load_font_style() {
3882 2733 wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
3883 2734 }
@@ -3883,147 +2734,99 @@
3883 2734 }
3884 2735
3885 2736 /**
3886 2737 * @param string $location
3887 - *
3888 - * @return void
3889 2738 */
3890 2739 public static function localize_script( $location ) {
3891 - global $wp_scripts, $wp_version;
2740 + global $wp_scripts;
3892 2741
2742 + $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2743 + $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2744 +
3893 2745 $script_strings = array(
3894 - 'ajax_url' => esc_url_raw( self::get_ajax_url() ),
3895 - 'images_url' => self::plugin_url() . '/images',
3896 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
3897 - 'remove' => __( 'Remove', 'formidable' ),
3898 - 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
3899 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
3900 - 'id' => __( 'ID', 'formidable' ),
3901 - 'no_results' => __( 'No results match', 'formidable' ),
3902 - 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
3903 - 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
3904 - 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
3905 - 'focus_first_error' => self::should_focus_first_error(),
3906 - 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
3907 - // We need to keep this setting for a few versions because Pro checks for this.
3908 - 'include_resend_email' => false,
2746 + 'ajax_url' => $ajax_url,
2747 + 'images_url' => self::plugin_url() . '/images',
2748 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2749 + 'remove' => __( 'Remove', 'formidable' ),
2750 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2751 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2752 + 'id' => __( 'ID', 'formidable' ),
2753 + 'no_results' => __( 'No results match', 'formidable' ),
2754 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2755 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2756 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2757 + 'focus_first_error' => self::should_focus_first_error(),
2758 + 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
3909 2759 );
3910 2760
3911 2761 $data = $wp_scripts->get_data( 'formidable', 'data' );
3912 -
3913 - if ( ! $data ) {
2762 + if ( empty( $data ) ) {
3914 2763 wp_localize_script( 'formidable', 'frm_js', $script_strings );
3915 2764 }
3916 2765
3917 - if ( $location === 'admin' ) {
2766 + if ( $location == 'admin' ) {
2767 + $frm_settings = self::get_settings();
3918 2768 $admin_script_strings = array(
3919 - 'desc' => __( '(Click to add description)', 'formidable' ),
3920 - 'blank' => __( '(Blank)', 'formidable' ),
3921 - 'no_label' => self::get_no_label_text(),
3922 - 'ok' => __( 'OK', 'formidable' ),
3923 - 'cancel' => __( 'Cancel', 'formidable' ),
3924 - 'default_label' => __( 'Default', 'formidable' ),
3925 - 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
3926 - 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
3927 - 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3928 - 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3929 - 'confirm' => __( 'Are you sure?', 'formidable' ),
3930 - 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3931 - 'conf_delete_sec' => __( 'All fields inside this Section will be deleted along with their data. Are you sure you want to delete this group of fields?', 'formidable' ),
3932 - 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3933 - 'default_unique' => FrmFieldsHelper::default_unique_msg(),
3934 - 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3935 - 'enter_email' => __( 'Enter Email', 'formidable' ),
3936 - 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3937 - 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3938 - 'new_option' => __( 'New Option', 'formidable' ),
3939 - 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ),
3940 - 'enter_password' => __( 'Enter Password', 'formidable' ),
3941 - 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3942 - 'import_complete' => __( 'Import Complete', 'formidable' ),
3943 - 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
3944 - 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
3945 - 'private_label' => __( 'Private', 'formidable' ),
3946 - 'jquery_ui_url' => '',
3947 - 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3948 - 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3949 - 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3950 - 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
3951 - 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3952 - /* translators: %d is the number of allowed actions per form */
3953 - 'only_one_action' => sprintf( __( 'This form action is limited to %d per form.', 'formidable' ), 1 ),
3954 - 'edit_action_text' => __( 'Please edit the existing form action.', 'formidable' ),
3955 - 'unsafe_params' => FrmFormsHelper::reserved_words(),
2769 + 'desc' => __( '(Click to add description)', 'formidable' ),
2770 + 'blank' => __( '(Blank)', 'formidable' ),
2771 + 'no_label' => __( '(no label)', 'formidable' ),
2772 + 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
2773 + 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2774 + 'ok' => __( 'OK', 'formidable' ),
2775 + 'cancel' => __( 'Cancel', 'formidable' ),
2776 + 'default_label' => __( 'Default', 'formidable' ),
2777 + 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2778 + 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2779 + 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2780 + 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2781 + 'caution' => __( 'Heads up', 'formidable' ),
2782 + 'confirm' => __( 'Are you sure?', 'formidable' ),
2783 + 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2784 + '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' ),
2785 + 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
2786 + 'default_unique' => $frm_settings->unique_msg,
2787 + 'default_conf' => __( 'The entered values do not match', 'formidable' ),
2788 + 'enter_email' => __( 'Enter Email', 'formidable' ),
2789 + 'confirm_email' => __( 'Confirm Email', 'formidable' ),
2790 + 'conditional_text' => __( 'Conditional content here', 'formidable' ),
2791 + 'new_option' => __( 'New Option', 'formidable' ),
2792 + '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' ),
2793 + 'enter_password' => __( 'Enter Password', 'formidable' ),
2794 + 'confirm_password' => __( 'Confirm Password', 'formidable' ),
2795 + 'import_complete' => __( 'Import Complete', 'formidable' ),
2796 + 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2797 + 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2798 + 'private_label' => __( 'Private', 'formidable' ),
2799 + 'jquery_ui_url' => '',
2800 + 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
2801 + 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
2802 + 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
2803 + 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
2804 + 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
2805 + 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ),
2806 + 'unsafe_params' => FrmFormsHelper::reserved_words(),
3956 2807 /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/
3957 - 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
2808 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3958 2809 /* 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. */
3959 - 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3960 - 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3961 - 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3962 - 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3963 - 'install' => __( 'Install', 'formidable' ),
3964 - 'active' => __( 'Active', 'formidable' ),
3965 - 'installed' => __( 'Installed', 'formidable' ),
3966 - 'not_installed' => __( 'Not Installed', 'formidable' ),
3967 - 'select_a_field' => __( 'Select a Field', 'formidable' ),
3968 - 'no_items_found' => __( 'No items found.', 'formidable' ),
3969 - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3970 -
3971 - // Deprecated in 6.0.
3972 - 'saving' => '',
3973 -
3974 - // Deprecated in 6.0.
3975 - 'saved' => '',
3976 -
3977 - // translators: %1$s: HTML open tag, %2$s: HTML end tag.
3978 - 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ),
3979 - 'noTitleText' => FrmFormsHelper::get_no_title_text(),
3980 -
3981 - // In older versions this event listener causes the section to immediately close again
3982 - // when the h3 element is clicked. It's only required in WP 6.7+.
3983 - 'requireAccordionTitleClickListener' => version_compare( $wp_version, '6.7', '>=' ),
2810 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
2811 + 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
2812 + 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
2813 + 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
2814 + 'install' => __( 'Install', 'formidable' ),
2815 + 'active' => __( 'Active', 'formidable' ),
2816 + 'select_a_field' => __( 'Select a Field', 'formidable' ),
2817 + 'no_items_found' => __( 'No items found.', 'formidable' ),
3984 2818 );
3985 - /**
3986 - * @param array $admin_script_strings
3987 - */
3988 2819 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3989 2820
3990 2821 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3991 -
3992 - if ( ! $data ) {
2822 + if ( empty( $data ) ) {
3993 2823 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3994 2824 }
3995 - }//end if
2825 + }
3996 2826 }
3997 2827
3998 2828 /**
3999 - * Get the no label text.
4000 - *
4001 - * @since 6.25.1
4002 - *
4003 - * @return string
4004 - */
4005 - public static function get_no_label_text() {
4006 - return __( '(no label)', 'formidable' );
4007 - }
4008 -
4009 - /**
4010 - * @since 6.5
4011 - *
4012 - * @return string
4013 - */
4014 - public static function get_ajax_url() {
4015 - $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
4016 -
4017 - /**
4018 - * @since 2.0.13
4019 - *
4020 - * @param string $ajax_url
4021 - */
4022 - return apply_filters( 'frm_ajax_url', $ajax_url );
4023 - }
4024 -
4025 - /**
4026 2829 * Returns whether or not the first errored input should be auto-focused (default true).
4027 2830 *
4028 2831 * @since 5.2.05
4029 2832 *
@@ -4048,11 +2851,9 @@
4048 2851 * Echo the message on the plugins listing page
4049 2852 *
4050 2853 * @since 1.07.10
4051 2854 *
4052 - * @param float $min_version The version the add-on requires.
4053 - *
4054 - * @return void
2855 + * @param float $min_version The version the add-on requires
4055 2856 */
4056 2857 public static function min_version_notice( $min_version ) {
4057 2858 $frm_version = self::plugin_version();
4058 2859
@@ -4070,12 +2871,8 @@
4070 2871 /**
4071 2872 * If Pro is far outdated, show a message.
4072 2873 *
4073 2874 * @since 4.0.01
4074 - *
4075 - * @param string $min_version
4076 - *
4077 - * @return void
4078 2875 */
4079 2876 public static function min_pro_version_notice( $min_version ) {
4080 2877 if ( ! self::is_formidable_admin() ) {
4081 2878 // Don't show admin-wide.
@@ -4084,14 +2881,26 @@
4084 2881
4085 2882 self::php_version_notice();
4086 2883
4087 2884 $is_pro = self::pro_is_installed() && class_exists( 'FrmProDb' );
4088 -
4089 2885 if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) {
4090 2886 return;
4091 2887 }
4092 2888
4093 - include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
2889 + $pro_version = FrmProDb::$plug_version;
2890 + $expired = FrmAddonsController::is_license_expired();
2891 + ?>
2892 + <div class="error frm_previous_install">
2893 + <?php
2894 + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
2895 + if ( empty( $expired ) ) {
2896 + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
2897 + } else {
2898 + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
2899 + }
2900 + ?>
2901 + </div>
2902 + <?php
4094 2903 }
4095 2904
4096 2905 /**
4097 2906 * If Pro is installed, check the version number.
@@ -4096,12 +2905,8 @@
4096 2905 /**
4097 2906 * If Pro is installed, check the version number.
4098 2907 *
4099 2908 * @since 4.0.01
4100 - *
4101 - * @param string $min_version
4102 - *
4103 - * @return bool
4104 2909 */
4105 2910 public static function meets_min_pro_version( $min_version ) {
4106 2911 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
4107 2912 }
@@ -4106,24 +2911,27 @@
4106 2911 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
4107 2912 }
4108 2913
4109 2914 /**
4110 - * Show a message if the PHP version is below the recommendations.
2915 + * Show a message if the browser or PHP version is below the recommendations.
4111 2916 *
4112 2917 * @since 4.0.02
4113 - *
4114 - * @return void
4115 2918 */
4116 2919 private static function php_version_notice() {
4117 2920 $message = array();
2921 + if ( version_compare( phpversion(), '5.6', '<' ) ) {
2922 + $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' );
2923 + }
4118 2924
4119 - if ( version_compare( phpversion(), '7.0', '<' ) ) {
4120 - $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' );
2925 + $browser = self::get_server_value( 'HTTP_USER_AGENT' );
2926 + $is_ie = strpos( $browser, 'MSIE' ) !== false;
2927 + if ( $is_ie ) {
2928 + $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' );
4121 2929 }
4122 2930
4123 2931 foreach ( $message as $m ) {
4124 2932 ?>
4125 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2933 + <div class="error frm_previous_install">
4126 2934 <?php echo esc_html( $m ); ?>
4127 2935 </div>
4128 2936 <?php
4129 2937 }
@@ -4128,26 +2936,17 @@
4128 2936 <?php
4129 2937 }
4130 2938 }
4131 2939
4132 - /**
4133 - * @param string $type
4134 - *
4135 - * @return array<string,string>
4136 - */
4137 2940 public static function locales( $type = 'date' ) {
4138 2941 $locales = array(
4139 2942 'en' => __( 'English', 'formidable' ),
4140 2943 'af' => __( 'Afrikaans', 'formidable' ),
4141 2944 'sq' => __( 'Albanian', 'formidable' ),
4142 - 'ar-DZ' => __( 'Algerian Arabic', 'formidable' ),
4143 - 'am' => __( 'Amharic', 'formidable' ),
4144 2945 'ar' => __( 'Arabic', 'formidable' ),
4145 2946 'hy' => __( 'Armenian', 'formidable' ),
4146 2947 'az' => __( 'Azerbaijani', 'formidable' ),
4147 2948 'eu' => __( 'Basque', 'formidable' ),
4148 - 'be' => __( 'Belarusian', 'formidable' ),
4149 - 'bn' => __( 'Bengali', 'formidable' ),
4150 2949 'bs' => __( 'Bosnian', 'formidable' ),
4151 2950 'bg' => __( 'Bulgarian', 'formidable' ),
4152 2951 'ca' => __( 'Catalan', 'formidable' ),
4153 2952 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
@@ -4166,15 +2965,12 @@
4166 2965 'fi' => __( 'Finnish', 'formidable' ),
4167 2966 'fr' => __( 'French', 'formidable' ),
4168 2967 'fr-CA' => __( 'French/Canadian', 'formidable' ),
4169 2968 'fr-CH' => __( 'French/Swiss', 'formidable' ),
4170 - 'gl' => __( 'Galician', 'formidable' ),
4171 - 'ka' => __( 'Georgian', 'formidable' ),
4172 2969 'de' => __( 'German', 'formidable' ),
4173 2970 'de-AT' => __( 'German/Austria', 'formidable' ),
4174 2971 'de-CH' => __( 'German/Switzerland', 'formidable' ),
4175 2972 'el' => __( 'Greek', 'formidable' ),
4176 - 'gu' => __( 'Gujarati', 'formidable' ),
4177 2973 'he' => __( 'Hebrew', 'formidable' ),
4178 2974 'iw' => __( 'Hebrew', 'formidable' ),
4179 2975 'hi' => __( 'Hindi', 'formidable' ),
4180 2976 'hu' => __( 'Hungarian', 'formidable' ),
@@ -4181,85 +2977,59 @@
4181 2977 'is' => __( 'Icelandic', 'formidable' ),
4182 2978 'id' => __( 'Indonesian', 'formidable' ),
4183 2979 'it' => __( 'Italian', 'formidable' ),
4184 2980 'ja' => __( 'Japanese', 'formidable' ),
4185 - 'kn' => __( 'Kannada', 'formidable' ),
4186 - 'kk' => __( 'Kazakh', 'formidable' ),
4187 - 'km' => __( 'Khmer', 'formidable' ),
4188 2981 'ko' => __( 'Korean', 'formidable' ),
4189 - 'ky' => __( 'Kyrgyz', 'formidable' ),
4190 - 'lo' => __( 'Laothian', 'formidable' ),
4191 2982 'lv' => __( 'Latvian', 'formidable' ),
4192 2983 'lt' => __( 'Lithuanian', 'formidable' ),
4193 - 'lb' => __( 'Luxembourgish', 'formidable' ),
4194 - 'mk' => __( 'Macedonian', 'formidable' ),
4195 - 'ml' => __( 'Malayalam', 'formidable' ),
4196 2984 'ms' => __( 'Malaysian', 'formidable' ),
4197 - 'mr' => __( 'Marathi', 'formidable' ),
4198 2985 'no' => __( 'Norwegian', 'formidable' ),
4199 - 'nb' => __( 'Norwegian Bokmål', 'formidable' ),
4200 - 'nn' => __( 'Norwegian Nynorsk', 'formidable' ),
4201 2986 'pl' => __( 'Polish', 'formidable' ),
4202 2987 'pt' => __( 'Portuguese', 'formidable' ),
4203 2988 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
4204 2989 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ),
4205 - 'rm' => __( 'Romansh', 'formidable' ),
4206 2990 'ro' => __( 'Romanian', 'formidable' ),
4207 2991 'ru' => __( 'Russian', 'formidable' ),
4208 2992 'sr' => __( 'Serbian', 'formidable' ),
4209 2993 'sr-SR' => __( 'Serbian', 'formidable' ),
4210 - 'si' => __( 'Sinhalese', 'formidable' ),
4211 2994 'sk' => __( 'Slovak', 'formidable' ),
4212 2995 'sl' => __( 'Slovenian', 'formidable' ),
4213 2996 'es' => __( 'Spanish', 'formidable' ),
4214 2997 'es-419' => __( 'Spanish/Latin America', 'formidable' ),
4215 - 'sw' => __( 'Swahili', 'formidable' ),
4216 2998 'sv' => __( 'Swedish', 'formidable' ),
4217 2999 'ta' => __( 'Tamil', 'formidable' ),
4218 - 'te' => __( 'Telugu', 'formidable' ),
4219 3000 'th' => __( 'Thai', 'formidable' ),
4220 - 'tj' => __( 'Tajiki', 'formidable' ),
4221 3001 'tr' => __( 'Turkish', 'formidable' ),
4222 3002 'uk' => __( 'Ukrainian', 'formidable' ),
4223 - 'ur' => __( 'Urdu', 'formidable' ),
4224 3003 'vi' => __( 'Vietnamese', 'formidable' ),
4225 - 'cy-GB' => __( 'Welsh', 'formidable' ),
4226 - 'zu' => __( 'Zulu', 'formidable' ),
4227 3004 );
4228 3005
4229 3006 if ( $type === 'captcha' ) {
4230 3007 // remove the languages unavailable for the captcha
4231 - $unset = array( 'sq', 'bs', 'eo', 'fo', 'fr-CH', 'sr-SR', 'ar-DZ', 'be', 'cy-GB', 'kk', 'km', 'ky', 'lb', 'mk', 'nb', 'nn', 'rm', 'tj' );
3008 + $unset = array( 'af', 'sq', 'hy', 'az', 'eu', 'bs', 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', 'he', 'is', 'ms', 'sr-SR', 'ta' );
4232 3009 } else {
4233 3010 // remove the languages unavailable for the datepicker
4234 - $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' );
3011 + $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419' );
4235 3012 }
4236 3013
4237 3014 $locales = array_diff_key( $locales, array_flip( $unset ) );
3015 + $locales = apply_filters( 'frm_locales', $locales );
4238 3016
4239 - /**
4240 - * Filter available locale options.
4241 - *
4242 - * @since 5.4.5 Added $args parameter with type.
4243 - *
4244 - * @param array<string,string> $locales
4245 - * @param array $args {
4246 - *
4247 - * @type string $type
4248 - * }
4249 - */
4250 - $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
4251 -
4252 3017 return $locales;
4253 3018 }
4254 3019
4255 3020 /**
4256 - * @return string
3021 + * Output HTML containing reference text for accessibility
3022 + *
3023 + * @deprecated 5.1
4257 3024 */
3025 + public static function multiselect_accessibility() {
3026 + _deprecated_function( __METHOD__, '5.1' );
3027 + }
3028 +
4258 3029 public static function get_menu_icon_class() {
4259 3030 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
4260 3031 $settings = FrmProAppHelper::get_settings();
4261 -
4262 3032 if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
4263 3033 return $settings->menu_icon;
4264 3034 }
4265 3035 }
@@ -4305,9 +3075,8 @@
4305 3075 *
4306 3076 * @since 5.0.04
4307 3077 *
4308 3078 * @param array $args The arguments.
4309 - *
4310 3079 * @return array
4311 3080 */
4312 3081 private static function fill_default_images_dropdown_args( $args ) {
4313 3082 $defaults = array(
@@ -4320,8 +3089,14 @@
4320 3089
4321 3090 $new_args['options'] = (array) $new_args['options'];
4322 3091 $new_args['input_attrs'] = (array) $new_args['input_attrs'];
4323 3092
3093 + // Set the number of columns.
3094 + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) );
3095 + if ( $new_args['col_class'] > 6 ) {
3096 + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 );
3097 + }
3098 +
4324 3099 /**
4325 3100 * Allows modifying the arguments of images_dropdown() method.
4326 3101 *
4327 3102 * @since 5.0.04
@@ -4337,9 +3112,8 @@
4337 3112 *
4338 3113 * @since 5.0.04
4339 3114 *
4340 3115 * @param array $args The arguments.
4341 - *
4342 3116 * @return string
4343 3117 */
4344 3118 private static function get_images_dropdown_input_attrs( $args ) {
4345 3119 $input_attrs = $args['input_attrs'];
@@ -4346,9 +3120,8 @@
4346 3120 $input_attrs['type'] = 'radio';
4347 3121 $input_attrs['name'] = $args['name'];
4348 3122
4349 3123 $input_attrs_str = '';
4350 -
4351 3124 foreach ( $input_attrs as $key => $input_attr ) {
4352 3125 $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) );
4353 3126 }
4354 3127
@@ -4363,23 +3136,8 @@
4363 3136 return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args );
4364 3137 }
4365 3138
4366 3139 /**
4367 - * @since 6.7.1
4368 - *
4369 - * @param array $option Option data.
4370 - * @param array $args The arguments of images_dropdown() method.
4371 - *
4372 - * @return array
4373 - */
4374 - public static function get_images_dropdown_atts( $option, $args ) {
4375 - $image = self::get_images_dropdown_option_image( $option, $args );
4376 - $classes = self::get_images_dropdown_option_classes( $option, $args );
4377 - $custom_attrs = self::get_images_dropdown_option_html_attrs( $option, $args );
4378 - return compact( 'image', 'classes', 'custom_attrs' );
4379 - }
4380 -
4381 - /**
4382 3140 * Gets the image of each option in images_dropdown() method.
4383 3141 *
4384 3142 * @since 5.0.04
4385 3143 *
@@ -4384,9 +3142,8 @@
4384 3142 * @since 5.0.04
4385 3143 *
4386 3144 * @param array $option Option data.
4387 3145 * @param array $args The arguments of images_dropdown() method.
4388 - *
4389 3146 * @return string
4390 3147 */
4391 3148 private static function get_images_dropdown_option_image( $option, $args ) {
4392 3149 $image = self::icon_by_class(
@@ -4391,9 +3148,9 @@
4391 3148 private static function get_images_dropdown_option_image( $option, $args ) {
4392 3149 $image = self::icon_by_class(
4393 3150 'frmfont ' . $option['svg'],
4394 3151 array(
4395 - 'echo' => false,
3152 + 'echo' => false,
4396 3153 )
4397 3154 );
4398 3155
4399 3156 $args['option'] = $option;
@@ -4415,9 +3172,8 @@
4415 3172 * @since 5.0.04
4416 3173 *
4417 3174 * @param array $option Option data.
4418 3175 * @param array $args The arguments of images_dropdown() method.
4419 - *
4420 3176 * @return string
4421 3177 */
4422 3178 private static function get_images_dropdown_option_classes( $option, $args ) {
4423 3179 $classes = '';
@@ -4445,14 +3201,12 @@
4445 3201 * @since 5.0.04
4446 3202 *
4447 3203 * @param array $option Option data.
4448 3204 * @param array $args The arguments of images_dropdown() method.
4449 - *
4450 3205 * @return string
4451 3206 */
4452 3207 private static function get_images_dropdown_option_html_attrs( $option, $args ) {
4453 3208 $html_attrs = '';
4454 -
4455 3209 if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) {
4456 3210 $html_attrs_arr = array();
4457 3211
4458 3212 foreach ( $option['custom_attrs'] as $key => $value ) {
@@ -4515,9 +3269,8 @@
4515 3269 * @since 5.0.07
4516 3270 *
4517 3271 * @param array $values
4518 3272 * @param array $keys
4519 - *
4520 3273 * @return array
4521 3274 */
4522 3275 public static function maybe_filter_array( $values, $keys ) {
4523 3276 $allow_unfiltered_html = self::allow_unfiltered_html();
@@ -4535,16 +3288,15 @@
4535 3288 return $values;
4536 3289 }
4537 3290
4538 3291 /**
4539 - * Some back end fields allow privileged users to add scripts.
3292 + * Some back end fields allow privleged users to add scripts.
4540 3293 * A site that uses the DISALLOW_UNFILTERED_HTML always remove scripts on echo.
4541 3294 *
4542 3295 * @since 5.0.13
4543 3296 *
4544 3297 * @param string $value
4545 - * @param array|string $allowed 'all' for everything included as defaults.
4546 - *
3298 + * @param array|string $allowed 'all' for everything included as defaults
4547 3299 * @return string
4548 3300 */
4549 3301 public static function maybe_kses( $value, $allowed = 'all' ) {
4550 3302 if ( self::should_never_allow_unfiltered_html() ) {
@@ -4553,78 +3305,26 @@
4553 3305 return $value;
4554 3306 }
4555 3307
4556 3308 /**
4557 - * Check if an option attribute used in an [input] shortcode is safe.
3309 + * @since 5.0.16
4558 3310 *
4559 - * @since 6.11.2
4560 - *
4561 - * @param string $key
4562 - * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed.
4563 - *
4564 3311 * @return bool
4565 3312 */
4566 - public static function input_key_is_safe( $key, $context = 'display' ) {
4567 - if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) {
4568 - $safe = true;
4569 - } elseif ( 0 === strpos( $key, 'data-' ) ) {
4570 - // Allow all data attributes.
4571 - $safe = true;
4572 - } elseif ( 0 === strpos( $key, 'aria-' ) ) {
4573 - // Allow all aria attributes.
4574 - $safe = true;
4575 - } else {
4576 - $safe_keys = array(
4577 - 'class',
4578 - 'required',
4579 - 'title',
4580 - 'placeholder',
4581 - 'value',
4582 - 'readonly',
4583 - 'disabled',
4584 - 'size',
4585 - 'maxlength',
4586 - 'min',
4587 - 'max',
4588 - 'pattern',
4589 - 'step',
4590 - 'autofocus',
4591 - 'width',
4592 - 'height',
4593 - 'autocomplete',
4594 - 'tabindex',
4595 - 'role',
4596 - 'style',
4597 - );
4598 - $safe = in_array( $key, $safe_keys, true );
4599 - }//end if
4600 -
4601 - /**
4602 - * Filter the $safe value so additional keys can be allowed or disallowed.
4603 - *
4604 - * @since 6.11.2
4605 - *
4606 - * @param bool $safe True if the key is considered safe.
4607 - * @param string $key
4608 - * @param string $context Either 'display' or 'update'.
4609 - */
4610 - return (bool) apply_filters( 'frm_input_key_is_safe', $safe, $key, $context );
3313 + public static function show_landing_pages() {
3314 + return self::show_new_feature( 'landing' );
4611 3315 }
4612 3316
4613 3317 /**
4614 3318 * @since 5.0.16
4615 3319 *
4616 - * @param string $medium
4617 - *
4618 3320 * @return array
4619 3321 */
4620 3322 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
4621 3323 $params = array(
4622 - 'medium' => $medium,
4623 - 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
4624 - 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4625 - 'screenshot' => 'landing.png',
4626 - 'learn-more' => self::get_doc_url( 'landing-page-forms', 'form-landing-page-settings', false ),
3324 + 'medium' => $medium,
3325 + 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
3326 + 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4627 3327 );
4628 3328 return self::get_upgrade_data_params( 'landing', $params );
4629 3329 }
4630 3330
@@ -4630,10 +3330,20 @@
4630 3330
4631 3331 /**
4632 3332 * @since 5.0.17
4633 3333 *
4634 - * @param string $feature
3334 + * @param string $plugin
3335 + * @return string|false
3336 + */
3337 + private static function get_plan_required( $plugin ) {
3338 + $link = FrmAddonsController::install_link( $plugin );
3339 + return FrmFormsHelper::get_plan_required( $link );
3340 + }
3341 +
3342 + /**
3343 + * @since 5.0.17
4635 3344 *
3345 + * @param string
4636 3346 * @return bool
4637 3347 */
4638 3348 public static function show_new_feature( $feature ) {
4639 3349 $link = FrmAddonsController::install_link( $feature );
@@ -4640,21 +3350,16 @@
4640 3350 return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
4641 3351 }
4642 3352
4643 3353 /**
4644 - * Enhances upgrade data parameters with installation link and plan requirement information.
4645 - *
4646 3354 * @since 5.0.17
4647 3355 *
4648 - * @param string $plugin The plugin slug to get installation data for.
4649 - * @param array $params Initial parameters for the upgrade data.
4650 - * @param bool $detailed Whether to include detailed information.
4651 - *
4652 - * @return array Modified parameters with installation data.
3356 + * @param string $plugin
3357 + * @param array $params
3358 + * @return array
4653 3359 */
4654 - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) {
3360 + public static function get_upgrade_data_params( $plugin, $params ) {
4655 3361 $link = FrmAddonsController::install_link( $plugin );
4656 -
4657 3362 if ( ! $link ) {
4658 3363 return $params;
4659 3364 }
4660 3365
@@ -4660,20 +3365,15 @@
4660 3365
4661 3366 if ( ! empty( $link['url'] ) && self::pro_is_installed() ) {
4662 3367 $params['oneclick'] = json_encode( $link );
4663 3368 unset( $params['message'] );
4664 -
4665 3369 if ( ! isset( $params['medium'] ) ) {
4666 3370 $params['medium'] = $plugin;
4667 3371 }
4668 3372 } else {
4669 - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link );
3373 + $params['requires'] = FrmFormsHelper::get_plan_required( $link );
4670 3374 }
4671 3375
4672 - if ( $detailed ) {
4673 - $params['plugin-status'] = $link['status'] ?? '';
4674 - }
4675 -
4676 3376 return $params;
4677 3377 }
4678 3378
4679 3379 /**
@@ -4682,9 +3382,8 @@
4682 3382 *
4683 3383 * @since 5.0.17
4684 3384 *
4685 3385 * @param string $text
4686 - *
4687 3386 * @return bool
4688 3387 */
4689 3388 public static function ctype_xdigit( $text ) {
4690 3389 if ( function_exists( 'ctype_xdigit' ) ) {
@@ -4699,9 +3398,8 @@
4699 3398 * @since 5.2.01
4700 3399 */
4701 3400 public static function set_current_screen_and_hook_suffix() {
4702 3401 global $hook_suffix;
4703 -
4704 3402 if ( is_null( $hook_suffix ) ) {
4705 3403 // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
4706 3404 $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
4707 3405 }
@@ -4708,8 +3406,36 @@
4708 3406 set_current_screen();
4709 3407 }
4710 3408
4711 3409 /**
3410 + * @since 4.07
3411 + * @deprecated 4.09.01
3412 + */
3413 + public static function renewal_message() {
3414 + if ( is_callable( 'FrmProAddonsController::renewal_message' ) ) {
3415 + FrmProAddonsController::renewal_message();
3416 + return;
3417 + }
3418 +
3419 + if ( ! FrmAddonsController::is_license_expired() ) {
3420 + return;
3421 + }
3422 +
3423 + ?>
3424 + <div class="frm_error_style" style="text-align:left">
3425 + <?php self::icon_by_class( 'frmfont frm_alert_icon' ); ?>
3426 + &nbsp;
3427 + <?php esc_html_e( 'Your account has expired', 'formidable' ); ?>
3428 + <div style="float:right">
3429 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'form-expired', 'account/downloads/' ) ); ?>">
3430 + <?php esc_html_e( 'Renew Now', 'formidable' ); ?>
3431 + </a>
3432 + </div>
3433 + </div>
3434 + <?php
3435 + }
3436 +
3437 + /**
4712 3438 * Shows pill text.
4713 3439 *
4714 3440 * @since 5.2.02
4715 3441 *
@@ -4718,9 +3444,9 @@
4718 3444 public static function show_pill_text( $text = null ) {
4719 3445 if ( null === $text ) {
4720 3446 $text = __( 'NEW', 'formidable' );
4721 3447 }
4722 - echo '<span class="frm-meta-tag frm-new-pill">' . esc_html( $text ) . '</span>';
3448 + echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>';
4723 3449 }
4724 3450
4725 3451 /**
4726 3452 * Count the number of decimals digits.
@@ -4727,10 +3453,9 @@
4727 3453 *
4728 3454 * @since 5.2.07
4729 3455 *
4730 3456 * @param mixed $num Number.
4731 - *
4732 - * @return false|int Returns `false` if the passed parameter is not number.
3457 + * @return int|false Returns `false` if the passed parameter is not number.
4733 3458 */
4734 3459 public static function count_decimals( $num ) {
4735 3460 if ( ! is_numeric( $num ) ) {
4736 3461 return false;
@@ -4737,9 +3462,8 @@
4737 3462 }
4738 3463
4739 3464 $num = (string) $num;
4740 3465 $parts = explode( '.', $num );
4741 -
4742 3466 if ( 1 === count( $parts ) ) {
4743 3467 return 0;
4744 3468 }
4745 3469
@@ -4762,9 +3486,9 @@
4762 3486 }
4763 3487
4764 3488 add_filter(
4765 3489 'option_gmt_offset',
4766 - function ( $offset ) {
3490 + function( $offset ) {
4767 3491 if ( ! is_string( $offset ) || is_numeric( $offset ) ) {
4768 3492 // Leave a valid value alone.
4769 3493 return $offset;
4770 3494 }
@@ -4800,285 +3524,213 @@
4800 3524 return array( 'list', 'trash', 'untrash', 'destroy' );
4801 3525 }
4802 3526
4803 3527 /**
4804 - * Safely call get_plugins, importing the required files if they are not yet loaded.
4805 - *
4806 - * @since 5.5
4807 - *
4808 - * @return array
3528 + * @since 4.08
3529 + * @deprecated 4.09.01
4809 3530 */
4810 - public static function get_plugins() {
4811 - if ( ! function_exists( 'get_plugins' ) ) {
4812 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
3531 + public static function expiring_message() {
3532 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3533 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3534 + FrmProAddonsController::expiring_message();
4813 3535 }
4814 - return get_plugins();
4815 3536 }
4816 3537
4817 3538 /**
4818 - * 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.
4819 - * This is to make sure that the URL can't be exploited for a SSRF attack.
3539 + * Use the WP 4.7 wp_doing_ajax function
4820 3540 *
4821 - * @since 5.5.5
4822 - *
4823 - * @param string $url
4824 - * @param string $expected_extension
4825 - *
4826 - * @return bool
3541 + * @since 2.05.07
3542 + * @deprecated 4.04.04
4827 3543 */
4828 - public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
4829 - $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
3544 + public static function wp_doing_ajax() {
3545 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3546 + return wp_doing_ajax();
3547 + }
4830 3548
4831 - if ( ! $file_is_in_expected_s3_bucket ) {
4832 - return false;
4833 - }
4834 -
4835 - $parsed = parse_url( $url );
4836 -
4837 - if ( ! is_array( $parsed ) ) {
4838 - // URL is malformed.
4839 - return false;
4840 - }
4841 -
4842 - $path = $parsed['path'];
4843 - $ext = pathinfo( $path, PATHINFO_EXTENSION );
4844 -
4845 - if ( $expected_extension !== $ext ) {
4846 - // The URL isn't to an XML file.
4847 - return false;
4848 - }
4849 -
4850 - return true;
3549 + /**
3550 + * @deprecated 4.0
3551 + */
3552 + public static function insert_opt_html( $args ) {
3553 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3554 + FrmFormsHelper::insert_opt_html( $args );
4851 3555 }
4852 3556
4853 3557 /**
4854 - * Display a dismissable warning message and save its dismissal state.
3558 + * Used to filter shortcode in text widgets
4855 3559 *
4856 - * @since 6.3
4857 - *
4858 - * @param string $message The warning message to display.
4859 - * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
4860 - *
4861 - * @return void
3560 + * @deprecated 2.5.4
3561 + * @codeCoverageIgnore
4862 3562 */
4863 - public static function add_dismissable_warning_message( $message = '', $option = '' ) {
4864 - if ( ! $message || ! $option ) {
4865 - return;
4866 - }
3563 + public static function widget_text_filter_callback( $matches ) {
3564 + return FrmDeprecated::widget_text_filter_callback( $matches );
3565 + }
4867 3566
4868 - $ajax_callback = function () use ( $option ) {
4869 - self::dismiss_warning_message( $option );
4870 - };
4871 -
4872 - // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action.
4873 - // To prevent any issues, we add 'frm_' from the beginning of the action.
4874 - add_action( 'wp_ajax_frm_' . $option, $ajax_callback );
4875 -
4876 - add_filter(
4877 - 'frm_message_list',
4878 - function ( $show_messages ) use ( $message, $option ) {
4879 - if ( get_option( $option, false ) ) {
4880 - return $show_messages;
4881 - }
4882 -
4883 - $dismiss_icon = self::icon_by_class(
4884 - 'frmfont frm_close_icon',
4885 - array(
4886 - 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ),
4887 - 'echo' => false,
4888 - )
4889 - );
4890 -
4891 - $show_messages[] = $message;
4892 - $show_messages[] = '<span class="frm-warning-dismiss frmsvg" data-action="' . esc_attr( $option ) . '">' . $dismiss_icon . '</span>';
4893 -
4894 - return $show_messages;
4895 - }
4896 - );
3567 + /**
3568 + * @deprecated 3.01
3569 + * @codeCoverageIgnore
3570 + */
3571 + public static function sanitize_array( &$values ) {
3572 + FrmDeprecated::sanitize_array( $values );
4897 3573 }
4898 3574
4899 3575 /**
4900 - * Dismiss a warning message and update the dismissal state.
3576 + * @param array $settings
3577 + * @param string $group
4901 3578 *
4902 - * @since 6.3
4903 - *
4904 - * @param string $option The unique identifier for the dismissal state of the message.
4905 - *
4906 - * @return void
3579 + * @since 2.0.6
3580 + * @deprecated 2.05.06
3581 + * @codeCoverageIgnore
4907 3582 */
4908 - public static function dismiss_warning_message( $option = '' ) {
4909 - self::permission_check( 'frm_change_settings' );
4910 - check_ajax_referer( 'frm_ajax', 'nonce' );
3583 + public static function save_settings( $settings, $group ) {
3584 + return FrmDeprecated::save_settings( $settings, $group );
3585 + }
4911 3586
4912 - if ( $option ) {
4913 - update_option( $option, true, 'no' );
4914 - }
4915 -
4916 - wp_send_json_success();
3587 + /**
3588 + * @since 2.0.4
3589 + * @deprecated 2.05.06
3590 + * @codeCoverageIgnore
3591 + */
3592 + public static function save_json_post( $settings ) {
3593 + return FrmDeprecated::save_json_post( $settings );
4917 3594 }
4918 3595
4919 3596 /**
4920 - * Lite license copy.
4921 - * Used in FrmDashboardController & FrmSettingsController
3597 + * @since 2.0
3598 + * @deprecated 2.05.06
3599 + * @codeCoverageIgnore
4922 3600 *
4923 - * @since 6.8
3601 + * @param string $cache_key The unique name for this cache
3602 + * @param string $group The name of the cache group
3603 + * @param string $query If blank, don't run a db call
3604 + * @param string $type The wpdb function to use with this query
4924 3605 *
4925 - * @return string
3606 + * @return mixed $results The cache or query results
4926 3607 */
4927 - public static function copy_for_lite_license() {
4928 - $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂';
3608 + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
3609 + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time );
3610 + }
4929 3611
4930 - return apply_filters( 'frm_license_type_text', $message );
3612 + /**
3613 + * @deprecated 2.05.06
3614 + * @codeCoverageIgnore
3615 + */
3616 + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
3617 + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time );
4931 3618 }
4932 3619
4933 3620 /**
4934 - * Removes scripts that are unnecessarily loaded across the pages!
4935 - *
4936 - * @since 6.9
4937 - *
4938 - * @return void
3621 + * @deprecated 2.05.06
3622 + * @codeCoverageIgnore
4939 3623 */
4940 - public static function dequeue_extra_global_scripts() {
4941 - wp_dequeue_script( 'frm-surveys-admin' );
4942 - wp_dequeue_script( 'frm-quizzes-form-action' );
3624 + public static function add_key_to_group_cache( $key, $group ) {
3625 + FrmDeprecated::add_key_to_group_cache( $key, $group );
4943 3626 }
4944 3627
4945 3628 /**
4946 - * Shows tooltip icon.
4947 - *
4948 - * @since 6.12
4949 - *
4950 - * @param string $tooltip_text Tooltip text.
4951 - * @param array $atts Tooltip wrapper HTML attributes.
4952 - *
4953 - * @return void
3629 + * @deprecated 2.05.06
3630 + * @codeCoverageIgnore
4954 3631 */
4955 - public static function tooltip_icon( $tooltip_text, $atts = array() ) {
4956 - $atts['title'] = $tooltip_text;
3632 + public static function get_group_cached_keys( $group ) {
3633 + return FrmDeprecated::get_group_cached_keys( $group );
3634 + }
4957 3635
4958 - if ( isset( $atts['class'] ) ) {
4959 - $atts['class'] .= ' frm_help';
4960 - } else {
4961 - $atts['class'] = 'frm_help';
4962 - }
4963 - ?>
4964 - <span <?php self::array_to_html_params( $atts, true ); ?>>
4965 - <?php self::icon_by_class( 'frmfont frm_tooltip_icon' ); ?>
4966 - </span>
4967 - <?php
3636 + /**
3637 + * @since 2.0
3638 + * @deprecated 2.05.06
3639 + * @codeCoverageIgnore
3640 + * @return mixed The cached value or false
3641 + */
3642 + public static function check_cache_and_transient( $cache_key ) {
3643 + return FrmDeprecated::check_cache( $cache_key );
4968 3644 }
4969 3645
4970 3646 /**
4971 - * Prints errors for settings in onboarding wizard or template settings.
3647 + * @since 2.0
3648 + * @deprecated 2.05.06
3649 + * @codeCoverageIgnore
4972 3650 *
4973 - * @since 6.15
4974 - *
4975 - * @param array $args Args.
4976 - *
4977 - * @return void
3651 + * @param string $cache_key
4978 3652 */
4979 - public static function print_setting_error( $args ) {
4980 - $args = wp_parse_args(
4981 - $args,
4982 - array(
4983 - 'id' => '',
4984 - 'errors' => array(),
4985 - 'class' => '',
4986 - )
4987 - );
4988 -
4989 - $args['class'] .= ' frm-validation-error frm-mt-xs frm_hidden';
4990 - ?>
4991 - <span id="<?php echo esc_attr( $args['id'] ); ?>" class="<?php echo esc_attr( $args['class'] ); ?>">
4992 - <?php
4993 - if ( is_array( $args['errors'] ) ) {
4994 - foreach ( $args['errors'] as $key => $msg ) {
4995 - ?>
4996 - <span frm-error="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $msg ); ?></span>
4997 - <?php
4998 - }
4999 - } else {
5000 - echo '<span>' . esc_html( $args['errors'] ) . '</span>';
5001 - }
5002 - ?>
5003 - </span>
5004 - <?php
3653 + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
3654 + FrmDeprecated::delete_cache_and_transient( $cache_key, $group );
5005 3655 }
5006 3656
5007 3657 /**
5008 - * Check if GDPR is enabled.
3658 + * @since 2.0
3659 + * @deprecated 2.05.06
3660 + * @codeCoverageIgnore
5009 3661 *
5010 - * @since 6.19
5011 - *
5012 - * @return bool
3662 + * @param string $group The name of the cache group
5013 3663 */
5014 - public static function is_gdpr_enabled() {
5015 - $frm_settings = self::get_settings();
5016 - return $frm_settings->enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies;
3664 + public static function cache_delete_group( $group ) {
3665 + FrmDeprecated::cache_delete_group( $group );
5017 3666 }
5018 3667
5019 3668 /**
5020 - * Check if GDPR cookies are disabled.
3669 + * @since 1.07.10
3670 + * @deprecated 2.05.06
3671 + * @codeCoverageIgnore
5021 3672 *
5022 - * @since 6.19
3673 + * @param string $term The value to escape
5023 3674 *
5024 - * @return bool
3675 + * @return string The escaped value
5025 3676 */
5026 - public static function no_gdpr_cookies() {
5027 - $frm_settings = self::get_settings();
5028 - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies;
3677 + public static function esc_like( $term ) {
3678 + return FrmDeprecated::esc_like( $term );
5029 3679 }
5030 3680
5031 3681 /**
5032 - * Check if a string is valid UTF-8.
3682 + * @param string $order_query
5033 3683 *
5034 - * @since 6.24
5035 - *
5036 - * @param string $string The string to check.
5037 - *
5038 - * @return bool
3684 + * @deprecated 2.05.06
3685 + * @codeCoverageIgnore
5039 3686 */
5040 - public static function is_valid_utf8( $string ) {
5041 - // wp_is_valid_utf8 is added in WP 6.9.
5042 - if ( function_exists( 'wp_is_valid_utf8' ) ) {
5043 - return wp_is_valid_utf8( $string );
5044 - }
3687 + public static function esc_order( $order_query ) {
3688 + return FrmDeprecated::esc_order( $order_query );
3689 + }
5045 3690
5046 - // As of WP 6.9, seems_utf8 is deprecated.
5047 - if ( function_exists( 'seems_utf8' ) ) {
5048 - return seems_utf8( $string );
5049 - }
5050 - return false;
3691 + /**
3692 + * @deprecated 2.05.06
3693 + * @codeCoverageIgnore
3694 + */
3695 + public static function esc_order_by( &$order_by ) {
3696 + FrmDeprecated::esc_order_by( $order_by );
5051 3697 }
5052 3698
5053 3699 /**
5054 - * Get a documentation URL with UTM parameters and affiliate tracking.
3700 + * @param string $limit
5055 3701 *
5056 - * @since 6.26
5057 - *
5058 - * @param string $path The relative path to append to the base URL.
5059 - * @param string $campaign The campaign to use for UTM parameters.
5060 - * @param bool $add_kb_base Whether to prepend 'knowledgebase/' to the path. Default true.
5061 - *
5062 - * @return string The processed URL with UTM parameters and affiliate tracking.
3702 + * @deprecated 2.05.06
3703 + * @codeCoverageIgnore
5063 3704 */
5064 - public static function get_doc_url( $path, $campaign, $add_kb_base = true ) {
5065 - $path = trim( $path, '/' );
3705 + public static function esc_limit( $limit ) {
3706 + return FrmDeprecated::esc_limit( $limit );
3707 + }
5066 3708
5067 - if ( $add_kb_base ) {
5068 - $path = 'knowledgebase/' . $path;
5069 - }
3709 + /**
3710 + * @since 2.0
3711 + * @deprecated 2.05.06
3712 + * @codeCoverageIgnore
3713 + */
3714 + public static function prepare_array_values( $array, $type = '%s' ) {
3715 + return FrmDeprecated::prepare_array_values( $array, $type );
3716 + }
5070 3717
5071 - return self::maybe_add_missing_utm( 'https://formidableforms.com/' . $path, array( 'campaign' => $campaign ) );
3718 + /**
3719 + * @deprecated 2.05.06
3720 + * @codeCoverageIgnore
3721 + */
3722 + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
3723 + return FrmDeprecated::prepend_and_or_where( $starts_with, $where );
5072 3724 }
5073 3725
5074 3726 /**
5075 - * @since 5.0.16
5076 - * @deprecated 6.26
3727 + * @since 2.0
3728 + * @deprecated 5.0.13
5077 3729 *
5078 - * @return bool
3730 + * @return string The base Google APIS url for the current version of jQuery UI
5079 3731 */
5080 - public static function show_landing_pages() {
5081 - _deprecated_function( __METHOD__, '6.26' );
5082 - return true;
3732 + public static function jquery_ui_base_url() {
3733 + _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3734 + return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
5083 3735 }
5084 3736 }