PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.1
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 +260 -622 6.35.1 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';
14 + public static $plug_version = '5.1';
20 15
21 16 /**
22 17 * @since 1.07.02
23 18 *
@@ -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];
@@ -965,18 +921,8 @@
965 921
966 922 $html_atts = self::array_to_html_params( $atts );
967 923
968 924 $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 925 if ( $icon === $class ) {
980 926 $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>';
981 927 } else {
982 928 $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon;
@@ -1033,9 +979,9 @@
1033 979 * @param array $allowed_attr
1034 980 * @return array
1035 981 */
1036 982 public static function allow_vars_in_styles( $allowed_attr ) {
1037 - $allowed_attr[] = '--primary-700';
983 + $allowed_attr[] = '--primary-hover';
1038 984 return $allowed_attr;
1039 985 }
1040 986
1041 987 /**
@@ -1044,9 +990,9 @@
1044 990 * @param bool $allow_css
1045 991 * @param string $css_string
1046 992 */
1047 993 public static function allow_style( $allow_css, $css_string ) {
1048 - if ( ! $allow_css && 0 === strpos( $css_string, '--primary-700:' ) ) {
994 + if ( ! $allow_css && 0 === strpos( $css_string, '--primary-hover:' ) ) {
1049 995 $split = explode( ':', $css_string, 2 );
1050 996 $allow_css = 2 === count( $split ) && self::is_a_valid_color( $split[1] );
1051 997 }
1052 998 return $allow_css;
@@ -1075,9 +1021,9 @@
1075 1021 *
1076 1022 * @since 4.0.02
1077 1023 */
1078 1024 public static function include_svg() {
1079 - include_once self::plugin_path() . '/images/icons.svg';
1025 + include_once( self::plugin_path() . '/images/icons.svg' );
1080 1026 }
1081 1027
1082 1028 /**
1083 1029 * Convert an associative array to HTML values.
@@ -1113,11 +1059,9 @@
1113 1059 if ( ! $echo ) {
1114 1060 ob_start();
1115 1061 }
1116 1062
1117 - if ( is_callable( $echo_function ) ) {
1118 - $echo_function();
1119 - }
1063 + $echo_function();
1120 1064
1121 1065 if ( ! $echo ) {
1122 1066 $return = ob_get_contents();
1123 1067 ob_end_clean();
@@ -1140,94 +1084,31 @@
1140 1084 include( self::plugin_path() . '/classes/views/shared/admin-header.php' );
1141 1085 }
1142 1086
1143 1087 /**
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 1088 * @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
1089 + * @param array $atts
1204 1090 */
1205 1091 public static function add_new_item_link( $atts ) {
1206 - if ( isset( $atts['link_hook'] ) ) {
1092 + if ( ! empty( $atts['new_link'] ) ) {
1093 + ?>
1094 + <a href="<?php echo esc_url( $atts['new_link'] ); ?>" class="button button-primary frm-button-primary frm-with-plus">
1095 + <?php self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' ); ?>
1096 + <?php esc_html_e( 'Add New', 'formidable' ); ?>
1097 + </a>
1098 + <?php
1099 + } elseif ( ! empty( $atts['trigger_new_form_modal'] ) ) {
1100 + ?>
1101 + <a href="#" class="button button-primary frm-button-primary frm-with-plus frm-trigger-new-form-modal">
1102 + <?php
1103 + self::icon_by_class( 'frmfont frm_plus_icon frm_svg15' );
1104 + esc_html_e( 'Add New', 'formidable' );
1105 + ?>
1106 + </a>
1107 + <?php
1108 + } elseif ( isset( $atts['link_hook'] ) ) {
1207 1109 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1208 - return;
1209 1110 }
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 1111 }
1231 1112
1232 1113 /**
1233 1114 * @since 3.06
@@ -1466,8 +1347,9 @@
1466 1347 public static function post_edit_link( $post_id ) {
1467 1348 $post = get_post( $post_id );
1468 1349 if ( $post ) {
1469 1350 $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' );
1351 + $post_url = self::maybe_full_screen_link( $post_url );
1470 1352
1471 1353 return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>';
1472 1354 }
1473 1355
@@ -1477,64 +1359,25 @@
1477 1359 /**
1478 1360 * Hide the WordPress menus on some pages.
1479 1361 *
1480 1362 * @since 4.0
1481 - *
1482 - * @return bool
1483 1363 */
1484 1364 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 - }
1365 + $full_builder = self::is_form_builder_page();
1366 + $styler = self::is_admin_page( 'formidable-styles' ) || self::is_admin_page( 'formidable-styles2' );
1367 + $full_entries = self::simple_get( 'frm-full', 'absint' );
1489 1368
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;
1369 + return $full_builder || $full_entries || $styler || self::is_view_builder_page();
1520 1370 }
1521 1371
1522 1372 /**
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 1373 * @since 4.0
1533 - * @deprecated 5.5.3
1534 1374 */
1535 1375 public static function maybe_full_screen_link( $link ) {
1536 - _deprecated_function( __METHOD__, '5.5.3' );
1376 + $is_full = self::simple_get( 'frm-full', 'absint' );
1377 + if ( $is_full && ! empty( $link ) && $link !== '#' ) {
1378 + $link .= '&frm-full=1';
1379 + }
1537 1380 return $link;
1538 1381 }
1539 1382
1540 1383 /**
@@ -1594,10 +1437,19 @@
1594 1437 * @param string $type Supports `auto`, `pro`, or `pro_only`.
1595 1438 * @return array
1596 1439 */
1597 1440 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();
1441 + $cap = array(
1442 + 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1443 + 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1444 + 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1445 + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1446 + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
1447 + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ),
1448 + );
1449 +
1450 + if ( ! self::pro_is_installed() && 'pro' !== $type && 'pro_only' !== $type ) {
1451 + return $cap;
1600 1452 }
1601 1453
1602 1454 $pro_cap = array(
1603 1455 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
@@ -1604,41 +1456,17 @@
1604 1456 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
1605 1457 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1606 1458 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
1607 1459 );
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 1460
1615 1461 if ( 'pro_only' === $type ) {
1616 1462 return $pro_cap;
1617 1463 }
1618 1464
1619 - return self::get_lite_capabilities() + $pro_cap;
1465 + return $cap + $pro_cap;
1620 1466 }
1621 1467
1622 1468 /**
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 1469 * Call the WordPress current_user_can but also validate empty strings as true for any logged in user
1642 1470 *
1643 1471 * @since 4.06.03
1644 1472 *
@@ -1976,38 +1804,21 @@
1976 1804 }
1977 1805
1978 1806 $key = self::prevent_numeric_and_reserved_keys( $key );
1979 1807
1980 - $similar_keys = FrmDb::get_col(
1808 + $key_check = FrmDb::get_var(
1981 1809 $table_name,
1982 1810 array(
1983 - $column . ' like%' => $key,
1984 - 'ID !' => $id,
1811 + $column => $key,
1812 + 'ID !' => $id,
1985 1813 ),
1986 1814 $column
1987 1815 );
1988 1816
1989 - // Create a unique field id if it has already been used.
1990 - if ( in_array( $key, $similar_keys, true ) ) {
1817 + if ( $key_check || is_numeric( $key_check ) ) {
1991 1818 $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;
1819 + // Create a unique field id if it has already been used.
1820 + $key = $key . substr( md5( microtime() . rand() ), 0, 10 );
2010 1821 }
2011 1822
2012 1823 return $key;
2013 1824 }
@@ -2024,11 +1835,8 @@
2024 1835 if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) {
2025 1836 $max_key_length_before_truncating = 60;
2026 1837 if ( strlen( $key ) > $max_key_length_before_truncating ) {
2027 1838 $key = substr( $key, 0, $max_key_length_before_truncating );
2028 - if ( is_numeric( $key ) ) {
2029 - $key .= 'a';
2030 - }
2031 1839 }
2032 1840 }
2033 1841 return $key;
2034 1842 }
@@ -2394,9 +2202,9 @@
2394 2202 *
2395 2203 * @return string $time_ago
2396 2204 */
2397 2205 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
2398 - if ( empty( $to ) && 0 !== $to ) {
2206 + if ( empty( $to ) ) {
2399 2207 $now = new DateTime();
2400 2208 } else {
2401 2209 $now = new DateTime( '@' . $to );
2402 2210 }
@@ -2675,12 +2483,8 @@
2675 2483 return;
2676 2484 }
2677 2485
2678 2486 $frm_action = self::simple_get( 'frm_action', 'sanitize_title' );
2679 - if ( 'lite-reports' === $frm_action ) {
2680 - $frm_action = 'reports';
2681 - }
2682 -
2683 2487 if ( empty( $action ) || ( ! empty( $frm_action ) && in_array( $frm_action, $action ) ) ) {
2684 2488 echo ' class="current_page"';
2685 2489 }
2686 2490 }
@@ -2737,15 +2541,12 @@
2737 2541 }
2738 2542 }
2739 2543
2740 2544 /**
2741 - * Check for either json or serialized data. This is temporary while transitioning
2545 + * Check for either json or serilized data. This is temporary while transitioning
2742 2546 * all data to json.
2743 2547 *
2744 2548 * @since 4.02.03
2745 - *
2746 - * @param array|string $value
2747 - * @return void
2748 2549 */
2749 2550 public static function unserialize_or_decode( &$value ) {
2750 2551 if ( is_array( $value ) ) {
2751 2552 return;
@@ -2751,9 +2552,9 @@
2751 2552 return;
2752 2553 }
2753 2554
2754 2555 if ( is_serialized( $value ) ) {
2755 - $value = self::maybe_unserialize_array( $value );
2556 + $value = maybe_unserialize( $value );
2756 2557 } else {
2757 2558 $value = self::maybe_json_decode( $value, false );
2758 2559 }
2759 2560 }
@@ -2758,44 +2559,13 @@
2758 2559 }
2759 2560 }
2760 2561
2761 2562 /**
2762 - * Safely unserialize an array if necessary.
2763 - * This function doesn't actually use unserialize. The string is parsed instead.
2764 - *
2765 - * @since 6.2
2766 - *
2767 - * @param mixed $value
2768 - * @return mixed
2769 - */
2770 - public static function maybe_unserialize_array( $value ) {
2771 - if ( ! is_string( $value ) ) {
2772 - return $value;
2773 - }
2774 -
2775 - // Since we only expect an array, skip anything that doesn't start with a:.
2776 - if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) {
2777 - return $value;
2778 - }
2779 -
2780 - $parsed = FrmSerializedStringParserHelper::get()->parse( $value );
2781 - if ( is_array( $parsed ) ) {
2782 - $value = $parsed;
2783 - }
2784 -
2785 - return $value;
2786 - }
2787 -
2788 - /**
2789 2563 * Decode a JSON string.
2790 2564 * Do not switch shortcodes like [24] to array unless intentional ie XML values.
2791 - *
2792 - * @param mixed $string
2793 - * @param bool $single_to_array
2794 - * @return mixed
2795 2565 */
2796 2566 public static function maybe_json_decode( $string, $single_to_array = true ) {
2797 - if ( is_array( $string ) || is_null( $string ) ) {
2567 + if ( is_array( $string ) ) {
2798 2568 return $string;
2799 2569 }
2800 2570
2801 2571 $new_string = json_decode( $string, true );
@@ -2813,36 +2583,8 @@
2813 2583 return $string;
2814 2584 }
2815 2585
2816 2586 /**
2817 - * @since 6.2.3
2818 - *
2819 - * @param string $value
2820 - * @return string
2821 - */
2822 - public static function maybe_utf8_encode( $value ) {
2823 - $from_format = 'ISO-8859-1';
2824 - $to_format = 'UTF-8';
2825 -
2826 - if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) {
2827 - if ( mb_check_encoding( $value, $from_format ) ) {
2828 - return mb_convert_encoding( $value, $to_format, $from_format );
2829 - }
2830 - return $value;
2831 - }
2832 -
2833 - if ( function_exists( 'iconv' ) ) {
2834 - $converted = iconv( $from_format, $to_format, $value );
2835 - // Value is false if $value is not ISO-8859-1.
2836 - if ( false !== $converted ) {
2837 - return $converted;
2838 - }
2839 - }
2840 -
2841 - return $value;
2842 - }
2843 -
2844 - /**
2845 2587 * Reformat the json serialized array in name => value array.
2846 2588 *
2847 2589 * @since 4.02.03
2848 2590 */
@@ -2908,17 +2650,14 @@
2908 2650 $version = self::plugin_version();
2909 2651 wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
2910 2652
2911 2653 $global_strings = array(
2912 - 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2913 - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2914 - 'url' => self::plugin_url(),
2915 - 'app_url' => 'https://formidableforms.com/',
2916 - 'applicationsUrl' => admin_url( 'admin.php?page=formidable-applications' ),
2917 - 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ),
2918 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
2919 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
2920 - 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ),
2654 + 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
2655 + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
2656 + 'url' => self::plugin_url(),
2657 + 'app_url' => 'https://formidableforms.com/',
2658 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2659 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2921 2660 );
2922 2661 wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
2923 2662
2924 2663 if ( $load ) {
@@ -2942,21 +2681,19 @@
2942 2681 $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2943 2682 $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2944 2683
2945 2684 $script_strings = array(
2946 - 'ajax_url' => $ajax_url,
2947 - 'images_url' => self::plugin_url() . '/images',
2948 - 'loading' => __( 'Loading&hellip;', 'formidable' ),
2949 - 'remove' => __( 'Remove', 'formidable' ),
2950 - 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2951 - 'nonce' => wp_create_nonce( 'frm_ajax' ),
2952 - 'id' => __( 'ID', 'formidable' ),
2953 - 'no_results' => __( 'No results match', 'formidable' ),
2954 - 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2955 - 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2956 - 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2957 - 'focus_first_error' => self::should_focus_first_error(),
2958 - 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
2685 + 'ajax_url' => $ajax_url,
2686 + 'images_url' => self::plugin_url() . '/images',
2687 + 'loading' => __( 'Loading&hellip;', 'formidable' ),
2688 + 'remove' => __( 'Remove', 'formidable' ),
2689 + 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
2690 + 'nonce' => wp_create_nonce( 'frm_ajax' ),
2691 + 'id' => __( 'ID', 'formidable' ),
2692 + 'no_results' => __( 'No results match', 'formidable' ),
2693 + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ),
2694 + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ),
2695 + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ),
2959 2696 );
2960 2697
2961 2698 $data = $wp_scripts->get_data( 'formidable', 'data' );
2962 2699 if ( empty( $data ) ) {
@@ -2968,10 +2705,10 @@
2968 2705 $admin_script_strings = array(
2969 2706 'desc' => __( '(Click to add description)', 'formidable' ),
2970 2707 'blank' => __( '(Blank)', 'formidable' ),
2971 2708 'no_label' => __( '(no label)', 'formidable' ),
2972 - 'saving' => '', // Deprecated in 6.0.
2973 - 'saved' => '', // Deprecated in 6.0.
2709 + 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
2710 + 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
2974 2711 'ok' => __( 'OK', 'formidable' ),
2975 2712 'cancel' => __( 'Cancel', 'formidable' ),
2976 2713 'default_label' => __( 'Default', 'formidable' ),
2977 2714 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
@@ -2977,8 +2714,9 @@
2977 2714 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2978 2715 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2979 2716 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2980 2717 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2718 + 'caution' => __( 'Heads up', 'formidable' ),
2981 2719 'confirm' => __( 'Are you sure?', 'formidable' ),
2982 2720 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2983 2721 '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' ),
2984 2722 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
@@ -3013,9 +2751,8 @@
3013 2751 'install' => __( 'Install', 'formidable' ),
3014 2752 'active' => __( 'Active', 'formidable' ),
3015 2753 'select_a_field' => __( 'Select a Field', 'formidable' ),
3016 2754 'no_items_found' => __( 'No items found.', 'formidable' ),
3017 - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3018 2755 );
3019 2756 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3020 2757
3021 2758 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
@@ -3025,30 +2762,8 @@
3025 2762 }
3026 2763 }
3027 2764
3028 2765 /**
3029 - * Returns whether or not the first errored input should be auto-focused (default true).
3030 - *
3031 - * @since 5.2.05
3032 - *
3033 - * @return bool
3034 - */
3035 - private static function should_focus_first_error() {
3036 - return (bool) apply_filters( 'frm_focus_first_error', true );
3037 - }
3038 -
3039 - /**
3040 - * Returns whether or not field errors should include role="alert" (default true).
3041 - *
3042 - * @since 5.2.05
3043 - *
3044 - * @return bool
3045 - */
3046 - public static function should_include_alert_role_on_field_errors() {
3047 - return (bool) apply_filters( 'frm_include_alert_role_on_field_errors', true );
3048 - }
3049 -
3050 - /**
3051 2766 * Echo the message on the plugins listing page
3052 2767 *
3053 2768 * @since 1.07.10
3054 2769 *
@@ -3071,10 +2786,8 @@
3071 2786 /**
3072 2787 * If Pro is far outdated, show a message.
3073 2788 *
3074 2789 * @since 4.0.01
3075 - *
3076 - * @return void
3077 2790 */
3078 2791 public static function min_pro_version_notice( $min_version ) {
3079 2792 if ( ! self::is_formidable_admin() ) {
3080 2793 // Don't show admin-wide.
@@ -3090,9 +2803,9 @@
3090 2803
3091 2804 $pro_version = FrmProDb::$plug_version;
3092 2805 $expired = FrmAddonsController::is_license_expired();
3093 2806 ?>
3094 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2807 + <div class="error frm_previous_install">
3095 2808 <?php
3096 2809 esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' );
3097 2810 if ( empty( $expired ) ) {
3098 2811 echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.';
@@ -3131,9 +2844,9 @@
3131 2844 }
3132 2845
3133 2846 foreach ( $message as $m ) {
3134 2847 ?>
3135 - <div class="frm-banner-alert frm_error_style frm_previous_install">
2848 + <div class="error frm_previous_install">
3136 2849 <?php echo esc_html( $m ); ?>
3137 2850 </div>
3138 2851 <?php
3139 2852 }
@@ -3138,25 +2851,17 @@
3138 2851 <?php
3139 2852 }
3140 2853 }
3141 2854
3142 - /**
3143 - * @param string $type
3144 - * @return array<string,string>
3145 - */
3146 2855 public static function locales( $type = 'date' ) {
3147 2856 $locales = array(
3148 2857 'en' => __( 'English', 'formidable' ),
3149 2858 'af' => __( 'Afrikaans', 'formidable' ),
3150 2859 'sq' => __( 'Albanian', 'formidable' ),
3151 - 'ar-DZ' => __( 'Algerian Arabic', 'formidable' ),
3152 - 'am' => __( 'Amharic', 'formidable' ),
3153 2860 'ar' => __( 'Arabic', 'formidable' ),
3154 2861 'hy' => __( 'Armenian', 'formidable' ),
3155 2862 'az' => __( 'Azerbaijani', 'formidable' ),
3156 2863 'eu' => __( 'Basque', 'formidable' ),
3157 - 'be' => __( 'Belarusian', 'formidable' ),
3158 - 'bn' => __( 'Bengali', 'formidable' ),
3159 2864 'bs' => __( 'Bosnian', 'formidable' ),
3160 2865 'bg' => __( 'Bulgarian', 'formidable' ),
3161 2866 'ca' => __( 'Catalan', 'formidable' ),
3162 2867 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ),
@@ -3175,15 +2880,12 @@
3175 2880 'fi' => __( 'Finnish', 'formidable' ),
3176 2881 'fr' => __( 'French', 'formidable' ),
3177 2882 'fr-CA' => __( 'French/Canadian', 'formidable' ),
3178 2883 'fr-CH' => __( 'French/Swiss', 'formidable' ),
3179 - 'gl' => __( 'Galician', 'formidable' ),
3180 - 'ka' => __( 'Georgian', 'formidable' ),
3181 2884 'de' => __( 'German', 'formidable' ),
3182 2885 'de-AT' => __( 'German/Austria', 'formidable' ),
3183 2886 'de-CH' => __( 'German/Switzerland', 'formidable' ),
3184 2887 'el' => __( 'Greek', 'formidable' ),
3185 - 'gu' => __( 'Gujarati', 'formidable' ),
3186 2888 'he' => __( 'Hebrew', 'formidable' ),
3187 2889 'iw' => __( 'Hebrew', 'formidable' ),
3188 2890 'hi' => __( 'Hindi', 'formidable' ),
3189 2891 'hu' => __( 'Hungarian', 'formidable' ),
@@ -3190,74 +2892,44 @@
3190 2892 'is' => __( 'Icelandic', 'formidable' ),
3191 2893 'id' => __( 'Indonesian', 'formidable' ),
3192 2894 'it' => __( 'Italian', 'formidable' ),
3193 2895 'ja' => __( 'Japanese', 'formidable' ),
3194 - 'kn' => __( 'Kannada', 'formidable' ),
3195 - 'kk' => __( 'Kazakh', 'formidable' ),
3196 - 'km' => __( 'Khmer', 'formidable' ),
3197 2896 'ko' => __( 'Korean', 'formidable' ),
3198 - 'ky' => __( 'Kyrgyz', 'formidable' ),
3199 - 'lo' => __( 'Laothian', 'formidable' ),
3200 2897 'lv' => __( 'Latvian', 'formidable' ),
3201 2898 'lt' => __( 'Lithuanian', 'formidable' ),
3202 - 'lb' => __( 'Luxembourgish', 'formidable' ),
3203 - 'mk' => __( 'Macedonian', 'formidable' ),
3204 - 'ml' => __( 'Malayalam', 'formidable' ),
3205 2899 'ms' => __( 'Malaysian', 'formidable' ),
3206 - 'mr' => __( 'Marathi', 'formidable' ),
3207 2900 'no' => __( 'Norwegian', 'formidable' ),
3208 - 'nb' => __( 'Norwegian Bokmål', 'formidable' ),
3209 - 'nn' => __( 'Norwegian Nynorsk', 'formidable' ),
3210 2901 'pl' => __( 'Polish', 'formidable' ),
3211 2902 'pt' => __( 'Portuguese', 'formidable' ),
3212 2903 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ),
3213 2904 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ),
3214 - 'rm' => __( 'Romansh', 'formidable' ),
3215 2905 'ro' => __( 'Romanian', 'formidable' ),
3216 2906 'ru' => __( 'Russian', 'formidable' ),
3217 2907 'sr' => __( 'Serbian', 'formidable' ),
3218 2908 'sr-SR' => __( 'Serbian', 'formidable' ),
3219 - 'si' => __( 'Sinhalese', 'formidable' ),
3220 2909 'sk' => __( 'Slovak', 'formidable' ),
3221 2910 'sl' => __( 'Slovenian', 'formidable' ),
3222 2911 'es' => __( 'Spanish', 'formidable' ),
3223 2912 'es-419' => __( 'Spanish/Latin America', 'formidable' ),
3224 - 'sw' => __( 'Swahili', 'formidable' ),
3225 2913 'sv' => __( 'Swedish', 'formidable' ),
3226 2914 'ta' => __( 'Tamil', 'formidable' ),
3227 - 'te' => __( 'Telugu', 'formidable' ),
3228 2915 'th' => __( 'Thai', 'formidable' ),
3229 - 'tj' => __( 'Tajiki', 'formidable' ),
3230 2916 'tr' => __( 'Turkish', 'formidable' ),
3231 2917 'uk' => __( 'Ukrainian', 'formidable' ),
3232 - 'ur' => __( 'Urdu', 'formidable' ),
3233 2918 'vi' => __( 'Vietnamese', 'formidable' ),
3234 - 'cy-GB' => __( 'Welsh', 'formidable' ),
3235 - 'zu' => __( 'Zulu', 'formidable' ),
3236 2919 );
3237 2920
3238 2921 if ( $type === 'captcha' ) {
3239 2922 // remove the languages unavailable for the captcha
3240 - $unset = array( 'sq', 'bs', 'eo', 'fo', 'fr-CH', 'sr-SR', 'ar-DZ', 'be', 'cy-GB', 'kk', 'km', 'ky', 'lb', 'mk', 'nb', 'nn', 'rm', 'tj' );
2923 + $unset = array( 'af', 'sq', 'hy', 'az', 'eu', 'bs', 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', 'he', 'is', 'ms', 'sr-SR', 'ta' );
3241 2924 } else {
3242 2925 // remove the languages unavailable for the datepicker
3243 - $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' );
2926 + $unset = array( 'fil', 'fr-CA', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419' );
3244 2927 }
3245 2928
3246 2929 $locales = array_diff_key( $locales, array_flip( $unset ) );
2930 + $locales = apply_filters( 'frm_locales', $locales );
3247 2931
3248 - /**
3249 - * Filter available locale options.
3250 - *
3251 - * @since 5.4.5 Added $args parameter with type.
3252 - *
3253 - * @param array<string,string> $locales
3254 - * @param array $args {
3255 - * @type string $type
3256 - * }
3257 - */
3258 - $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) );
3259 -
3260 2932 return $locales;
3261 2933 }
3262 2934
3263 2935 /**
@@ -3563,12 +3235,11 @@
3563 3235 * @return array
3564 3236 */
3565 3237 public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) {
3566 3238 $params = array(
3567 - 'medium' => $medium,
3568 - 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
3569 - 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
3570 - 'screenshot' => 'landing.png',
3239 + 'medium' => $medium,
3240 + 'upgrade' => __( 'Form Landing Pages', 'formidable' ),
3241 + 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ),
3571 3242 );
3572 3243 return self::get_upgrade_data_params( 'landing', $params );
3573 3244 }
3574 3245
@@ -3613,9 +3284,9 @@
3613 3284 if ( ! isset( $params['medium'] ) ) {
3614 3285 $params['medium'] = $plugin;
3615 3286 }
3616 3287 } else {
3617 - $params['requires'] = FrmFormsHelper::get_plan_required( $link );
3288 + $params['requires'] = FrmFormsHelper::get_plan_required( $link, false );
3618 3289 }
3619 3290
3620 3291 return $params;
3621 3292 }
@@ -3636,274 +3307,241 @@
3636 3307 return is_string( $text ) && '' !== $text && ! preg_match( '/[^A-Fa-f0-9]/', $text );
3637 3308 }
3638 3309
3639 3310 /**
3640 - * Set the current screen to avoid undefined notices.
3641 - *
3642 - * @since 5.2.01
3311 + * @since 4.07
3312 + * @deprecated 4.09.01
3643 3313 */
3644 - public static function set_current_screen_and_hook_suffix() {
3645 - global $hook_suffix;
3646 - if ( is_null( $hook_suffix ) ) {
3647 - // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr.
3648 - $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
3314 + public static function renewal_message() {
3315 + if ( is_callable( 'FrmProAddonsController::renewal_message' ) ) {
3316 + FrmProAddonsController::renewal_message();
3317 + return;
3649 3318 }
3650 - set_current_screen();
3319 +
3320 + if ( ! FrmAddonsController::is_license_expired() ) {
3321 + return;
3322 + }
3323 +
3324 + ?>
3325 + <div class="frm_error_style" style="text-align:left">
3326 + <?php self::icon_by_class( 'frmfont frm_alert_icon' ); ?>
3327 + &nbsp;
3328 + <?php esc_html_e( 'Your account has expired', 'formidable' ); ?>
3329 + <div style="float:right">
3330 + <a href="<?php echo esc_url( self::admin_upgrade_link( 'form-expired', 'account/downloads/' ) ); ?>">
3331 + <?php esc_html_e( 'Renew Now', 'formidable' ); ?>
3332 + </a>
3333 + </div>
3334 + </div>
3335 + <?php
3651 3336 }
3652 3337
3653 3338 /**
3654 - * Shows pill text.
3655 - *
3656 - * @since 5.2.02
3657 - *
3658 - * @param string $text Text in the pill. Default is NEW.
3339 + * @since 4.08
3340 + * @deprecated 4.09.01
3659 3341 */
3660 - public static function show_pill_text( $text = null ) {
3661 - if ( null === $text ) {
3662 - $text = __( 'NEW', 'formidable' );
3342 + public static function expiring_message() {
3343 + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3344 + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3345 + FrmProAddonsController::expiring_message();
3663 3346 }
3664 - echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>';
3665 3347 }
3666 3348
3667 3349 /**
3668 - * Count the number of decimals digits.
3350 + * Use the WP 4.7 wp_doing_ajax function
3669 3351 *
3670 - * @since 5.2.07
3671 - *
3672 - * @param mixed $num Number.
3673 - * @return int|false Returns `false` if the passed parameter is not number.
3352 + * @since 2.05.07
3353 + * @deprecated 4.04.04
3674 3354 */
3675 - public static function count_decimals( $num ) {
3676 - if ( ! is_numeric( $num ) ) {
3677 - return false;
3678 - }
3355 + public static function wp_doing_ajax() {
3356 + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3357 + return wp_doing_ajax();
3358 + }
3679 3359
3680 - $num = (string) $num;
3681 - $parts = explode( '.', $num );
3682 - if ( 1 === count( $parts ) ) {
3683 - return 0;
3684 - }
3685 -
3686 - return strlen( $parts[ count( $parts ) - 1 ] );
3360 + /**
3361 + * @deprecated 4.0
3362 + */
3363 + public static function insert_opt_html( $args ) {
3364 + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3365 + FrmFormsHelper::insert_opt_html( $args );
3687 3366 }
3688 3367
3689 3368 /**
3690 - * Prevent a fatal error in PHP8 if gmt_offset happens to be set an empty string.
3691 - * This is a bug in WordPress. It isn't safe to call current_time( 'timestamp' ) without this with an empty string offset.
3692 - * In the future this might be safe to remove. Keep an eye on the current_time function in functions.php.
3369 + * Used to filter shortcode in text widgets
3693 3370 *
3694 - * @since 5.3.1
3695 - *
3696 - * @return void
3371 + * @deprecated 2.5.4
3372 + * @codeCoverageIgnore
3697 3373 */
3698 - public static function filter_gmt_offset() {
3699 - if ( self::$added_gmt_offset_filter ) {
3700 - // Avoid adding twice.
3701 - return;
3702 - }
3703 -
3704 - add_filter(
3705 - 'option_gmt_offset',
3706 - function( $offset ) {
3707 - if ( ! is_string( $offset ) || is_numeric( $offset ) ) {
3708 - // Leave a valid value alone.
3709 - return $offset;
3710 - }
3711 -
3712 - return 0;
3713 - }
3714 - );
3715 - self::$added_gmt_offset_filter = true;
3374 + public static function widget_text_filter_callback( $matches ) {
3375 + return FrmDeprecated::widget_text_filter_callback( $matches );
3716 3376 }
3717 3377
3718 3378 /**
3719 - * @since 5.3.1
3720 - *
3721 - * @return bool
3379 + * @deprecated 3.01
3380 + * @codeCoverageIgnore
3722 3381 */
3723 - public static function on_form_listing_page() {
3724 - if ( ! self::is_admin_page( 'formidable' ) ) {
3725 - return false;
3726 - }
3727 -
3728 - $action = self::simple_get( 'frm_action', 'sanitize_title' );
3729 - return ! $action || in_array( $action, self::get_form_listing_page_actions(), true );
3382 + public static function sanitize_array( &$values ) {
3383 + FrmDeprecated::sanitize_array( $values );
3730 3384 }
3731 3385
3732 3386 /**
3733 - * Get all actions that also display the forms list.
3387 + * @param array $settings
3388 + * @param string $group
3734 3389 *
3735 - * @since 5.3.1
3736 - *
3737 - * @return array<string>
3390 + * @since 2.0.6
3391 + * @deprecated 2.05.06
3392 + * @codeCoverageIgnore
3738 3393 */
3739 - private static function get_form_listing_page_actions() {
3740 - return array( 'list', 'trash', 'untrash', 'destroy' );
3394 + public static function save_settings( $settings, $group ) {
3395 + return FrmDeprecated::save_settings( $settings, $group );
3741 3396 }
3742 3397
3743 3398 /**
3744 - * Safely call get_plugins, importing the required files if they are not yet loaded.
3745 - *
3746 - * @since 5.5
3747 - *
3748 - * @return array
3399 + * @since 2.0.4
3400 + * @deprecated 2.05.06
3401 + * @codeCoverageIgnore
3749 3402 */
3750 - public static function get_plugins() {
3751 - if ( ! function_exists( 'get_plugins' ) ) {
3752 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
3753 - }
3754 - return get_plugins();
3403 + public static function save_json_post( $settings ) {
3404 + return FrmDeprecated::save_json_post( $settings );
3755 3405 }
3756 3406
3757 3407 /**
3758 - * 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.
3759 - * This is to make sure that the URL can't be exploited for a SSRF attack.
3408 + * @since 2.0
3409 + * @deprecated 2.05.06
3410 + * @codeCoverageIgnore
3760 3411 *
3761 - * @since 5.5.5
3412 + * @param string $cache_key The unique name for this cache
3413 + * @param string $group The name of the cache group
3414 + * @param string $query If blank, don't run a db call
3415 + * @param string $type The wpdb function to use with this query
3762 3416 *
3763 - * @param string $url
3764 - * @param string $expected_extension
3765 - * @return bool
3417 + * @return mixed $results The cache or query results
3766 3418 */
3767 - public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) {
3768 - $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' );
3769 - if ( ! $file_is_in_expected_s3_bucket ) {
3770 - return false;
3771 - }
3772 -
3773 - $parsed = parse_url( $url );
3774 - if ( ! is_array( $parsed ) ) {
3775 - // URL is malformed.
3776 - return false;
3777 - }
3778 -
3779 - $path = $parsed['path'];
3780 - $ext = pathinfo( $path, PATHINFO_EXTENSION );
3781 - if ( $expected_extension !== $ext ) {
3782 - // The URL isn't to an XML file.
3783 - return false;
3784 - }
3785 -
3786 - return true;
3419 + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) {
3420 + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time );
3787 3421 }
3788 3422
3789 3423 /**
3790 - * @since 4.08
3791 - * @deprecated 4.09.01
3424 + * @deprecated 2.05.06
3425 + * @codeCoverageIgnore
3792 3426 */
3793 - public static function expiring_message() {
3794 - _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' );
3795 - if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) {
3796 - FrmProAddonsController::expiring_message();
3797 - }
3427 + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) {
3428 + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time );
3798 3429 }
3799 3430
3800 3431 /**
3801 - * Use the WP 4.7 wp_doing_ajax function
3802 - *
3803 - * @since 2.05.07
3804 - * @deprecated 4.04.04
3432 + * @deprecated 2.05.06
3433 + * @codeCoverageIgnore
3805 3434 */
3806 - public static function wp_doing_ajax() {
3807 - _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' );
3808 - return wp_doing_ajax();
3435 + public static function add_key_to_group_cache( $key, $group ) {
3436 + FrmDeprecated::add_key_to_group_cache( $key, $group );
3809 3437 }
3810 3438
3811 3439 /**
3812 - * @deprecated 4.0
3440 + * @deprecated 2.05.06
3441 + * @codeCoverageIgnore
3813 3442 */
3814 - public static function insert_opt_html( $args ) {
3815 - _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' );
3816 - FrmFormsHelper::insert_opt_html( $args );
3443 + public static function get_group_cached_keys( $group ) {
3444 + return FrmDeprecated::get_group_cached_keys( $group );
3817 3445 }
3818 3446
3819 3447 /**
3820 - * @deprecated 3.01
3448 + * @since 2.0
3449 + * @deprecated 2.05.06
3821 3450 * @codeCoverageIgnore
3451 + * @return mixed The cached value or false
3822 3452 */
3823 - public static function sanitize_array( &$values ) {
3824 - FrmDeprecated::sanitize_array( $values );
3453 + public static function check_cache_and_transient( $cache_key ) {
3454 + return FrmDeprecated::check_cache( $cache_key );
3825 3455 }
3826 3456
3827 3457 /**
3828 3458 * @since 2.0
3829 - * @deprecated 5.0.13
3459 + * @deprecated 2.05.06
3460 + * @codeCoverageIgnore
3830 3461 *
3831 - * @return string The base Google APIS url for the current version of jQuery UI
3462 + * @param string $cache_key
3832 3463 */
3833 - public static function jquery_ui_base_url() {
3834 - _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3835 - return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
3464 + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) {
3465 + FrmDeprecated::delete_cache_and_transient( $cache_key, $group );
3836 3466 }
3837 3467
3838 3468 /**
3839 - * @since 4.07
3840 - * @deprecated 6.0
3469 + * @since 2.0
3470 + * @deprecated 2.05.06
3471 + * @codeCoverageIgnore
3472 + *
3473 + * @param string $group The name of the cache group
3841 3474 */
3842 - public static function renewal_message() {
3843 - _deprecated_function( __METHOD__, '6.0', 'FrmProAddonsController::renewal_message' );
3475 + public static function cache_delete_group( $group ) {
3476 + FrmDeprecated::cache_delete_group( $group );
3844 3477 }
3845 3478
3846 3479 /**
3847 - * Display a dismissable warning message and save its dismissal state.
3480 + * @since 1.07.10
3481 + * @deprecated 2.05.06
3482 + * @codeCoverageIgnore
3848 3483 *
3849 - * @since 6.3
3484 + * @param string $term The value to escape
3850 3485 *
3851 - * @param string $message The warning message to display.
3852 - * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action.
3853 - * @return void
3486 + * @return string The escaped value
3854 3487 */
3855 - public static function add_dismissable_warning_message( $message = '', $option = '' ) {
3856 - if ( ! $message || ! $option ) {
3857 - return;
3858 - }
3488 + public static function esc_like( $term ) {
3489 + return FrmDeprecated::esc_like( $term );
3490 + }
3859 3491
3860 - $ajax_callback = function() use ( $option ) {
3861 - self::dismiss_warning_message( $option );
3862 - };
3492 + /**
3493 + * @param string $order_query
3494 + *
3495 + * @deprecated 2.05.06
3496 + * @codeCoverageIgnore
3497 + */
3498 + public static function esc_order( $order_query ) {
3499 + return FrmDeprecated::esc_order( $order_query );
3500 + }
3863 3501
3864 - // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action.
3865 - // To prevent any issues, we add 'frm_' from the beginning of the action.
3866 - add_action( 'wp_ajax_frm_' . $option, $ajax_callback );
3502 + /**
3503 + * @deprecated 2.05.06
3504 + * @codeCoverageIgnore
3505 + */
3506 + public static function esc_order_by( &$order_by ) {
3507 + FrmDeprecated::esc_order_by( $order_by );
3508 + }
3867 3509
3868 - add_filter(
3869 - 'frm_message_list',
3870 - function( $show_messages ) use ( $message, $option ) {
3871 - if ( get_option( $option, false ) ) {
3872 - return $show_messages;
3873 - }
3510 + /**
3511 + * @param string $limit
3512 + *
3513 + * @deprecated 2.05.06
3514 + * @codeCoverageIgnore
3515 + */
3516 + public static function esc_limit( $limit ) {
3517 + return FrmDeprecated::esc_limit( $limit );
3518 + }
3874 3519
3875 - $dismiss_icon = self::icon_by_class(
3876 - 'frmfont frm_close_icon',
3877 - array(
3878 - 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ),
3879 - 'echo' => false,
3880 - )
3881 - );
3520 + /**
3521 + * @since 2.0
3522 + * @deprecated 2.05.06
3523 + * @codeCoverageIgnore
3524 + */
3525 + public static function prepare_array_values( $array, $type = '%s' ) {
3526 + return FrmDeprecated::prepare_array_values( $array, $type );
3527 + }
3882 3528
3883 - $show_messages[] = $message;
3884 - $show_messages[] = '<span class="frm-warning-dismiss frmsvg" data-action="' . esc_attr( $option ) . '">' . $dismiss_icon . '</span>';
3885 -
3886 - return $show_messages;
3887 - }
3888 - );
3529 + /**
3530 + * @deprecated 2.05.06
3531 + * @codeCoverageIgnore
3532 + */
3533 + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) {
3534 + return FrmDeprecated::prepend_and_or_where( $starts_with, $where );
3889 3535 }
3890 3536
3891 3537 /**
3892 - * Dismiss a warning message and update the dismissal state.
3538 + * @since 2.0
3539 + * @deprecated 5.0.13
3893 3540 *
3894 - * @since 6.3
3895 - *
3896 - * @param string $option The unique identifier for the dismissal state of the message.
3897 - * @return void
3541 + * @return string The base Google APIS url for the current version of jQuery UI
3898 3542 */
3899 - public static function dismiss_warning_message( $option = '' ) {
3900 - self::permission_check( 'frm_change_settings' );
3901 - check_ajax_referer( 'frm_ajax', 'nonce' );
3902 -
3903 - if ( $option ) {
3904 - update_option( $option, true, 'no' );
3905 - }
3906 -
3907 - wp_send_json_success();
3543 + public static function jquery_ui_base_url() {
3544 + _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' );
3545 + return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : '';
3908 3546 }
3909 3547 }