PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.01
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.01
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 +284 -1230 6.4.15.0.01 View file →
@@ -3,21 +3,16 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmAppHelper {
7 - public static $db_version = 98; // Version of the database we are moving to.
7 + public static $db_version = 98; // Version of the database we are moving to.
8 8 public static $pro_db_version = 37; //deprecated
9 - public static $font_version = 7;
9 + public static $font_version = 7;
10 10
11 11 /**
12 - * @var bool $added_gmt_offset_filter
13 - */
14 - private static $added_gmt_offset_filter = false;
15 -
16 - /**
17 12 * @since 2.0
18 13 */
19 - public static $plug_version = '6.4.1';
14 + public static $plug_version = '5.0.01';
20 15
21 16 /**
22 17 * @since 1.07.02
23 18 *
@@ -173,9 +168,9 @@
173 168 /**
174 169 * @since 4.0
175 170 */
176 171 public static function show_logo( $atts = array() ) {
177 - echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
172 + echo self::kses( self::svg_logo( $atts ), 'all' ); // WPCS: XSS ok.
178 173 }
179 174
180 175 /**
181 176 * @since 4.03.02
@@ -196,9 +191,9 @@
196 191 // Show nothing if it isn't an SVG.
197 192 $icon = '<div style="height:39px"></div>';
198 193 }
199 194 }
200 - echo self::kses( $icon, 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
195 + echo self::kses( $icon, 'all' ); // WPCS: XSS ok.
201 196 }
202 197
203 198 /**
204 199 * @since 2.02.04
@@ -252,15 +247,15 @@
252 247 global $pagenow;
253 248 $get_page = self::simple_get( 'page', 'sanitize_title' );
254 249 if ( $pagenow ) {
255 250 // allow this to be true during ajax load i.e. ajax form builder loading
256 - $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page;
251 + $is_page = ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page;
257 252 if ( $is_page ) {
258 253 return true;
259 254 }
260 255 }
261 256
262 - return is_admin() && $get_page === $page;
257 + return is_admin() && $get_page == $page;
263 258 }
264 259
265 260 /**
266 261 * If the current page is for editing or creating a view.
@@ -332,18 +327,14 @@
332 327 * Check if on an admin page
333 328 *
334 329 * @since 2.0
335 330 *
331 + * @param None
332 + *
336 333 * @return boolean
337 334 */
338 335 public static function is_admin() {
339 - $is_admin = is_admin() && ! wp_doing_ajax();
340 -
341 - /**
342 - * @since 6.0
343 - * @param bool $is_admin
344 - */
345 - return apply_filters( 'frm_is_admin', $is_admin );
336 + return is_admin() && ! wp_doing_ajax();
346 337 }
347 338
348 339 /**
349 340 * Check if value contains blank value or empty array
@@ -376,17 +367,26 @@
376 367 return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
377 368 }
378 369
379 370 /**
380 - * Check for the IP address in several places (when custom headers are enabled).
381 - * Used by [ip] shortcode.
371 + * Check for the IP address in several places
372 + * Used by [ip] shortcode
382 373 *
383 374 * @return string The IP address of the current user
384 375 */
385 376 public static function get_ip_address() {
386 - $ip_options = self::should_use_custom_header_ip() ? self::get_custom_header_keys_for_ip() : array( 'REMOTE_ADDR' );
387 - $ip = '';
388 -
377 + $ip_options = array(
378 + 'HTTP_CLIENT_IP',
379 + 'HTTP_CF_CONNECTING_IP',
380 + 'HTTP_X_FORWARDED_FOR',
381 + 'HTTP_X_FORWARDED',
382 + 'HTTP_X_CLUSTER_CLIENT_IP',
383 + 'HTTP_X_REAL_IP',
384 + 'HTTP_FORWARDED_FOR',
385 + 'HTTP_FORWARDED',
386 + 'REMOTE_ADDR',
387 + );
388 + $ip = '';
389 389 foreach ( $ip_options as $key ) {
390 390 if ( ! isset( $_SERVER[ $key ] ) ) {
391 391 continue;
392 392 }
@@ -392,9 +392,9 @@
392 392 }
393 393
394 394 $key = self::get_server_value( $key );
395 395 foreach ( explode( ',', $key ) as $ip ) {
396 - $ip = trim( $ip ); // Just to be safe.
396 + $ip = trim( $ip ); // just to be safe.
397 397
398 398 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
399 399 return sanitize_text_field( $ip );
400 400 }
@@ -403,52 +403,8 @@
403 403
404 404 return sanitize_text_field( $ip );
405 405 }
406 406
407 - /**
408 - * @since 6.1
409 - *
410 - * @return array
411 - */
412 - public static function get_custom_header_keys_for_ip() {
413 - return array(
414 - 'HTTP_CLIENT_IP',
415 - 'HTTP_CF_CONNECTING_IP',
416 - 'HTTP_X_FORWARDED_FOR',
417 - 'HTTP_X_FORWARDED',
418 - 'HTTP_X_CLUSTER_CLIENT_IP',
419 - 'HTTP_X_REAL_IP',
420 - 'HTTP_FORWARDED_FOR',
421 - 'HTTP_FORWARDED',
422 - 'REMOTE_ADDR',
423 - );
424 - }
425 -
426 - /**
427 - * Check if we should check every HTTP header or just $_SERVER['REMOTE_ADDR'].
428 - * The other HTTP headers can be spoofed so this isn't recommended.
429 - * But in some cases (like reverse proxies), the IP may be empty if you use $_SERVER['REMOTE_ADDR'].
430 - *
431 - * @since 6.1
432 - *
433 - * @return bool
434 - */
435 - private static function should_use_custom_header_ip() {
436 - $settings = self::get_settings();
437 - $should_use_custom_header_ip = ! $settings->no_ips && $settings->custom_header_ip;
438 -
439 - /**
440 - * Filter whether to check spoofable HTTP headers.
441 - * This uses the custom_header_ip setting, but it is hidden if the GDPR option is also on.
442 - * As the IP is still checked for blacklist checks, someone with the GDPR option may still want to enable this when behind a reverse proxy.
443 - *
444 - * @since 6.1
445 - *
446 - * @param bool $should_use_custom_header_ip
447 - */
448 - return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip );
449 - }
450 -
451 407 public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) {
452 408 if ( strpos( $param, '[' ) ) {
453 409 $params = explode( '[', $param );
454 410 $param = $params[0];
@@ -453,11 +409,12 @@
453 409 $params = explode( '[', $param );
454 410 $param = $params[0];
455 411 }
456 412
457 - if ( $src === 'get' ) {
458 - $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
459 - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
413 + if ( $src == 'get' ) {
414 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
415 + $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default );
416 + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) {
460 417 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
461 418 $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) );
462 419 }
463 420 self::sanitize_value( $sanitize, $value );
@@ -539,14 +496,14 @@
539 496
540 497 $value = $args['default'];
541 498 if ( $args['type'] == 'get' ) {
542 499 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
543 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
500 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
544 501 $value = wp_unslash( $_GET[ $args['param'] ] );
545 502 }
546 503 } elseif ( $args['type'] == 'post' ) {
547 - if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
548 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
504 + if ( isset( $_POST[ $args['param'] ] ) ) {
505 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
549 506 $value = wp_unslash( $_POST[ $args['param'] ] );
550 507 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
551 508 self::unserialize_or_decode( $value );
552 509 }
@@ -551,9 +508,9 @@
551 508 self::unserialize_or_decode( $value );
552 509 }
553 510 }
554 511 } else {
555 - if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
512 + if ( isset( $_REQUEST[ $args['param'] ] ) ) {
556 513 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
557 514 $value = wp_unslash( $_REQUEST[ $args['param'] ] );
558 515 }
559 516 }
@@ -688,80 +645,14 @@
688 645 return wp_kses( $value, $allowed_html );
689 646 }
690 647
691 648 /**
692 - * The regular kses function strips [button_action] from submit button HTML.
693 - *
694 - * @since 5.0.13
695 - *
696 - * @param string $html
697 - * @return string
698 - */
699 - public static function kses_submit_button( $html ) {
700 - $included_button_action = false !== strpos( $html, '[button_action]' );
701 - $included_back_hook = false !== strpos( $html, '[back_hook]' );
702 - $included_draft_hook = false !== strpos( $html, '[draft_hook]' );
703 - add_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
704 - add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
705 - $html = self::kses( $html, 'all' );
706 - remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' );
707 - remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' );
708 - if ( $included_button_action ) {
709 - if ( false !== strpos( $html, '<input type="submit"' ) ) {
710 - $pattern = '/(<input type="submit")([^>]*)(\/>)/';
711 - $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 );
712 - } else {
713 - $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/';
714 - $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 );
715 - }
716 - }
717 - if ( $included_back_hook ) {
718 - $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html );
719 - }
720 - if ( $included_draft_hook ) {
721 - $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html );
722 - }
723 - return $html;
724 - }
725 -
726 - /**
727 - * @since 5.0.13
728 - *
729 - * @param array $allowed_attr
730 - * @return array
731 - */
732 - public static function allow_visibility_style( $allowed_attr ) {
733 - $allowed_attr[] = 'visibility';
734 - return $allowed_attr;
735 - }
736 -
737 - /**
738 - * @since 5.0.13
739 - *
740 - * @param array $allowed_html
741 - * @return array
742 - */
743 - public static function add_allowed_submit_button_tags( $allowed_html ) {
744 - $allowed_html['input'] = array(
745 - 'type' => true,
746 - 'value' => true,
747 - 'formnovalidate' => true,
748 - 'name' => true,
749 - 'class' => true,
750 - );
751 - $allowed_html['button']['formnovalidate'] = true;
752 - $allowed_html['button']['name'] = true;
753 - $allowed_html['img']['style'] = true;
754 - return $allowed_html;
755 - }
756 -
757 - /**
758 649 * @since 2.05.03
759 650 */
760 651 private static function allowed_html( $allowed ) {
761 652 $html = self::safe_html();
762 653 $allowed_html = array();
763 - if ( $allowed === 'all' ) {
654 + if ( $allowed == 'all' ) {
764 655 $allowed_html = $html;
765 656 } elseif ( ! empty( $allowed ) ) {
766 657 foreach ( (array) $allowed as $a ) {
767 658 $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array();
@@ -780,16 +671,15 @@
780 671 'id' => true,
781 672 );
782 673
783 674 return array(
784 - 'a' => array(
785 - 'class' => true,
786 - 'href' => true,
787 - 'id' => true,
788 - 'rel' => true,
789 - 'target' => true,
790 - 'title' => true,
791 - 'tabindex' => true,
675 + 'a' => array(
676 + 'class' => true,
677 + 'href' => true,
678 + 'id' => true,
679 + 'rel' => true,
680 + 'target' => true,
681 + 'title' => true,
792 682 ),
793 683 'abbr' => array(
794 684 'title' => true,
795 685 ),
@@ -813,9 +703,8 @@
813 703 'class' => true,
814 704 'id' => true,
815 705 'title' => true,
816 706 'style' => true,
817 - 'role' => true,
818 707 ),
819 708 'dl' => array(),
820 709 'dt' => array(),
821 710 'em' => array(),
@@ -864,13 +753,12 @@
864 753 'stroke-width' => true,
865 754 ),
866 755 'section' => $allow_class,
867 756 'span' => array(
868 - 'class' => true,
869 - 'id' => true,
870 - 'title' => true,
871 - 'style' => true,
872 - 'aria-hidden' => true,
757 + 'class' => true,
758 + 'id' => true,
759 + 'title' => true,
760 + 'style' => true,
873 761 ),
874 762 'strike' => array(),
875 763 'strong' => array(),
876 764 'symbol' => array(
@@ -878,36 +766,22 @@
878 766 'id' => true,
879 767 'viewbox' => true,
880 768 ),
881 769 'svg' => array(
882 - 'class' => true,
883 - 'id' => true,
884 - 'xmlns' => true,
885 - 'viewbox' => true,
886 - 'width' => true,
887 - 'height' => true,
888 - 'style' => true,
889 - 'fill' => true,
890 - 'aria-label' => true,
891 - 'aria-hidden' => true,
770 + 'class' => true,
771 + 'id' => true,
772 + 'xmlns' => true,
773 + 'viewbox' => true,
774 + 'width' => true,
775 + 'height' => true,
776 + 'style' => true,
777 + 'fill' => true,
892 778 ),
893 779 'use' => array(
894 - 'href' => true,
780 + 'href' => true,
895 781 'xlink:href' => true,
896 782 ),
897 783 'ul' => $allow_class,
898 - 'label' => array(
899 - 'for' => true,
900 - 'class' => true,
901 - 'id' => true,
902 - ),
903 - 'button' => array(
904 - 'class' => true,
905 - 'type' => true,
906 - ),
907 - 'legend' => array(
908 - 'class' => true,
909 - ),
910 784 );
911 785 }
912 786
913 787 /**
@@ -965,18 +839,8 @@
965 839
966 840 $html_atts = self::array_to_html_params( $atts );
967 841
968 842 $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
969 -
970 - // Replace icons that have been removed.
971 - $deprecated = array(
972 - 'frm_clone_solid_icon' => 'frm_clone_icon',
973 - );
974 - if ( isset( $deprecated[ $icon ] ) ) {
975 - $icon = $deprecated[ $icon ];
976 - $class = str_replace( $icon, $deprecated[ $icon ], $class );
977 - }
978 -
979 843 if ( $icon === $class ) {
980 844 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
981 845 } else {
982 846 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
@@ -983,15 +847,15 @@
983 847 if ( strpos( $icon, ' ' ) ) {
984 848 $icon = explode( ' ', $icon );
985 849 $icon = reset( $icon );
986 850 }
987 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
851 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
988 852 <use xlink:href="#' . esc_attr( $icon ) . '" />
989 853 </svg>';
990 854 }
991 855
992 856 if ( $echo ) {
993 - echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
857 + echo $icon; // WPCS: XSS ok.
994 858 } else {
995 859 return $icon;
996 860 }
997 861 }
@@ -996,88 +860,14 @@
996 860 }
997 861 }
998 862
999 863 /**
1000 - * Run kses for icons. It needs to add a few filters first in order to preserve some custom style values.
1001 - *
1002 - * @since 5.0.13
1003 - *
1004 - * @param string $icon
1005 - * @return string
1006 - */
1007 - public static function kses_icon( $icon ) {
1008 - add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
1009 - add_filter( 'safecss_filter_attr_allow_css', 'FrmAppHelper::allow_style', 10, 2 );
1010 - add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_icon_tags' );
1011 - $icon = self::kses( $icon, 'all' );
1012 - remove_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' );
1013 - remove_filter( 'safecss_filter_attr_allow_css', 'FrmAppHelper::allow_style' );
1014 - remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_icon_tags' );
1015 - return $icon;
1016 - }
1017 -
1018 - /**
1019 - * @since 5.0.13.1
1020 - *
1021 - * @param array $allowed_html
1022 - * @return array
1023 - */
1024 - public static function add_allowed_icon_tags( $allowed_html ) {
1025 - $allowed_html['svg']['data-open'] = true;
1026 - $allowed_html['svg']['title'] = true;
1027 - return $allowed_html;
1028 - }
1029 -
1030 - /**
1031 - * @since 5.0.13
1032 - *
1033 - * @param array $allowed_attr
1034 - * @return array
1035 - */
1036 - public static function allow_vars_in_styles( $allowed_attr ) {
1037 - $allowed_attr[] = '--primary-700';
1038 - return $allowed_attr;
1039 - }
1040 -
1041 - /**
1042 - * @since 5.0.13
1043 - *
1044 - * @param bool $allow_css
1045 - * @param string $css_string
1046 - */
1047 - public static function allow_style( $allow_css, $css_string ) {
1048 - if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
1049 - $split = explode( ':', $css_string, 2 );
1050 - $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1051 - }
1052 - return $allow_css;
1053 - }
1054 -
1055 - /**
1056 - * @since 5.0.13
1057 - *
1058 - * @param string $value
1059 - * @return bool
1060 - */
1061 - private static function is_a_valid_color( $value ) {
1062 - $match = 0;
1063 - if ( 0 === strpos( $value, 'rgba(' ) ) {
1064 - $match = preg_match( '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/', $value );
1065 - } elseif ( 0 === strpos( $value, 'rgb(' ) ) {
1066 - $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value );
1067 - } elseif ( 0 === strpos( $value, '#' ) ) {
1068 - $match = preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})\b$/', $value );
1069 - }
1070 - return (bool) $match;
1071 - }
1072 -
1073 - /**
1074 864 * Include svg images.
1075 865 *
1076 866 * @since 4.0.02
1077 867 */
1078 868 public static function include_svg() {
1079 - include_once self::plugin_path() . '/images/icons.svg';
869 + include_once( self::plugin_path() . '/images/icons.svg' );
1080 870 }
1081 871
1082 872 /**
1083 873 * Convert an associative array to HTML values.
@@ -1082,48 +872,19 @@
1082 872 /**
1083 873 * Convert an associative array to HTML values.
1084 874 *
1085 875 * @since 4.0.02
1086 - * @since 5.0.13 added $echo parameter.
1087 - *
1088 876 * @param array $atts
1089 - * @param bool $echo
1090 - * @return string|void
877 + * @return string
1091 878 */
1092 - public static function array_to_html_params( $atts, $echo = false ) {
1093 - $callback = function() use ( $atts ) {
1094 - if ( $atts ) {
1095 - foreach ( $atts as $key => $value ) {
1096 - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1097 - }
879 + public static function array_to_html_params( $atts ) {
880 + $html = '';
881 + if ( ! empty( $atts ) ) {
882 + foreach ( $atts as $key => $value ) {
883 + $html .= ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1098 884 }
1099 - };
1100 - return self::clip( $callback, $echo );
1101 - }
1102 -
1103 - /**
1104 - * Call an echo function and either echo it or return the result as a string.
1105 - *
1106 - * @since 5.0.13
1107 - *
1108 - * @param Closure $echo_function
1109 - * @param bool $echo
1110 - * @return string|void
1111 - */
1112 - public static function clip( $echo_function, $echo = false ) {
1113 - if ( ! $echo ) {
1114 - ob_start();
1115 885 }
1116 -
1117 - if ( is_callable( $echo_function ) ) {
1118 - $echo_function();
1119 - }
1120 -
1121 - if ( ! $echo ) {
1122 - $return = ob_get_contents();
1123 - ob_end_clean();
1124 - return $return;
1125 - }
886 + return $html;
1126 887 }
1127 888
1128 889 /**
1129 890 * @since 3.0
@@ -1140,94 +901,31 @@
1140 901 include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1141 902 }
1142 903
1143 904 /**
1144 - * @since 6.0
1145 - *
1146 - * @param string $type
1147 - * @return void
1148 - */
1149 - public static function import_link( $type = 'secondary' ) {
1150 - ?>
1151 - <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-import' ) ); ?>" class="button frm-button-<?php echo esc_attr( $type ); ?> frm_animate_bg">
1152 - <?php esc_html_e( 'Import', 'formidable' ); ?>
1153 - </a>
1154 - <?php
1155 - }
1156 -
1157 - /**
1158 - * Print applicable admin banner.
1159 - *
1160 - * @since 5.4.2
1161 - *
1162 - * @param bool $should_show_lite_upgrade
1163 - * @return void
1164 - */
1165 - public static function print_admin_banner( $should_show_lite_upgrade ) {
1166 - if ( ! current_user_can( 'administrator' ) ) {
1167 - FrmInbox::maybe_show_banner();
1168 - return;
1169 - }
1170 -
1171 - if ( self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) {
1172 - // Print license warning or inbox banner and exit if either prints.
1173 - // And exit before printing the upgrade bar if it shouldn't be shown.
1174 - return;
1175 - }
1176 - ?>
1177 - <div class="frm-upgrade-bar">
1178 - <span>You're using Formidable Forms Lite. To unlock more features consider</span>
1179 - <a href="<?php echo esc_url( self::admin_upgrade_link( 'top-bar' ) ); ?>" target="_blank" rel="noopener">upgrading to Pro</a>.
1180 - </div>
1181 - <?php
1182 - }
1183 -
1184 - /**
1185 - * @since 5.4.2
1186 - *
1187 - * @return bool True if a banner is available and shown.
1188 - */
1189 - private static function maybe_show_license_warning() {
1190 - return is_callable( 'FrmProAddonsController::admin_banner' ) && FrmProAddonsController::admin_banner();
1191 - }
1192 -
1193 - /**
1194 - * Render a button for a new item (Form, Application, etc).
1195 - *
1196 905 * @since 3.0
1197 - * @param array $atts {
1198 - * @type array $link_hook Custom link hook, calls do_action and exits early.
1199 - * @type string $new_link Href value, default #.
1200 - * @type string $class Custom class names, space separated.
1201 - * @type string $button_text Button text. Default "Add New".
1202 - * }
1203 - * @return void
906 + * @param array $atts
1204 907 */
1205 908 public static function add_new_item_link( $atts ) {
1206 - if ( isset( $atts['link_hook'] ) ) {
909 + if ( ! empty( $atts['new_link'] ) ) {
910 + ?>
911 + <a href="<?php echo esc_url( $atts['new_link'] ); ?>" class="button button-primary frm-button-primary frm-with-plus">
912 + <?php self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' ); ?>
913 + <?php esc_html_e( 'Add New', 'formidable' ); ?>
914 + </a>
915 + <?php
916 + } elseif ( ! empty( $atts['trigger_new_form_modal'] ) ) {
917 + ?>
918 + <a href="#" class="button button-primary frm-button-primary frm-with-plus frm-trigger-new-form-modal">
919 + <?php
920 + self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' );
921 + esc_html_e( 'Add New', 'formidable' );
922 + ?>
923 + </a>
924 + <?php
925 + } elseif ( isset( $atts['link_hook'] ) ) {
1207 926 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1208 - return;
1209 927 }
1210 -
1211 - if ( empty( $atts['new_link'] ) && empty( $atts['trigger_new_form_modal'] ) && empty( $atts['class'] ) ) {
1212 - // Do not render a button if none of these attributes are set.
1213 - return;
1214 - }
1215 -
1216 - $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#';
1217 - $class = 'button button-primary frm-button-primary';
1218 -
1219 - if ( ! empty( $atts['trigger_new_form_modal'] ) ) {
1220 - $class .= ' frm-trigger-new-form-modal';
1221 - }
1222 -
1223 - if ( ! empty( $atts['class'] ) ) {
1224 - $class .= ' ' . $atts['class'];
1225 - }
1226 -
1227 - $button_text = ! empty( $atts['button_text'] ) ? $atts['button_text'] : __( 'Add New', 'formidable' );
1228 -
1229 - require self::plugin_path() . '/classes/views/shared/add-button.php';
1230 928 }
1231 929
1232 930 /**
1233 931 * @since 3.06
@@ -1300,8 +998,9 @@
1300 998 );
1301 999 $new_file = new FrmCreateFile( $file_atts );
1302 1000
1303 1001 $files = array(
1002 + self::plugin_path() . '/js/jquery/jquery.placeholder.min.js',
1304 1003 self::plugin_path() . '/js/formidable.min.js',
1305 1004 );
1306 1005 $files = apply_filters( 'frm_combined_js_files', $files );
1307 1006 $new_file->combine_files( $files );
@@ -1322,9 +1021,8 @@
1322 1021 }
1323 1022
1324 1023 /**
1325 1024 * Gets all post from a specific post type.
1326 - * This gets the entire WP_Post object so it can require a lot of memory. When only id and title are needed, consider using FrmAppHelper::get_post_ids_and_titles instead.
1327 1025 *
1328 1026 * @since 4.10.01 Add `$post_type` argument.
1329 1027 *
1330 1028 * @param string $post_type Post type to query. Default is `page`.
@@ -1342,30 +1040,8 @@
1342 1040 return get_posts( $query );
1343 1041 }
1344 1042
1345 1043 /**
1346 - * Gets post ids and titles for a specific post type.
1347 - *
1348 - * @since 5.0.09
1349 - *
1350 - * @param string $post_type Post type to query. Default is `page`.
1351 - * @return array
1352 - */
1353 - public static function get_post_ids_and_titles( $post_type = 'page' ) {
1354 - return FrmDb::get_results(
1355 - 'posts',
1356 - array(
1357 - 'post_type' => $post_type,
1358 - 'post_status' => array( 'publish', 'private' ),
1359 - ),
1360 - 'ID, post_title',
1361 - array(
1362 - 'order_by' => 'post_title ASC',
1363 - )
1364 - );
1365 - }
1366 -
1367 - /**
1368 1044 * Renders an autocomplete page selection or a regular dropdown depending on
1369 1045 * the total page count
1370 1046 *
1371 1047 * @since 4.03.06
@@ -1410,9 +1086,9 @@
1410 1086 */
1411 1087 public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) {
1412 1088 self::prep_page_dropdown_params( $page_id, $truncate, $args );
1413 1089
1414 - $pages = self::get_post_ids_and_titles( $args['post_type'] );
1090 + $pages = self::get_pages( $args['post_type'] );
1415 1091 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1416 1092
1417 1093 ?>
1418 1094 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
@@ -1466,8 +1142,9 @@
1466 1142 public static function post_edit_link( $post_id ) {
1467 1143 $post = get_post( $post_id );
1468 1144 if ( $post ) {
1469 1145 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1146 + $post_url = self::maybe_full_screen_link( $post_url );
1470 1147
1471 1148 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
1472 1149 }
1473 1150
@@ -1477,64 +1154,25 @@
1477 1154 /**
1478 1155 * Hide the WordPress menus on some pages.
1479 1156 *
1480 1157 * @since 4.0
1481 - *
1482 - * @return bool
1483 1158 */
1484 1159 public static function is_full_screen() {
1485 - return self::is_form_builder_page() ||
1486 - self::is_style_editor_page() ||
1487 - self::is_full_screen_view_builder_page();
1488 - }
1160 + $full_builder = self::is_form_builder_page();
1161 + $styler = self::is_admin_page( 'formidable-styles' ) || self::is_admin_page( 'formidable-styles2' );
1162 + $full_entries = self::simple_get( 'frm-full', 'absint' );
1489 1163
1490 - /**
1491 - * Check if user is on the style editor or its alternative URL.
1492 - * The first URL is a submenu "Styles" in the Formidable menu /wp-admin/admin.php?page=formidable-styles.
1493 - * The alternative URL is linked as a submenu "Forms" item of the Appearance menu /wp-admin/themes.php?page=formidable-styles2.
1494 - *
1495 - * @since 5.5.3
1496 - * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view.
1497 - *
1498 - * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match.
1499 - * @return bool
1500 - */
1501 - public static function is_style_editor_page( $view = '' ) {
1502 - if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) {
1503 - return false;
1504 - }
1505 -
1506 - if ( ! in_array( $view, array( 'list', 'edit' ), true ) ) {
1507 - return true;
1508 - }
1509 -
1510 - $action = self::simple_get( 'frm_action' );
1511 - $is_edit_mode = 'edit' === $action || ( ! $action && ! self::simple_get( 'id' ) && ! self::simple_get( 'form' ) );
1512 -
1513 - if ( ! $is_edit_mode && class_exists( 'FrmProStylesController' ) && in_array( $action, array( 'new_style', 'duplicate' ), true ) ) {
1514 - $is_edit_mode = true;
1515 - }
1516 -
1517 - $checking_for_edit_mode = 'edit' === $view;
1518 -
1519 - return $is_edit_mode === $checking_for_edit_mode;
1164 + return $full_builder || $full_entries || $styler || self::is_view_builder_page();
1520 1165 }
1521 1166
1522 1167 /**
1523 - * @since 5.5.3
1524 - *
1525 - * @return bool
1526 - */
1527 - private static function is_full_screen_view_builder_page() {
1528 - return self::is_admin_page( 'formidable-views-editor' );
1529 - }
1530 -
1531 - /**
1532 1168 * @since 4.0
1533 - * @deprecated 5.5.3
1534 1169 */
1535 1170 public static function maybe_full_screen_link( $link ) {
1536 - _deprecated_function( __METHOD__, '5.5.3' );
1171 + $is_full = self::simple_get( 'frm-full', 'absint' );
1172 + if ( $is_full && ! empty( $link ) && $link !== '#' ) {
1173 + $link .= '&frm-full=1';
1174 + }
1537 1175 return $link;
1538 1176 }
1539 1177
1540 1178 /**
@@ -1594,10 +1232,19 @@
1594 1232 * @param string $type Supports `auto`, `pro`, or `pro_only`.
1595 1233 * @return array
1596 1234 */
1597 1235 public static function frm_capabilities( $type = 'auto' ) {
1598 - if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) {
1599 - return self::get_lite_capabilities();
1236 + $cap = array(
1237 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1238 + 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1239 + 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1240 + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1241 + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
1242 + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
1243 + );
1244 +
1245 + if ( ! self::pro_is_installed() && 'pro' !== $type && 'pro_only' !== $type ) {
1246 + return $cap;
1600 1247 }
1601 1248
1602 1249 $pro_cap = array(
1603 1250 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
@@ -1604,41 +1251,17 @@
1604 1251 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
1605 1252 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1606 1253 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
1607 1254 );
1608 - /**
1609 - * @since 5.3.1
1610 - *
1611 - * @param array<string,string> $pro_cap
1612 - */
1613 - $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
1614 1255
1615 1256 if ( 'pro_only' === $type ) {
1616 1257 return $pro_cap;
1617 1258 }
1618 1259
1619 - return self::get_lite_capabilities() + $pro_cap;
1260 + return $cap + $pro_cap;
1620 1261 }
1621 1262
1622 1263 /**
1623 - * Get the list of lite plugin capabilities.
1624 - *
1625 - * @since 5.3.1
1626 - *
1627 - * @return array<string,string>
1628 - */
1629 - private static function get_lite_capabilities() {
1630 - return array(
1631 - 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1632 - 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1633 - 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1634 - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1635 - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
1636 - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
1637 - );
1638 - }
1639 -
1640 - /**
1641 1264 * Call the WordPress current_user_can but also validate empty strings as true for any logged in user
1642 1265 *
1643 1266 * @since 4.06.03
1644 1267 *
@@ -1883,8 +1506,19 @@
1883 1506 return $val;
1884 1507 }
1885 1508
1886 1509 /**
1510 + * @since 2.0
1511 + * @return string The base Google APIS url for the current version of jQuery UI
1512 + */
1513 + public static function jquery_ui_base_url() {
1514 + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
1515 + $url = apply_filters( 'frm_jquery_ui_base_url', $url );
1516 +
1517 + return $url;
1518 + }
1519 +
1520 + /**
1887 1521 * @param string $handle
1888 1522 */
1889 1523 public static function script_version( $handle, $default = 0 ) {
1890 1524 global $wp_scripts;
@@ -1904,20 +1538,10 @@
1904 1538
1905 1539 return $ver;
1906 1540 }
1907 1541
1908 - /**
1909 - * @since 5.0.13 added $echo param.
1910 - *
1911 - * @param string $url
1912 - * @param bool $echo
1913 - * @return string|void
1914 - */
1915 - public static function js_redirect( $url, $echo = false ) {
1916 - $callback = function() use ( $url ) {
1917 - echo '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1918 - };
1919 - return self::clip( $callback, $echo );
1542 + public static function js_redirect( $url ) {
1543 + return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1920 1544 }
1921 1545
1922 1546 public static function get_user_id_param( $user_id ) {
1923 1547 if ( ! $user_id || is_numeric( $user_id ) ) {
@@ -1976,38 +1600,21 @@
1976 1600 }
1977 1601
1978 1602 $key = self::prevent_numeric_and_reserved_keys( $key );
1979 1603
1980 - $similar_keys = FrmDb::get_col(
1604 + $key_check = FrmDb::get_var(
1981 1605 $table_name,
1982 1606 array(
1983 - $column . ' like%' => $key,
1984 - 'ID !' => $id,
1607 + $column => $key,
1608 + 'ID !' => $id,
1985 1609 ),
1986 1610 $column
1987 1611 );
1988 1612
1989 - // Create a unique field id if it has already been used.
1990 - if ( in_array( $key, $similar_keys, true ) ) {
1613 + if ( $key_check || is_numeric( $key_check ) ) {
1991 1614 $key = self::maybe_truncate_key_before_appending( $column, $key );
1992 -
1993 - /**
1994 - * Allow for a custom separator between the attempted key and the generated suffix.
1995 - *
1996 - * @since 5.2.03
1997 - *
1998 - * @param string $separator. Default empty.
1999 - * @param string $key the key without the added suffix.
2000 - */
2001 - $separator = apply_filters( 'frm_unique_' . $column . '_separator', '', $key );
2002 -
2003 - $suffix = 2;
2004 - do {
2005 - $key_check = $key . $separator . $suffix;
2006 - ++$suffix;
2007 - } while ( in_array( $key_check, $similar_keys, true ) );
2008 -
2009 - $key = $key_check;
1615 + // Create a unique field id if it has already been used.
1616 + $key = $key . substr( md5( microtime() . rand() ), 0, 10 );
2010 1617 }
2011 1618
2012 1619 return $key;
2013 1620 }
@@ -2024,11 +1631,8 @@
2024 1631 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2025 1632 $max_key_length_before_truncating = 60;
2026 1633 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2027 1634 $key = substr( $key, 0, $max_key_length_before_truncating );
2028 - if ( is_numeric( $key ) ) {
2029 - $key .= 'a';
2030 - }
2031 1635 }
2032 1636 }
2033 1637 return $key;
2034 1638 }
@@ -2093,9 +1697,9 @@
2093 1697 return false;
2094 1698 }
2095 1699
2096 1700 if ( empty( $post_values ) ) {
2097 - $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1701 + $post_values = wp_unslash( $_POST );
2098 1702 }
2099 1703
2100 1704 $values = array(
2101 1705 'id' => $record->id,
@@ -2113,11 +1717,11 @@
2113 1717 self::fill_form_opts( $record, $table, $post_values, $values );
2114 1718
2115 1719 self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
2116 1720
2117 - if ( $table === 'entries' ) {
1721 + if ( $table == 'entries' ) {
2118 1722 $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
2119 - } elseif ( $table === 'forms' ) {
1723 + } elseif ( $table == 'forms' ) {
2120 1724 $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
2121 1725 }
2122 1726
2123 1727 return $values;
@@ -2394,9 +1998,9 @@
2394 1998 *
2395 1999 * @return string $time_ago
2396 2000 */
2397 2001 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
2398 - if ( empty( $to ) && 0 !== $to ) {
2002 + if ( empty( $to ) ) {
2399 2003 $now = new DateTime();
2400 2004 } else {
2401 2005 $now = new DateTime( '@' . $to );
2402 2006 }
@@ -2647,9 +2251,8 @@
2647 2251 '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' ),
2648 2252 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
2649 2253 /* translators: %1$s: Form name, %2$s: Date */
2650 2254 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ),
2651 - 'new_tab' => __( 'This option will open the link in a new browser tab. Please note that some popup blockers may prevent this from happening, in which case the link will be displayed.', 'formidable' ),
2652 2255 );
2653 2256
2654 2257 if ( ! isset( $tooltips[ $name ] ) ) {
2655 2258 return;
@@ -2676,12 +2279,8 @@
2676 2279 return;
2677 2280 }
2678 2281
2679 2282 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
2680 - if ( 'lite-reports' === $frm_action ) {
2681 - $frm_action = 'reports';
2682 - }
2683 -
2684 2283 if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
2685 2284 echo ' class="current_page"';
2686 2285 }
2687 2286 }
@@ -2738,15 +2337,12 @@
2738 2337 }
2739 2338 }
2740 2339
2741 2340 /**
2742 - * Check for either json or serialized data. This is temporary while transitioning
2341 + * Check for either json or serilized data. This is temporary while transitioning
2743 2342 * all data to json.
2744 2343 *
2745 2344 * @since 4.02.03
2746 - *
2747 - * @param array|string $value
2748 - * @return void
2749 2345 */
2750 2346 public static function unserialize_or_decode( &$value ) {
2751 2347 if ( is_array( $value ) ) {
2752 2348 return;
@@ -2752,9 +2348,9 @@
2752 2348 return;
2753 2349 }
2754 2350
2755 2351 if ( is_serialized( $value ) ) {
2756 - $value = self::maybe_unserialize_array( $value );
2352 + $value = maybe_unserialize( $value );
2757 2353 } else {
2758 2354 $value = self::maybe_json_decode( $value, false );
2759 2355 }
2760 2356 }
@@ -2759,44 +2355,13 @@
2759 2355 }
2760 2356 }
2761 2357
2762 2358 /**
2763 - * Safely unserialize an array if necessary.
2764 - * This function doesn't actually use unserialize. The string is parsed instead.
2765 - *
2766 - * @since 6.2
2767 - *
2768 - * @param mixed $value
2769 - * @return mixed
2770 - */
2771 - public static function maybe_unserialize_array( $value ) {
2772 - if ( ! is_string( $value ) ) {
2773 - return $value;
2774 - }
2775 -
2776 - // Since we only expect an array, skip anything that doesn't start with a:.
2777 - if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
2778 - return $value;
2779 - }
2780 -
2781 - $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
2782 - if ( is_array( $parsed ) ) {
2783 - $value = $parsed;
2784 - }
2785 -
2786 - return $value;
2787 - }
2788 -
2789 - /**
2790 2359 * Decode a JSON string.
2791 2360 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
2792 - *
2793 - * @param mixed $string
2794 - * @param bool $single_to_array
2795 - * @return mixed
2796 2361 */
2797 2362 public static function maybe_json_decode( $string, $single_to_array = true ) {
2798 - if ( is_array( $string ) || is_null( $string ) ) {
2363 + if ( is_array( $string ) ) {
2799 2364 return $string;
2800 2365 }
2801 2366
2802 2367 $new_string = json_decode( $string, true );
@@ -2814,36 +2379,8 @@
2814 2379 return $string;
2815 2380 }
2816 2381
2817 2382 /**
2818 - * @since 6.2.3
2819 - *
2820 - * @param string $value
2821 - * @return string
2822 - */
2823 - public static function maybe_utf8_encode( $value ) {
2824 - $from_format = 'ISO-8859-1';
2825 - $to_format = 'UTF-8';
2826 -
2827 - if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
2828 - if ( mb_check_encoding( $value, $from_format ) ) {
2829 - return mb_convert_encoding( $value, $to_format, $from_format );
2830 - }
2831 - return $value;
2832 - }
2833 -
2834 - if ( function_exists( 'iconv' ) ) {
2835 - $converted = iconv( $from_format, $to_format, $value );
2836 - // Value is false if $value is not ISO-8859-1.
2837 - if ( false !== $converted ) {
2838 - return $converted;
2839 - }
2840 - }
2841 -
2842 - return $value;
2843 - }
2844 -
2845 - /**
2846 2383 * Reformat the json serialized array in name => value array.
2847 2384 *
2848 2385 * @since 4.02.03
2849 2386 */
@@ -2909,17 +2446,14 @@
2909 2446 $version = self::plugin_version();
2910 2447 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
2911 2448
2912 2449 $global_strings = array(
2913 - 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2914 - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2915 - 'url' => self::plugin_url(),
2916 - 'app_url' => 'https://formidableforms.com/',
2917 - 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
2918 - 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
2919 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
2920 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
2921 - 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
2450 + 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2451 + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2452 + 'url' => self::plugin_url(),
2453 + 'app_url' => 'https://formidableforms.com/',
2454 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2455 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2922 2456 );
2923 2457 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
2924 2458
2925 2459 if ( $load ) {
@@ -2943,21 +2477,19 @@
2943 2477 $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2944 2478 $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2945 2479
2946 2480 $script_strings = array(
2947 - 'ajax_url' => $ajax_url,
2948 - 'images_url' => self::plugin_url() . '/images',
2949 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
2950 - 'remove' => __( 'Remove', 'formidable' ),
2951 - 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2952 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
2953 - 'id' => __( 'ID', 'formidable' ),
2954 - 'no_results' => __( 'No results match', 'formidable' ),
2955 - 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2956 - 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2957 - 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2958 - 'focus_first_error' => self::should_focus_first_error(),
2959 - 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
2481 + 'ajax_url' => $ajax_url,
2482 + 'images_url' => self::plugin_url() . '/images',
2483 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2484 + 'remove' => __( 'Remove', 'formidable' ),
2485 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2486 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2487 + 'id' => __( 'ID', 'formidable' ),
2488 + 'no_results' => __( 'No results match', 'formidable' ),
2489 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2490 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2491 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2960 2492 );
2961 2493
2962 2494 $data = $wp_scripts->get_data( 'formidable', 'data' );
2963 2495 if ( empty( $data ) ) {
@@ -2969,10 +2501,10 @@
2969 2501 $admin_script_strings = array(
2970 2502 'desc' => __( '(Click to add description)', 'formidable' ),
2971 2503 'blank' => __( '(Blank)', 'formidable' ),
2972 2504 'no_label' => __( '(no label)', 'formidable' ),
2973 - 'saving' => '', // Deprecated in 6.0.
2974 - 'saved' => '', // Deprecated in 6.0.
2505 + 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
2506 + 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2975 2507 'ok' => __( 'OK', 'formidable' ),
2976 2508 'cancel' => __( 'Cancel', 'formidable' ),
2977 2509 'default_label' => __( 'Default', 'formidable' ),
2978 2510 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
@@ -2978,8 +2510,9 @@
2978 2510 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2979 2511 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2980 2512 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2981 2513 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2514 + 'caution' => __( 'Heads up', 'formidable' ),
2982 2515 'confirm' => __( 'Are you sure?', 'formidable' ),
2983 2516 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2984 2517 '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' ),
2985 2518 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
@@ -2995,9 +2528,9 @@
2995 2528 'import_complete' => __( 'Import Complete', 'formidable' ),
2996 2529 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2997 2530 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2998 2531 'private_label' => __( 'Private', 'formidable' ),
2999 - 'jquery_ui_url' => '',
2532 + 'jquery_ui_url' => self::jquery_ui_base_url(),
3000 2533 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3001 2534 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3002 2535 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3003 2536 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
@@ -3014,9 +2547,8 @@
3014 2547 'install' => __( 'Install', 'formidable' ),
3015 2548 'active' => __( 'Active', 'formidable' ),
3016 2549 'select_a_field' => __( 'Select a Field', 'formidable' ),
3017 2550 'no_items_found' => __( 'No items found.', 'formidable' ),
3018 - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3019 2551 );
3020 2552 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3021 2553
3022 2554 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
@@ -3026,30 +2558,8 @@
3026 2558 }
3027 2559 }
3028 2560
3029 2561 /**
3030 - * Returns whether or not the first errored input should be auto-focused (default true).
3031 - *
3032 - * @since 5.2.05
3033 - *
3034 - * @return bool
3035 - */
3036 - private static function should_focus_first_error() {
3037 - return (bool) apply_filters( 'frm_focus_first_error', true );
3038 - }
3039 -
3040 - /**
3041 - * Returns whether or not field errors should include role="alert" (default true).
3042 - *
3043 - * @since 5.2.05
3044 - *
3045 - * @return bool
3046 - */
3047 - public static function should_include_alert_role_on_field_errors() {
3048 - return (bool) apply_filters( 'frm_include_alert_role_on_field_errors', true );
3049 - }
3050 -
3051 - /**
3052 2562 * Echo the message on the plugins listing page
3053 2563 *
3054 2564 * @since 1.07.10
3055 2565 *
@@ -3072,10 +2582,8 @@
3072 2582 /**
3073 2583 * If Pro is far outdated, show a message.
3074 2584 *
3075 2585 * @since 4.0.01
3076 - *
3077 - * @return void
3078 2586 */
3079 2587 public static function min_pro_version_notice( $min_version ) {
3080 2588 if ( ! self::is_formidable_admin() ) {
3081 2589 // Don't show admin-wide.
@@ -3091,9 +2599,9 @@
3091 2599
3092 2600 $pro_version = FrmProDb::$plug_version;
3093 2601 $expired = FrmAddonsController::is_license_expired();
3094 2602 ?>
3095 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2603 + <div class="error frm_previous_install">
3096 2604 <?php
3097 2605 esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
3098 2606 if ( empty( $expired ) ) {
3099 2607 echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
@@ -3132,9 +2640,9 @@
3132 2640 }
3133 2641
3134 2642 foreach ( $message as $m ) {
3135 2643 ?>
3136 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2644 + <div class="error frm_previous_install">
3137 2645 <?php echo esc_html( $m ); ?>
3138 2646 </div>
3139 2647 <?php
3140 2648 }
@@ -3139,25 +2647,17 @@
3139 2647 <?php
3140 2648 }
3141 2649 }
3142 2650
3143 - /**
3144 - * @param string $type
3145 - * @return array<string,string>
3146 - */
3147 2651 public static function locales( $type = 'date' ) {
3148 2652 $locales = array(
3149 2653 'en' => __( 'English', 'formidable' ),
3150 2654 'af' => __( 'Afrikaans', 'formidable' ),
3151 2655 'sq' => __( 'Albanian', 'formidable' ),
3152 - 'ar-DZ' => __( 'Algerian Arabic', 'formidable' ),
3153 - 'am' => __( 'Amharic', 'formidable' ),
3154 2656 'ar' => __( 'Arabic', 'formidable' ),
3155 2657 'hy' => __( 'Armenian', 'formidable' ),
3156 2658 'az' => __( 'Azerbaijani', 'formidable' ),
3157 2659 'eu' => __( 'Basque', 'formidable' ),
3158 - 'be' => __( 'Belarusian', 'formidable' ),
3159 - 'bn' => __( 'Bengali', 'formidable' ),
3160 2660 'bs' => __( 'Bosnian', 'formidable' ),
3161 2661 'bg' => __( 'Bulgarian', 'formidable' ),
3162 2662 'ca' => __( 'Catalan', 'formidable' ),
3163 2663 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
@@ -3176,15 +2676,12 @@
3176 2676 'fi' => __( 'Finnish', 'formidable' ),
3177 2677 'fr' => __( 'French', 'formidable' ),
3178 2678 'fr-CA' => __( 'French/Canadian', 'formidable' ),
3179 2679 'fr-CH' => __( 'French/Swiss', 'formidable' ),
3180 - 'gl' => __( 'Galician', 'formidable' ),
3181 - 'ka' => __( 'Georgian', 'formidable' ),
3182 2680 'de' => __( 'German', 'formidable' ),
3183 2681 'de-AT' => __( 'German/Austria', 'formidable' ),
3184 2682 'de-CH' => __( 'German/Switzerland', 'formidable' ),
3185 2683 'el' => __( 'Greek', 'formidable' ),
3186 - 'gu' => __( 'Gujarati', 'formidable' ),
3187 2684 'he' => __( 'Hebrew', 'formidable' ),
3188 2685 'iw' => __( 'Hebrew', 'formidable' ),
3189 2686 'hi' => __( 'Hindi', 'formidable' ),
3190 2687 'hu' => __( 'Hungarian', 'formidable' ),
@@ -3191,720 +2688,277 @@
3191 2688 'is' => __( 'Icelandic', 'formidable' ),
3192 2689 'id' => __( 'Indonesian', 'formidable' ),
3193 2690 'it' => __( 'Italian', 'formidable' ),
3194 2691 'ja' => __( 'Japanese', 'formidable' ),
3195 - 'kn' => __( 'Kannada', 'formidable' ),
3196 - 'kk' => __( 'Kazakh', 'formidable' ),
3197 - 'km' => __( 'Khmer', 'formidable' ),
3198 2692 'ko' => __( 'Korean', 'formidable' ),
3199 - 'ky' => __( 'Kyrgyz', 'formidable' ),
3200 - 'lo' => __( 'Laothian', 'formidable' ),
3201 2693 'lv' => __( 'Latvian', 'formidable' ),
3202 2694 'lt' => __( 'Lithuanian', 'formidable' ),
3203 - 'lb' => __( 'Luxembourgish', 'formidable' ),
3204 - 'mk' => __( 'Macedonian', 'formidable' ),
3205 - 'ml' => __( 'Malayalam', 'formidable' ),
3206 2695 'ms' => __( 'Malaysian', 'formidable' ),
3207 - 'mr' => __( 'Marathi', 'formidable' ),
3208 2696 'no' => __( 'Norwegian', 'formidable' ),
3209 - 'nb' => __( 'Norwegian Bokmål', 'formidable' ),
3210 - 'nn' => __( 'Norwegian Nynorsk', 'formidable' ),
3211 2697 'pl' => __( 'Polish', 'formidable' ),
3212 2698 'pt' => __( 'Portuguese', 'formidable' ),
3213 2699 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
3214 2700 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ),
3215 - 'rm' => __( 'Romansh', 'formidable' ),
3216 2701 'ro' => __( 'Romanian', 'formidable' ),
3217 2702 'ru' => __( 'Russian', 'formidable' ),
3218 2703 'sr' => __( 'Serbian', 'formidable' ),
3219 2704 'sr-SR' => __( 'Serbian', 'formidable' ),
3220 - 'si' => __( 'Sinhalese', 'formidable' ),
3221 2705 'sk' => __( 'Slovak', 'formidable' ),
3222 2706 'sl' => __( 'Slovenian', 'formidable' ),
3223 2707 'es' => __( 'Spanish', 'formidable' ),
3224 2708 'es-419' => __( 'Spanish/Latin America', 'formidable' ),
3225 - 'sw' => __( 'Swahili', 'formidable' ),
3226 2709 'sv' => __( 'Swedish', 'formidable' ),
3227 2710 'ta' => __( 'Tamil', 'formidable' ),
3228 - 'te' => __( 'Telugu', 'formidable' ),
3229 2711 'th' => __( 'Thai', 'formidable' ),
3230 - 'tj' => __( 'Tajiki', 'formidable' ),
3231 2712 'tr' => __( 'Turkish', 'formidable' ),
3232 - 'uk' => __( 'Ukrainian', 'formidable' ),
3233 - 'ur' => __( 'Urdu', 'formidable' ),
2713 + 'uk' => __( 'Ukranian', 'formidable' ),
3234 2714 'vi' => __( 'Vietnamese', 'formidable' ),
3235 - 'cy-GB' => __( 'Welsh', 'formidable' ),
3236 - 'zu' => __( 'Zulu', 'formidable' ),
3237 2715 );
3238 2716
3239 2717 if ( $type === 'captcha' ) {
3240 2718 // remove the languages unavailable for the captcha
3241 - $unset = array( 'sq', 'bs', 'eo', 'fo', 'fr-CH', 'sr-SR', 'ar-DZ', 'be', 'cy-GB', 'kk', 'km', 'ky', 'lb', 'mk', 'nb', 'nn', 'rm', 'tj' );
2719 + $unset = array( 'af', 'sq', 'hy', 'az', 'eu', 'bs', 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', 'he', 'is', 'ms', 'sr-SR', 'ta' );
3242 2720 } else {
3243 2721 // remove the languages unavailable for the datepicker
3244 - $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'mr', 'lo', 'kn', 'si', 'gu', 'bn', 'zu', 'ur', 'te', 'sw', 'am' );
2722 + $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419' );
3245 2723 }
3246 2724
3247 2725 $locales = array_diff_key( $locales, array_flip( $unset ) );
2726 + $locales = apply_filters( 'frm_locales', $locales );
3248 2727
3249 - /**
3250 - * Filter available locale options.
3251 - *
3252 - * @since 5.4.5 Added $args parameter with type.
3253 - *
3254 - * @param array<string,string> $locales
3255 - * @param array $args {
3256 - * @type string $type
3257 - * }
3258 - */
3259 - $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3260 -
3261 2728 return $locales;
3262 2729 }
3263 2730
3264 2731 /**
3265 2732 * Output HTML containing reference text for accessibility
3266 - *
3267 - * @deprecated 5.1
3268 2733 */
3269 2734 public static function multiselect_accessibility() {
3270 - _deprecated_function( __METHOD__, '5.1' );
2735 + include_once self::plugin_path() . '/classes/views/frm-forms/multiselect-accessibility.php';
3271 2736 }
3272 2737
3273 - public static function get_menu_icon_class() {
3274 - if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
3275 - $settings = FrmProAppHelper::get_settings();
3276 - if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) {
3277 - return $settings->menu_icon;
3278 - }
3279 - }
3280 - return 'frmfont frm_logo_icon';
3281 - }
3282 -
3283 2738 /**
3284 - * Shows the images dropdown.
3285 - *
3286 - * @since 5.0.04
3287 - *
3288 - * @param array $args {
3289 - * Arguments.
3290 - *
3291 - * @type string $selected Selected value.
3292 - * @type array[] $options Array of options with keys are option values and values are array.
3293 - * The option array contains `text`, `svg` and `custom_atts`.
3294 - * @type string $classes Custom CSS classes for the wrapper element.
3295 - * @type array $input_attrs Attributes of value input.
3296 - * }
2739 + * @since 4.07
2740 + * @deprecated 4.09.01
3297 2741 */
3298 - public static function images_dropdown( $args ) {
3299 - $args = self::fill_default_images_dropdown_args( $args );
3300 -
3301 - $input_attrs_str = self::get_images_dropdown_input_attrs( $args );
3302 - ob_start();
3303 - include self::plugin_path() . '/classes/views/shared/images-dropdown.php';
3304 - $output = ob_get_clean();
3305 -
3306 - /**
3307 - * Allows modifying the output of FrmAppHelper::images_dropdown() method.
3308 - *
3309 - * @since 5.0.04
3310 - *
3311 - * @param string $output The output.
3312 - * @param array $args Passed arguments.
3313 - */
3314 - echo apply_filters( 'frm_images_dropdown_output', $output, $args ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3315 - }
3316 -
3317 - /**
3318 - * Fills the default images_dropdown() arguments.
3319 - *
3320 - * @since 5.0.04
3321 - *
3322 - * @param array $args The arguments.
3323 - * @return array
3324 - */
3325 - private static function fill_default_images_dropdown_args( $args ) {
3326 - $defaults = array(
3327 - 'selected' => '',
3328 - 'options' => array(),
3329 - 'classes' => '',
3330 - 'input_attrs' => array(),
3331 - );
3332 - $new_args = wp_parse_args( $args, $defaults );
3333 -
3334 - $new_args['options'] = (array) $new_args['options'];
3335 - $new_args['input_attrs'] = (array) $new_args['input_attrs'];
3336 -
3337 - // Set the number of columns.
3338 - $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) );
3339 - if ( $new_args['col_class'] > 6 ) {
3340 - $new_args['col_class'] = ceil( $new_args['col_class'] / 2 );
2742 + public static function renewal_message() {
2743 + if ( is_callable( 'FrmProAddonsController::renewal_message' ) ) {
2744 + FrmProAddonsController::renewal_message();
2745 + return;
3341 2746 }
3342 2747
3343 - /**
3344 - * Allows modifying the arguments of images_dropdown() method.
3345 - *
3346 - * @since 5.0.04
3347 - *
3348 - * @param array $new_args Arguments after filling the defaults.
3349 - * @param array $args Arguments passed to the method, before filling the defaults.
3350 - */
3351 - return apply_filters( 'frm_images_dropdown_args', $new_args, $args );
3352 - }
3353 -
3354 - /**
3355 - * Gets HTML attributes of the input in images_dropdown() method.
3356 - *
3357 - * @since 5.0.04
3358 - *
3359 - * @param array $args The arguments.
3360 - * @return string
3361 - */
3362 - private static function get_images_dropdown_input_attrs( $args ) {
3363 - $input_attrs = $args['input_attrs'];
3364 - $input_attrs['type'] = 'radio';
3365 - $input_attrs['name'] = $args['name'];
3366 -
3367 - $input_attrs_str = '';
3368 - foreach ( $input_attrs as $key => $input_attr ) {
3369 - $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) );
2748 + if ( ! FrmAddonsController::is_license_expired() ) {
2749 + return;
3370 2750 }
3371 2751
3372 - /**
3373 - * Allows modifying the HTML attributes of the input in images_dropdown() method.
3374 - *
3375 - * @since 5.0.04
3376 - *
3377 - * @param string $input_attrs_str HTML attributes string.
3378 - * @param array $args The arguments of images_dropdown() method.
3379 - */
3380 - return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args );
2752 + ?>
2753 + <div class="frm_error_style" style="text-align:left">
2754 + <?php self::icon_by_class( 'frmfont frm_alert_icon' ); ?>
2755 + &nbsp;
2756 + <?php esc_html_e( 'Your account has expired', 'formidable' ); ?>
2757 + <div style="float:right">
2758 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'form-expired', 'account/downloads/' ) ); ?>">
2759 + <?php esc_html_e( 'Renew Now', 'formidable' ); ?>
2760 + </a>
2761 + </div>
2762 + </div>
2763 + <?php
3381 2764 }
3382 2765
3383 2766 /**
3384 - * Gets the image of each option in images_dropdown() method.
3385 - *
3386 - * @since 5.0.04
3387 - *
3388 - * @param array $option Option data.
3389 - * @param array $args The arguments of images_dropdown() method.
3390 - * @return string
2767 + * @since 4.08
2768 + * @deprecated 4.09.01
3391 2769 */
3392 - private static function get_images_dropdown_option_image( $option, $args ) {
3393 - $image = self::icon_by_class(
3394 - 'frmfont ' . $option['svg'],
3395 - array(
3396 - 'echo' => false,
3397 - )
3398 - );
3399 -
3400 - $args['option'] = $option;
3401 -
3402 - /**
3403 - * Allows modifying the image of each option in images_dropdown() method.
3404 - *
3405 - * @since 5.0.04
3406 - *
3407 - * @param string $image The image HTML.
3408 - * @param array $args The arguments of images_dropdown() method, with `option` array is added.
3409 - */
3410 - return apply_filters( 'frm_images_dropdown_option_image', $image, $args );
3411 - }
3412 -
3413 - /**
3414 - * Gets the HTML classes of each option in images_dropdown() method.
3415 - *
3416 - * @since 5.0.04
3417 - *
3418 - * @param array $option Option data.
3419 - * @param array $args The arguments of images_dropdown() method.
3420 - * @return string
3421 - */
3422 - private static function get_images_dropdown_option_classes( $option, $args ) {
3423 - $classes = '';
3424 -
3425 - if ( ! empty( $option['custom_attrs']['class'] ) ) {
3426 - $classes .= ' ' . $option['custom_attrs']['class'];
2770 + public static function expiring_message() {
2771 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
2772 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
2773 + FrmProAddonsController::expiring_message();
3427 2774 }
3428 -
3429 - $args['option'] = $option;
3430 -
3431 - /**
3432 - * Allows modifying the CSS classes of each option in images_dropdown() method.
3433 - *
3434 - * @since 5.0.04
3435 - *
3436 - * @param string $classes CSS classes.
3437 - * @param array $args The arguments of images_dropdown() method, with `option` array is added.
3438 - */
3439 - return apply_filters( 'frm_images_dropdown_option_classes', $classes, $args );
3440 2775 }
3441 2776
3442 2777 /**
3443 - * Gets the custom HTML attributes of each option in images_dropdown() method.
2778 + * Use the WP 4.7 wp_doing_ajax function
3444 2779 *
3445 - * @since 5.0.04
3446 - *
3447 - * @param array $option Option data.
3448 - * @param array $args The arguments of images_dropdown() method.
3449 - * @return string
2780 + * @since 2.05.07
2781 + * @deprecated 4.04.04
3450 2782 */
3451 - private static function get_images_dropdown_option_html_attrs( $option, $args ) {
3452 - $html_attrs = '';
3453 - if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) {
3454 - $html_attrs_arr = array();
3455 -
3456 - foreach ( $option['custom_attrs'] as $key => $value ) {
3457 - if ( in_array( $key, array( 'type', 'class', 'data-value' ) ) ) {
3458 - continue;
3459 - }
3460 -
3461 - $html_attrs_arr[] = sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $value ) );
3462 - }
3463 -
3464 - $html_attrs = implode( ' ', $html_attrs_arr );
3465 - }
3466 -
3467 - $args['option'] = $option;
3468 -
3469 - /**
3470 - * Allows modifying the custom HTML attributes of each option in images_dropdown() method.
3471 - *
3472 - * @since 5.0.04
3473 - *
3474 - * @param string $html_attrs The HTML attributes string.
3475 - * @param array $args The arguments of images_dropdown() method, with `option` array is added.
3476 - */
3477 - return apply_filters( 'frm_images_dropdown_option_html_attrs', $html_attrs, $args );
2783 + public static function wp_doing_ajax() {
2784 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
2785 + return wp_doing_ajax();
3478 2786 }
3479 2787
3480 2788 /**
3481 - * @since 5.0.07
3482 - *
3483 - * @return bool true if the current user is allowed to save unfiltered HTML.
2789 + * @deprecated 4.0
3484 2790 */
3485 - public static function allow_unfiltered_html() {
3486 - if ( self::should_never_allow_unfiltered_html() ) {
3487 - return false;
3488 - }
3489 - return current_user_can( 'unfiltered_html' );
2791 + public static function insert_opt_html( $args ) {
2792 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
2793 + FrmFormsHelper::insert_opt_html( $args );
3490 2794 }
3491 2795
3492 2796 /**
3493 - * @since 5.0.13
2797 + * Used to filter shortcode in text widgets
3494 2798 *
3495 - * @return bool
2799 + * @deprecated 2.5.4
2800 + * @codeCoverageIgnore
3496 2801 */
3497 - public static function should_never_allow_unfiltered_html() {
3498 - if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) {
3499 - return true;
3500 - }
3501 -
3502 - /**
3503 - * Formidable will check DISALLOW_UNFILTERED_HTML to determine if some form HTML should be filtered or not.
3504 - * In many cases, scripts are added intentionally to forms and will not be stripped if DISALLOW_UNFILTERED_HTML is not set.
3505 - * It is also possible to filter Formidable without defining DISALLOW_UNFILTERED_HTML, with add_filter( 'frm_disallow_unfiltered_html', '__return_true' );
3506 - *
3507 - * @since 5.0.13
3508 - */
3509 - return apply_filters( 'frm_disallow_unfiltered_html', false );
2802 + public static function widget_text_filter_callback( $matches ) {
2803 + return FrmDeprecated::widget_text_filter_callback( $matches );
3510 2804 }
3511 2805
3512 2806 /**
3513 - * @since 5.0.07
3514 - *
3515 - * @param array $values
3516 - * @param array $keys
3517 - * @return array
2807 + * @deprecated 3.01
2808 + * @codeCoverageIgnore
3518 2809 */
3519 - public static function maybe_filter_array( $values, $keys ) {
3520 - $allow_unfiltered_html = self::allow_unfiltered_html();
3521 -
3522 - if ( $allow_unfiltered_html ) {
3523 - return $values;
3524 - }
3525 -
3526 - foreach ( $keys as $key ) {
3527 - if ( isset( $values[ $key ] ) ) {
3528 - $values[ $key ] = self::kses( $values[ $key ], 'all' );
3529 - }
3530 - }
3531 -
3532 - return $values;
2810 + public static function sanitize_array( &$values ) {
2811 + FrmDeprecated::sanitize_array( $values );
3533 2812 }
3534 2813
3535 2814 /**
3536 - * Some back end fields allow privleged users to add scripts.
3537 - * A site that uses the DISALLOW_UNFILTERED_HTML always remove scripts on echo.
2815 + * @param array $settings
2816 + * @param string $group
3538 2817 *
3539 - * @since 5.0.13
3540 - *
3541 - * @param string $value
3542 - * @param array|string $allowed 'all' for everything included as defaults
3543 - * @return string
2818 + * @since 2.0.6
2819 + * @deprecated 2.05.06
2820 + * @codeCoverageIgnore
3544 2821 */
3545 - public static function maybe_kses( $value, $allowed = 'all' ) {
3546 - if ( self::should_never_allow_unfiltered_html() ) {
3547 - $value = self::kses( $value, $allowed );
3548 - }
3549 - return $value;
2822 + public static function save_settings( $settings, $group ) {
2823 + return FrmDeprecated::save_settings( $settings, $group );
3550 2824 }
3551 2825
3552 2826 /**
3553 - * @since 5.0.16
3554 - *
3555 - * @return bool
2827 + * @since 2.0.4
2828 + * @deprecated 2.05.06
2829 + * @codeCoverageIgnore
3556 2830 */
3557 - public static function show_landing_pages() {
3558 - return self::show_new_feature( 'landing' );
2831 + public static function save_json_post( $settings ) {
2832 + return FrmDeprecated::save_json_post( $settings );
3559 2833 }
3560 2834
3561 2835 /**
3562 - * @since 5.0.16
2836 + * @since 2.0
2837 + * @deprecated 2.05.06
2838 + * @codeCoverageIgnore
3563 2839 *
3564 - * @return array
3565 - */
3566 - public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
3567 - $params = array(
3568 - 'medium' => $medium,
3569 - 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
3570 - 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
3571 - 'screenshot' => 'landing.png',
3572 - );
3573 - return self::get_upgrade_data_params( 'landing', $params );
3574 - }
3575 -
3576 - /**
3577 - * @since 5.0.17
2840 + * @param string $cache_key The unique name for this cache
2841 + * @param string $group The name of the cache group
2842 + * @param string $query If blank, don't run a db call
2843 + * @param string $type The wpdb function to use with this query
3578 2844 *
3579 - * @param string $plugin
3580 - * @return string|false
2845 + * @return mixed $results The cache or query results
3581 2846 */
3582 - private static function get_plan_required( $plugin ) {
3583 - $link = FrmAddonsController::install_link( $plugin );
3584 - return FrmFormsHelper::get_plan_required( $link );
2847 + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
2848 + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time );
3585 2849 }
3586 2850
3587 2851 /**
3588 - * @since 5.0.17
3589 - *
3590 - * @param string
3591 - * @return bool
2852 + * @deprecated 2.05.06
2853 + * @codeCoverageIgnore
3592 2854 */
3593 - public static function show_new_feature( $feature ) {
3594 - $link = FrmAddonsController::install_link( $feature );
3595 - return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link );
2855 + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
2856 + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time );
3596 2857 }
3597 2858
3598 2859 /**
3599 - * @since 5.0.17
3600 - *
3601 - * @param string $plugin
3602 - * @param array $params
3603 - * @return array
2860 + * @deprecated 2.05.06
2861 + * @codeCoverageIgnore
3604 2862 */
3605 - public static function get_upgrade_data_params( $plugin, $params ) {
3606 - $link = FrmAddonsController::install_link( $plugin );
3607 - if ( ! $link ) {
3608 - return $params;
3609 - }
3610 -
3611 - if ( ! empty( $link['url'] ) && self::pro_is_installed() ) {
3612 - $params['oneclick'] = json_encode( $link );
3613 - unset( $params['message'] );
3614 - if ( ! isset( $params['medium'] ) ) {
3615 - $params['medium'] = $plugin;
3616 - }
3617 - } else {
3618 - $params['requires'] = FrmFormsHelper::get_plan_required( $link );
3619 - }
3620 -
3621 - return $params;
2863 + public static function add_key_to_group_cache( $key, $group ) {
2864 + FrmDeprecated::add_key_to_group_cache( $key, $group );
3622 2865 }
3623 2866
3624 2867 /**
3625 - * Returns true if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f], false otherwise.
3626 - * Not every server installs the ctype extension, so use a fallback if the function does not exist.
3627 - *
3628 - * @since 5.0.17
3629 - *
3630 - * @param string $text
3631 - * @return bool
2868 + * @deprecated 2.05.06
2869 + * @codeCoverageIgnore
3632 2870 */
3633 - public static function ctype_xdigit( $text ) {
3634 - if ( function_exists( 'ctype_xdigit' ) ) {
3635 - return ctype_xdigit( $text );
3636 - }
3637 - return is_string( $text ) && '' !== $text && ! preg_match( '/[^A-Fa-f0-9]/', $text );
2871 + public static function get_group_cached_keys( $group ) {
2872 + return FrmDeprecated::get_group_cached_keys( $group );
3638 2873 }
3639 2874
3640 2875 /**
3641 - * Set the current screen to avoid undefined notices.
3642 - *
3643 - * @since 5.2.01
2876 + * @since 2.0
2877 + * @deprecated 2.05.06
2878 + * @codeCoverageIgnore
2879 + * @return mixed The cached value or false
3644 2880 */
3645 - public static function set_current_screen_and_hook_suffix() {
3646 - global $hook_suffix;
3647 - if ( is_null( $hook_suffix ) ) {
3648 - // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
3649 - $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
3650 - }
3651 - set_current_screen();
2881 + public static function check_cache_and_transient( $cache_key ) {
2882 + return FrmDeprecated::check_cache( $cache_key );
3652 2883 }
3653 2884
3654 2885 /**
3655 - * Shows pill text.
2886 + * @since 2.0
2887 + * @deprecated 2.05.06
2888 + * @codeCoverageIgnore
3656 2889 *
3657 - * @since 5.2.02
3658 - *
3659 - * @param string $text Text in the pill. Default is NEW.
2890 + * @param string $cache_key
3660 2891 */
3661 - public static function show_pill_text( $text = null ) {
3662 - if ( null === $text ) {
3663 - $text = __( 'NEW', 'formidable' );
3664 - }
3665 - echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>';
2892 + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
2893 + FrmDeprecated::delete_cache_and_transient( $cache_key, $group );
3666 2894 }
3667 2895
3668 2896 /**
3669 - * Count the number of decimals digits.
2897 + * @since 2.0
2898 + * @deprecated 2.05.06
2899 + * @codeCoverageIgnore
3670 2900 *
3671 - * @since 5.2.07
3672 - *
3673 - * @param mixed $num Number.
3674 - * @return int|false Returns `false` if the passed parameter is not number.
2901 + * @param string $group The name of the cache group
3675 2902 */
3676 - public static function count_decimals( $num ) {
3677 - if ( ! is_numeric( $num ) ) {
3678 - return false;
3679 - }
3680 -
3681 - $num = (string) $num;
3682 - $parts = explode( '.', $num );
3683 - if ( 1 === count( $parts ) ) {
3684 - return 0;
3685 - }
3686 -
3687 - return strlen( $parts[ count( $parts ) - 1 ] );
2903 + public static function cache_delete_group( $group ) {
2904 + FrmDeprecated::cache_delete_group( $group );
3688 2905 }
3689 2906
3690 2907 /**
3691 - * Prevent a fatal error in PHP8 if gmt_offset happens to be set an empty string.
3692 - * This is a bug in WordPress. It isn't safe to call current_time( 'timestamp' ) without this with an empty string offset.
3693 - * In the future this might be safe to remove. Keep an eye on the current_time function in functions.php.
2908 + * @since 1.07.10
2909 + * @deprecated 2.05.06
2910 + * @codeCoverageIgnore
3694 2911 *
3695 - * @since 5.3.1
2912 + * @param string $term The value to escape
3696 2913 *
3697 - * @return void
2914 + * @return string The escaped value
3698 2915 */
3699 - public static function filter_gmt_offset() {
3700 - if ( self::$added_gmt_offset_filter ) {
3701 - // Avoid adding twice.
3702 - return;
3703 - }
3704 -
3705 - add_filter(
3706 - 'option_gmt_offset',
3707 - function( $offset ) {
3708 - if ( ! is_string( $offset ) || is_numeric( $offset ) ) {
3709 - // Leave a valid value alone.
3710 - return $offset;
3711 - }
3712 -
3713 - return 0;
3714 - }
3715 - );
3716 - self::$added_gmt_offset_filter = true;
2916 + public static function esc_like( $term ) {
2917 + return FrmDeprecated::esc_like( $term );
3717 2918 }
3718 2919
3719 2920 /**
3720 - * @since 5.3.1
2921 + * @param string $order_query
3721 2922 *
3722 - * @return bool
2923 + * @deprecated 2.05.06
2924 + * @codeCoverageIgnore
3723 2925 */
3724 - public static function on_form_listing_page() {
3725 - if ( ! self::is_admin_page( 'formidable' ) ) {
3726 - return false;
3727 - }
3728 -
3729 - $action = self::simple_get( 'frm_action', 'sanitize_title' );
3730 - return ! $action || in_array( $action, self::get_form_listing_page_actions(), true );
2926 + public static function esc_order( $order_query ) {
2927 + return FrmDeprecated::esc_order( $order_query );
3731 2928 }
3732 2929
3733 2930 /**
3734 - * Get all actions that also display the forms list.
3735 - *
3736 - * @since 5.3.1
3737 - *
3738 - * @return array<string>
2931 + * @deprecated 2.05.06
2932 + * @codeCoverageIgnore
3739 2933 */
3740 - private static function get_form_listing_page_actions() {
3741 - return array( 'list', 'trash', 'untrash', 'destroy' );
2934 + public static function esc_order_by( &$order_by ) {
2935 + FrmDeprecated::esc_order_by( $order_by );
3742 2936 }
3743 2937
3744 2938 /**
3745 - * Safely call get_plugins, importing the required files if they are not yet loaded.
2939 + * @param string $limit
3746 2940 *
3747 - * @since 5.5
3748 - *
3749 - * @return array
3750 - */
3751 - public static function get_plugins() {
3752 - if ( ! function_exists( 'get_plugins' ) ) {
3753 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
3754 - }
3755 - return get_plugins();
3756 - }
3757 -
3758 - /**
3759 - * Make sure that the file we're trying to load is in fact the expected file type, and that it's coming from our S3 bucket.
3760 - * This is to make sure that the URL can't be exploited for a SSRF attack.
3761 - *
3762 - * @since 5.5.5
3763 - *
3764 - * @param string $url
3765 - * @param string $expected_extension
3766 - * @return bool
3767 - */
3768 - public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
3769 - $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
3770 - if ( ! $file_is_in_expected_s3_bucket ) {
3771 - return false;
3772 - }
3773 -
3774 - $parsed = parse_url( $url );
3775 - if ( ! is_array( $parsed ) ) {
3776 - // URL is malformed.
3777 - return false;
3778 - }
3779 -
3780 - $path = $parsed['path'];
3781 - $ext = pathinfo( $path, PATHINFO_EXTENSION );
3782 - if ( $expected_extension !== $ext ) {
3783 - // The URL isn't to an XML file.
3784 - return false;
3785 - }
3786 -
3787 - return true;
3788 - }
3789 -
3790 - /**
3791 - * @since 4.08
3792 - * @deprecated 4.09.01
3793 - */
3794 - public static function expiring_message() {
3795 - _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3796 - if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3797 - FrmProAddonsController::expiring_message();
3798 - }
3799 - }
3800 -
3801 - /**
3802 - * Use the WP 4.7 wp_doing_ajax function
3803 - *
3804 - * @since 2.05.07
3805 - * @deprecated 4.04.04
3806 - */
3807 - public static function wp_doing_ajax() {
3808 - _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3809 - return wp_doing_ajax();
3810 - }
3811 -
3812 - /**
3813 - * @deprecated 4.0
3814 - */
3815 - public static function insert_opt_html( $args ) {
3816 - _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3817 - FrmFormsHelper::insert_opt_html( $args );
3818 - }
3819 -
3820 - /**
3821 - * @deprecated 3.01
2941 + * @deprecated 2.05.06
3822 2942 * @codeCoverageIgnore
3823 2943 */
3824 - public static function sanitize_array( &$values ) {
3825 - FrmDeprecated::sanitize_array( $values );
2944 + public static function esc_limit( $limit ) {
2945 + return FrmDeprecated::esc_limit( $limit );
3826 2946 }
3827 2947
3828 2948 /**
3829 2949 * @since 2.0
3830 - * @deprecated 5.0.13
3831 - *
3832 - * @return string The base Google APIS url for the current version of jQuery UI
2950 + * @deprecated 2.05.06
2951 + * @codeCoverageIgnore
3833 2952 */
3834 - public static function jquery_ui_base_url() {
3835 - _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3836 - return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
2953 + public static function prepare_array_values( $array, $type = '%s' ) {
2954 + return FrmDeprecated::prepare_array_values( $array, $type );
3837 2955 }
3838 2956
3839 2957 /**
3840 - * @since 4.07
3841 - * @deprecated 6.0
2958 + * @deprecated 2.05.06
2959 + * @codeCoverageIgnore
3842 2960 */
3843 - public static function renewal_message() {
3844 - _deprecated_function( __METHOD__, '6.0', 'FrmProAddonsController::renewal_message' );
3845 - }
3846 -
3847 - /**
3848 - * Display a dismissable warning message and save its dismissal state.
3849 - *
3850 - * @since 6.3
3851 - *
3852 - * @param string $message The warning message to display.
3853 - * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
3854 - * @return void
3855 - */
3856 - public static function add_dismissable_warning_message( $message = '', $option = '' ) {
3857 - if ( ! $message || ! $option ) {
3858 - return;
3859 - }
3860 -
3861 - $ajax_callback = function() use ( $option ) {
3862 - self::dismiss_warning_message( $option );
3863 - };
3864 -
3865 - // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action.
3866 - // To prevent any issues, we add 'frm_' from the beginning of the action.
3867 - add_action( 'wp_ajax_frm_' . $option, $ajax_callback );
3868 -
3869 - add_filter(
3870 - 'frm_message_list',
3871 - function( $show_messages ) use ( $message, $option ) {
3872 - if ( get_option( $option, false ) ) {
3873 - return $show_messages;
3874 - }
3875 -
3876 - $dismiss_icon = self::icon_by_class(
3877 - 'frmfont frm_close_icon',
3878 - array(
3879 - 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ),
3880 - 'echo' => false,
3881 - )
3882 - );
3883 -
3884 - $show_messages[] = $message;
3885 - $show_messages[] = '<span class="frm-warning-dismiss frmsvg" data-action="' . esc_attr( $option ) . '">' . $dismiss_icon . '</span>';
3886 -
3887 - return $show_messages;
3888 - }
3889 - );
3890 - }
3891 -
3892 - /**
3893 - * Dismiss a warning message and update the dismissal state.
3894 - *
3895 - * @since 6.3
3896 - *
3897 - * @param string $option The unique identifier for the dismissal state of the message.
3898 - * @return void
3899 - */
3900 - public static function dismiss_warning_message( $option = '' ) {
3901 - self::permission_check( 'frm_change_settings' );
3902 - check_ajax_referer( 'frm_ajax', 'nonce' );
3903 -
3904 - if ( $option ) {
3905 - update_option( $option, true, 'no' );
3906 - }
3907 -
3908 - wp_send_json_success();
2961 + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
2962 + return FrmDeprecated::prepend_and_or_where( $starts_with, $where );
3909 2963 }
3910 2964 }