PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmAppHelper.php +315 -110 6.3.26.7.2 View file →
@@ -3,13 +3,28 @@
3 3 die( 'You are not allowed to call this page directly.' );
4 4 }
5 5
6 6 class FrmAppHelper {
7 - public static $db_version = 98; // Version of the database we are moving to.
8 - public static $pro_db_version = 37; //deprecated
9 - public static $font_version = 7;
7 + /**
8 + * Version of the database we are moving to.
9 + *
10 + * @var int
11 + */
12 + public static $db_version = 100;
10 13
11 14 /**
15 + * Deprecated.
16 + *
17 + * @var int
18 + */
19 + public static $pro_db_version = 37;
20 +
21 + /**
22 + * @var float
23 + */
24 + public static $font_version = 7;
25 +
26 + /**
12 27 * @var bool $added_gmt_offset_filter
13 28 */
14 29 private static $added_gmt_offset_filter = false;
15 30
@@ -14,16 +29,21 @@
14 29 private static $added_gmt_offset_filter = false;
15 30
16 31 /**
17 32 * @since 2.0
33 + *
34 + * @var string
18 35 */
19 - public static $plug_version = '6.3.2';
36 + public static $plug_version = '6.7.2';
20 37
21 38 /**
39 + * @var bool
40 + */
41 + private static $included_svg = false;
42 +
43 + /**
22 44 * @since 1.07.02
23 45 *
24 - * @param none
25 - *
26 46 * @return string The version of this plugin
27 47 */
28 48 public static function plugin_version() {
29 49 return self::$plug_version;
@@ -148,12 +168,28 @@
148 168
149 169 public static function get_menu_name() {
150 170 $frm_settings = self::get_settings();
151 171
152 - return $frm_settings->menu;
172 + return FrmAddonsController::is_license_expired() ? 'Formidable' : $frm_settings->menu;
153 173 }
154 174
155 175 /**
176 + * Determine if the current branding is set to 'formidable'.
177 + *
178 + * Checks the menu title, retrieved through get_menu_name,
179 + * and verifies if it matches the 'formidable' branding.
180 + *
181 + * @since 6.4.2
182 + *
183 + * @return bool True if the menu title is 'formidable', false otherwise.
184 + */
185 + public static function is_formidable_branding() {
186 + $menu_title = self::get_menu_name();
187 +
188 + return 'formidable' === strtolower( trim( $menu_title ) );
189 + }
190 +
191 + /**
156 192 * @since 3.05
157 193 */
158 194 public static function svg_logo( $atts = array() ) {
159 195 $defaults = array(
@@ -243,9 +279,9 @@
243 279 * Check for certain page in Formidable settings
244 280 *
245 281 * @since 2.0
246 282 *
247 - * @param string $page The name of the page to check
283 + * @param string $page The name of the page to check.
248 284 *
249 285 * @return boolean
250 286 */
251 287 public static function is_admin_page( $page = 'formidable' ) {
@@ -290,10 +326,8 @@
290 326 * Check for the form preview page
291 327 *
292 328 * @since 2.0
293 329 *
294 - * @param None
295 - *
296 330 * @return boolean
297 331 */
298 332 public static function is_preview_page() {
299 333 global $pagenow;
@@ -306,10 +340,8 @@
306 340 * Check for ajax except the form preview page
307 341 *
308 342 * @since 2.0
309 343 *
310 - * @param None
311 - *
312 344 * @return boolean
313 345 */
314 346 public static function doing_ajax() {
315 347 return wp_doing_ajax() && ! self::is_preview_page();
@@ -349,10 +381,10 @@
349 381 * Check if value contains blank value or empty array
350 382 *
351 383 * @since 2.0
352 384 *
353 - * @param mixed $value - value to check
354 - * @param string
385 + * @param mixed $value Value to check.
386 + * @param string $empty
355 387 *
356 388 * @return boolean
357 389 */
358 390 public static function is_empty_value( $value, $empty = '' ) {
@@ -376,8 +408,28 @@
376 408 return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : '';
377 409 }
378 410
379 411 /**
412 + * Get the server OS
413 + *
414 + * @since 6.4.2
415 + *
416 + * @return string
417 + */
418 + public static function get_server_os() {
419 + if ( function_exists( 'php_uname' ) ) {
420 + return php_uname( 's' );
421 + }
422 +
423 + if ( ! defined( 'PHP_OS' ) ) {
424 + return '';
425 + }
426 +
427 + // match the same response for Windows server as php_uname('s')
428 + return in_array( PHP_OS, array( 'WIN32', 'WINNT', 'Windows_NT' ), true ) ? 'Windows NT' : PHP_OS;
429 + }
430 +
431 + /**
380 432 * Check for the IP address in several places (when custom headers are enabled).
381 433 * Used by [ip] shortcode.
382 434 *
383 435 * @return string The IP address of the current user
@@ -392,9 +444,10 @@
392 444 }
393 445
394 446 $key = self::get_server_value( $key );
395 447 foreach ( explode( ',', $key ) as $ip ) {
396 - $ip = trim( $ip ); // Just to be safe.
448 + // Just to be safe.
449 + $ip = trim( $ip );
397 450
398 451 if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) {
399 452 return sanitize_text_field( $ip );
400 453 }
@@ -537,14 +590,14 @@
537 590 );
538 591 $args = wp_parse_args( $args, $defaults );
539 592
540 593 $value = $args['default'];
541 - if ( $args['type'] == 'get' ) {
594 + if ( $args['type'] === 'get' ) {
542 595 if ( $_GET && isset( $_GET[ $args['param'] ] ) ) {
543 596 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
544 597 $value = wp_unslash( $_GET[ $args['param'] ] );
545 598 }
546 - } elseif ( $args['type'] == 'post' ) {
599 + } elseif ( $args['type'] === 'post' ) {
547 600 if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
548 601 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
549 602 $value = wp_unslash( $_POST[ $args['param'] ] );
550 603 if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) {
@@ -604,15 +657,49 @@
604 657 }
605 658
606 659 /**
607 660 * @since 4.0.04
661 + *
662 + * @param mixed $value
663 + * @return void
608 664 */
609 665 public static function sanitize_with_html( &$value ) {
610 - self::sanitize_value( 'wp_kses_post', $value );
666 + if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) {
667 + // Only strip unsafe HTML like scripts for a privileged user submitting a form.
668 + self::sanitize_value( 'wp_kses_post', $value );
669 + } else {
670 + self::sanitize_value( self::class . '::strip_most_html', $value );
671 + }
611 672 self::decode_specialchars( $value );
612 673 }
613 674
614 675 /**
676 + * Allow only a small set of very basic HTML for unprivileged users.
677 + *
678 + * @since 6.7.1
679 + *
680 + * @param string $value
681 + */
682 + public static function strip_most_html( $value ) {
683 + $allowed_html = array(
684 + 'b' => array(),
685 + 'br' => array(),
686 + 'strong' => array(),
687 + 'p' => array(),
688 + 'i' => array(),
689 + );
690 +
691 + /**
692 + * @since 6.7.1
693 + *
694 + * @param array $allowed_html
695 + */
696 + $allowed_html = apply_filters( 'frm_allowed_form_input_html', $allowed_html );
697 +
698 + return wp_kses( $value, $allowed_html );
699 + }
700 +
701 + /**
615 702 * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&'
616 703 * this MUST be done, else we'll be back to the '& entity' problem.
617 704 *
618 705 * @since 4.0.04
@@ -646,10 +733,12 @@
646 733 $translation = array(
647 734 '"' => '"',
648 735 '"' => '"',
649 736 '"' => '"',
650 - '&lt; ' => '< ', // The space preserves the HTML.
651 - '&#060; ' => '< ', // The space preserves the HTML.
737 + // The space preserves the HTML.
738 + '&lt; ' => '< ',
739 + // The space preserves the HTML.
740 + '&#060; ' => '< ',
652 741 '&gt;' => '>',
653 742 '&#062;' => '>',
654 743 '&amp;' => '&',
655 744 '&#038;' => '&',
@@ -676,10 +765,10 @@
676 765 * Sanitize the value, and allow some HTML
677 766 *
678 767 * @since 2.0
679 768 *
680 - * @param string $value
681 - * @param array|string $allowed 'all' for everything included as defaults
769 + * @param string $value
770 + * @param array|string $allowed 'all' for everything included as defaults.
682 771 *
683 772 * @return string
684 773 */
685 774 public static function kses( $value, $allowed = array() ) {
@@ -915,9 +1004,9 @@
915 1004 *
916 1005 * @since 2.0
917 1006 */
918 1007 public static function remove_get_action() {
919 - if ( ! isset( $_GET ) ) {
1008 + if ( empty( $_GET ) ) {
920 1009 return;
921 1010 }
922 1011
923 1012 $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' );
@@ -966,14 +1055,16 @@
966 1055 $html_atts = self::array_to_html_params( $atts );
967 1056
968 1057 $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) );
969 1058
970 - // Replace icons that have been removed.
1059 + // Replace icons that have been removed or renamed.
971 1060 $deprecated = array(
972 - 'frm_clone_solid_icon' => 'frm_clone_icon',
1061 + 'frm_clone_solid_icon' => 'frm_clone_icon',
1062 + 'frm_keyalt_icon' => 'frm_key_icon',
1063 + 'frm_keyalt_solid_icon' => 'frm_key_solid_icon',
973 1064 );
974 1065 if ( isset( $deprecated[ $icon ] ) ) {
975 - $icon = $deprecated[ $icon ];
1066 + $icon = $deprecated[ $icon ];
976 1067 $class = str_replace( $icon, $deprecated[ $icon ], $class );
977 1068 }
978 1069
979 1070 if ( $icon === $class ) {
@@ -1073,11 +1164,18 @@
1073 1164 /**
1074 1165 * Include svg images.
1075 1166 *
1076 1167 * @since 4.0.02
1168 + * @return void
1077 1169 */
1078 1170 public static function include_svg() {
1079 - include_once self::plugin_path() . '/images/icons.svg';
1171 + if ( self::$included_svg ) {
1172 + return;
1173 + }
1174 +
1175 + // Use readfile instead of include_once because of a default security rule in Snuffleupagus.
1176 + readfile( self::plugin_path() . '/images/icons.svg' );
1177 + self::$included_svg = true;
1080 1178 }
1081 1179
1082 1180 /**
1083 1181 * Convert an associative array to HTML values.
@@ -1194,8 +1292,10 @@
1194 1292 * Render a button for a new item (Form, Application, etc).
1195 1293 *
1196 1294 * @since 3.0
1197 1295 * @param array $atts {
1296 + * Details about the button.
1297 + *
1198 1298 * @type array $link_hook Custom link hook, calls do_action and exits early.
1199 1299 * @type string $new_link Href value, default #.
1200 1300 * @type string $class Custom class names, space separated.
1201 1301 * @type string $button_text Button text. Default "Add New".
@@ -1207,9 +1307,9 @@
1207 1307 do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] );
1208 1308 return;
1209 1309 }
1210 1310
1211 - if ( empty( $atts['new_link'] ) && empty( $atts['trigger_new_form_modal'] ) && empty( $atts['class'] ) ) {
1311 + if ( empty( $atts['new_link'] ) && empty( $atts['create_form'] ) && empty( $atts['class'] ) ) {
1212 1312 // Do not render a button if none of these attributes are set.
1213 1313 return;
1214 1314 }
1215 1315
@@ -1215,12 +1315,8 @@
1215 1315
1216 1316 $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#';
1217 1317 $class = 'button button-primary frm-button-primary';
1218 1318
1219 - if ( ! empty( $atts['trigger_new_form_modal'] ) ) {
1220 - $class .= ' frm-trigger-new-form-modal';
1221 - }
1222 -
1223 1319 if ( ! empty( $atts['class'] ) ) {
1224 1320 $class .= ' ' . $atts['class'];
1225 1321 }
1226 1322
@@ -1285,11 +1381,14 @@
1285 1381 }
1286 1382 }
1287 1383
1288 1384 /**
1289 - * Save all front-end js scripts into a single file
1385 + * Save all front-end js scripts into a single file.
1386 + * And save an additional single file of all front-end Stripe JS scripts.
1290 1387 *
1291 1388 * @since 3.0
1389 + *
1390 + * @return void
1292 1391 */
1293 1392 public static function save_combined_js() {
1294 1393 $file_atts = apply_filters(
1295 1394 'frm_js_location',
@@ -1302,10 +1401,34 @@
1302 1401
1303 1402 $files = array(
1304 1403 self::plugin_path() . '/js/formidable.min.js',
1305 1404 );
1405 + /**
1406 + * @param array $files
1407 + */
1306 1408 $files = apply_filters( 'frm_combined_js_files', $files );
1307 1409 $new_file->combine_files( $files );
1410 +
1411 + // Create the minified Stripe Script.
1412 + $file_atts = apply_filters(
1413 + 'frm_stripe_js_location',
1414 + array(
1415 + 'file_name' => 'frmstrp.min.js',
1416 + 'new_file_path' => self::plugin_path() . '/js',
1417 + )
1418 + );
1419 + $new_file = new FrmCreateFile( $file_atts );
1420 + $files = array(
1421 + FrmStrpLiteAppHelper::plugin_path() . 'js/frmstrp.min.js',
1422 + );
1423 +
1424 + /**
1425 + * @since 6.5
1426 + *
1427 + * @param array $files
1428 + */
1429 + $files = apply_filters( 'frm_stripe_combined_js_files', $files );
1430 + $new_file->combine_files( $files );
1308 1431 }
1309 1432
1310 1433 /**
1311 1434 * Check a value from a shortcode to see if true or false.
@@ -1312,9 +1435,9 @@
1312 1435 * True when value is 1, true, 'true', 'yes'
1313 1436 *
1314 1437 * @since 1.07.10
1315 1438 *
1316 - * @param string $value The value to compare
1439 + * @param string $value The value to compare.
1317 1440 *
1318 1441 * @return boolean True or False
1319 1442 */
1320 1443 public static function is_true( $value ) {
@@ -1537,11 +1660,11 @@
1537 1660 return $link;
1538 1661 }
1539 1662
1540 1663 /**
1541 - * @param string $field_name
1542 - * @param string|array $capability
1543 - * @param string $multiple 'single' and 'multiple'
1664 + * @param string $field_name
1665 + * @param string|array $capability
1666 + * @param string $multiple 'single' and 'multiple'.
1544 1667 */
1545 1668 public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) {
1546 1669 ?>
1547 1670 <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>"
@@ -1554,9 +1677,9 @@
1554 1677
1555 1678 /**
1556 1679 * @since 4.07
1557 1680 * @param array|string $selected
1558 - * @param string $current
1681 + * @param string $current
1559 1682 */
1560 1683 private static function selected( $selected, $current ) {
1561 1684 if ( is_callable( 'FrmProAppHelper::selected' ) ) {
1562 1685 FrmProAppHelper::selected( $selected, $current );
@@ -1602,9 +1725,8 @@
1602 1725 $pro_cap = array(
1603 1726 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ),
1604 1727 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ),
1605 1728 'frm_view_reports' => __( 'View Reports', 'formidable' ),
1606 - 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ),
1607 1729 );
1608 1730 /**
1609 1731 * @since 5.3.1
1610 1732 *
@@ -1611,8 +1733,14 @@
1611 1733 * @param array<string,string> $pro_cap
1612 1734 */
1613 1735 $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap );
1614 1736
1737 + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) {
1738 + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date.
1739 + // This was added in 6.5.4. Remove this in the future.
1740 + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' );
1741 + }
1742 +
1615 1743 if ( 'pro_only' === $type ) {
1616 1744 return $pro_cap;
1617 1745 }
1618 1746
@@ -1627,9 +1755,9 @@
1627 1755 * @return array<string,string>
1628 1756 */
1629 1757 private static function get_lite_capabilities() {
1630 1758 return array(
1631 - 'frm_view_forms' => __( 'View Forms', 'formidable' ),
1759 + 'frm_view_forms' => __( 'View Forms List', 'formidable' ),
1632 1760 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ),
1633 1761 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ),
1634 1762 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ),
1635 1763 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ),
@@ -1838,9 +1966,9 @@
1838 1966 foreach ( $array as $key => $value ) {
1839 1967 if ( is_array( $value ) ) {
1840 1968 $return = array_merge( $return, self::array_flatten( $value, $keys ) );
1841 1969 } else {
1842 - if ( $keys == 'keep' ) {
1970 + if ( $keys === 'keep' ) {
1843 1971 $return[ $key ] = $value;
1844 1972 } else {
1845 1973 $return[] = $value;
1846 1974 }
@@ -1924,9 +2052,9 @@
1924 2052 return $user_id;
1925 2053 }
1926 2054
1927 2055 $user_id = sanitize_text_field( $user_id );
1928 - if ( $user_id == 'current' ) {
2056 + if ( $user_id === 'current' ) {
1929 2057 $user_id = get_current_user_id();
1930 2058 } else {
1931 2059 if ( is_email( $user_id ) ) {
1932 2060 $user = get_user_by( 'email', $user_id );
@@ -2006,9 +2134,9 @@
2006 2134 ++$suffix;
2007 2135 } while ( in_array( $key_check, $similar_keys, true ) );
2008 2136
2009 2137 $key = $key_check;
2010 - }
2138 + }//end if
2011 2139
2012 2140 return $key;
2013 2141 }
2014 2142
@@ -2052,9 +2180,11 @@
2052 2180 * @return string
2053 2181 */
2054 2182 private static function generate_new_key( $num_chars ) {
2055 2183 $max_slug_value = pow( 36, $num_chars );
2056 - $min_slug_value = 37; // we want to have at least 2 characters in the slug
2184 +
2185 + // We want to have at least 2 characters in the slug.
2186 + $min_slug_value = 37;
2057 2187 return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 );
2058 2188 }
2059 2189
2060 2190 /**
@@ -2083,9 +2213,14 @@
2083 2213
2084 2214 /**
2085 2215 * Editing a Form or Entry
2086 2216 *
2087 - * @param string $table
2217 + * @param object $record
2218 + * @param string $table
2219 + * @param array|string $fields
2220 + * @param bool $default
2221 + * @param array $post_values
2222 + * @param array $args
2088 2223 *
2089 2224 * @return bool|array
2090 2225 */
2091 2226 public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) {
@@ -2159,9 +2294,9 @@
2159 2294 );
2160 2295 } else {
2161 2296 $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id );
2162 2297 }
2163 - }
2298 + }//end if
2164 2299
2165 2300 $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type;
2166 2301 if ( isset( $post_values['item_meta'][ $field->id ] ) ) {
2167 2302 $new_value = $post_values['item_meta'][ $field->id ];
@@ -2209,9 +2344,12 @@
2209 2344 );
2210 2345 }
2211 2346
2212 2347 /**
2348 + * @param object $record
2213 2349 * @param string $table
2350 + * @param array $post_values
2351 + * @param array $values
2214 2352 */
2215 2353 private static function fill_form_opts( $record, $table, $post_values, array &$values ) {
2216 2354 if ( $table == 'entries' ) {
2217 2355 $form = $record->form_id;
@@ -2325,11 +2463,37 @@
2325 2463
2326 2464 unset( $total_len, $word );
2327 2465 }
2328 2466
2467 + $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length );
2468 +
2329 2469 return $sub . ( ( $len < $original_len ) ? $continue : '' );
2330 2470 }
2331 2471
2472 + /**
2473 + * If the string is still too long because there may not have been any spaces, force truncate.
2474 + *
2475 + * @since 6.5.4
2476 + *
2477 + * @param string $sub Current substring.
2478 + * @param int $length The length limit.
2479 + * @return string
2480 + */
2481 + private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) {
2482 + if ( strlen( $sub ) < $length + 50 ) {
2483 + // If the string isn't way over the limit, leave it.
2484 + return $sub;
2485 + }
2486 +
2487 + $first_space = strpos( $sub, ' ', $length );
2488 + if ( false !== $first_space ) {
2489 + // Ignore anything with spaces.
2490 + return $sub;
2491 + }
2492 +
2493 + return substr( $sub, 0, $length + 10 );
2494 + }
2495 +
2332 2496 public static function mb_function( $function_names, $args ) {
2333 2497 $mb_function_name = $function_names[0];
2334 2498 $function_name = $function_names[1];
2335 2499 if ( function_exists( $mb_function_name ) ) {
@@ -2386,12 +2550,12 @@
2386 2550 return date_i18n( $date_format, strtotime( $date ) );
2387 2551 }
2388 2552
2389 2553 /**
2390 - * Gets the time ago in words
2554 + * Gets the time ago in words.
2391 2555 *
2392 - * @param int $from in seconds
2393 - * @param int|string $to in seconds
2556 + * @param int $from In seconds.
2557 + * @param int|string $to In seconds.
2394 2558 *
2395 2559 * @return string $time_ago
2396 2560 */
2397 2561 public static function human_time_diff( $from, $to = '', $levels = 1 ) {
@@ -2554,9 +2718,12 @@
2554 2718
2555 2719 // Pagination Methods.
2556 2720
2557 2721 /**
2722 + * @param integer $r_count
2558 2723 * @param integer $current_p
2724 + * @param integer $p_size
2725 + * @return int
2559 2726 */
2560 2727 public static function get_last_record_num( $r_count, $current_p, $p_size ) {
2561 2728 return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
2562 2729 }
@@ -2561,9 +2728,12 @@
2561 2728 return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) );
2562 2729 }
2563 2730
2564 2731 /**
2732 + * @param integer $r_count
2565 2733 * @param integer $current_p
2734 + * @param integer $p_size
2735 + * @return int
2566 2736 */
2567 2737 public static function get_first_record_num( $r_count, $current_p, $p_size ) {
2568 2738 if ( $current_p == 1 ) {
2569 2739 return 1;
@@ -2617,12 +2787,12 @@
2617 2787 self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] );
2618 2788 }
2619 2789
2620 2790 unset( $this_val, $n );
2621 - }
2791 + }//end foreach
2622 2792
2623 2793 unset( $last, $jv );
2624 - }
2794 + }//end foreach
2625 2795
2626 2796 return $vars;
2627 2797 }
2628 2798
@@ -2879,12 +3049,14 @@
2879 3049 return $value;
2880 3050 }
2881 3051
2882 3052 /**
3053 + * Echo The javascript to open and highlight the Formidable menu
3054 + *
2883 3055 * @since 1.07.10
2884 3056 *
2885 - * @param string $post_type The name of the post type that may need to be highlighted
2886 - * echo The javascript to open and highlight the Formidable menu
3057 + * @param string $post_type The name of the post type that may need to be highlighted.
3058 + * @return void
2887 3059 */
2888 3060 public static function maybe_highlight_menu( $post_type ) {
2889 3061 global $post;
2890 3062
@@ -2939,13 +3111,10 @@
2939 3111 */
2940 3112 public static function localize_script( $location ) {
2941 3113 global $wp_scripts;
2942 3114
2943 - $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
2944 - $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url );
2945 -
2946 3115 $script_strings = array(
2947 - 'ajax_url' => $ajax_url,
3116 + 'ajax_url' => esc_url_raw( self::get_ajax_url() ),
2948 3117 'images_url' => self::plugin_url() . '/images',
2949 3118 'loading' => __( 'Loading&hellip;', 'formidable' ),
2950 3119 'remove' => __( 'Remove', 'formidable' ),
2951 3120 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
@@ -2959,75 +3128,101 @@
2959 3128 'include_alert_role' => self::should_include_alert_role_on_field_errors(),
2960 3129 );
2961 3130
2962 3131 $data = $wp_scripts->get_data( 'formidable', 'data' );
2963 - if ( empty( $data ) ) {
3132 + if ( ! $data ) {
2964 3133 wp_localize_script( 'formidable', 'frm_js', $script_strings );
2965 3134 }
2966 3135
2967 - if ( $location == 'admin' ) {
3136 + if ( $location === 'admin' ) {
2968 3137 $frm_settings = self::get_settings();
2969 3138 $admin_script_strings = array(
2970 - 'desc' => __( '(Click to add description)', 'formidable' ),
2971 - 'blank' => __( '(Blank)', 'formidable' ),
2972 - 'no_label' => __( '(no label)', 'formidable' ),
2973 - 'saving' => '', // Deprecated in 6.0.
2974 - 'saved' => '', // Deprecated in 6.0.
2975 - 'ok' => __( 'OK', 'formidable' ),
2976 - 'cancel' => __( 'Cancel', 'formidable' ),
2977 - 'default_label' => __( 'Default', 'formidable' ),
2978 - 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
2979 - 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
2980 - 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
2981 - 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
2982 - 'confirm' => __( 'Are you sure?', 'formidable' ),
2983 - 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
2984 - '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 - 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
2986 - 'default_unique' => $frm_settings->unique_msg,
2987 - 'default_conf' => __( 'The entered values do not match', 'formidable' ),
2988 - 'enter_email' => __( 'Enter Email', 'formidable' ),
2989 - 'confirm_email' => __( 'Confirm Email', 'formidable' ),
2990 - 'conditional_text' => __( 'Conditional content here', 'formidable' ),
2991 - 'new_option' => __( 'New Option', 'formidable' ),
2992 - 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ),
2993 - 'enter_password' => __( 'Enter Password', 'formidable' ),
2994 - 'confirm_password' => __( 'Confirm Password', 'formidable' ),
2995 - 'import_complete' => __( 'Import Complete', 'formidable' ),
2996 - 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
2997 - 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
2998 - 'private_label' => __( 'Private', 'formidable' ),
2999 - 'jquery_ui_url' => '',
3000 - 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3001 - 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3002 - 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3003 - 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
3004 - 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3005 - 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ),
3006 - 'unsafe_params' => FrmFormsHelper::reserved_words(),
3139 + 'desc' => __( '(Click to add description)', 'formidable' ),
3140 + 'blank' => __( '(Blank)', 'formidable' ),
3141 + 'no_label' => __( '(no label)', 'formidable' ),
3142 + 'ok' => __( 'OK', 'formidable' ),
3143 + 'cancel' => __( 'Cancel', 'formidable' ),
3144 + 'default_label' => __( 'Default', 'formidable' ),
3145 + 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
3146 + 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
3147 + 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
3148 + 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
3149 + 'confirm' => __( 'Are you sure?', 'formidable' ),
3150 + 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
3151 + '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' ),
3152 + 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ),
3153 + 'default_unique' => $frm_settings->unique_msg,
3154 + 'default_conf' => __( 'The entered values do not match', 'formidable' ),
3155 + 'enter_email' => __( 'Enter Email', 'formidable' ),
3156 + 'confirm_email' => __( 'Confirm Email', 'formidable' ),
3157 + 'conditional_text' => __( 'Conditional content here', 'formidable' ),
3158 + 'new_option' => __( 'New Option', 'formidable' ),
3159 + 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ),
3160 + 'enter_password' => __( 'Enter Password', 'formidable' ),
3161 + 'confirm_password' => __( 'Confirm Password', 'formidable' ),
3162 + 'import_complete' => __( 'Import Complete', 'formidable' ),
3163 + 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
3164 + 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
3165 + 'private_label' => __( 'Private', 'formidable' ),
3166 + 'jquery_ui_url' => '',
3167 + 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
3168 + 'no_licenses' => __( 'No new licenses were found', 'formidable' ),
3169 + 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ),
3170 + 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ),
3171 + 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ),
3172 + 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ),
3173 + 'unsafe_params' => FrmFormsHelper::reserved_words(),
3007 3174 /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/
3008 - 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3175 + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ),
3009 3176 /* Translators: %s is the name of a parameter that is a reserved word. More than one word could be listed here, though that would not be common. */
3010 - 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3011 - 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3012 - 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3013 - 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3014 - 'install' => __( 'Install', 'formidable' ),
3015 - 'active' => __( 'Active', 'formidable' ),
3016 - 'select_a_field' => __( 'Select a Field', 'formidable' ),
3017 - 'no_items_found' => __( 'No items found.', 'formidable' ),
3177 + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ),
3178 + 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ),
3179 + 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ),
3180 + 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ),
3181 + 'install' => __( 'Install', 'formidable' ),
3182 + 'active' => __( 'Active', 'formidable' ),
3183 + 'select_a_field' => __( 'Select a Field', 'formidable' ),
3184 + 'no_items_found' => __( 'No items found.', 'formidable' ),
3018 3185 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ),
3186 +
3187 + // Deprecated in 6.0.
3188 + 'saving' => '',
3189 +
3190 + // Deprecated in 6.0.
3191 + 'saved' => '',
3192 +
3193 + // translators: %1$s: HTML open tag, %2$s: HTML end tag.
3194 + 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ),
3019 3195 );
3196 + /**
3197 + * @param array $admin_script_strings
3198 + */
3020 3199 $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings );
3021 3200
3022 3201 $data = $wp_scripts->get_data( 'formidable_admin', 'data' );
3023 - if ( empty( $data ) ) {
3202 + if ( ! $data ) {
3024 3203 wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings );
3025 3204 }
3026 - }
3205 + }//end if
3027 3206 }
3028 3207
3029 3208 /**
3209 + * @since 6.5
3210 + *
3211 + * @return string
3212 + */
3213 + public static function get_ajax_url() {
3214 + $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' );
3215 +
3216 + /**
3217 + * @since 2.0.13
3218 + *
3219 + * @param string $ajax_url
3220 + */
3221 + return apply_filters( 'frm_ajax_url', $ajax_url );
3222 + }
3223 +
3224 + /**
3030 3225 * Returns whether or not the first errored input should be auto-focused (default true).
3031 3226 *
3032 3227 * @since 5.2.05
3033 3228 *
@@ -3052,9 +3247,9 @@
3052 3247 * Echo the message on the plugins listing page
3053 3248 *
3054 3249 * @since 1.07.10
3055 3250 *
3056 - * @param float $min_version The version the add-on requires
3251 + * @param float $min_version The version the add-on requires.
3057 3252 */
3058 3253 public static function min_version_notice( $min_version ) {
3059 3254 $frm_version = self::plugin_version();
3060 3255
@@ -3380,8 +3575,18 @@
3380 3575 return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args );
3381 3576 }
3382 3577
3383 3578 /**
3579 + * @since 6.7.1
3580 + */
3581 + public static function get_images_dropdown_atts( $option, $args ) {
3582 + $image = self::get_images_dropdown_option_image( $option, $args );
3583 + $classes = self::get_images_dropdown_option_classes( $option, $args );
3584 + $custom_attrs = self::get_images_dropdown_option_html_attrs( $option, $args );
3585 + return compact( 'image', 'classes', 'custom_attrs' );
3586 + }
3587 +
3588 + /**
3384 3589 * Gets the image of each option in images_dropdown() method.
3385 3590 *
3386 3591 * @since 5.0.04
3387 3592 *
@@ -3538,9 +3743,9 @@
3538 3743 *
3539 3744 * @since 5.0.13
3540 3745 *
3541 3746 * @param string $value
3542 - * @param array|string $allowed 'all' for everything included as defaults
3747 + * @param array|string $allowed 'all' for everything included as defaults.
3543 3748 * @return string
3544 3749 */
3545 3750 public static function maybe_kses( $value, $allowed = 'all' ) {
3546 3751 if ( self::should_never_allow_unfiltered_html() ) {
@@ -3586,9 +3791,9 @@
3586 3791
3587 3792 /**
3588 3793 * @since 5.0.17
3589 3794 *
3590 - * @param string
3795 + * @param string $feature
3591 3796 * @return bool
3592 3797 */
3593 3798 public static function show_new_feature( $feature ) {
3594 3799 $link = FrmAddonsController::install_link( $feature );