PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7
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 +417 -1469 6.266.7 View file →
@@ -3,26 +3,15 @@
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 = 100; // 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
@@ -28,9 +17,9 @@
28 17 * @since 2.0
29 18 *
30 19 * @var string
31 20 */
32 - public static $plug_version = '6.26';
21 + public static $plug_version = '6.7';
33 22
34 23 /**
35 24 * @var bool
36 25 */
@@ -38,8 +27,10 @@
38 27
39 28 /**
40 29 * @since 1.07.02
41 30 *
31 + * @param none
32 + *
42 33 * @return string The version of this plugin
43 34 */
44 35 public static function plugin_version() {
45 36 return self::$plug_version;
@@ -44,33 +35,21 @@
44 35 public static function plugin_version() {
45 36 return self::$plug_version;
46 37 }
47 38
48 - /**
49 - * @return string
50 - */
51 39 public static function plugin_folder() {
52 40 return basename( self::plugin_path() );
53 41 }
54 42
55 - /**
56 - * @return string
57 - */
58 43 public static function plugin_path() {
59 - return dirname( __DIR__, 2 );
44 + return dirname( dirname( dirname( __FILE__ ) ) );
60 45 }
61 46
62 - /**
63 - * @return string
64 - */
65 47 public static function plugin_url() {
66 - // Previously FRM_URL constant.
48 + // Prevously FRM_URL constant.
67 49 return plugins_url( '', self::plugin_path() . '/formidable.php' );
68 50 }
69 51
70 - /**
71 - * @return string
72 - */
73 52 public static function relative_plugin_url() {
74 53 return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() );
75 54 }
76 55
@@ -85,9 +64,8 @@
85 64 * Get the name of this site
86 65 * Used for [sitename] shortcode
87 66 *
88 67 * @since 2.0
89 - *
90 68 * @return string
91 69 */
92 70 public static function site_name() {
93 71 return get_option( 'blogname' );
@@ -92,16 +70,10 @@
92 70 public static function site_name() {
93 71 return get_option( 'blogname' );
94 72 }
95 73
96 - /**
97 - * @param string $url
98 - *
99 - * @return string
100 - */
101 74 public static function make_affiliate_url( $url ) {
102 75 $affiliate_id = self::get_affiliate();
103 -
104 76 if ( ! empty( $affiliate_id ) ) {
105 77 $url = str_replace( array( 'http://', 'https://' ), '', $url );
106 78 $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url );
107 79 }
@@ -108,11 +80,8 @@
108 80
109 81 return $url;
110 82 }
111 83
112 - /**
113 - * @return int
114 - */
115 84 public static function get_affiliate() {
116 85 return absint( apply_filters( 'frm_affiliate_id', 0 ) );
117 86 }
118 87
@@ -117,178 +86,64 @@
117 86 }
118 87
119 88 /**
120 89 * @since 3.04.02
121 - *
122 - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute.
90 + * @param array|string $args
123 91 * @param string $page
124 92 */
125 93 public static function admin_upgrade_link( $args, $page = '' ) {
126 - if ( $page ) {
94 + if ( empty( $page ) ) {
95 + $page = 'https://formidableforms.com/lite-upgrade/';
96 + } else {
127 97 $page = str_replace( 'https://formidableforms.com/', '', $page );
128 98 $page = 'https://formidableforms.com/' . $page;
129 - } else {
130 - $page = 'https://formidableforms.com/lite-upgrade/';
131 99 }
132 100
101 + $anchor = '';
133 102 if ( is_array( $args ) ) {
134 - $args = self::adjust_legacy_utm_args( $args );
103 + $medium = $args['medium'];
104 + if ( isset( $args['content'] ) ) {
105 + $content = $args['content'];
106 + }
107 + if ( isset( $args['anchor'] ) ) {
108 + $anchor = '#' . $args['anchor'];
109 + }
135 110 } else {
136 - $args = array( 'campaign' => $args );
111 + $medium = $args;
137 112 }
138 113
139 114 $query_args = array(
140 - 'utm_source' => 'plugin',
141 - 'utm_medium' => self::get_utm_medium(),
115 + 'utm_source' => 'WordPress',
116 + 'utm_medium' => $medium,
117 + 'utm_campaign' => 'liteplugin',
142 118 );
143 - $query_args = self::maybe_add_utm_license( $query_args );
144 119
145 - if ( isset( $args['campaign'] ) ) {
146 - $query_args['utm_campaign'] = $args['campaign'];
120 + if ( isset( $content ) ) {
121 + $query_args['utm_content'] = $content;
147 122 }
148 123
149 - if ( isset( $args['content'] ) ) {
150 - $query_args['utm_content'] = $args['content'];
151 - }
152 -
153 - if ( isset( $args['param'] ) ) {
124 + if ( is_array( $args ) && isset( $args['param'] ) ) {
154 125 $query_args['f'] = $args['param'];
155 126 }
156 127
157 - if ( ! empty( $args['plan'] ) ) {
128 + if ( is_array( $args ) && ! empty( $args['plan'] ) ) {
158 129 $query_args['plan'] = $args['plan'];
159 130 }
160 131
161 - $link = add_query_arg( $query_args, $page );
162 -
163 - if ( isset( $args['anchor'] ) ) {
164 - $link .= '#' . $args['anchor'];
165 - }
166 -
132 + $link = add_query_arg( $query_args, $page ) . $anchor;
167 133 return self::make_affiliate_url( $link );
168 134 }
169 135
170 136 /**
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 137 * Get the Formidable settings
281 138 *
282 139 * @since 2.0
283 140 *
284 141 * @param array $args - May include the form id when values need translation.
285 - *
286 - * @return FrmSettings $frm_settings
142 + * @return FrmSettings $frm_setings
287 143 */
288 144 public static function get_settings( $args = array() ) {
289 145 global $frm_settings;
290 -
291 146 if ( empty( $frm_settings ) ) {
292 147 $frm_settings = new FrmSettings( $args );
293 148 } elseif ( isset( $args['current_form'] ) ) {
294 149 // If the global has already been set, allow strings to be filtered.
@@ -297,40 +152,32 @@
297 152
298 153 return $frm_settings;
299 154 }
300 155
301 - /**
302 - * @return string
303 - */
304 156 public static function get_menu_name() {
305 157 $frm_settings = self::get_settings();
306 158
307 - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu;
159 + return FrmAddonsController::is_license_expired() ? 'Formidable' : $frm_settings->menu;
308 160 }
309 161
310 162 /**
311 163 * Determine if the current branding is set to 'formidable'.
312 - * Checks the menu icon, and verifies if it matches the formidable branding.
313 164 *
165 + * Checks the menu title, retrieved through get_menu_name,
166 + * and verifies if it matches the 'formidable' branding.
167 + *
314 168 * @since 6.4.2
315 169 *
316 - * @return bool True if the menu icon is the logo, false otherwise.
170 + * @return bool True if the menu title is 'formidable', false otherwise.
317 171 */
318 172 public static function is_formidable_branding() {
319 - if ( ! self::pro_is_installed() ) {
320 - return true;
321 - }
173 + $menu_title = self::get_menu_name();
322 174
323 - $menu_icon = self::get_menu_icon_class();
324 - return strpos( $menu_icon, 'frm_logo_icon' ) !== false;
175 + return 'formidable' === strtolower( trim( $menu_title ) );
325 176 }
326 177
327 178 /**
328 179 * @since 3.05
329 - *
330 - * @param array $atts
331 - *
332 - * @return string
333 180 */
334 181 public static function svg_logo( $atts = array() ) {
335 182 $defaults = array(
336 183 'height' => 18,
@@ -347,12 +194,8 @@
347 194 }
348 195
349 196 /**
350 197 * @since 4.0
351 - *
352 - * @param array $atts
353 - *
354 - * @return void
355 198 */
356 199 public static function show_logo( $atts = array() ) {
357 200 echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
358 201 }
@@ -358,10 +201,8 @@
358 201 }
359 202
360 203 /**
361 204 * @since 4.03.02
362 - *
363 - * @return void
364 205 */
365 206 public static function show_header_logo() {
366 207 $icon = self::svg_logo(
367 208 array(
@@ -370,9 +211,8 @@
370 211 )
371 212 );
372 213
373 214 $new_icon = apply_filters( 'frm_icon', $icon, true );
374 -
375 215 if ( $new_icon !== $icon ) {
376 216 if ( strpos( $new_icon, '<svg' ) === 0 ) {
377 217 $icon = str_replace( 'viewBox="0 0 20', 'width="30" height="35" style="color:#929699" viewBox="0 0 20', $new_icon );
378 218 } else {
@@ -384,38 +224,21 @@
384 224 }
385 225
386 226 /**
387 227 * @since 2.02.04
388 - *
389 - * @return bool
390 228 */
391 229 public static function ips_saved() {
392 230 $frm_settings = self::get_settings();
231 +
393 232 return ! $frm_settings->no_ips;
394 233 }
395 234
396 - /**
397 - * @return bool
398 - */
399 235 public static function pro_is_installed() {
400 - return (bool) apply_filters( 'frm_pro_installed', false );
236 + return apply_filters( 'frm_pro_installed', false );
401 237 }
402 238
403 239 /**
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 240 * @since 4.06.02
416 - *
417 - * @return bool
418 241 */
419 242 public static function pro_is_connected() {
420 243 global $frm_vars;
421 244 return self::pro_is_installed() && $frm_vars['pro_is_authorized'];
@@ -422,31 +245,17 @@
422 245 }
423 246
424 247 /**
425 248 * @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 249 */
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 );
250 + public static function is_form_builder_page() {
251 + $action = self::simple_get( 'frm_action', 'sanitize_title' );
252 + return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' );
440 253 }
441 254
442 - /**
443 - * @return bool
444 - */
445 255 public static function is_formidable_admin() {
446 256 $page = self::simple_get( 'page', 'sanitize_title' );
447 257 $is_formidable = strpos( $page, 'formidable' ) !== false;
448 -
449 258 if ( empty( $page ) ) {
450 259 $is_formidable = self::is_view_builder_page();
451 260 }
452 261
@@ -453,63 +262,22 @@
453 262 return $is_formidable;
454 263 }
455 264
456 265 /**
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 266 * Check for certain page in Formidable settings
497 267 *
498 268 * @since 2.0
499 269 *
500 - * @param string $page The name of the page to check.
270 + * @param string $page The name of the page to check
501 271 *
502 - * @return bool
272 + * @return boolean
503 273 */
504 274 public static function is_admin_page( $page = 'formidable' ) {
505 275 global $pagenow;
506 276 $get_page = self::simple_get( 'page', 'sanitize_title' );
507 -
508 277 if ( $pagenow ) {
509 278 // allow this to be true during ajax load i.e. ajax form builder loading
510 279 $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
511 -
512 280 if ( $is_page ) {
513 281 return true;
514 282 }
515 283 }
@@ -521,10 +289,8 @@
521 289 * If the current page is for editing or creating a view.
522 290 * Returns false for the views listing page.
523 291 *
524 292 * @since 4.0
525 - *
526 - * @return bool
527 293 */
528 294 public static function is_view_builder_page() {
529 295 global $pagenow;
530 296
@@ -534,10 +300,10 @@
534 300
535 301 $post_type = self::simple_get( 'post_type', 'sanitize_title' );
536 302
537 303 if ( empty( $post_type ) ) {
538 - $post_id = self::simple_get( 'post', 'absint' );
539 - $post = get_post( $post_id );
304 + $post_id = self::simple_get( 'post', 'absint' );
305 + $post = get_post( $post_id );
540 306 $post_type = $post ? $post->post_type : '';
541 307 }
542 308
543 309 return $post_type === 'frm_display';
@@ -547,15 +313,17 @@
547 313 * Check for the form preview page
548 314 *
549 315 * @since 2.0
550 316 *
551 - * @return bool
317 + * @param None
318 + *
319 + * @return boolean
552 320 */
553 321 public static function is_preview_page() {
554 322 global $pagenow;
555 323 $action = self::simple_get( 'action', 'sanitize_title' );
556 324
557 - return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview';
325 + return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview';
558 326 }
559 327
560 328 /**
561 329 * Check for ajax except the form preview page
@@ -561,17 +329,16 @@
561 329 * Check for ajax except the form preview page
562 330 *
563 331 * @since 2.0
564 332 *
565 - * @return bool
333 + * @param None
334 + *
335 + * @return boolean
566 336 */
567 337 public static function doing_ajax() {
568 338 return wp_doing_ajax() && ! self::is_preview_page();
569 339 }
570 340
571 - /**
572 - * @return string
573 - */
574 341 public static function js_suffix() {
575 342 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
576 343 }
577 344
@@ -576,14 +343,13 @@
576 343 }
577 344
578 345 /**
579 346 * @since 2.0.8
580 - *
581 - * @return bool
582 347 */
583 348 public static function prevent_caching() {
584 349 global $frm_vars;
585 - return ! empty( $frm_vars['prevent_caching'] );
350 +
351 + return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching'];
586 352 }
587 353
588 354 /**
589 355 * Check if on an admin page
@@ -589,9 +355,9 @@
589 355 * Check if on an admin page
590 356 *
591 357 * @since 2.0
592 358 *
593 - * @return bool
359 + * @return boolean
594 360 */
595 361 public static function is_admin() {
596 362 $is_admin = is_admin() && ! wp_doing_ajax();
597 363
@@ -596,9 +362,8 @@
596 362 $is_admin = is_admin() && ! wp_doing_ajax();
597 363
598 364 /**
599 365 * @since 6.0
600 - *
601 366 * @param bool $is_admin
602 367 */
603 368 return apply_filters( 'frm_is_admin', $is_admin );
604 369 }
@@ -607,23 +372,17 @@
607 372 * Check if value contains blank value or empty array
608 373 *
609 374 * @since 2.0
610 375 *
611 - * @param mixed $value Value to check.
612 - * @param string $empty
376 + * @param mixed $value - value to check
377 + * @param string
613 378 *
614 - * @return bool
379 + * @return boolean
615 380 */
616 381 public static function is_empty_value( $value, $empty = '' ) {
617 382 return ( is_array( $value ) && empty( $value ) ) || $value === $empty;
618 383 }
619 384
620 - /**
621 - * @param mixed $value
622 - * @param string $empty
623 - *
624 - * @return bool
625 - */
626 385 public static function is_not_empty_value( $value, $empty = '' ) {
627 386 return ! self::is_empty_value( $value, $empty );
628 387 }
629 388
@@ -675,12 +434,10 @@
675 434 continue;
676 435 }
677 436
678 437 $key = self::get_server_value( $key );
679 -
680 438 foreach ( explode( ',', $key ) as $ip ) {
681 - // Just to be safe.
682 - $ip = trim( $ip );
439 + $ip = trim( $ip ); // Just to be safe.
683 440
684 441 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
685 442 return sanitize_text_field( $ip );
686 443 }
@@ -733,16 +490,8 @@
733 490 */
734 491 return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
735 492 }
736 493
737 - /**
738 - * @param string $param
739 - * @param mixed $default
740 - * @param string $src
741 - * @param callable|string $sanitize
742 - *
743 - * @return mixed
744 - */
745 494 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
746 495 if ( strpos( $param, '[' ) ) {
747 496 $params = explode( '[', $param );
748 497 $param = $params[0];
@@ -749,9 +498,8 @@
749 498 }
750 499
751 500 if ( $src === 'get' ) {
752 501 $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 502 if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
755 503 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
756 504 $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
757 505 }
@@ -773,9 +521,9 @@
773 521 continue;
774 522 }
775 523
776 524 $p = trim( $p, ']' );
777 - $value = $value[ $p ] ?? $default;
525 + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default;
778 526 }
779 527 }
780 528
781 529 return $value;
@@ -780,25 +528,15 @@
780 528
781 529 return $value;
782 530 }
783 531
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 532 public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) {
795 533 return self::get_simple_request(
796 534 array(
797 - 'type' => 'post',
798 - 'param' => $param,
799 - 'default' => $default,
800 - 'sanitize' => $sanitize,
535 + 'type' => 'post',
536 + 'param' => $param,
537 + 'default' => $default,
538 + 'sanitize' => $sanitize,
801 539 'serialized' => $serialized,
802 540 )
803 541 );
804 542 }
@@ -809,9 +547,9 @@
809 547 * @param string $param
810 548 * @param string $sanitize
811 549 * @param string $default
812 550 *
813 - * @return array|string
551 + * @return string|array
814 552 */
815 553 public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) {
816 554 return self::get_simple_request(
817 555 array(
@@ -829,22 +567,21 @@
829 567 * @since 2.0.6
830 568 *
831 569 * @param array $args
832 570 *
833 - * @return array|string
571 + * @return string|array
834 572 */
835 573 public static function get_simple_request( $args ) {
836 574 $defaults = array(
837 - 'param' => '',
838 - 'default' => '',
839 - 'type' => 'get',
840 - 'sanitize' => 'sanitize_text_field',
575 + 'param' => '',
576 + 'default' => '',
577 + 'type' => 'get',
578 + 'sanitize' => 'sanitize_text_field',
841 579 'serialized' => false,
842 580 );
843 581 $args = wp_parse_args( $args, $defaults );
844 582
845 583 $value = $args['default'];
846 -
847 584 if ( $args['type'] === 'get' ) {
848 585 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
849 586 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
850 587 $value = wp_unslash( $_GET[ $args['param'] ] );
@@ -852,17 +589,17 @@
852 589 } elseif ( $args['type'] === 'post' ) {
853 590 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
854 591 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
855 592 $value = wp_unslash( $_POST[ $args['param'] ] );
856 -
857 593 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
858 594 self::unserialize_or_decode( $value );
859 595 }
860 596 }
861 - } elseif ( isset( $_REQUEST[ $args['param'] ] ) ) {
862 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
597 + } else {
598 + if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
863 599 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
864 600 $value = wp_unslash( $_REQUEST[ $args['param'] ] );
601 + }
865 602 }
866 603
867 604 self::sanitize_value( $args['sanitize'], $value );
868 605
@@ -886,48 +623,23 @@
886 623
887 624 return $value;
888 625 }
889 626
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 627 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 ] );
628 + if ( ! empty( $sanitize ) ) {
629 + if ( is_array( $value ) ) {
630 + $temp_values = $value;
631 + foreach ( $temp_values as $k => $v ) {
632 + self::sanitize_value( $sanitize, $value[ $k ] );
633 + }
634 + } else {
635 + $value = call_user_func( $sanitize, $value );
914 636 }
915 - return;
916 637 }
917 -
918 - $value = call_user_func( $sanitize, $value );
919 638 }
920 639
921 - /**
922 - * @param array $sanitize_method
923 - * @param array $values
924 - *
925 - * @return void
926 - */
927 640 public static function sanitize_request( $sanitize_method, &$values ) {
928 641 $temp_values = $values;
929 -
930 642 foreach ( $temp_values as $k => $val ) {
931 643 if ( isset( $sanitize_method[ $k ] ) ) {
932 644 $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val );
933 645 }
@@ -935,64 +647,23 @@
935 647 }
936 648
937 649 /**
938 650 * @since 4.0.04
939 - *
940 - * @param mixed $value
941 - *
942 - * @return void
943 651 */
944 652 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 - }
653 + self::sanitize_value( 'wp_kses_post', $value );
951 654 self::decode_specialchars( $value );
952 655 }
953 656
954 657 /**
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 658 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&amp;'
985 659 * this MUST be done, else we'll be back to the '& entity' problem.
986 660 *
987 661 * @since 4.0.04
988 - *
989 - * @param mixed $value Value to decode, passed by reference.
990 662 */
991 663 public static function decode_specialchars( &$value ) {
992 664 if ( is_array( $value ) ) {
993 665 $temp_values = $value;
994 -
995 666 foreach ( $temp_values as $k => $v ) {
996 667 self::decode_specialchars( $value[ $k ] );
997 668 }
998 669 } else {
@@ -1006,9 +677,9 @@
1006 677 * Adapted from wp_specialchars_decode().
1007 678 *
1008 679 * @since 4.03.01
1009 680 *
1010 - * @param string $string The string to prep, passed by reference.
681 + * @param string $string The string to prep.
1011 682 */
1012 683 private static function decode_amp( &$string ) {
1013 684 // Don't bother if there are no entities - saves a lot of processing
1014 685 if ( empty( $string ) || strpos( $string, '&' ) === false ) {
@@ -1018,12 +689,10 @@
1018 689 $translation = array(
1019 690 '&quot;' => '"',
1020 691 '&#034;' => '"',
1021 692 '&#x22;' => '"',
1022 - // The space preserves the HTML.
1023 - '&lt; ' => '< ',
1024 - // The space preserves the HTML.
1025 - '&#060; ' => '< ',
693 + '&lt; ' => '< ', // The space preserves the HTML.
694 + '&#060; ' => '< ', // The space preserves the HTML.
1026 695 '&gt;' => '>',
1027 696 '&#062;' => '>',
1028 697 '&amp;' => '&',
1029 698 '&#038;' => '&',
@@ -1050,10 +719,10 @@
1050 719 * Sanitize the value, and allow some HTML
1051 720 *
1052 721 * @since 2.0
1053 722 *
1054 - * @param string $value The value to sanitize.
1055 - * @param array|string $allowed Allowed HTML tags and attributes, or 'all' for defaults.
723 + * @param string $value
724 + * @param array|string $allowed 'all' for everything included as defaults
1056 725 *
1057 726 * @return string
1058 727 */
1059 728 public static function kses( $value, $allowed = array() ) {
@@ -1062,28 +731,13 @@
1062 731 return wp_kses( $value, $allowed_html );
1063 732 }
1064 733
1065 734 /**
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 735 * The regular kses function strips [button_action] from submit button HTML.
1081 736 *
1082 737 * @since 5.0.13
1083 738 *
1084 739 * @param string $html
1085 - *
1086 740 * @return string
1087 741 */
1088 742 public static function kses_submit_button( $html ) {
1089 743 $included_button_action = false !== strpos( $html, '[button_action]' );
@@ -1093,9 +747,8 @@
1093 747 add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1094 748 $html = self::kses( $html, 'all' );
1095 749 remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
1096 750 remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
1097 -
1098 751 if ( $included_button_action ) {
1099 752 if ( false !== strpos( $html, '<input type="submit"' ) ) {
1100 753 $pattern = '/(<input type="submit")([^>]*)(\/>)/';
1101 754 $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
@@ -1103,13 +756,11 @@
1103 756 $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
1104 757 $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
1105 758 }
1106 759 }
1107 -
1108 760 if ( $included_back_hook ) {
1109 761 $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html );
1110 762 }
1111 -
1112 763 if ( $included_draft_hook ) {
1113 764 $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
1114 765 }
1115 766 return $html;
@@ -1118,9 +769,8 @@
1118 769 /**
1119 770 * @since 5.0.13
1120 771 *
1121 772 * @param array $allowed_attr
1122 - *
1123 773 * @return array
1124 774 */
1125 775 public static function allow_visibility_style( $allowed_attr ) {
1126 776 $allowed_attr[] = 'visibility';
@@ -1130,9 +780,8 @@
1130 780 /**
1131 781 * @since 5.0.13
1132 782 *
1133 783 * @param array $allowed_html
1134 - *
1135 784 * @return array
1136 785 */
1137 786 public static function add_allowed_submit_button_tags( $allowed_html ) {
1138 787 $allowed_html['input'] = array(
@@ -1149,22 +798,17 @@
1149 798 }
1150 799
1151 800 /**
1152 801 * @since 2.05.03
1153 - *
1154 - * @param array|string $allowed
1155 - *
1156 - * @return array
1157 802 */
1158 803 private static function allowed_html( $allowed ) {
1159 804 $html = self::safe_html();
1160 805 $allowed_html = array();
1161 -
1162 806 if ( $allowed === 'all' ) {
1163 807 $allowed_html = $html;
1164 808 } elseif ( ! empty( $allowed ) ) {
1165 809 foreach ( (array) $allowed as $a ) {
1166 - $allowed_html[ $a ] = $html[ $a ] ?? array();
810 + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
1167 811 }
1168 812 }
1169 813
1170 814 return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html );
@@ -1179,9 +823,9 @@
1179 823 'id' => true,
1180 824 );
1181 825
1182 826 return array(
1183 - 'a' => array(
827 + 'a' => array(
1184 828 'class' => true,
1185 829 'href' => true,
1186 830 'id' => true,
1187 831 'rel' => true,
@@ -1250,16 +894,16 @@
1250 894 'cite' => true,
1251 895 'title' => true,
1252 896 ),
1253 897 '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,
898 + 'class' => true,
899 + 'fill' => true,
900 + 'height' => true,
901 + 'width' => true,
902 + 'x' => true,
903 + 'y' => true,
904 + 'rx' => true,
905 + 'stroke' => true,
1262 906 'stroke-opacity' => true,
1263 907 'stroke-width' => true,
1264 908 ),
1265 909 'section' => $allow_class,
@@ -1294,9 +938,9 @@
1294 938 'xlink:href' => true,
1295 939 ),
1296 940 'ul' => $allow_class,
1297 941 'label' => array(
1298 - 'for' => true,
942 + 'for' => true,
1299 943 'class' => true,
1300 944 'id' => true,
1301 945 ),
1302 946 'button' => array(
@@ -1305,13 +949,8 @@
1305 949 ),
1306 950 'legend' => array(
1307 951 'class' => true,
1308 952 ),
1309 - 'option' => array(
1310 - 'class' => true,
1311 - 'value' => true,
1312 - 'selected' => true,
1313 - ),
1314 953 );
1315 954 }
1316 955
1317 956 /**
@@ -1319,20 +958,18 @@
1319 958 *
1320 959 * @since 2.0
1321 960 */
1322 961 public static function remove_get_action() {
1323 - if ( empty( $_GET ) ) {
962 + if ( ! isset( $_GET ) ) {
1324 963 return;
1325 964 }
1326 965
1327 966 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
1328 -
1329 967 if ( empty( $action_name ) ) {
1330 968 return;
1331 969 }
1332 970
1333 971 $new_action = self::get_param( $action_name, '', 'get', 'sanitize_text_field' );
1334 -
1335 972 if ( ! empty( $new_action ) ) {
1336 973 $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) );
1337 974 }
1338 975 }
@@ -1340,13 +977,9 @@
1340 977 /**
1341 978 * Check the WP query for a parameter
1342 979 *
1343 980 * @since 2.0
1344 - *
1345 - * @param array|string $value
1346 - * @param string $param
1347 - *
1348 - * @return array|string
981 + * @return string|array
1349 982 */
1350 983 public static function get_query_var( $value, $param ) {
1351 984 if ( $value != '' ) {
1352 985 return $value;
@@ -1352,9 +985,8 @@
1352 985 return $value;
1353 986 }
1354 987
1355 988 global $wp_query;
1356 -
1357 989 if ( isset( $wp_query->query_vars[ $param ] ) ) {
1358 990 $value = $wp_query->query_vars[ $param ];
1359 991 }
1360 992
@@ -1364,17 +996,13 @@
1364 996 /**
1365 997 * Try to show the SVG if possible. Otherwise, use the font icon.
1366 998 *
1367 999 * @since 4.0.02
1368 - *
1369 1000 * @param string $class
1370 1001 * @param array $atts
1371 - *
1372 - * @return string|null
1373 1002 */
1374 1003 public static function icon_by_class( $class, $atts = array() ) {
1375 1004 $echo = ! isset( $atts['echo'] ) || $atts['echo'];
1376 -
1377 1005 if ( isset( $atts['echo'] ) ) {
1378 1006 unset( $atts['echo'] );
1379 1007 }
1380 1008
@@ -1381,17 +1009,14 @@
1381 1009 $html_atts = self::array_to_html_params( $atts );
1382 1010
1383 1011 $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
1384 1012
1385 - // Replace icons that have been removed or renamed.
1013 + // Replace icons that have been removed.
1386 1014 $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',
1015 + 'frm_clone_solid_icon' => 'frm_clone_icon',
1390 1016 );
1391 -
1392 1017 if ( isset( $deprecated[ $icon ] ) ) {
1393 - $icon = $deprecated[ $icon ];
1018 + $icon = $deprecated[ $icon ];
1394 1019 $class = str_replace( $icon, $deprecated[ $icon ], $class );
1395 1020 }
1396 1021
1397 1022 if ( $icon === $class ) {
@@ -1397,15 +1022,15 @@
1397 1022 if ( $icon === $class ) {
1398 1023 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
1399 1024 } else {
1400 1025 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
1401 -
1402 1026 if ( strpos( $icon, ' ' ) ) {
1403 1027 $icon = explode( ' ', $icon );
1404 1028 $icon = reset( $icon );
1405 1029 }
1406 -
1407 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>';
1030 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
1031 + <use xlink:href="#' . esc_attr( $icon ) . '" />
1032 + </svg>';
1408 1033 }
1409 1034
1410 1035 if ( $echo ) {
1411 1036 echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -1419,9 +1044,8 @@
1419 1044 *
1420 1045 * @since 5.0.13
1421 1046 *
1422 1047 * @param string $icon
1423 - *
1424 1048 * @return string
1425 1049 */
1426 1050 public static function kses_icon( $icon ) {
1427 1051 add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
@@ -1437,15 +1061,13 @@
1437 1061 /**
1438 1062 * @since 5.0.13.1
1439 1063 *
1440 1064 * @param array $allowed_html
1441 - *
1442 1065 * @return array
1443 1066 */
1444 1067 public static function add_allowed_icon_tags( $allowed_html ) {
1445 1068 $allowed_html['svg']['data-open'] = true;
1446 1069 $allowed_html['svg']['title'] = true;
1447 - $allowed_html['svg']['tabindex'] = true;
1448 1070 return $allowed_html;
1449 1071 }
1450 1072
1451 1073 /**
@@ -1451,9 +1073,8 @@
1451 1073 /**
1452 1074 * @since 5.0.13
1453 1075 *
1454 1076 * @param array $allowed_attr
1455 - *
1456 1077 * @return array
1457 1078 */
1458 1079 public static function allow_vars_in_styles( $allowed_attr ) {
1459 1080 $allowed_attr[] = '--primary-700';
@@ -1477,14 +1098,12 @@
1477 1098 /**
1478 1099 * @since 5.0.13
1479 1100 *
1480 1101 * @param string $value
1481 - *
1482 1102 * @return bool
1483 1103 */
1484 1104 private static function is_a_valid_color( $value ) {
1485 1105 $match = 0;
1486 -
1487 1106 if ( 0 === strpos( $value, 'rgba(' ) ) {
1488 1107 $match = preg_match( '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/', $value );
1489 1108 } elseif ( 0 === strpos( $value, 'rgb(' ) ) {
1490 1109 $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value );
@@ -1497,9 +1116,8 @@
1497 1116 /**
1498 1117 * Include svg images.
1499 1118 *
1500 1119 * @since 4.0.02
1501 - *
1502 1120 * @return void
1503 1121 */
1504 1122 public static function include_svg() {
1505 1123 if ( self::$included_svg ) {
@@ -1518,13 +1136,12 @@
1518 1136 * @since 5.0.13 added $echo parameter.
1519 1137 *
1520 1138 * @param array $atts
1521 1139 * @param bool $echo
1522 - *
1523 1140 * @return string|void
1524 1141 */
1525 1142 public static function array_to_html_params( $atts, $echo = false ) {
1526 - $callback = function () use ( $atts ) {
1143 + $callback = function() use ( $atts ) {
1527 1144 if ( $atts ) {
1528 1145 foreach ( $atts as $key => $value ) {
1529 1146 echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1530 1147 }
@@ -1539,10 +1156,9 @@
1539 1156 * @since 5.0.13
1540 1157 *
1541 1158 * @param Closure $echo_function
1542 1159 * @param bool $echo
1543 - *
1544 - * @return string|null
1160 + * @return string|void
1545 1161 */
1546 1162 public static function clip( $echo_function, $echo = false ) {
1547 1163 if ( ! $echo ) {
1548 1164 ob_start();
@@ -1560,25 +1176,19 @@
1560 1176 }
1561 1177
1562 1178 /**
1563 1179 * @since 3.0
1564 - *
1565 - * @param array $atts
1566 - *
1567 - * @return void
1568 1180 */
1569 1181 public static function get_admin_header( $atts ) {
1570 - $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] );
1571 -
1572 - if ( empty( $atts['close'] ) ) {
1182 + $has_nav = ( isset( $atts['form'] ) && ! empty( $atts['form'] ) && ( ! isset( $atts['is_template'] ) || ! $atts['is_template'] ) );
1183 + if ( ! isset( $atts['close'] ) || empty( $atts['close'] ) ) {
1573 1184 $atts['close'] = admin_url( 'admin.php?page=formidable' );
1574 1185 }
1575 -
1576 1186 if ( ! isset( $atts['import_link'] ) ) {
1577 1187 $atts['import_link'] = false;
1578 1188 }
1579 1189
1580 - include self::plugin_path() . '/classes/views/shared/admin-header.php';
1190 + include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1581 1191 }
1582 1192
1583 1193 /**
1584 1194 * @since 6.0
@@ -1583,9 +1193,8 @@
1583 1193 /**
1584 1194 * @since 6.0
1585 1195 *
1586 1196 * @param string $type
1587 - *
1588 1197 * @return void
1589 1198 */
1590 1199 public static function import_link( $type = 'secondary' ) {
1591 1200 ?>
@@ -1600,9 +1209,8 @@
1600 1209 *
1601 1210 * @since 5.4.2
1602 1211 *
1603 1212 * @param bool $should_show_lite_upgrade
1604 - *
1605 1213 * @return void
1606 1214 */
1607 1215 public static function print_admin_banner( $should_show_lite_upgrade ) {
1608 1216 if ( ! current_user_can( 'administrator' ) ) {
@@ -1609,9 +1217,9 @@
1609 1217 FrmInbox::maybe_show_banner();
1610 1218 return;
1611 1219 }
1612 1220
1613 - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1221 + if ( self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1614 1222 // Print license warning or inbox banner and exit if either prints.
1615 1223 // And exit before printing the upgrade bar if it shouldn't be shown.
1616 1224 return;
1617 1225 }
@@ -1616,37 +1224,10 @@
1616 1224 return;
1617 1225 }
1618 1226 ?>
1619 1227 <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>
1228 + <span>You're using Formidable Forms Lite. To unlock more features consider</span>
1229 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'top-bar' ) ); ?>" target="_blank" rel="noopener">upgrading to Pro</a>.
1649 1230 </div>
1650 1231 <?php
1651 1232 }
1652 1233
@@ -1662,18 +1243,14 @@
1662 1243 /**
1663 1244 * Render a button for a new item (Form, Application, etc).
1664 1245 *
1665 1246 * @since 3.0
1666 - *
1667 1247 * @param array $atts {
1668 - * Details about the button.
1669 - *
1670 1248 * @type array $link_hook Custom link hook, calls do_action and exits early.
1671 1249 * @type string $new_link Href value, default #.
1672 1250 * @type string $class Custom class names, space separated.
1673 1251 * @type string $button_text Button text. Default "Add New".
1674 1252 * }
1675 - *
1676 1253 * @return void
1677 1254 */
1678 1255 public static function add_new_item_link( $atts ) {
1679 1256 if ( isset( $atts['link_hook'] ) ) {
@@ -1699,12 +1276,8 @@
1699 1276 }
1700 1277
1701 1278 /**
1702 1279 * @since 3.06
1703 - *
1704 - * @param array $atts
1705 - *
1706 - * @return void
1707 1280 */
1708 1281 public static function show_search_box( $atts ) {
1709 1282 $defaults = array(
1710 1283 'placeholder' => '',
@@ -1710,12 +1283,10 @@
1710 1283 'placeholder' => '',
1711 1284 'tosearch' => '',
1712 1285 'text' => __( 'Search', 'formidable' ),
1713 1286 'input_id' => '',
1714 - 'value' => false,
1715 - 'class' => '',
1716 1287 );
1717 - $atts = array_merge( $defaults, $atts );
1288 + $atts = array_merge( $defaults, $atts );
1718 1289
1719 1290 if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) {
1720 1291 $atts['tosearch'] = 'frm-card';
1721 1292 }
@@ -1720,9 +1291,8 @@
1720 1291 $atts['tosearch'] = 'frm-card';
1721 1292 }
1722 1293
1723 1294 $class = 'frm-search-input';
1724 -
1725 1295 if ( ! empty( $atts['tosearch'] ) ) {
1726 1296 $class .= ' frm-auto-search';
1727 1297 }
1728 1298
@@ -1727,34 +1297,21 @@
1727 1297 }
1728 1298
1729 1299 $input_id = $atts['input_id'] . '-search-input';
1730 1300
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 1301 ?>
1751 - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>">
1302 + <p class="frm-search">
1752 1303 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>">
1753 1304 <?php echo esc_html( $atts['text'] ); ?>:
1754 1305 </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 ); ?> />
1306 + <span class="frmfont frm_search_icon"></span>
1307 + <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s"
1308 + value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( $atts['placeholder'] ); ?>"
1309 + class="<?php echo esc_attr( $class ); ?>" data-tosearch="<?php echo esc_attr( $atts['tosearch'] ); ?>"
1310 + <?php if ( ! empty( $atts['tosearch'] ) ) { ?>
1311 + autocomplete="off"
1312 + <?php } ?>
1313 + />
1757 1314 <?php
1758 1315 if ( empty( $atts['tosearch'] ) ) {
1759 1316 submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
1760 1317 }
@@ -1763,17 +1320,13 @@
1763 1320 <?php
1764 1321 }
1765 1322
1766 1323 /**
1767 - * @param string $type Hook type slug.
1768 - * @param object|null $object Optional related object.
1769 - *
1770 - * @return void
1324 + * @param string $type
1771 1325 */
1772 1326 public static function trigger_hook_load( $type, $object = null ) {
1773 1327 // Only load the form hooks once.
1774 1328 $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object );
1775 -
1776 1329 if ( ! $hooks_loaded ) {
1777 1330 do_action( 'frm_load_' . $type . '_hooks' );
1778 1331 }
1779 1332 }
@@ -1813,9 +1366,9 @@
1813 1366 'new_file_path' => self::plugin_path() . '/js',
1814 1367 )
1815 1368 );
1816 1369 $new_file = new FrmCreateFile( $file_atts );
1817 - $files = array(
1370 + $files = array(
1818 1371 FrmStrpLiteAppHelper::plugin_path() . 'js/frmstrp.min.js',
1819 1372 );
1820 1373
1821 1374 /**
@@ -1832,14 +1385,14 @@
1832 1385 * True when value is 1, true, 'true', 'yes'
1833 1386 *
1834 1387 * @since 1.07.10
1835 1388 *
1836 - * @param string $value The value to compare.
1389 + * @param string $value The value to compare
1837 1390 *
1838 - * @return bool
1391 + * @return boolean True or False
1839 1392 */
1840 1393 public static function is_true( $value ) {
1841 - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value;
1394 + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value );
1842 1395 }
1843 1396
1844 1397 /**
1845 1398 * Gets all post from a specific post type.
@@ -1847,9 +1400,8 @@
1847 1400 *
1848 1401 * @since 4.10.01 Add `$post_type` argument.
1849 1402 *
1850 1403 * @param string $post_type Post type to query. Default is `page`.
1851 - *
1852 1404 * @return WP_Post[]
1853 1405 */
1854 1406 public static function get_pages( $post_type = 'page' ) {
1855 1407 $query = array(
@@ -1868,9 +1420,8 @@
1868 1420 *
1869 1421 * @since 5.0.09
1870 1422 *
1871 1423 * @param string $post_type Post type to query. Default is `page`.
1872 - *
1873 1424 * @return array
1874 1425 */
1875 1426 public static function get_post_ids_and_titles( $post_type = 'page' ) {
1876 1427 return FrmDb::get_results(
@@ -1899,9 +1450,9 @@
1899 1450 $args = self::preformat_selection_args( $args );
1900 1451
1901 1452 $pages_count = wp_count_posts( $args['post_type'] );
1902 1453
1903 - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) {
1454 + if ( $pages_count->publish <= 50 ) {
1904 1455 self::wp_pages_dropdown( $args );
1905 1456 return;
1906 1457 }
1907 1458
@@ -1907,9 +1458,9 @@
1907 1458
1908 1459 wp_enqueue_script( 'jquery-ui-autocomplete' );
1909 1460
1910 1461 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1911 - $title = '';
1462 + $title = '';
1912 1463
1913 1464 if ( $selected ) {
1914 1465 $title = get_the_title( $selected );
1915 1466 }
@@ -1925,116 +1476,18 @@
1925 1476 <?php
1926 1477 }
1927 1478
1928 1479 /**
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.
1480 + * @param array $args
1481 + * @param string $page_id Deprecated.
1482 + * @param boolean $truncate Deprecated.
1934 1483 */
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 1484 public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) {
2033 1485 self::prep_page_dropdown_params( $page_id, $truncate, $args );
2034 1486
2035 1487 $pages = self::get_post_ids_and_titles( $args['post_type'] );
2036 1488 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1489 +
2037 1490 ?>
2038 1491 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
2039 1492 <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option>
2040 1493 <?php foreach ( $pages as $page ) { ?>
@@ -2050,14 +1503,8 @@
2050 1503 * Fill in missing parameters passed to wp_pages_dropdown().
2051 1504 * This is for reverse compatibility with switching 3 params to 1.
2052 1505 *
2053 1506 * @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 1507 */
2061 1508 private static function prep_page_dropdown_params( $page_id, $truncate, &$args ) {
2062 1509 if ( ! is_array( $args ) ) {
2063 1510 $args = array(
@@ -2074,20 +1521,16 @@
2074 1521 * Filter to format args for page dropdown or autocomplete
2075 1522 *
2076 1523 * @since 4.03.06
2077 1524 * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array.
2078 - *
2079 - * @param array $args
2080 - *
2081 - * @return array
2082 1525 */
2083 1526 private static function preformat_selection_args( $args ) {
2084 1527 $defaults = array(
2085 - 'truncate' => false,
2086 - 'placeholder' => ' ',
2087 - 'field_name' => '',
2088 - 'page_id' => '',
2089 - 'post_type' => 'page',
1528 + 'truncate' => false,
1529 + 'placeholder' => ' ',
1530 + 'field_name' => '',
1531 + 'page_id' => '',
1532 + 'post_type' => 'page',
2090 1533 'autocomplete_placeholder' => __( 'Select a Page', 'formidable' ),
2091 1534 );
2092 1535
2093 1536 return array_merge( $defaults, $args );
@@ -2092,16 +1535,10 @@
2092 1535
2093 1536 return array_merge( $defaults, $args );
2094 1537 }
2095 1538
2096 - /**
2097 - * @param int $post_id
2098 - *
2099 - * @return string
2100 - */
2101 1539 public static function post_edit_link( $post_id ) {
2102 1540 $post = get_post( $post_id );
2103 -
2104 1541 if ( $post ) {
2105 1542 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
2106 1543
2107 1544 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
@@ -2131,9 +1568,8 @@
2131 1568 * @since 5.5.3
2132 1569 * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
2133 1570 *
2134 1571 * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
2135 - *
2136 1572 * @return bool
2137 1573 */
2138 1574 public static function is_style_editor_page( $view = '' ) {
2139 1575 if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
@@ -2165,16 +1601,25 @@
2165 1601 return self::is_admin_page( 'formidable-views-editor' );
2166 1602 }
2167 1603
2168 1604 /**
2169 - * @param string $field_name
2170 - * @param array|string $capability
2171 - * @param string $multiple 'single' and 'multiple'.
1605 + * @since 4.0
1606 + * @deprecated 5.5.3
2172 1607 */
1608 + public static function maybe_full_screen_link( $link ) {
1609 + _deprecated_function( __METHOD__, '5.5.3' );
1610 + return $link;
1611 + }
1612 +
1613 + /**
1614 + * @param string $field_name
1615 + * @param string|array $capability
1616 + * @param string $multiple 'single' and 'multiple'
1617 + */
2173 1618 public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
2174 1619 ?>
2175 1620 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>"
2176 - <?php echo 'multiple' === $multiple ? 'multiple="multiple"' : ''; ?>
1621 + <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?>
2177 1622 class="frm_multiselect">
2178 1623 <?php self::roles_options( $capability ); ?>
2179 1624 </select>
2180 1625 <?php
@@ -2181,11 +1626,10 @@
2181 1626 }
2182 1627
2183 1628 /**
2184 1629 * @since 4.07
2185 - *
2186 1630 * @param array|string $selected
2187 - * @param string $current
1631 + * @param string $current
2188 1632 */
2189 1633 private static function selected( $selected, $current ) {
2190 1634 if ( is_callable( 'FrmProAppHelper::selected' ) ) {
2191 1635 FrmProAppHelper::selected( $selected, $current );
@@ -2194,13 +1638,12 @@
2194 1638 }
2195 1639 }
2196 1640
2197 1641 /**
2198 - * @param array|string $capability
1642 + * @param string|array $capability
2199 1643 */
2200 1644 public static function roles_options( $capability ) {
2201 1645 global $frm_vars;
2202 -
2203 1646 if ( isset( $frm_vars['editable_roles'] ) ) {
2204 1647 $editable_roles = $frm_vars['editable_roles'];
2205 1648 } else {
2206 1649 $editable_roles = get_editable_roles();
@@ -2209,9 +1652,9 @@
2209 1652
2210 1653 foreach ( $editable_roles as $role => $details ) {
2211 1654 $name = translate_user_role( $details['name'] );
2212 1655 ?>
2213 - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option>
1656 + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_attr( $name ); ?> </option>
2214 1657 <?php
2215 1658 unset( $role, $details );
2216 1659 }
2217 1660 }
@@ -2221,9 +1664,8 @@
2221 1664 *
2222 1665 * @since 5.0 Parameter `$type` supports `pro_only` value.
2223 1666 *
2224 1667 * @param string $type Supports `auto`, `pro`, or `pro_only`.
2225 - *
2226 1668 * @return array
2227 1669 */
2228 1670 public static function frm_capabilities( $type = 'auto' ) {
2229 1671 if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
@@ -2241,8 +1683,14 @@
2241 1683 * @param array<string,string> $pro_cap
2242 1684 */
2243 1685 $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
2244 1686
1687 + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) {
1688 + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date.
1689 + // This was added in 6.5.4. Remove this in the future.
1690 + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
1691 + }
1692 +
2245 1693 if ( 'pro_only' === $type ) {
2246 1694 return $pro_cap;
2247 1695 }
2248 1696
@@ -2257,9 +1705,9 @@
2257 1705 * @return array<string,string>
2258 1706 */
2259 1707 private static function get_lite_capabilities() {
2260 1708 return array(
2261 - 'frm_view_forms' => __( 'View Forms List', 'formidable' ),
1709 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
2262 1710 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
2263 1711 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
2264 1712 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
2265 1713 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
@@ -2300,10 +1748,9 @@
2300 1748 return current_user_can( $role );
2301 1749 }
2302 1750
2303 1751 /**
2304 - * @param array|string $needed_role
2305 - *
1752 + * @param string|array $needed_role
2306 1753 * @return bool
2307 1754 */
2308 1755 public static function user_has_permission( $needed_role ) {
2309 1756 if ( is_array( $needed_role ) ) {
@@ -2322,14 +1769,12 @@
2322 1769 return $can;
2323 1770 }
2324 1771
2325 1772 $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
2326 -
2327 1773 foreach ( $roles as $role ) {
2328 1774 if ( current_user_can( $role ) ) {
2329 1775 return true;
2330 1776 }
2331 -
2332 1777 if ( $role == $needed_role ) {
2333 1778 break;
2334 1779 }
2335 1780 }
@@ -2351,9 +1796,8 @@
2351 1796
2352 1797 $user_id = get_current_user_id();
2353 1798 $user = new WP_User( $user_id );
2354 1799 $frm_roles = self::frm_capabilities();
2355 -
2356 1800 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2357 1801 $user->add_cap( $frm_role );
2358 1802 unset( $frm_role, $frm_role_description );
2359 1803 }
@@ -2362,18 +1806,13 @@
2362 1806 /**
2363 1807 * Make sure admins have permission to see the menu items
2364 1808 *
2365 1809 * @since 2.0.6
2366 - *
2367 - * @param string $cap
2368 - *
2369 - * @return void
2370 1810 */
2371 1811 public static function force_capability( $cap = 'frm_change_settings' ) {
2372 1812 if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) {
2373 1813 $role = get_role( 'administrator' );
2374 1814 $frm_roles = self::frm_capabilities();
2375 -
2376 1815 foreach ( $frm_roles as $frm_role => $frm_role_description ) {
2377 1816 $role->add_cap( $frm_role );
2378 1817 }
2379 1818 }
@@ -2379,19 +1818,17 @@
2379 1818 }
2380 1819 }
2381 1820
2382 1821 /**
2383 - * Check if the user has permission for action.
1822 + * Check if the user has permision for action.
2384 1823 * Return permission message and stop the action if no permission
2385 1824 *
2386 1825 * @since 2.0
2387 1826 *
2388 1827 * @param string $permission
2389 - * @param string $show_message
2390 1828 */
2391 1829 public static function permission_check( $permission, $show_message = 'show' ) {
2392 1830 $permission_error = self::permission_nonce_error( $permission );
2393 -
2394 1831 if ( $permission_error !== false ) {
2395 1832 if ( 'hide' == $show_message ) {
2396 1833 $permission_error = '';
2397 1834 }
@@ -2404,10 +1841,8 @@
2404 1841 *
2405 1842 * @since 2.0
2406 1843 *
2407 1844 * @param string $permission
2408 - * @param string $nonce_name
2409 - * @param string $nonce
2410 1845 *
2411 1846 * @return false|string The permission message or false if allowed
2412 1847 */
2413 1848 public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) {
@@ -2417,15 +1852,13 @@
2417 1852 return $frm_settings->admin_permission;
2418 1853 }
2419 1854
2420 1855 $error = false;
2421 -
2422 1856 if ( empty( $nonce_name ) ) {
2423 1857 return $error;
2424 1858 }
2425 1859
2426 - $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2427 -
1860 + $nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : '';
2428 1861 if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) {
2429 1862 $frm_settings = self::get_settings();
2430 1863 $error = $frm_settings->admin_permission;
2431 1864 }
@@ -2432,14 +1865,8 @@
2432 1865
2433 1866 return $error;
2434 1867 }
2435 1868
2436 - /**
2437 - * @param array|string $values
2438 - * @param string $current
2439 - *
2440 - * @return void
2441 - */
2442 1869 public static function checked( $values, $current ) {
2443 1870 if ( self::check_selected( $values, $current ) ) {
2444 1871 echo ' checked="checked"';
2445 1872 }
@@ -2444,39 +1871,24 @@
2444 1871 echo ' checked="checked"';
2445 1872 }
2446 1873 }
2447 1874
2448 - /**
2449 - * @param array|string $values
2450 - * @param string $current
2451 - *
2452 - * @return bool
2453 - */
2454 1875 public static function check_selected( $values, $current ) {
2455 - $values = self::recursive_function_map( $values, 'trim' );
2456 - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1876 + $values = self::recursive_function_map( $values, 'trim' );
1877 + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' );
1878 + $current = htmlspecialchars_decode( trim( $current ) );
2457 1879
2458 - $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) );
2459 -
2460 1880 return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current );
2461 1881 }
2462 1882
2463 - /**
2464 - * @param array|string $value
2465 - * @param callable|string $function
2466 - *
2467 - * @return array|string
2468 - */
2469 1883 public static function recursive_function_map( $value, $function ) {
2470 1884 if ( is_array( $value ) ) {
2471 1885 $original_function = $function;
2472 -
2473 1886 if ( count( $value ) ) {
2474 1887 $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) );
2475 1888 } else {
2476 1889 $function = array( $function );
2477 1890 }
2478 -
2479 1891 if ( ! self::is_assoc( $value ) ) {
2480 1892 $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function );
2481 1893 } else {
2482 1894 foreach ( $value as $k => $v ) {
@@ -2485,38 +1897,14 @@
2485 1897 }
2486 1898 }
2487 1899 }
2488 1900 } else {
2489 - $value = self::maybe_update_value_if_null( $value, $function );
2490 1901 $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 1902 }
2510 1903
2511 1904 return $value;
2512 1905 }
2513 1906
2514 - /**
2515 - * @param array $array
2516 - *
2517 - * @return bool
2518 - */
2519 1907 public static function is_assoc( $array ) {
2520 1908 return (bool) count( array_filter( array_keys( $array ), 'is_string' ) );
2521 1909 }
2522 1910
@@ -2521,24 +1909,20 @@
2521 1909 }
2522 1910
2523 1911 /**
2524 1912 * Flatten a multi-dimensional array
2525 - *
2526 - * @param array $array
2527 - * @param string $keys
2528 - *
2529 - * @return array
2530 1913 */
2531 1914 public static function array_flatten( $array, $keys = 'keep' ) {
2532 1915 $return = array();
2533 -
2534 1916 foreach ( $array as $key => $value ) {
2535 1917 if ( is_array( $value ) ) {
2536 1918 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
2537 - } elseif ( $keys === 'keep' ) {
1919 + } else {
1920 + if ( $keys === 'keep' ) {
2538 1921 $return[ $key ] = $value;
2539 - } else {
2540 - $return[] = $value;
1922 + } else {
1923 + $return[] = $value;
1924 + }
2541 1925 }
2542 1926 }
2543 1927
2544 1928 return $return;
@@ -2543,43 +1927,16 @@
2543 1927
2544 1928 return $return;
2545 1929 }
2546 1930
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 1931 public static function esc_textarea( $text, $is_rich_text = false ) {
2569 1932 $safe_text = str_replace( '&quot;', '"', $text );
2570 -
2571 1933 if ( ! $is_rich_text ) {
2572 1934 $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
2573 1935 }
2574 -
2575 1936 $safe_text = str_replace( '&amp; ', '& ', $safe_text );
2576 1937
2577 - /**
2578 - * @param string $safe_text
2579 - * @param string $text
2580 - */
2581 - return (string) apply_filters( 'esc_textarea', $safe_text, $text );
1938 + return apply_filters( 'esc_textarea', $safe_text, $text );
2582 1939 }
2583 1940
2584 1941 /**
2585 1942 * Add auto paragraphs to text areas
@@ -2584,15 +1941,11 @@
2584 1941 /**
2585 1942 * Add auto paragraphs to text areas
2586 1943 *
2587 1944 * @since 2.0
2588 - *
2589 - * @param mixed $content
2590 - *
2591 - * @return mixed
2592 1945 */
2593 1946 public static function use_wpautop( $content ) {
2594 - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) {
1947 + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) {
2595 1948 $content = wpautop( str_replace( '<br>', '<br />', $content ) );
2596 1949 }
2597 1950
2598 1951 return $content;
@@ -2597,15 +1950,8 @@
2597 1950
2598 1951 return $content;
2599 1952 }
2600 1953
2601 - /**
2602 - * Replace quotes with their HTML entities.
2603 - *
2604 - * @param string $val
2605 - *
2606 - * @return string
2607 - */
2608 1954 public static function replace_quotes( $val ) {
2609 1955 // Replace double quotes.
2610 1956 $val = str_replace( array( '&#8220;', '&#8221;', '&#8243;' ), '"', $val );
2611 1957
@@ -2615,28 +1961,22 @@
2615 1961 return $val;
2616 1962 }
2617 1963
2618 1964 /**
2619 - * @param string $handle
2620 - * @param int|string $default
2621 - *
2622 - * @return int|string
1965 + * @param string $handle
2623 1966 */
2624 1967 public static function script_version( $handle, $default = 0 ) {
2625 1968 global $wp_scripts;
2626 -
2627 1969 if ( ! $wp_scripts ) {
2628 1970 return $default;
2629 1971 }
2630 1972
2631 1973 $ver = $default;
2632 -
2633 1974 if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
2634 1975 return $ver;
2635 1976 }
2636 1977
2637 1978 $query = $wp_scripts->registered[ $handle ];
2638 -
2639 1979 if ( is_object( $query ) && ! empty( $query->ver ) ) {
2640 1980 $ver = $query->ver;
2641 1981 }
2642 1982
@@ -2647,23 +1987,17 @@
2647 1987 * @since 5.0.13 added $echo param.
2648 1988 *
2649 1989 * @param string $url
2650 1990 * @param bool $echo
2651 - *
2652 - * @return string|null
1991 + * @return string|void
2653 1992 */
2654 1993 public static function js_redirect( $url, $echo = false ) {
2655 - $callback = function () use ( $url ) {
1994 + $callback = function() use ( $url ) {
2656 1995 echo '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
2657 1996 };
2658 1997 return self::clip( $callback, $echo );
2659 1998 }
2660 1999
2661 - /**
2662 - * @param int|string $user_id
2663 - *
2664 - * @return int|string
2665 - */
2666 2000 public static function get_user_id_param( $user_id ) {
2667 2001 if ( ! $user_id || is_numeric( $user_id ) ) {
2668 2002 return $user_id;
2669 2003 }
@@ -2668,9 +2002,8 @@
2668 2002 return $user_id;
2669 2003 }
2670 2004
2671 2005 $user_id = sanitize_text_field( $user_id );
2672 -
2673 2006 if ( $user_id === 'current' ) {
2674 2007 $user_id = get_current_user_id();
2675 2008 } else {
2676 2009 if ( is_email( $user_id ) ) {
@@ -2687,14 +2020,8 @@
2687 2020
2688 2021 return $user_id;
2689 2022 }
2690 2023
2691 - /**
2692 - * @param string $filename
2693 - * @param array $atts
2694 - *
2695 - * @return false|string
2696 - */
2697 2024 public static function get_file_contents( $filename, $atts = array() ) {
2698 2025 if ( ! is_file( $filename ) ) {
2699 2026 return false;
2700 2027 }
@@ -2700,9 +2027,9 @@
2700 2027 }
2701 2028
2702 2029 extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract
2703 2030 ob_start();
2704 - include $filename;
2031 + include( $filename );
2705 2032 $contents = ob_get_contents();
2706 2033 ob_end_clean();
2707 2034
2708 2035 return $contents;
@@ -2716,9 +2043,8 @@
2716 2043 * @param int $num_chars
2717 2044 */
2718 2045 public static function get_unique_key( $name, $table_name, $column, $id = 0, $num_chars = 5 ) {
2719 2046 $key = '';
2720 -
2721 2047 if ( $name ) {
2722 2048 $key = sanitize_key( $name );
2723 2049 $key = self::maybe_clear_long_key( $key, $column );
2724 2050 }
@@ -2758,9 +2084,9 @@
2758 2084 ++$suffix;
2759 2085 } while ( in_array( $key_check, $similar_keys, true ) );
2760 2086
2761 2087 $key = $key_check;
2762 - }//end if
2088 + }
2763 2089
2764 2090 return $key;
2765 2091 }
2766 2092
@@ -2769,18 +2095,15 @@
2769 2095 * The database limit is 100 for form and field keys so we want to avoid getting too close.
2770 2096 *
2771 2097 * @param string $column
2772 2098 * @param string $key
2773 - *
2774 2099 * @return string
2775 2100 */
2776 2101 private static function maybe_truncate_key_before_appending( $column, $key ) {
2777 2102 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2778 2103 $max_key_length_before_truncating = 60;
2779 -
2780 2104 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2781 2105 $key = substr( $key, 0, $max_key_length_before_truncating );
2782 -
2783 2106 if ( is_numeric( $key ) ) {
2784 2107 $key .= 'a';
2785 2108 }
2786 2109 }
@@ -2792,9 +2115,8 @@
2792 2115 * Possibly reset a key to avoid conflicts with column size limits.
2793 2116 *
2794 2117 * @param string $key
2795 2118 * @param string $column
2796 - *
2797 2119 * @return string either the original key value, or an empty string if the key was too long.
2798 2120 */
2799 2121 private static function maybe_clear_long_key( $key, $column ) {
2800 2122 if ( 'field_key' === $column && strlen( $key ) >= 70 ) {
@@ -2803,25 +2125,19 @@
2803 2125 return $key;
2804 2126 }
2805 2127
2806 2128 /**
2807 - * @since 6.21 This is changed from `private` to `public`.
2808 - *
2809 2129 * @param int $num_chars
2810 - *
2811 2130 * @return string
2812 2131 */
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 );
2132 + private static function generate_new_key( $num_chars ) {
2133 + $max_slug_value = pow( 36, $num_chars );
2134 + $min_slug_value = 37; // we want to have at least 2 characters in the slug
2135 + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2819 2136 }
2820 2137
2821 2138 /**
2822 2139 * @param string $key
2823 - *
2824 2140 * @return string
2825 2141 */
2826 2142 private static function prevent_numeric_and_reserved_keys( $key ) {
2827 2143 if ( is_numeric( $key ) ) {
@@ -2835,9 +2151,8 @@
2835 2151 'editlink',
2836 2152 'siteurl',
2837 2153 'evenodd',
2838 2154 );
2839 -
2840 2155 if ( in_array( $key, $not_allowed, true ) ) {
2841 2156 $key .= 'a';
2842 2157 }
2843 2158 }
@@ -2846,16 +2161,11 @@
2846 2161
2847 2162 /**
2848 2163 * Editing a Form or Entry
2849 2164 *
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
2165 + * @param string $table
2856 2166 *
2857 - * @return array|bool
2167 + * @return bool|array
2858 2168 */
2859 2169 public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
2860 2170 if ( ! $record ) {
2861 2171 return false;
@@ -2870,9 +2180,9 @@
2870 2180 'fields' => array(),
2871 2181 );
2872 2182
2873 2183 foreach ( array( 'name', 'description' ) as $var ) {
2874 - $default_val = $record->{$var} ?? '';
2184 + $default_val = isset( $record->{$var} ) ? $record->{$var} : '';
2875 2185 $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' );
2876 2186 unset( $var, $default_val );
2877 2187 }
2878 2188
@@ -2890,16 +2200,8 @@
2890 2200
2891 2201 return $values;
2892 2202 }
2893 2203
2894 - /**
2895 - * @param array|string $fields
2896 - * @param object $record
2897 - * @param array $values
2898 - * @param array $args
2899 - *
2900 - * @return void
2901 - */
2902 2204 private static function prepare_field_arrays( $fields, $record, array &$values, $args ) {
2903 2205 if ( ! empty( $fields ) ) {
2904 2206 foreach ( (array) $fields as $field ) {
2905 2207 if ( ! self::is_admin_page() ) {
@@ -2905,32 +2207,24 @@
2905 2207 if ( ! self::is_admin_page() ) {
2906 2208 // Don't prep default values on the form settings page.
2907 2209 $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true );
2908 2210 }
2909 - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
2211 + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
2910 2212 self::fill_field_defaults( $field, $record, $values, $args );
2911 2213 }
2912 2214 }
2913 2215 }
2914 2216
2915 - /**
2916 - * @param object $field
2917 - * @param object $record
2918 - * @param array $values
2919 - * @param array $args
2920 - *
2921 - * @return void
2922 - */
2923 2217 private static function fill_field_defaults( $field, $record, array &$values, $args ) {
2924 2218 $post_values = $args['post_values'];
2925 2219
2926 2220 if ( $args['default'] ) {
2927 2221 $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 -
2222 + } else {
2223 + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) {
2224 + if ( ! isset( $field->field_options['custom_field'] ) ) {
2225 + $field->field_options['custom_field'] = '';
2226 + }
2933 2227 $meta_value = FrmProEntryMetaHelper::get_post_value(
2934 2228 $record->post_id,
2935 2229 $field->field_options['post_field'],
2936 2230 $field->field_options['custom_field'],
@@ -2940,14 +2234,14 @@
2940 2234 'form_id' => $field->form_id,
2941 2235 'field' => $field,
2942 2236 )
2943 2237 );
2944 - } else {
2945 - $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2946 - }//end if
2238 + } else {
2239 + $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2240 + }
2241 + }
2947 2242
2948 - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type;
2949 -
2243 + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2950 2244 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2951 2245 $new_value = $post_values['item_meta'][ $field->id ];
2952 2246 self::unserialize_or_decode( $new_value );
2953 2247 } else {
@@ -2993,15 +2287,12 @@
2993 2287 );
2994 2288 }
2995 2289
2996 2290 /**
2997 - * @param object $record
2998 2291 * @param string $table
2999 - * @param array $post_values
3000 - * @param array $values
3001 2292 */
3002 2293 private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
3003 - if ( $table === 'entries' ) {
2294 + if ( $table == 'entries' ) {
3004 2295 $form = $record->form_id;
3005 2296 FrmForm::maybe_get_form( $form );
3006 2297 } else {
3007 2298 $form = $record;
@@ -3031,13 +2322,8 @@
3031 2322 }
3032 2323
3033 2324 /**
3034 2325 * Set to POST value or default
3035 - *
3036 - * @param array $post_values
3037 - * @param array $values
3038 - *
3039 - * @return void
3040 2326 */
3041 2327 private static function fill_form_defaults( $post_values, array &$values ) {
3042 2328 $form_defaults = FrmFormsHelper::get_default_opts();
3043 2329
@@ -3042,9 +2328,9 @@
3042 2328 $form_defaults = FrmFormsHelper::get_default_opts();
3043 2329
3044 2330 foreach ( $form_defaults as $opt => $default ) {
3045 2331 if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) {
3046 - $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default;
2332 + $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default;
3047 2333 }
3048 2334
3049 2335 unset( $opt, $default );
3050 2336 }
@@ -3054,9 +2340,9 @@
3054 2340 }
3055 2341
3056 2342 foreach ( array( 'before', 'after', 'submit' ) as $h ) {
3057 2343 if ( ! isset( $values[ $h . '_html' ] ) ) {
3058 - $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) );
2344 + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) );
3059 2345 }
3060 2346 unset( $h );
3061 2347 }
3062 2348 }
@@ -3065,9 +2351,9 @@
3065 2351 * @since 2.2.10
3066 2352 *
3067 2353 * @param array $post_values
3068 2354 *
3069 - * @return bool|int
2355 + * @return boolean|int
3070 2356 */
3071 2357 public static function custom_style_value( $post_values ) {
3072 2358 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
3073 2359 $custom_style = absint( $post_values['options']['custom_style'] );
@@ -3072,38 +2358,29 @@
3072 2358 if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) {
3073 2359 $custom_style = absint( $post_values['options']['custom_style'] );
3074 2360 } else {
3075 2361 $frm_settings = self::get_settings();
3076 - $custom_style = ( $frm_settings->load_style !== 'none' );
2362 + $custom_style = ( $frm_settings->load_style != 'none' );
3077 2363 }
3078 2364
3079 2365 return $custom_style;
3080 2366 }
3081 2367
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 ) ) {
2368 + public static function truncate( $str, $length, $minword = 3, $continue = '...' ) {
2369 + if ( is_array( $str ) ) {
3092 2370 return '';
3093 2371 }
3094 2372
3095 2373 $length = (int) $length;
3096 - $str = wp_strip_all_tags( (string) $original_string );
2374 + $str = wp_strip_all_tags( $str );
3097 2375 $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) );
3098 2376
3099 2377 if ( $length == 0 ) {
3100 2378 return '';
3101 - }
2379 + } elseif ( $length <= 10 ) {
2380 + $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3102 2381
3103 - if ( $length <= 10 ) {
3104 - $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) );
3105 - return $sub . ( $length < $original_len ? $continue : '' );
2382 + return $sub . ( ( $length < $original_len ) ? $continue : '' );
3106 2383 }
3107 2384
3108 2385 $sub = '';
3109 2386 $len = 0;
@@ -3109,16 +2386,11 @@
3109 2386 $len = 0;
3110 2387
3111 2388 $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) );
3112 2389
3113 - if ( ! is_array( $words ) ) {
3114 - return $original_string;
3115 - }
3116 -
3117 2390 foreach ( $words as $word ) {
3118 - $part = ( $sub !== '' ? ' ' : '' ) . $word;
2391 + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word;
3119 2392 $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) );
3120 -
3121 2393 if ( $total_len > $length && substr_count( $sub, ' ' ) ) {
3122 2394 break;
3123 2395 }
3124 2396
@@ -3133,9 +2405,9 @@
3133 2405 }
3134 2406
3135 2407 $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length );
3136 2408
3137 - return $sub . ( $len < $original_len ? $continue : '' );
2409 + return $sub . ( ( $len < $original_len ) ? $continue : '' );
3138 2410 }
3139 2411
3140 2412 /**
3141 2413 * If the string is still too long because there may not have been any spaces, force truncate.
@@ -3143,9 +2415,8 @@
3143 2415 * @since 6.5.4
3144 2416 *
3145 2417 * @param string $sub Current substring.
3146 2418 * @param int $length The length limit.
3147 - *
3148 2419 * @return string
3149 2420 */
3150 2421 private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
3151 2422 if ( strlen( $sub ) < $length + 50 ) {
@@ -3153,9 +2424,8 @@
3153 2424 return $sub;
3154 2425 }
3155 2426
3156 2427 $first_space = strpos( $sub, ' ', $length );
3157 -
3158 2428 if ( false !== $first_space ) {
3159 2429 // Ignore anything with spaces.
3160 2430 return $sub;
3161 2431 }
@@ -3162,18 +2432,11 @@
3162 2432
3163 2433 return substr( $sub, 0, $length + 10 );
3164 2434 }
3165 2435
3166 - /**
3167 - * @param array $function_names
3168 - * @param array $args
3169 - *
3170 - * @return mixed
3171 - */
3172 2436 public static function mb_function( $function_names, $args ) {
3173 2437 $mb_function_name = $function_names[0];
3174 2438 $function_name = $function_names[1];
3175 -
3176 2439 if ( function_exists( $mb_function_name ) ) {
3177 2440 $function_name = $mb_function_name;
3178 2441 }
3179 2442
@@ -3179,15 +2442,8 @@
3179 2442
3180 2443 return call_user_func_array( $function_name, $args );
3181 2444 }
3182 2445
3183 - /**
3184 - * @param string $date
3185 - * @param string $date_format
3186 - * @param string $time_format
3187 - *
3188 - * @return string
3189 - */
3190 2446 public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) {
3191 2447 if ( empty( $date ) ) {
3192 2448 return $date;
3193 2449 }
@@ -3202,10 +2458,9 @@
3202 2458 }
3203 2459
3204 2460 $formatted = self::get_localized_date( $date_format, $date );
3205 2461
3206 - $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00' );
3207 -
2462 + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) != '00:00:00' );
3208 2463 if ( $do_time ) {
3209 2464 $formatted .= self::add_time_to_date( $time_format, $date );
3210 2465 }
3211 2466
@@ -3211,14 +2466,8 @@
3211 2466
3212 2467 return $formatted;
3213 2468 }
3214 2469
3215 - /**
3216 - * @param string $time_format
3217 - * @param string $date
3218 - *
3219 - * @return string
3220 - */
3221 2470 private static function add_time_to_date( $time_format, $date ) {
3222 2471 if ( empty( $time_format ) ) {
3223 2472 $time_format = get_option( 'time_format' );
3224 2473 }
@@ -3224,9 +2473,8 @@
3224 2473 }
3225 2474
3226 2475 $trimmed_format = trim( $time_format );
3227 2476 $time = '';
3228 -
3229 2477 if ( $time_format && ! empty( $trimmed_format ) ) {
3230 2478 $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date );
3231 2479 }
3232 2480
@@ -3234,13 +2482,8 @@
3234 2482 }
3235 2483
3236 2484 /**
3237 2485 * @since 2.0.8
3238 - *
3239 - * @param string $date_format
3240 - * @param string $date
3241 - *
3242 - * @return string
3243 2486 */
3244 2487 public static function get_localized_date( $date_format, $date ) {
3245 2488 $date = get_date_from_gmt( $date );
3246 2489
@@ -3247,13 +2490,12 @@
3247 2490 return date_i18n( $date_format, strtotime( $date ) );
3248 2491 }
3249 2492
3250 2493 /**
3251 - * Gets the time ago in words.
2494 + * Gets the time ago in words
3252 2495 *
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.
2496 + * @param int $from in seconds
2497 + * @param int|string $to in seconds
3256 2498 *
3257 2499 * @return string $time_ago
3258 2500 */
3259 2501 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
@@ -3261,9 +2503,8 @@
3261 2503 $now = new DateTime();
3262 2504 } else {
3263 2505 $now = new DateTime( '@' . $to );
3264 2506 }
3265 -
3266 2507 $ago = new DateTime( '@' . $from );
3267 2508
3268 2509 // Get the time difference
3269 2510 $diff_object = $now->diff( $ago );
@@ -3269,9 +2510,9 @@
3269 2510 $diff_object = $now->diff( $ago );
3270 2511 $diff = get_object_vars( $diff_object );
3271 2512
3272 2513 // Add week amount and update day amount
3273 - $diff['w'] = floor( $diff['d'] / 7 );
2514 + $diff['w'] = floor( $diff['d'] / 7 );
3274 2515 $diff['d'] -= $diff['w'] * 7;
3275 2516
3276 2517 $time_strings = self::get_time_strings();
3277 2518
@@ -3277,11 +2518,10 @@
3277 2518
3278 2519 if ( ! is_numeric( $levels ) ) {
3279 2520 // Show time in specified unit.
3280 2521 $levels = self::get_unit( $levels );
3281 -
3282 2522 if ( isset( $time_strings[ $levels ] ) ) {
3283 - $diff = array(
2523 + $diff = array(
3284 2524 $levels => self::time_format( $levels, $diff ),
3285 2525 );
3286 2526 $time_strings = array(
3287 2527 $levels => $time_strings[ $levels ],
@@ -3286,9 +2526,8 @@
3286 2526 $time_strings = array(
3287 2527 $levels => $time_strings[ $levels ],
3288 2528 );
3289 2529 }
3290 -
3291 2530 $levels = 1;
3292 2531 }
3293 2532
3294 2533 foreach ( $time_strings as $k => $v ) {
@@ -3310,13 +2549,8 @@
3310 2549 }
3311 2550
3312 2551 /**
3313 2552 * @since 4.05.01
3314 - *
3315 - * @param string $unit
3316 - * @param array $diff
3317 - *
3318 - * @return int
3319 2553 */
3320 2554 private static function time_format( $unit, $diff ) {
3321 2555 $return = array(
3322 2556 'y' => 'y',
@@ -3321,9 +2555,8 @@
3321 2555 $return = array(
3322 2556 'y' => 'y',
3323 2557 'd' => 'days',
3324 2558 );
3325 -
3326 2559 if ( isset( $return[ $unit ] ) ) {
3327 2560 return $diff[ $return[ $unit ] ];
3328 2561 }
3329 2562
@@ -3343,13 +2576,8 @@
3343 2576 }
3344 2577
3345 2578 /**
3346 2579 * @since 4.05.01
3347 - *
3348 - * @param string $from
3349 - * @param string $to
3350 - *
3351 - * @return int
3352 2580 */
3353 2581 private static function convert_time( $from, $to ) {
3354 2582 $convert = array(
3355 2583 's' => 1,
@@ -3365,16 +2593,11 @@
3365 2593 }
3366 2594
3367 2595 /**
3368 2596 * @since 4.05.01
3369 - *
3370 - * @param string $unit
3371 - *
3372 - * @return int|string
3373 2597 */
3374 2598 private static function get_unit( $unit ) {
3375 2599 $units = self::get_time_strings();
3376 -
3377 2600 if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) {
3378 2601 return $unit;
3379 2602 }
3380 2603
@@ -3387,12 +2610,11 @@
3387 2610 }
3388 2611
3389 2612 /**
3390 2613 * Get the translatable time strings. The untranslated version is a failsafe
3391 - * in case languages are changing for the unit set in the shortcode.
2614 + * in case langauges are changing for the unit set in the shortcode.
3392 2615 *
3393 2616 * @since 2.0.20
3394 - *
3395 2617 * @return array
3396 2618 */
3397 2619 private static function get_time_strings() {
3398 2620 return array(
@@ -3436,47 +2658,35 @@
3436 2658
3437 2659 // Pagination Methods.
3438 2660
3439 2661 /**
3440 - * @param int $r_count
3441 - * @param int $current_p
3442 - * @param int $p_size
3443 - *
3444 - * @return int
2662 + * @param integer $current_p
3445 2663 */
3446 2664 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 );
2665 + return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
3448 2666 }
3449 2667
3450 2668 /**
3451 - * @param int $r_count
3452 - * @param int $current_p
3453 - * @param int $p_size
3454 - *
3455 - * @return int
2669 + * @param integer $current_p
3456 2670 */
3457 2671 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
3458 2672 if ( $current_p == 1 ) {
3459 2673 return 1;
2674 + } else {
2675 + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 );
3460 2676 }
3461 - return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1;
3462 2677 }
3463 2678
3464 2679 /**
3465 - * @param array $json_vars
3466 - *
3467 2680 * @return array
3468 2681 */
3469 2682 public static function json_to_array( $json_vars ) {
3470 2683 $vars = array();
3471 -
3472 2684 foreach ( $json_vars as $jv ) {
3473 2685 $jv_name = explode( '[', $jv['name'] );
3474 2686 $last = count( $jv_name ) - 1;
3475 -
3476 2687 foreach ( $jv_name as $p => $n ) {
3477 2688 $name = trim( $n, ']' );
3478 -
3479 2689 if ( ! isset( $l1 ) ) {
3480 2690 $l1 = $name;
3481 2691 }
3482 2692
@@ -3487,9 +2697,9 @@
3487 2697 if ( ! isset( $l3 ) ) {
3488 2698 $l3 = $name;
3489 2699 }
3490 2700
3491 - $this_val = $p == $last ? $jv['value'] : array();
2701 + $this_val = ( $p == $last ) ? $jv['value'] : array();
3492 2702
3493 2703 switch ( $p ) {
3494 2704 case 0:
3495 2705 $l1 = $name;
@@ -3511,12 +2721,12 @@
3511 2721 self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
3512 2722 }
3513 2723
3514 2724 unset( $this_val, $n );
3515 - }//end foreach
2725 + }
3516 2726
3517 2727 unset( $last, $jv );
3518 - }//end foreach
2728 + }
3519 2729
3520 2730 return $vars;
3521 2731 }
3522 2732
@@ -3522,12 +2732,8 @@
3522 2732
3523 2733 /**
3524 2734 * @param string $name
3525 2735 * @param string $l1
3526 - * @param mixed $val
3527 - * @param array $vars
3528 - *
3529 - * @return void
3530 2736 */
3531 2737 public static function add_value_to_array( $name, $l1, $val, &$vars ) {
3532 2738 if ( $name == '' ) {
3533 2739 $vars[] = $val;
@@ -3535,19 +2741,12 @@
3535 2741 $vars[ $l1 ] = $val;
3536 2742 }
3537 2743 }
3538 2744
3539 - /**
3540 - * @param string $name
3541 - * @param string $class
3542 - * @param string $form_name
3543 - *
3544 - * @return void
3545 - */
3546 2745 public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) {
3547 2746 $tooltips = array(
3548 2747 '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 <name@email.com> or name@email.com. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ),
2748 + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [admin_email] is the address set in WP General Settings.', 'formidable' ),
3550 2749 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3551 2750 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3552 2751 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ),
3553 2752 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
@@ -3574,14 +2773,8 @@
3574 2773 }
3575 2774
3576 2775 /**
3577 2776 * 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 2777 */
3585 2778 public static function select_current_page( $page, $current_page, $action = array() ) {
3586 2779 if ( $current_page != $page ) {
3587 2780 return;
@@ -3587,9 +2780,8 @@
3587 2780 return;
3588 2781 }
3589 2782
3590 2783 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
3591 -
3592 2784 if ( 'lite-reports' === $frm_action ) {
3593 2785 $frm_action = 'reports';
3594 2786 }
3595 2787
@@ -3630,15 +2822,8 @@
3630 2822
3631 2823 return $post_content;
3632 2824 }
3633 2825
3634 - /**
3635 - * @param array|string $val
3636 - * @param int|string $key
3637 - * @param array $post_content
3638 - *
3639 - * @return void
3640 - */
3641 2826 private static function prepare_action_slashes( $val, $key, &$post_content ) {
3642 2827 if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) {
3643 2828 return;
3644 2829 }
@@ -3663,9 +2848,8 @@
3663 2848 *
3664 2849 * @since 4.02.03
3665 2850 *
3666 2851 * @param array|string $value
3667 - *
3668 2852 * @return void
3669 2853 */
3670 2854 public static function unserialize_or_decode( &$value ) {
3671 2855 if ( is_array( $value ) ) {
@@ -3685,9 +2869,8 @@
3685 2869 *
3686 2870 * @since 6.2
3687 2871 *
3688 2872 * @param mixed $value
3689 - *
3690 2873 * @return mixed
3691 2874 */
3692 2875 public static function maybe_unserialize_array( $value ) {
3693 2876 if ( ! is_string( $value ) ) {
@@ -3699,9 +2882,8 @@
3699 2882 return $value;
3700 2883 }
3701 2884
3702 2885 $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
3703 -
3704 2886 if ( is_array( $parsed ) ) {
3705 2887 $value = $parsed;
3706 2888 }
3707 2889
@@ -3713,9 +2895,8 @@
3713 2895 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
3714 2896 *
3715 2897 * @param mixed $string
3716 2898 * @param bool $single_to_array
3717 - *
3718 2899 * @return mixed
3719 2900 */
3720 2901 public static function maybe_json_decode( $string, $single_to_array = true ) {
3721 2902 if ( is_array( $string ) || is_null( $string ) ) {
@@ -3722,17 +2903,14 @@
3722 2903 return $string;
3723 2904 }
3724 2905
3725 2906 $new_string = json_decode( $string, true );
3726 -
3727 2907 if ( function_exists( 'json_last_error' ) ) {
3728 2908 // php 5.3+
3729 2909 $single_value = false;
3730 -
3731 2910 if ( ! $single_to_array ) {
3732 2911 $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] );
3733 2912 }
3734 -
3735 2913 if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) {
3736 2914 $string = $new_string;
3737 2915 }
3738 2916 }
@@ -3743,9 +2921,8 @@
3743 2921 /**
3744 2922 * @since 6.2.3
3745 2923 *
3746 2924 * @param string $value
3747 - *
3748 2925 * @return string
3749 2926 */
3750 2927 public static function maybe_utf8_encode( $value ) {
3751 2928 $from_format = 'ISO-8859-1';
@@ -3759,9 +2936,8 @@
3759 2936 }
3760 2937
3761 2938 if ( function_exists( 'iconv' ) ) {
3762 2939 $converted = iconv( $from_format, $to_format, $value );
3763 -
3764 2940 // Value is false if $value is not ISO-8859-1.
3765 2941 if ( false !== $converted ) {
3766 2942 return $converted;
3767 2943 }
@@ -3773,12 +2949,8 @@
3773 2949 /**
3774 2950 * Reformat the json serialized array in name => value array.
3775 2951 *
3776 2952 * @since 4.02.03
3777 - *
3778 - * @param array $form
3779 - *
3780 - * @return void
3781 2953 */
3782 2954 public static function format_form_data( &$form ) {
3783 2955 $formatted = array();
3784 2956
@@ -3785,11 +2957,9 @@
3785 2957 foreach ( $form as $input ) {
3786 2958 if ( ! isset( $input['name'] ) ) {
3787 2959 continue;
3788 2960 }
3789 -
3790 2961 $key = $input['name'];
3791 -
3792 2962 if ( isset( $formatted[ $key ] ) ) {
3793 2963 if ( is_array( $formatted[ $key ] ) ) {
3794 2964 $formatted[ $key ][] = $input['value'];
3795 2965 } else {
@@ -3804,12 +2974,8 @@
3804 2974 }
3805 2975
3806 2976 /**
3807 2977 * @since 4.02.03
3808 - *
3809 - * @param array|string $value
3810 - *
3811 - * @return string
3812 2978 */
3813 2979 public static function maybe_json_encode( $value ) {
3814 2980 if ( is_array( $value ) ) {
3815 2981 $value = wp_json_encode( $value );
@@ -3817,15 +2983,12 @@
3817 2983 return $value;
3818 2984 }
3819 2985
3820 2986 /**
3821 - * Echo The javascript to open and highlight the Formidable menu
3822 - *
3823 2987 * @since 1.07.10
3824 2988 *
3825 - * @param string $post_type The name of the post type that may need to be highlighted.
3826 - *
3827 - * @return void
2989 + * @param string $post_type The name of the post type that may need to be highlighted
2990 + * echo The javascript to open and highlight the Formidable menu
3828 2991 */
3829 2992 public static function maybe_highlight_menu( $post_type ) {
3830 2993 global $post;
3831 2994
@@ -3844,12 +3007,8 @@
3844 3007 /**
3845 3008 * Load the JS file on non-Formidable pages in the admin area
3846 3009 *
3847 3010 * @since 2.0
3848 - *
3849 - * @param bool $load
3850 - *
3851 - * @return void
3852 3011 */
3853 3012 public static function load_admin_wide_js( $load = true ) {
3854 3013 $version = self::plugin_version();
3855 3014 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
@@ -3863,9 +3022,8 @@
3863 3022 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
3864 3023 'loading' => __( 'Loading&hellip;', 'formidable' ),
3865 3024 'nonce' => wp_create_nonce( 'frm_ajax' ),
3866 3025 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
3867 - 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(),
3868 3026 );
3869 3027 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
3870 3028
3871 3029 if ( $load ) {
@@ -3874,10 +3032,8 @@
3874 3032 }
3875 3033
3876 3034 /**
3877 3035 * @since 2.0.9
3878 - *
3879 - * @return void
3880 3036 */
3881 3037 public static function load_font_style() {
3882 3038 wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() );
3883 3039 }
@@ -3883,105 +3039,87 @@
3883 3039 }
3884 3040
3885 3041 /**
3886 3042 * @param string $location
3887 - *
3888 - * @return void
3889 3043 */
3890 3044 public static function localize_script( $location ) {
3891 - global $wp_scripts, $wp_version;
3045 + global $wp_scripts;
3892 3046
3893 3047 $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,
3048 + 'ajax_url' => esc_url_raw( self::get_ajax_url() ),
3049 + 'images_url' => self::plugin_url() . '/images',
3050 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
3051 + 'remove' => __( 'Remove', 'formidable' ),
3052 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
3053 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
3054 + 'id' => __( 'ID', 'formidable' ),
3055 + 'no_results' => __( 'No results match', 'formidable' ),
3056 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
3057 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
3058 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
3059 + 'focus_first_error' => self::should_focus_first_error(),
3060 + 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
3909 3061 );
3910 3062
3911 3063 $data = $wp_scripts->get_data( 'formidable', 'data' );
3912 -
3913 3064 if ( ! $data ) {
3914 3065 wp_localize_script( 'formidable', 'frm_js', $script_strings );
3915 3066 }
3916 3067
3917 3068 if ( $location === 'admin' ) {
3069 + $frm_settings = self::get_settings();
3918 3070 $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(),
3071 + 'desc' => __( '(Click to add description)', 'formidable' ),
3072 + 'blank' => __( '(Blank)', 'formidable' ),
3073 + 'no_label' => __( '(no label)', 'formidable' ),
3074 + 'ok' => __( 'OK', 'formidable' ),
3075 + 'cancel' => __( 'Cancel', 'formidable' ),
3076 + 'default_label' => __( 'Default', 'formidable' ),
3077 + 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
3078 + 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
3079 + 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3080 + 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3081 + 'confirm' => __( 'Are you sure?', 'formidable' ),
3082 + 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3083 + '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' ),
3084 + 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3085 + 'default_unique' => $frm_settings->unique_msg,
3086 + 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3087 + 'enter_email' => __( 'Enter Email', 'formidable' ),
3088 + 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3089 + 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3090 + 'new_option' => __( 'New Option', 'formidable' ),
3091 + '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' ),
3092 + 'enter_password' => __( 'Enter Password', 'formidable' ),
3093 + 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3094 + 'import_complete' => __( 'Import Complete', 'formidable' ),
3095 + 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
3096 + 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
3097 + 'private_label' => __( 'Private', 'formidable' ),
3098 + 'jquery_ui_url' => '',
3099 + 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3100 + 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3101 + 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3102 + 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
3103 + 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3104 + 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ),
3105 + 'unsafe_params' => FrmFormsHelper::reserved_words(),
3956 3106 /* 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' ), '****' ),
3107 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3958 3108 /* 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 -
3109 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3110 + 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3111 + 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3112 + 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3113 + 'install' => __( 'Install', 'formidable' ),
3114 + 'active' => __( 'Active', 'formidable' ),
3115 + 'select_a_field' => __( 'Select a Field', 'formidable' ),
3116 + 'no_items_found' => __( 'No items found.', 'formidable' ),
3117 + 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3118 + 'saving' => '', // Deprecated in 6.0.
3119 + 'saved' => '', // Deprecated in 6.0.
3977 3120 // 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', '>=' ),
3121 + 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ),
3984 3122 );
3985 3123 /**
3986 3124 * @param array $admin_script_strings
3987 3125 */
@@ -3987,27 +3125,15 @@
3987 3125 */
3988 3126 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3989 3127
3990 3128 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3991 -
3992 3129 if ( ! $data ) {
3993 3130 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3994 3131 }
3995 - }//end if
3132 + }
3996 3133 }
3997 3134
3998 3135 /**
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 3136 * @since 6.5
4011 3137 *
4012 3138 * @return string
4013 3139 */
@@ -4048,11 +3174,9 @@
4048 3174 * Echo the message on the plugins listing page
4049 3175 *
4050 3176 * @since 1.07.10
4051 3177 *
4052 - * @param float $min_version The version the add-on requires.
4053 - *
4054 - * @return void
3178 + * @param float $min_version The version the add-on requires
4055 3179 */
4056 3180 public static function min_version_notice( $min_version ) {
4057 3181 $frm_version = self::plugin_version();
4058 3182
@@ -4071,10 +3195,8 @@
4071 3195 * If Pro is far outdated, show a message.
4072 3196 *
4073 3197 * @since 4.0.01
4074 3198 *
4075 - * @param string $min_version
4076 - *
4077 3199 * @return void
4078 3200 */
4079 3201 public static function min_pro_version_notice( $min_version ) {
4080 3202 if ( ! self::is_formidable_admin() ) {
@@ -4084,14 +3206,26 @@
4084 3206
4085 3207 self::php_version_notice();
4086 3208
4087 3209 $is_pro = self::pro_is_installed() && class_exists( 'FrmProDb' );
4088 -
4089 3210 if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) {
4090 3211 return;
4091 3212 }
4092 3213
4093 - include self::plugin_path() . '/classes/views/addons/min-version-notice.php';
3214 + $pro_version = FrmProDb::$plug_version;
3215 + $expired = FrmAddonsController::is_license_expired();
3216 + ?>
3217 + <div class="frm-banner-alert frm_error_style frm_previous_install">
3218 + <?php
3219 + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
3220 + if ( empty( $expired ) ) {
3221 + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
3222 + } else {
3223 + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.';
3224 + }
3225 + ?>
3226 + </div>
3227 + <?php
4094 3228 }
4095 3229
4096 3230 /**
4097 3231 * If Pro is installed, check the version number.
@@ -4096,12 +3230,8 @@
4096 3230 /**
4097 3231 * If Pro is installed, check the version number.
4098 3232 *
4099 3233 * @since 4.0.01
4100 - *
4101 - * @param string $min_version
4102 - *
4103 - * @return bool
4104 3234 */
4105 3235 public static function meets_min_pro_version( $min_version ) {
4106 3236 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
4107 3237 }
@@ -4106,19 +3236,22 @@
4106 3236 return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' );
4107 3237 }
4108 3238
4109 3239 /**
4110 - * Show a message if the PHP version is below the recommendations.
3240 + * Show a message if the browser or PHP version is below the recommendations.
4111 3241 *
4112 3242 * @since 4.0.02
4113 - *
4114 - * @return void
4115 3243 */
4116 3244 private static function php_version_notice() {
4117 3245 $message = array();
3246 + if ( version_compare( phpversion(), '5.6', '<' ) ) {
3247 + $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' );
3248 + }
4118 3249
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' );
3250 + $browser = self::get_server_value( 'HTTP_USER_AGENT' );
3251 + $is_ie = strpos( $browser, 'MSIE' ) !== false;
3252 + if ( $is_ie ) {
3253 + $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 3254 }
4122 3255
4123 3256 foreach ( $message as $m ) {
4124 3257 ?>
@@ -4130,9 +3263,8 @@
4130 3263 }
4131 3264
4132 3265 /**
4133 3266 * @param string $type
4134 - *
4135 3267 * @return array<string,string>
4136 3268 */
4137 3269 public static function locales( $type = 'date' ) {
4138 3270 $locales = array(
@@ -4242,9 +3374,8 @@
4242 3374 * @since 5.4.5 Added $args parameter with type.
4243 3375 *
4244 3376 * @param array<string,string> $locales
4245 3377 * @param array $args {
4246 - *
4247 3378 * @type string $type
4248 3379 * }
4249 3380 */
4250 3381 $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
@@ -4252,14 +3383,19 @@
4252 3383 return $locales;
4253 3384 }
4254 3385
4255 3386 /**
4256 - * @return string
3387 + * Output HTML containing reference text for accessibility
3388 + *
3389 + * @deprecated 5.1
4257 3390 */
3391 + public static function multiselect_accessibility() {
3392 + _deprecated_function( __METHOD__, '5.1' );
3393 + }
3394 +
4258 3395 public static function get_menu_icon_class() {
4259 3396 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
4260 3397 $settings = FrmProAppHelper::get_settings();
4261 -
4262 3398 if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
4263 3399 return $settings->menu_icon;
4264 3400 }
4265 3401 }
@@ -4305,9 +3441,8 @@
4305 3441 *
4306 3442 * @since 5.0.04
4307 3443 *
4308 3444 * @param array $args The arguments.
4309 - *
4310 3445 * @return array
4311 3446 */
4312 3447 private static function fill_default_images_dropdown_args( $args ) {
4313 3448 $defaults = array(
@@ -4320,8 +3455,14 @@
4320 3455
4321 3456 $new_args['options'] = (array) $new_args['options'];
4322 3457 $new_args['input_attrs'] = (array) $new_args['input_attrs'];
4323 3458
3459 + // Set the number of columns.
3460 + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) );
3461 + if ( $new_args['col_class'] > 6 ) {
3462 + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 );
3463 + }
3464 +
4324 3465 /**
4325 3466 * Allows modifying the arguments of images_dropdown() method.
4326 3467 *
4327 3468 * @since 5.0.04
@@ -4337,9 +3478,8 @@
4337 3478 *
4338 3479 * @since 5.0.04
4339 3480 *
4340 3481 * @param array $args The arguments.
4341 - *
4342 3482 * @return string
4343 3483 */
4344 3484 private static function get_images_dropdown_input_attrs( $args ) {
4345 3485 $input_attrs = $args['input_attrs'];
@@ -4346,9 +3486,8 @@
4346 3486 $input_attrs['type'] = 'radio';
4347 3487 $input_attrs['name'] = $args['name'];
4348 3488
4349 3489 $input_attrs_str = '';
4350 -
4351 3490 foreach ( $input_attrs as $key => $input_attr ) {
4352 3491 $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) );
4353 3492 }
4354 3493
@@ -4363,23 +3502,8 @@
4363 3502 return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args );
4364 3503 }
4365 3504
4366 3505 /**
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 3506 * Gets the image of each option in images_dropdown() method.
4383 3507 *
4384 3508 * @since 5.0.04
4385 3509 *
@@ -4384,9 +3508,8 @@
4384 3508 * @since 5.0.04
4385 3509 *
4386 3510 * @param array $option Option data.
4387 3511 * @param array $args The arguments of images_dropdown() method.
4388 - *
4389 3512 * @return string
4390 3513 */
4391 3514 private static function get_images_dropdown_option_image( $option, $args ) {
4392 3515 $image = self::icon_by_class(
@@ -4391,9 +3514,9 @@
4391 3514 private static function get_images_dropdown_option_image( $option, $args ) {
4392 3515 $image = self::icon_by_class(
4393 3516 'frmfont ' . $option['svg'],
4394 3517 array(
4395 - 'echo' => false,
3518 + 'echo' => false,
4396 3519 )
4397 3520 );
4398 3521
4399 3522 $args['option'] = $option;
@@ -4415,9 +3538,8 @@
4415 3538 * @since 5.0.04
4416 3539 *
4417 3540 * @param array $option Option data.
4418 3541 * @param array $args The arguments of images_dropdown() method.
4419 - *
4420 3542 * @return string
4421 3543 */
4422 3544 private static function get_images_dropdown_option_classes( $option, $args ) {
4423 3545 $classes = '';
@@ -4445,14 +3567,12 @@
4445 3567 * @since 5.0.04
4446 3568 *
4447 3569 * @param array $option Option data.
4448 3570 * @param array $args The arguments of images_dropdown() method.
4449 - *
4450 3571 * @return string
4451 3572 */
4452 3573 private static function get_images_dropdown_option_html_attrs( $option, $args ) {
4453 3574 $html_attrs = '';
4454 -
4455 3575 if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) {
4456 3576 $html_attrs_arr = array();
4457 3577
4458 3578 foreach ( $option['custom_attrs'] as $key => $value ) {
@@ -4515,9 +3635,8 @@
4515 3635 * @since 5.0.07
4516 3636 *
4517 3637 * @param array $values
4518 3638 * @param array $keys
4519 - *
4520 3639 * @return array
4521 3640 */
4522 3641 public static function maybe_filter_array( $values, $keys ) {
4523 3642 $allow_unfiltered_html = self::allow_unfiltered_html();
@@ -4535,16 +3654,15 @@
4535 3654 return $values;
4536 3655 }
4537 3656
4538 3657 /**
4539 - * Some back end fields allow privileged users to add scripts.
3658 + * Some back end fields allow privleged users to add scripts.
4540 3659 * A site that uses the DISALLOW_UNFILTERED_HTML always remove scripts on echo.
4541 3660 *
4542 3661 * @since 5.0.13
4543 3662 *
4544 3663 * @param string $value
4545 - * @param array|string $allowed 'all' for everything included as defaults.
4546 - *
3664 + * @param array|string $allowed 'all' for everything included as defaults
4547 3665 * @return string
4548 3666 */
4549 3667 public static function maybe_kses( $value, $allowed = 'all' ) {
4550 3668 if ( self::should_never_allow_unfiltered_html() ) {
@@ -4553,69 +3671,19 @@
4553 3671 return $value;
4554 3672 }
4555 3673
4556 3674 /**
4557 - * Check if an option attribute used in an [input] shortcode is safe.
3675 + * @since 5.0.16
4558 3676 *
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 3677 * @return bool
4565 3678 */
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 );
3679 + public static function show_landing_pages() {
3680 + return self::show_new_feature( 'landing' );
4611 3681 }
4612 3682
4613 3683 /**
4614 3684 * @since 5.0.16
4615 3685 *
4616 - * @param string $medium
4617 - *
4618 3686 * @return array
4619 3687 */
4620 3688 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
4621 3689 $params = array(
@@ -4622,9 +3690,8 @@
4622 3690 'medium' => $medium,
4623 3691 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
4624 3692 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
4625 3693 'screenshot' => 'landing.png',
4626 - 'learn-more' => self::get_doc_url( 'landing-page-forms', 'form-landing-page-settings', false ),
4627 3694 );
4628 3695 return self::get_upgrade_data_params( 'landing', $params );
4629 3696 }
4630 3697
@@ -4630,10 +3697,20 @@
4630 3697
4631 3698 /**
4632 3699 * @since 5.0.17
4633 3700 *
4634 - * @param string $feature
3701 + * @param string $plugin
3702 + * @return string|false
3703 + */
3704 + private static function get_plan_required( $plugin ) {
3705 + $link = FrmAddonsController::install_link( $plugin );
3706 + return FrmFormsHelper::get_plan_required( $link );
3707 + }
3708 +
3709 + /**
3710 + * @since 5.0.17
4635 3711 *
3712 + * @param string
4636 3713 * @return bool
4637 3714 */
4638 3715 public static function show_new_feature( $feature ) {
4639 3716 $link = FrmAddonsController::install_link( $feature );
@@ -4640,21 +3717,16 @@
4640 3717 return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
4641 3718 }
4642 3719
4643 3720 /**
4644 - * Enhances upgrade data parameters with installation link and plan requirement information.
4645 - *
4646 3721 * @since 5.0.17
4647 3722 *
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.
3723 + * @param string $plugin
3724 + * @param array $params
3725 + * @return array
4653 3726 */
4654 - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) {
3727 + public static function get_upgrade_data_params( $plugin, $params ) {
4655 3728 $link = FrmAddonsController::install_link( $plugin );
4656 -
4657 3729 if ( ! $link ) {
4658 3730 return $params;
4659 3731 }
4660 3732
@@ -4660,20 +3732,15 @@
4660 3732
4661 3733 if ( ! empty( $link['url'] ) && self::pro_is_installed() ) {
4662 3734 $params['oneclick'] = json_encode( $link );
4663 3735 unset( $params['message'] );
4664 -
4665 3736 if ( ! isset( $params['medium'] ) ) {
4666 3737 $params['medium'] = $plugin;
4667 3738 }
4668 3739 } else {
4669 - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link );
3740 + $params['requires'] = FrmFormsHelper::get_plan_required( $link );
4670 3741 }
4671 3742
4672 - if ( $detailed ) {
4673 - $params['plugin-status'] = $link['status'] ?? '';
4674 - }
4675 -
4676 3743 return $params;
4677 3744 }
4678 3745
4679 3746 /**
@@ -4682,9 +3749,8 @@
4682 3749 *
4683 3750 * @since 5.0.17
4684 3751 *
4685 3752 * @param string $text
4686 - *
4687 3753 * @return bool
4688 3754 */
4689 3755 public static function ctype_xdigit( $text ) {
4690 3756 if ( function_exists( 'ctype_xdigit' ) ) {
@@ -4699,9 +3765,8 @@
4699 3765 * @since 5.2.01
4700 3766 */
4701 3767 public static function set_current_screen_and_hook_suffix() {
4702 3768 global $hook_suffix;
4703 -
4704 3769 if ( is_null( $hook_suffix ) ) {
4705 3770 // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
4706 3771 $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
4707 3772 }
@@ -4718,9 +3783,9 @@
4718 3783 public static function show_pill_text( $text = null ) {
4719 3784 if ( null === $text ) {
4720 3785 $text = __( 'NEW', 'formidable' );
4721 3786 }
4722 - echo '<span class="frm-meta-tag frm-new-pill">' . esc_html( $text ) . '</span>';
3787 + echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>';
4723 3788 }
4724 3789
4725 3790 /**
4726 3791 * Count the number of decimals digits.
@@ -4727,10 +3792,9 @@
4727 3792 *
4728 3793 * @since 5.2.07
4729 3794 *
4730 3795 * @param mixed $num Number.
4731 - *
4732 - * @return false|int Returns `false` if the passed parameter is not number.
3796 + * @return int|false Returns `false` if the passed parameter is not number.
4733 3797 */
4734 3798 public static function count_decimals( $num ) {
4735 3799 if ( ! is_numeric( $num ) ) {
4736 3800 return false;
@@ -4737,9 +3801,8 @@
4737 3801 }
4738 3802
4739 3803 $num = (string) $num;
4740 3804 $parts = explode( '.', $num );
4741 -
4742 3805 if ( 1 === count( $parts ) ) {
4743 3806 return 0;
4744 3807 }
4745 3808
@@ -4762,9 +3825,9 @@
4762 3825 }
4763 3826
4764 3827 add_filter(
4765 3828 'option_gmt_offset',
4766 - function ( $offset ) {
3829 + function( $offset ) {
4767 3830 if ( ! is_string( $offset ) || is_numeric( $offset ) ) {
4768 3831 // Leave a valid value alone.
4769 3832 return $offset;
4770 3833 }
@@ -4821,20 +3884,17 @@
4821 3884 * @since 5.5.5
4822 3885 *
4823 3886 * @param string $url
4824 3887 * @param string $expected_extension
4825 - *
4826 3888 * @return bool
4827 3889 */
4828 3890 public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
4829 3891 $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
4830 -
4831 3892 if ( ! $file_is_in_expected_s3_bucket ) {
4832 3893 return false;
4833 3894 }
4834 3895
4835 3896 $parsed = parse_url( $url );
4836 -
4837 3897 if ( ! is_array( $parsed ) ) {
4838 3898 // URL is malformed.
4839 3899 return false;
4840 3900 }
@@ -4840,9 +3900,8 @@
4840 3900 }
4841 3901
4842 3902 $path = $parsed['path'];
4843 3903 $ext = pathinfo( $path, PATHINFO_EXTENSION );
4844 -
4845 3904 if ( $expected_extension !== $ext ) {
4846 3905 // The URL isn't to an XML file.
4847 3906 return false;
4848 3907 }
@@ -4850,8 +3909,65 @@
4850 3909 return true;
4851 3910 }
4852 3911
4853 3912 /**
3913 + * @since 4.08
3914 + * @deprecated 4.09.01
3915 + */
3916 + public static function expiring_message() {
3917 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3918 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3919 + FrmProAddonsController::expiring_message();
3920 + }
3921 + }
3922 +
3923 + /**
3924 + * Use the WP 4.7 wp_doing_ajax function
3925 + *
3926 + * @since 2.05.07
3927 + * @deprecated 4.04.04
3928 + */
3929 + public static function wp_doing_ajax() {
3930 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3931 + return wp_doing_ajax();
3932 + }
3933 +
3934 + /**
3935 + * @deprecated 4.0
3936 + */
3937 + public static function insert_opt_html( $args ) {
3938 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3939 + FrmFormsHelper::insert_opt_html( $args );
3940 + }
3941 +
3942 + /**
3943 + * @deprecated 3.01
3944 + * @codeCoverageIgnore
3945 + */
3946 + public static function sanitize_array( &$values ) {
3947 + FrmDeprecated::sanitize_array( $values );
3948 + }
3949 +
3950 + /**
3951 + * @since 2.0
3952 + * @deprecated 5.0.13
3953 + *
3954 + * @return string The base Google APIS url for the current version of jQuery UI
3955 + */
3956 + public static function jquery_ui_base_url() {
3957 + _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3958 + return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
3959 + }
3960 +
3961 + /**
3962 + * @since 4.07
3963 + * @deprecated 6.0
3964 + */
3965 + public static function renewal_message() {
3966 + _deprecated_function( __METHOD__, '6.0', 'FrmProAddonsController::renewal_message' );
3967 + }
3968 +
3969 + /**
4854 3970 * Display a dismissable warning message and save its dismissal state.
4855 3971 *
4856 3972 * @since 6.3
4857 3973 *
@@ -4856,9 +3972,8 @@
4856 3972 * @since 6.3
4857 3973 *
4858 3974 * @param string $message The warning message to display.
4859 3975 * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
4860 - *
4861 3976 * @return void
4862 3977 */
4863 3978 public static function add_dismissable_warning_message( $message = '', $option = '' ) {
4864 3979 if ( ! $message || ! $option ) {
@@ -4864,9 +3979,9 @@
4864 3979 if ( ! $message || ! $option ) {
4865 3980 return;
4866 3981 }
4867 3982
4868 - $ajax_callback = function () use ( $option ) {
3983 + $ajax_callback = function() use ( $option ) {
4869 3984 self::dismiss_warning_message( $option );
4870 3985 };
4871 3986
4872 3987 // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action.
@@ -4874,9 +3989,9 @@
4874 3989 add_action( 'wp_ajax_frm_' . $option, $ajax_callback );
4875 3990
4876 3991 add_filter(
4877 3992 'frm_message_list',
4878 - function ( $show_messages ) use ( $message, $option ) {
3993 + function( $show_messages ) use ( $message, $option ) {
4879 3994 if ( get_option( $option, false ) ) {
4880 3995 return $show_messages;
4881 3996 }
4882 3997
@@ -4883,9 +3998,9 @@
4883 3998 $dismiss_icon = self::icon_by_class(
4884 3999 'frmfont frm_close_icon',
4885 4000 array(
4886 4001 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ),
4887 - 'echo' => false,
4002 + 'echo' => false,
4888 4003 )
4889 4004 );
4890 4005
4891 4006 $show_messages[] = $message;
@@ -4901,9 +4016,8 @@
4901 4016 *
4902 4017 * @since 6.3
4903 4018 *
4904 4019 * @param string $option The unique identifier for the dismissal state of the message.
4905 - *
4906 4020 * @return void
4907 4021 */
4908 4022 public static function dismiss_warning_message( $option = '' ) {
4909 4023 self::permission_check( 'frm_change_settings' );
@@ -4913,172 +4027,6 @@
4913 4027 update_option( $option, true, 'no' );
4914 4028 }
4915 4029
4916 4030 wp_send_json_success();
4917 - }
4918 -
4919 - /**
4920 - * Lite license copy.
4921 - * Used in FrmDashboardController & FrmSettingsController
4922 - *
4923 - * @since 6.8
4924 - *
4925 - * @return string
4926 - */
4927 - public static function copy_for_lite_license() {
4928 - $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂';
4929 -
4930 - return apply_filters( 'frm_license_type_text', $message );
4931 - }
4932 -
4933 - /**
4934 - * Removes scripts that are unnecessarily loaded across the pages!
4935 - *
4936 - * @since 6.9
4937 - *
4938 - * @return void
4939 - */
4940 - public static function dequeue_extra_global_scripts() {
4941 - wp_dequeue_script( 'frm-surveys-admin' );
4942 - wp_dequeue_script( 'frm-quizzes-form-action' );
4943 - }
4944 -
4945 - /**
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
4954 - */
4955 - public static function tooltip_icon( $tooltip_text, $atts = array() ) {
4956 - $atts['title'] = $tooltip_text;
4957 -
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
4968 - }
4969 -
4970 - /**
4971 - * Prints errors for settings in onboarding wizard or template settings.
4972 - *
4973 - * @since 6.15
4974 - *
4975 - * @param array $args Args.
4976 - *
4977 - * @return void
4978 - */
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
5005 - }
5006 -
5007 - /**
5008 - * Check if GDPR is enabled.
5009 - *
5010 - * @since 6.19
5011 - *
5012 - * @return bool
5013 - */
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;
5017 - }
5018 -
5019 - /**
5020 - * Check if GDPR cookies are disabled.
5021 - *
5022 - * @since 6.19
5023 - *
5024 - * @return bool
5025 - */
5026 - public static function no_gdpr_cookies() {
5027 - $frm_settings = self::get_settings();
5028 - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies;
5029 - }
5030 -
5031 - /**
5032 - * Check if a string is valid UTF-8.
5033 - *
5034 - * @since 6.24
5035 - *
5036 - * @param string $string The string to check.
5037 - *
5038 - * @return bool
5039 - */
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 - }
5045 -
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;
5051 - }
5052 -
5053 - /**
5054 - * Get a documentation URL with UTM parameters and affiliate tracking.
5055 - *
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.
5063 - */
5064 - public static function get_doc_url( $path, $campaign, $add_kb_base = true ) {
5065 - $path = trim( $path, '/' );
5066 -
5067 - if ( $add_kb_base ) {
5068 - $path = 'knowledgebase/' . $path;
5069 - }
5070 -
5071 - return self::maybe_add_missing_utm( 'https://formidableforms.com/' . $path, array( 'campaign' => $campaign ) );
5072 - }
5073 -
5074 - /**
5075 - * @since 5.0.16
5076 - * @deprecated 6.26
5077 - *
5078 - * @return bool
5079 - */
5080 - public static function show_landing_pages() {
5081 - _deprecated_function( __METHOD__, '6.26' );
5082 - return true;
5083 4031 }
5084 4032 }