PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0.08
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0.08
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 +286 -977 6.3.25.0.08 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.3.2';
14 + public static $plug_version = '5.0.08';
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,74 +645,8 @@
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();
@@ -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(),
@@ -878,21 +767,19 @@
878 767 'id' => true,
879 768 'viewbox' => true,
880 769 ),
881 770 '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,
771 + 'class' => true,
772 + 'id' => true,
773 + 'xmlns' => true,
774 + 'viewbox' => true,
775 + 'width' => true,
776 + 'height' => true,
777 + 'style' => true,
778 + 'fill' => true,
892 779 ),
893 780 'use' => array(
894 - 'href' => true,
781 + 'href' => true,
895 782 'xlink:href' => true,
896 783 ),
897 784 'ul' => $allow_class,
898 785 'label' => array(
@@ -965,18 +852,8 @@
965 852
966 853 $html_atts = self::array_to_html_params( $atts );
967 854
968 855 $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 856 if ( $icon === $class ) {
980 857 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
981 858 } else {
982 859 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
@@ -983,15 +860,15 @@
983 860 if ( strpos( $icon, ' ' ) ) {
984 861 $icon = explode( ' ', $icon );
985 862 $icon = reset( $icon );
986 863 }
987 - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
864 + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '>
988 865 <use xlink:href="#' . esc_attr( $icon ) . '" />
989 866 </svg>';
990 867 }
991 868
992 869 if ( $echo ) {
993 - echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
870 + echo $icon; // WPCS: XSS ok.
994 871 } else {
995 872 return $icon;
996 873 }
997 874 }
@@ -996,88 +873,14 @@
996 873 }
997 874 }
998 875
999 876 /**
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 877 * Include svg images.
1075 878 *
1076 879 * @since 4.0.02
1077 880 */
1078 881 public static function include_svg() {
1079 - include_once self::plugin_path() . '/images/icons.svg';
882 + include_once( self::plugin_path() . '/images/icons.svg' );
1080 883 }
1081 884
1082 885 /**
1083 886 * Convert an associative array to HTML values.
@@ -1082,48 +885,19 @@
1082 885 /**
1083 886 * Convert an associative array to HTML values.
1084 887 *
1085 888 * @since 4.0.02
1086 - * @since 5.0.13 added $echo parameter.
1087 - *
1088 889 * @param array $atts
1089 - * @param bool $echo
1090 - * @return string|void
890 + * @return string
1091 891 */
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 - }
892 + public static function array_to_html_params( $atts ) {
893 + $html = '';
894 + if ( ! empty( $atts ) ) {
895 + foreach ( $atts as $key => $value ) {
896 + $html .= ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
1098 897 }
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 898 }
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 - }
899 + return $html;
1126 900 }
1127 901
1128 902 /**
1129 903 * @since 3.0
@@ -1140,94 +914,31 @@
1140 914 include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1141 915 }
1142 916
1143 917 /**
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 918 * @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
919 + * @param array $atts
1204 920 */
1205 921 public static function add_new_item_link( $atts ) {
1206 - if ( isset( $atts['link_hook'] ) ) {
922 + if ( ! empty( $atts['new_link'] ) ) {
923 + ?>
924 + <a href="<?php echo esc_url( $atts['new_link'] ); ?>" class="button button-primary frm-button-primary frm-with-plus">
925 + <?php self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' ); ?>
926 + <?php esc_html_e( 'Add New', 'formidable' ); ?>
927 + </a>
928 + <?php
929 + } elseif ( ! empty( $atts['trigger_new_form_modal'] ) ) {
930 + ?>
931 + <a href="#" class="button button-primary frm-button-primary frm-with-plus frm-trigger-new-form-modal">
932 + <?php
933 + self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' );
934 + esc_html_e( 'Add New', 'formidable' );
935 + ?>
936 + </a>
937 + <?php
938 + } elseif ( isset( $atts['link_hook'] ) ) {
1207 939 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1208 - return;
1209 940 }
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 941 }
1231 942
1232 943 /**
1233 944 * @since 3.06
@@ -1300,8 +1011,9 @@
1300 1011 );
1301 1012 $new_file = new FrmCreateFile( $file_atts );
1302 1013
1303 1014 $files = array(
1015 + self::plugin_path() . '/js/jquery/jquery.placeholder.min.js',
1304 1016 self::plugin_path() . '/js/formidable.min.js',
1305 1017 );
1306 1018 $files = apply_filters( 'frm_combined_js_files', $files );
1307 1019 $new_file->combine_files( $files );
@@ -1322,9 +1034,8 @@
1322 1034 }
1323 1035
1324 1036 /**
1325 1037 * 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 1038 *
1328 1039 * @since 4.10.01 Add `$post_type` argument.
1329 1040 *
1330 1041 * @param string $post_type Post type to query. Default is `page`.
@@ -1342,30 +1053,8 @@
1342 1053 return get_posts( $query );
1343 1054 }
1344 1055
1345 1056 /**
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 1057 * Renders an autocomplete page selection or a regular dropdown depending on
1369 1058 * the total page count
1370 1059 *
1371 1060 * @since 4.03.06
@@ -1410,9 +1099,9 @@
1410 1099 */
1411 1100 public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) {
1412 1101 self::prep_page_dropdown_params( $page_id, $truncate, $args );
1413 1102
1414 - $pages = self::get_post_ids_and_titles( $args['post_type'] );
1103 + $pages = self::get_pages( $args['post_type'] );
1415 1104 $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' );
1416 1105
1417 1106 ?>
1418 1107 <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown">
@@ -1466,8 +1155,9 @@
1466 1155 public static function post_edit_link( $post_id ) {
1467 1156 $post = get_post( $post_id );
1468 1157 if ( $post ) {
1469 1158 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1159 + $post_url = self::maybe_full_screen_link( $post_url );
1470 1160
1471 1161 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
1472 1162 }
1473 1163
@@ -1477,64 +1167,25 @@
1477 1167 /**
1478 1168 * Hide the WordPress menus on some pages.
1479 1169 *
1480 1170 * @since 4.0
1481 - *
1482 - * @return bool
1483 1171 */
1484 1172 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 - }
1173 + $full_builder = self::is_form_builder_page();
1174 + $styler = self::is_admin_page( 'formidable-styles' ) || self::is_admin_page( 'formidable-styles2' );
1175 + $full_entries = self::simple_get( 'frm-full', 'absint' );
1489 1176
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;
1177 + return $full_builder || $full_entries || $styler || self::is_view_builder_page();
1520 1178 }
1521 1179
1522 1180 /**
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 1181 * @since 4.0
1533 - * @deprecated 5.5.3
1534 1182 */
1535 1183 public static function maybe_full_screen_link( $link ) {
1536 - _deprecated_function( __METHOD__, '5.5.3' );
1184 + $is_full = self::simple_get( 'frm-full', 'absint' );
1185 + if ( $is_full && ! empty( $link ) && $link !== '#' ) {
1186 + $link .= '&frm-full=1';
1187 + }
1537 1188 return $link;
1538 1189 }
1539 1190
1540 1191 /**
@@ -1594,10 +1245,19 @@
1594 1245 * @param string $type Supports `auto`, `pro`, or `pro_only`.
1595 1246 * @return array
1596 1247 */
1597 1248 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();
1249 + $cap = array(
1250 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1251 + 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1252 + 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1253 + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1254 + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
1255 + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
1256 + );
1257 +
1258 + if ( ! self::pro_is_installed() && 'pro' !== $type && 'pro_only' !== $type ) {
1259 + return $cap;
1600 1260 }
1601 1261
1602 1262 $pro_cap = array(
1603 1263 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
@@ -1604,41 +1264,17 @@
1604 1264 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
1605 1265 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1606 1266 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
1607 1267 );
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 1268
1615 1269 if ( 'pro_only' === $type ) {
1616 1270 return $pro_cap;
1617 1271 }
1618 1272
1619 - return self::get_lite_capabilities() + $pro_cap;
1273 + return $cap + $pro_cap;
1620 1274 }
1621 1275
1622 1276 /**
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 1277 * Call the WordPress current_user_can but also validate empty strings as true for any logged in user
1642 1278 *
1643 1279 * @since 4.06.03
1644 1280 *
@@ -1883,8 +1519,19 @@
1883 1519 return $val;
1884 1520 }
1885 1521
1886 1522 /**
1523 + * @since 2.0
1524 + * @return string The base Google APIS url for the current version of jQuery UI
1525 + */
1526 + public static function jquery_ui_base_url() {
1527 + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' );
1528 + $url = apply_filters( 'frm_jquery_ui_base_url', $url );
1529 +
1530 + return $url;
1531 + }
1532 +
1533 + /**
1887 1534 * @param string $handle
1888 1535 */
1889 1536 public static function script_version( $handle, $default = 0 ) {
1890 1537 global $wp_scripts;
@@ -1904,20 +1551,10 @@
1904 1551
1905 1552 return $ver;
1906 1553 }
1907 1554
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 );
1555 + public static function js_redirect( $url ) {
1556 + return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>';
1920 1557 }
1921 1558
1922 1559 public static function get_user_id_param( $user_id ) {
1923 1560 if ( ! $user_id || is_numeric( $user_id ) ) {
@@ -1976,38 +1613,21 @@
1976 1613 }
1977 1614
1978 1615 $key = self::prevent_numeric_and_reserved_keys( $key );
1979 1616
1980 - $similar_keys = FrmDb::get_col(
1617 + $key_check = FrmDb::get_var(
1981 1618 $table_name,
1982 1619 array(
1983 - $column . ' like%' => $key,
1984 - 'ID !' => $id,
1620 + $column => $key,
1621 + 'ID !' => $id,
1985 1622 ),
1986 1623 $column
1987 1624 );
1988 1625
1989 - // Create a unique field id if it has already been used.
1990 - if ( in_array( $key, $similar_keys, true ) ) {
1626 + if ( $key_check || is_numeric( $key_check ) ) {
1991 1627 $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;
1628 + // Create a unique field id if it has already been used.
1629 + $key = $key . substr( md5( microtime() . rand() ), 0, 10 );
2010 1630 }
2011 1631
2012 1632 return $key;
2013 1633 }
@@ -2024,11 +1644,8 @@
2024 1644 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2025 1645 $max_key_length_before_truncating = 60;
2026 1646 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2027 1647 $key = substr( $key, 0, $max_key_length_before_truncating );
2028 - if ( is_numeric( $key ) ) {
2029 - $key .= 'a';
2030 - }
2031 1648 }
2032 1649 }
2033 1650 return $key;
2034 1651 }
@@ -2093,9 +1710,9 @@
2093 1710 return false;
2094 1711 }
2095 1712
2096 1713 if ( empty( $post_values ) ) {
2097 - $post_values = wp_unslash( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
1714 + $post_values = wp_unslash( $_POST );
2098 1715 }
2099 1716
2100 1717 $values = array(
2101 1718 'id' => $record->id,
@@ -2113,11 +1730,11 @@
2113 1730 self::fill_form_opts( $record, $table, $post_values, $values );
2114 1731
2115 1732 self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) );
2116 1733
2117 - if ( $table === 'entries' ) {
1734 + if ( $table == 'entries' ) {
2118 1735 $values = FrmEntriesHelper::setup_edit_vars( $values, $record );
2119 - } elseif ( $table === 'forms' ) {
1736 + } elseif ( $table == 'forms' ) {
2120 1737 $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values );
2121 1738 }
2122 1739
2123 1740 return $values;
@@ -2394,9 +2011,9 @@
2394 2011 *
2395 2012 * @return string $time_ago
2396 2013 */
2397 2014 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
2398 - if ( empty( $to ) && 0 !== $to ) {
2015 + if ( empty( $to ) ) {
2399 2016 $now = new DateTime();
2400 2017 } else {
2401 2018 $now = new DateTime( '@' . $to );
2402 2019 }
@@ -2647,9 +2264,8 @@
2647 2264 '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 2265 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ),
2649 2266 /* translators: %1$s: Form name, %2$s: Date */
2650 2267 '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 2268 );
2653 2269
2654 2270 if ( ! isset( $tooltips[ $name ] ) ) {
2655 2271 return;
@@ -2676,12 +2292,8 @@
2676 2292 return;
2677 2293 }
2678 2294
2679 2295 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
2680 - if ( 'lite-reports' === $frm_action ) {
2681 - $frm_action = 'reports';
2682 - }
2683 -
2684 2296 if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
2685 2297 echo ' class="current_page"';
2686 2298 }
2687 2299 }
@@ -2738,15 +2350,12 @@
2738 2350 }
2739 2351 }
2740 2352
2741 2353 /**
2742 - * Check for either json or serialized data. This is temporary while transitioning
2354 + * Check for either json or serilized data. This is temporary while transitioning
2743 2355 * all data to json.
2744 2356 *
2745 2357 * @since 4.02.03
2746 - *
2747 - * @param array|string $value
2748 - * @return void
2749 2358 */
2750 2359 public static function unserialize_or_decode( &$value ) {
2751 2360 if ( is_array( $value ) ) {
2752 2361 return;
@@ -2752,9 +2361,9 @@
2752 2361 return;
2753 2362 }
2754 2363
2755 2364 if ( is_serialized( $value ) ) {
2756 - $value = self::maybe_unserialize_array( $value );
2365 + $value = maybe_unserialize( $value );
2757 2366 } else {
2758 2367 $value = self::maybe_json_decode( $value, false );
2759 2368 }
2760 2369 }
@@ -2759,44 +2368,13 @@
2759 2368 }
2760 2369 }
2761 2370
2762 2371 /**
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 2372 * Decode a JSON string.
2791 2373 * 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 2374 */
2797 2375 public static function maybe_json_decode( $string, $single_to_array = true ) {
2798 - if ( is_array( $string ) || is_null( $string ) ) {
2376 + if ( is_array( $string ) ) {
2799 2377 return $string;
2800 2378 }
2801 2379
2802 2380 $new_string = json_decode( $string, true );
@@ -2814,36 +2392,8 @@
2814 2392 return $string;
2815 2393 }
2816 2394
2817 2395 /**
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 2396 * Reformat the json serialized array in name => value array.
2847 2397 *
2848 2398 * @since 4.02.03
2849 2399 */
@@ -2909,17 +2459,14 @@
2909 2459 $version = self::plugin_version();
2910 2460 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
2911 2461
2912 2462 $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' ),
2463 + 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2464 + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2465 + 'url' => self::plugin_url(),
2466 + 'app_url' => 'https://formidableforms.com/',
2467 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2468 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2922 2469 );
2923 2470 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
2924 2471
2925 2472 if ( $load ) {
@@ -2943,21 +2490,19 @@
2943 2490 $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2944 2491 $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2945 2492
2946 2493 $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(),
2494 + 'ajax_url' => $ajax_url,
2495 + 'images_url' => self::plugin_url() . '/images',
2496 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2497 + 'remove' => __( 'Remove', 'formidable' ),
2498 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2499 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2500 + 'id' => __( 'ID', 'formidable' ),
2501 + 'no_results' => __( 'No results match', 'formidable' ),
2502 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2503 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2504 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2960 2505 );
2961 2506
2962 2507 $data = $wp_scripts->get_data( 'formidable', 'data' );
2963 2508 if ( empty( $data ) ) {
@@ -2969,10 +2514,10 @@
2969 2514 $admin_script_strings = array(
2970 2515 'desc' => __( '(Click to add description)', 'formidable' ),
2971 2516 'blank' => __( '(Blank)', 'formidable' ),
2972 2517 'no_label' => __( '(no label)', 'formidable' ),
2973 - 'saving' => '', // Deprecated in 6.0.
2974 - 'saved' => '', // Deprecated in 6.0.
2518 + 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
2519 + 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2975 2520 'ok' => __( 'OK', 'formidable' ),
2976 2521 'cancel' => __( 'Cancel', 'formidable' ),
2977 2522 'default_label' => __( 'Default', 'formidable' ),
2978 2523 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
@@ -2978,8 +2523,9 @@
2978 2523 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2979 2524 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2980 2525 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2981 2526 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2527 + 'caution' => __( 'Heads up', 'formidable' ),
2982 2528 'confirm' => __( 'Are you sure?', 'formidable' ),
2983 2529 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2984 2530 '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 2531 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
@@ -2995,9 +2541,9 @@
2995 2541 'import_complete' => __( 'Import Complete', 'formidable' ),
2996 2542 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2997 2543 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2998 2544 'private_label' => __( 'Private', 'formidable' ),
2999 - 'jquery_ui_url' => '',
2545 + 'jquery_ui_url' => self::jquery_ui_base_url(),
3000 2546 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3001 2547 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3002 2548 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3003 2549 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
@@ -3014,9 +2560,8 @@
3014 2560 'install' => __( 'Install', 'formidable' ),
3015 2561 'active' => __( 'Active', 'formidable' ),
3016 2562 'select_a_field' => __( 'Select a Field', 'formidable' ),
3017 2563 'no_items_found' => __( 'No items found.', 'formidable' ),
3018 - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3019 2564 );
3020 2565 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3021 2566
3022 2567 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
@@ -3026,30 +2571,8 @@
3026 2571 }
3027 2572 }
3028 2573
3029 2574 /**
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 2575 * Echo the message on the plugins listing page
3053 2576 *
3054 2577 * @since 1.07.10
3055 2578 *
@@ -3072,10 +2595,8 @@
3072 2595 /**
3073 2596 * If Pro is far outdated, show a message.
3074 2597 *
3075 2598 * @since 4.0.01
3076 - *
3077 - * @return void
3078 2599 */
3079 2600 public static function min_pro_version_notice( $min_version ) {
3080 2601 if ( ! self::is_formidable_admin() ) {
3081 2602 // Don't show admin-wide.
@@ -3091,9 +2612,9 @@
3091 2612
3092 2613 $pro_version = FrmProDb::$plug_version;
3093 2614 $expired = FrmAddonsController::is_license_expired();
3094 2615 ?>
3095 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2616 + <div class="error frm_previous_install">
3096 2617 <?php
3097 2618 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 2619 if ( empty( $expired ) ) {
3099 2620 echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
@@ -3132,9 +2653,9 @@
3132 2653 }
3133 2654
3134 2655 foreach ( $message as $m ) {
3135 2656 ?>
3136 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2657 + <div class="error frm_previous_install">
3137 2658 <?php echo esc_html( $m ); ?>
3138 2659 </div>
3139 2660 <?php
3140 2661 }
@@ -3139,25 +2660,17 @@
3139 2660 <?php
3140 2661 }
3141 2662 }
3142 2663
3143 - /**
3144 - * @param string $type
3145 - * @return array<string,string>
3146 - */
3147 2664 public static function locales( $type = 'date' ) {
3148 2665 $locales = array(
3149 2666 'en' => __( 'English', 'formidable' ),
3150 2667 'af' => __( 'Afrikaans', 'formidable' ),
3151 2668 'sq' => __( 'Albanian', 'formidable' ),
3152 - 'ar-DZ' => __( 'Algerian Arabic', 'formidable' ),
3153 - 'am' => __( 'Amharic', 'formidable' ),
3154 2669 'ar' => __( 'Arabic', 'formidable' ),
3155 2670 'hy' => __( 'Armenian', 'formidable' ),
3156 2671 'az' => __( 'Azerbaijani', 'formidable' ),
3157 2672 'eu' => __( 'Basque', 'formidable' ),
3158 - 'be' => __( 'Belarusian', 'formidable' ),
3159 - 'bn' => __( 'Bengali', 'formidable' ),
3160 2673 'bs' => __( 'Bosnian', 'formidable' ),
3161 2674 'bg' => __( 'Bulgarian', 'formidable' ),
3162 2675 'ca' => __( 'Catalan', 'formidable' ),
3163 2676 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
@@ -3176,15 +2689,12 @@
3176 2689 'fi' => __( 'Finnish', 'formidable' ),
3177 2690 'fr' => __( 'French', 'formidable' ),
3178 2691 'fr-CA' => __( 'French/Canadian', 'formidable' ),
3179 2692 'fr-CH' => __( 'French/Swiss', 'formidable' ),
3180 - 'gl' => __( 'Galician', 'formidable' ),
3181 - 'ka' => __( 'Georgian', 'formidable' ),
3182 2693 'de' => __( 'German', 'formidable' ),
3183 2694 'de-AT' => __( 'German/Austria', 'formidable' ),
3184 2695 'de-CH' => __( 'German/Switzerland', 'formidable' ),
3185 2696 'el' => __( 'Greek', 'formidable' ),
3186 - 'gu' => __( 'Gujarati', 'formidable' ),
3187 2697 'he' => __( 'Hebrew', 'formidable' ),
3188 2698 'iw' => __( 'Hebrew', 'formidable' ),
3189 2699 'hi' => __( 'Hindi', 'formidable' ),
3190 2700 'hu' => __( 'Hungarian', 'formidable' ),
@@ -3191,84 +2701,52 @@
3191 2701 'is' => __( 'Icelandic', 'formidable' ),
3192 2702 'id' => __( 'Indonesian', 'formidable' ),
3193 2703 'it' => __( 'Italian', 'formidable' ),
3194 2704 'ja' => __( 'Japanese', 'formidable' ),
3195 - 'kn' => __( 'Kannada', 'formidable' ),
3196 - 'kk' => __( 'Kazakh', 'formidable' ),
3197 - 'km' => __( 'Khmer', 'formidable' ),
3198 2705 'ko' => __( 'Korean', 'formidable' ),
3199 - 'ky' => __( 'Kyrgyz', 'formidable' ),
3200 - 'lo' => __( 'Laothian', 'formidable' ),
3201 2706 'lv' => __( 'Latvian', 'formidable' ),
3202 2707 'lt' => __( 'Lithuanian', 'formidable' ),
3203 - 'lb' => __( 'Luxembourgish', 'formidable' ),
3204 - 'mk' => __( 'Macedonian', 'formidable' ),
3205 - 'ml' => __( 'Malayalam', 'formidable' ),
3206 2708 'ms' => __( 'Malaysian', 'formidable' ),
3207 - 'mr' => __( 'Marathi', 'formidable' ),
3208 2709 'no' => __( 'Norwegian', 'formidable' ),
3209 - 'nb' => __( 'Norwegian Bokmål', 'formidable' ),
3210 - 'nn' => __( 'Norwegian Nynorsk', 'formidable' ),
3211 2710 'pl' => __( 'Polish', 'formidable' ),
3212 2711 'pt' => __( 'Portuguese', 'formidable' ),
3213 2712 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
3214 2713 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ),
3215 - 'rm' => __( 'Romansh', 'formidable' ),
3216 2714 'ro' => __( 'Romanian', 'formidable' ),
3217 2715 'ru' => __( 'Russian', 'formidable' ),
3218 2716 'sr' => __( 'Serbian', 'formidable' ),
3219 2717 'sr-SR' => __( 'Serbian', 'formidable' ),
3220 - 'si' => __( 'Sinhalese', 'formidable' ),
3221 2718 'sk' => __( 'Slovak', 'formidable' ),
3222 2719 'sl' => __( 'Slovenian', 'formidable' ),
3223 2720 'es' => __( 'Spanish', 'formidable' ),
3224 2721 'es-419' => __( 'Spanish/Latin America', 'formidable' ),
3225 - 'sw' => __( 'Swahili', 'formidable' ),
3226 2722 'sv' => __( 'Swedish', 'formidable' ),
3227 2723 'ta' => __( 'Tamil', 'formidable' ),
3228 - 'te' => __( 'Telugu', 'formidable' ),
3229 2724 'th' => __( 'Thai', 'formidable' ),
3230 - 'tj' => __( 'Tajiki', 'formidable' ),
3231 2725 'tr' => __( 'Turkish', 'formidable' ),
3232 2726 'uk' => __( 'Ukrainian', 'formidable' ),
3233 - 'ur' => __( 'Urdu', 'formidable' ),
3234 2727 'vi' => __( 'Vietnamese', 'formidable' ),
3235 - 'cy-GB' => __( 'Welsh', 'formidable' ),
3236 - 'zu' => __( 'Zulu', 'formidable' ),
3237 2728 );
3238 2729
3239 2730 if ( $type === 'captcha' ) {
3240 2731 // 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' );
2732 + $unset = array( 'af', 'sq', 'hy', 'az', 'eu', 'bs', 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', 'he', 'is', 'ms', 'sr-SR', 'ta' );
3242 2733 } else {
3243 2734 // 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' );
2735 + $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419' );
3245 2736 }
3246 2737
3247 2738 $locales = array_diff_key( $locales, array_flip( $unset ) );
2739 + $locales = apply_filters( 'frm_locales', $locales );
3248 2740
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 2741 return $locales;
3262 2742 }
3263 2743
3264 2744 /**
3265 2745 * Output HTML containing reference text for accessibility
3266 - *
3267 - * @deprecated 5.1
3268 2746 */
3269 2747 public static function multiselect_accessibility() {
3270 - _deprecated_function( __METHOD__, '5.1' );
2748 + include_once self::plugin_path() . '/classes/views/frm-forms/multiselect-accessibility.php';
3271 2749 }
3272 2750
3273 2751 public static function get_menu_icon_class() {
3274 2752 if ( is_callable( 'FrmProAppHelper::get_settings' ) ) {
@@ -3482,9 +2960,9 @@
3482 2960 *
3483 2961 * @return bool true if the current user is allowed to save unfiltered HTML.
3484 2962 */
3485 2963 public static function allow_unfiltered_html() {
3486 - if ( self::should_never_allow_unfiltered_html() ) {
2964 + if ( defined( 'DISALLOW_UNFILTERED_HTML' ) && DISALLOW_UNFILTERED_HTML ) {
3487 2965 return false;
3488 2966 }
3489 2967 return current_user_can( 'unfiltered_html' );
3490 2968 }
@@ -3489,28 +2967,8 @@
3489 2967 return current_user_can( 'unfiltered_html' );
3490 2968 }
3491 2969
3492 2970 /**
3493 - * @since 5.0.13
3494 - *
3495 - * @return bool
3496 - */
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 );
3510 - }
3511 -
3512 - /**
3513 2971 * @since 5.0.07
3514 2972 *
3515 2973 * @param array $values
3516 2974 * @param array $keys
@@ -3532,379 +2990,230 @@
3532 2990 return $values;
3533 2991 }
3534 2992
3535 2993 /**
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.
3538 - *
3539 - * @since 5.0.13
3540 - *
3541 - * @param string $value
3542 - * @param array|string $allowed 'all' for everything included as defaults
3543 - * @return string
2994 + * @since 4.07
2995 + * @deprecated 4.09.01
3544 2996 */
3545 - public static function maybe_kses( $value, $allowed = 'all' ) {
3546 - if ( self::should_never_allow_unfiltered_html() ) {
3547 - $value = self::kses( $value, $allowed );
2997 + public static function renewal_message() {
2998 + if ( is_callable( 'FrmProAddonsController::renewal_message' ) ) {
2999 + FrmProAddonsController::renewal_message();
3000 + return;
3548 3001 }
3549 - return $value;
3002 +
3003 + if ( ! FrmAddonsController::is_license_expired() ) {
3004 + return;
3005 + }
3006 +
3007 + ?>
3008 + <div class="frm_error_style" style="text-align:left">
3009 + <?php self::icon_by_class( 'frmfont frm_alert_icon' ); ?>
3010 + &nbsp;
3011 + <?php esc_html_e( 'Your account has expired', 'formidable' ); ?>
3012 + <div style="float:right">
3013 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'form-expired', 'account/downloads/' ) ); ?>">
3014 + <?php esc_html_e( 'Renew Now', 'formidable' ); ?>
3015 + </a>
3016 + </div>
3017 + </div>
3018 + <?php
3550 3019 }
3551 3020
3552 3021 /**
3553 - * @since 5.0.16
3554 - *
3555 - * @return bool
3022 + * @since 4.08
3023 + * @deprecated 4.09.01
3556 3024 */
3557 - public static function show_landing_pages() {
3558 - return self::show_new_feature( 'landing' );
3025 + public static function expiring_message() {
3026 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3027 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3028 + FrmProAddonsController::expiring_message();
3029 + }
3559 3030 }
3560 3031
3561 3032 /**
3562 - * @since 5.0.16
3033 + * Use the WP 4.7 wp_doing_ajax function
3563 3034 *
3564 - * @return array
3035 + * @since 2.05.07
3036 + * @deprecated 4.04.04
3565 3037 */
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 );
3038 + public static function wp_doing_ajax() {
3039 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3040 + return wp_doing_ajax();
3574 3041 }
3575 3042
3576 3043 /**
3577 - * @since 5.0.17
3578 - *
3579 - * @param string $plugin
3580 - * @return string|false
3044 + * @deprecated 4.0
3581 3045 */
3582 - private static function get_plan_required( $plugin ) {
3583 - $link = FrmAddonsController::install_link( $plugin );
3584 - return FrmFormsHelper::get_plan_required( $link );
3046 + public static function insert_opt_html( $args ) {
3047 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3048 + FrmFormsHelper::insert_opt_html( $args );
3585 3049 }
3586 3050
3587 3051 /**
3588 - * @since 5.0.17
3052 + * Used to filter shortcode in text widgets
3589 3053 *
3590 - * @param string
3591 - * @return bool
3054 + * @deprecated 2.5.4
3055 + * @codeCoverageIgnore
3592 3056 */
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 );
3057 + public static function widget_text_filter_callback( $matches ) {
3058 + return FrmDeprecated::widget_text_filter_callback( $matches );
3596 3059 }
3597 3060
3598 3061 /**
3599 - * @since 5.0.17
3600 - *
3601 - * @param string $plugin
3602 - * @param array $params
3603 - * @return array
3062 + * @deprecated 3.01
3063 + * @codeCoverageIgnore
3604 3064 */
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;
3065 + public static function sanitize_array( &$values ) {
3066 + FrmDeprecated::sanitize_array( $values );
3622 3067 }
3623 3068
3624 3069 /**
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.
3070 + * @param array $settings
3071 + * @param string $group
3627 3072 *
3628 - * @since 5.0.17
3629 - *
3630 - * @param string $text
3631 - * @return bool
3073 + * @since 2.0.6
3074 + * @deprecated 2.05.06
3075 + * @codeCoverageIgnore
3632 3076 */
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 );
3077 + public static function save_settings( $settings, $group ) {
3078 + return FrmDeprecated::save_settings( $settings, $group );
3638 3079 }
3639 3080
3640 3081 /**
3641 - * Set the current screen to avoid undefined notices.
3642 - *
3643 - * @since 5.2.01
3082 + * @since 2.0.4
3083 + * @deprecated 2.05.06
3084 + * @codeCoverageIgnore
3644 3085 */
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();
3086 + public static function save_json_post( $settings ) {
3087 + return FrmDeprecated::save_json_post( $settings );
3652 3088 }
3653 3089
3654 3090 /**
3655 - * Shows pill text.
3091 + * @since 2.0
3092 + * @deprecated 2.05.06
3093 + * @codeCoverageIgnore
3656 3094 *
3657 - * @since 5.2.02
3095 + * @param string $cache_key The unique name for this cache
3096 + * @param string $group The name of the cache group
3097 + * @param string $query If blank, don't run a db call
3098 + * @param string $type The wpdb function to use with this query
3658 3099 *
3659 - * @param string $text Text in the pill. Default is NEW.
3100 + * @return mixed $results The cache or query results
3660 3101 */
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>';
3102 + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
3103 + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time );
3666 3104 }
3667 3105
3668 3106 /**
3669 - * Count the number of decimals digits.
3670 - *
3671 - * @since 5.2.07
3672 - *
3673 - * @param mixed $num Number.
3674 - * @return int|false Returns `false` if the passed parameter is not number.
3107 + * @deprecated 2.05.06
3108 + * @codeCoverageIgnore
3675 3109 */
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 ] );
3110 + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
3111 + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time );
3688 3112 }
3689 3113
3690 3114 /**
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.
3694 - *
3695 - * @since 5.3.1
3696 - *
3697 - * @return void
3115 + * @deprecated 2.05.06
3116 + * @codeCoverageIgnore
3698 3117 */
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;
3118 + public static function add_key_to_group_cache( $key, $group ) {
3119 + FrmDeprecated::add_key_to_group_cache( $key, $group );
3717 3120 }
3718 3121
3719 3122 /**
3720 - * @since 5.3.1
3721 - *
3722 - * @return bool
3123 + * @deprecated 2.05.06
3124 + * @codeCoverageIgnore
3723 3125 */
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 );
3126 + public static function get_group_cached_keys( $group ) {
3127 + return FrmDeprecated::get_group_cached_keys( $group );
3731 3128 }
3732 3129
3733 3130 /**
3734 - * Get all actions that also display the forms list.
3735 - *
3736 - * @since 5.3.1
3737 - *
3738 - * @return array<string>
3131 + * @since 2.0
3132 + * @deprecated 2.05.06
3133 + * @codeCoverageIgnore
3134 + * @return mixed The cached value or false
3739 3135 */
3740 - private static function get_form_listing_page_actions() {
3741 - return array( 'list', 'trash', 'untrash', 'destroy' );
3136 + public static function check_cache_and_transient( $cache_key ) {
3137 + return FrmDeprecated::check_cache( $cache_key );
3742 3138 }
3743 3139
3744 3140 /**
3745 - * Safely call get_plugins, importing the required files if they are not yet loaded.
3141 + * @since 2.0
3142 + * @deprecated 2.05.06
3143 + * @codeCoverageIgnore
3746 3144 *
3747 - * @since 5.5
3748 - *
3749 - * @return array
3145 + * @param string $cache_key
3750 3146 */
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();
3147 + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
3148 + FrmDeprecated::delete_cache_and_transient( $cache_key, $group );
3756 3149 }
3757 3150
3758 3151 /**
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.
3152 + * @since 2.0
3153 + * @deprecated 2.05.06
3154 + * @codeCoverageIgnore
3761 3155 *
3762 - * @since 5.5.5
3763 - *
3764 - * @param string $url
3765 - * @param string $expected_extension
3766 - * @return bool
3156 + * @param string $group The name of the cache group
3767 3157 */
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;
3158 + public static function cache_delete_group( $group ) {
3159 + FrmDeprecated::cache_delete_group( $group );
3788 3160 }
3789 3161
3790 3162 /**
3791 - * @since 4.08
3792 - * @deprecated 4.09.01
3163 + * @since 1.07.10
3164 + * @deprecated 2.05.06
3165 + * @codeCoverageIgnore
3166 + *
3167 + * @param string $term The value to escape
3168 + *
3169 + * @return string The escaped value
3793 3170 */
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 - }
3171 + public static function esc_like( $term ) {
3172 + return FrmDeprecated::esc_like( $term );
3799 3173 }
3800 3174
3801 3175 /**
3802 - * Use the WP 4.7 wp_doing_ajax function
3176 + * @param string $order_query
3803 3177 *
3804 - * @since 2.05.07
3805 - * @deprecated 4.04.04
3178 + * @deprecated 2.05.06
3179 + * @codeCoverageIgnore
3806 3180 */
3807 - public static function wp_doing_ajax() {
3808 - _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3809 - return wp_doing_ajax();
3181 + public static function esc_order( $order_query ) {
3182 + return FrmDeprecated::esc_order( $order_query );
3810 3183 }
3811 3184
3812 3185 /**
3813 - * @deprecated 4.0
3186 + * @deprecated 2.05.06
3187 + * @codeCoverageIgnore
3814 3188 */
3815 - public static function insert_opt_html( $args ) {
3816 - _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3817 - FrmFormsHelper::insert_opt_html( $args );
3189 + public static function esc_order_by( &$order_by ) {
3190 + FrmDeprecated::esc_order_by( $order_by );
3818 3191 }
3819 3192
3820 3193 /**
3821 - * @deprecated 3.01
3194 + * @param string $limit
3195 + *
3196 + * @deprecated 2.05.06
3822 3197 * @codeCoverageIgnore
3823 3198 */
3824 - public static function sanitize_array( &$values ) {
3825 - FrmDeprecated::sanitize_array( $values );
3199 + public static function esc_limit( $limit ) {
3200 + return FrmDeprecated::esc_limit( $limit );
3826 3201 }
3827 3202
3828 3203 /**
3829 3204 * @since 2.0
3830 - * @deprecated 5.0.13
3831 - *
3832 - * @return string The base Google APIS url for the current version of jQuery UI
3205 + * @deprecated 2.05.06
3206 + * @codeCoverageIgnore
3833 3207 */
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() : '';
3208 + public static function prepare_array_values( $array, $type = '%s' ) {
3209 + return FrmDeprecated::prepare_array_values( $array, $type );
3837 3210 }
3838 3211
3839 3212 /**
3840 - * @since 4.07
3841 - * @deprecated 6.0
3213 + * @deprecated 2.05.06
3214 + * @codeCoverageIgnore
3842 3215 */
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();
3216 + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
3217 + return FrmDeprecated::prepend_and_or_where( $starts_with, $where );
3909 3218 }
3910 3219 }