| @@ -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 = 101; | |
| 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.5.2'; | |
| 36 | + public static $plug_version = '6.8'; | |
| 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; |
| @@ -259,9 +279,9 @@ | ||
| 259 | 279 | * Check for certain page in Formidable settings |
| 260 | 280 | * |
| 261 | 281 | * @since 2.0 |
| 262 | 282 | * |
| 263 | - * @param string $page The name of the page to check | |
| 283 | + * @param string $page The name of the page to check. | |
| 264 | 284 | * |
| 265 | 285 | * @return boolean |
| 266 | 286 | */ |
| 267 | 287 | public static function is_admin_page( $page = 'formidable' ) { |
| @@ -306,10 +326,8 @@ | ||
| 306 | 326 | * Check for the form preview page |
| 307 | 327 | * |
| 308 | 328 | * @since 2.0 |
| 309 | 329 | * |
| 310 | - * @param None | |
| 311 | - * | |
| 312 | 330 | * @return boolean |
| 313 | 331 | */ |
| 314 | 332 | public static function is_preview_page() { |
| 315 | 333 | global $pagenow; |
| @@ -322,10 +340,8 @@ | ||
| 322 | 340 | * Check for ajax except the form preview page |
| 323 | 341 | * |
| 324 | 342 | * @since 2.0 |
| 325 | 343 | * |
| 326 | - * @param None | |
| 327 | - * | |
| 328 | 344 | * @return boolean |
| 329 | 345 | */ |
| 330 | 346 | public static function doing_ajax() { |
| 331 | 347 | return wp_doing_ajax() && ! self::is_preview_page(); |
| @@ -365,10 +381,10 @@ | ||
| 365 | 381 | * Check if value contains blank value or empty array |
| 366 | 382 | * |
| 367 | 383 | * @since 2.0 |
| 368 | 384 | * |
| 369 | - * @param mixed $value - value to check | |
| 370 | - * @param string | |
| 385 | + * @param mixed $value Value to check. | |
| 386 | + * @param string $empty | |
| 371 | 387 | * |
| 372 | 388 | * @return boolean |
| 373 | 389 | */ |
| 374 | 390 | public static function is_empty_value( $value, $empty = '' ) { |
| @@ -428,9 +444,10 @@ | ||
| 428 | 444 | } |
| 429 | 445 | |
| 430 | 446 | $key = self::get_server_value( $key ); |
| 431 | 447 | foreach ( explode( ',', $key ) as $ip ) { |
| 432 | - $ip = trim( $ip ); // Just to be safe. | |
| 448 | + // Just to be safe. | |
| 449 | + $ip = trim( $ip ); | |
| 433 | 450 | |
| 434 | 451 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 435 | 452 | return sanitize_text_field( $ip ); |
| 436 | 453 | } |
| @@ -640,15 +657,52 @@ | ||
| 640 | 657 | } |
| 641 | 658 | |
| 642 | 659 | /** |
| 643 | 660 | * @since 4.0.04 |
| 661 | + * | |
| 662 | + * @param mixed $value | |
| 663 | + * @return void | |
| 644 | 664 | */ |
| 645 | 665 | public static function sanitize_with_html( &$value ) { |
| 646 | - 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 | + } | |
| 647 | 672 | self::decode_specialchars( $value ); |
| 648 | 673 | } |
| 649 | 674 | |
| 650 | 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 | + 'ul' => array(), | |
| 690 | + 'ol' => array(), | |
| 691 | + 'li' => array(), | |
| 692 | + ); | |
| 693 | + | |
| 694 | + /** | |
| 695 | + * @since 6.7.1 | |
| 696 | + * | |
| 697 | + * @param array $allowed_html | |
| 698 | + */ | |
| 699 | + $allowed_html = apply_filters( 'frm_allowed_form_input_html', $allowed_html ); | |
| 700 | + | |
| 701 | + return wp_kses( $value, $allowed_html ); | |
| 702 | + } | |
| 703 | + | |
| 704 | + /** | |
| 651 | 705 | * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&' |
| 652 | 706 | * this MUST be done, else we'll be back to the '& entity' problem. |
| 653 | 707 | * |
| 654 | 708 | * @since 4.0.04 |
| @@ -682,10 +736,12 @@ | ||
| 682 | 736 | $translation = array( |
| 683 | 737 | '"' => '"', |
| 684 | 738 | '"' => '"', |
| 685 | 739 | '"' => '"', |
| 686 | - '< ' => '< ', // The space preserves the HTML. | |
| 687 | - '< ' => '< ', // The space preserves the HTML. | |
| 740 | + // The space preserves the HTML. | |
| 741 | + '< ' => '< ', | |
| 742 | + // The space preserves the HTML. | |
| 743 | + '< ' => '< ', | |
| 688 | 744 | '>' => '>', |
| 689 | 745 | '>' => '>', |
| 690 | 746 | '&' => '&', |
| 691 | 747 | '&' => '&', |
| @@ -712,10 +768,10 @@ | ||
| 712 | 768 | * Sanitize the value, and allow some HTML |
| 713 | 769 | * |
| 714 | 770 | * @since 2.0 |
| 715 | 771 | * |
| 716 | - * @param string $value | |
| 717 | - * @param array|string $allowed 'all' for everything included as defaults | |
| 772 | + * @param string $value | |
| 773 | + * @param array|string $allowed 'all' for everything included as defaults. | |
| 718 | 774 | * |
| 719 | 775 | * @return string |
| 720 | 776 | */ |
| 721 | 777 | public static function kses( $value, $allowed = array() ) { |
| @@ -951,9 +1007,9 @@ | ||
| 951 | 1007 | * |
| 952 | 1008 | * @since 2.0 |
| 953 | 1009 | */ |
| 954 | 1010 | public static function remove_get_action() { |
| 955 | - if ( ! isset( $_GET ) ) { | |
| 1011 | + if ( empty( $_GET ) ) { | |
| 956 | 1012 | return; |
| 957 | 1013 | } |
| 958 | 1014 | |
| 959 | 1015 | $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' ); |
| @@ -1002,14 +1058,16 @@ | ||
| 1002 | 1058 | $html_atts = self::array_to_html_params( $atts ); |
| 1003 | 1059 | |
| 1004 | 1060 | $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) ); |
| 1005 | 1061 | |
| 1006 | - // Replace icons that have been removed. | |
| 1062 | + // Replace icons that have been removed or renamed. | |
| 1007 | 1063 | $deprecated = array( |
| 1008 | - 'frm_clone_solid_icon' => 'frm_clone_icon', | |
| 1064 | + 'frm_clone_solid_icon' => 'frm_clone_icon', | |
| 1065 | + 'frm_keyalt_icon' => 'frm_key_icon', | |
| 1066 | + 'frm_keyalt_solid_icon' => 'frm_key_solid_icon', | |
| 1009 | 1067 | ); |
| 1010 | 1068 | if ( isset( $deprecated[ $icon ] ) ) { |
| 1011 | - $icon = $deprecated[ $icon ]; | |
| 1069 | + $icon = $deprecated[ $icon ]; | |
| 1012 | 1070 | $class = str_replace( $icon, $deprecated[ $icon ], $class ); |
| 1013 | 1071 | } |
| 1014 | 1072 | |
| 1015 | 1073 | if ( $icon === $class ) { |
| @@ -1109,11 +1167,18 @@ | ||
| 1109 | 1167 | /** |
| 1110 | 1168 | * Include svg images. |
| 1111 | 1169 | * |
| 1112 | 1170 | * @since 4.0.02 |
| 1171 | + * @return void | |
| 1113 | 1172 | */ |
| 1114 | 1173 | public static function include_svg() { |
| 1115 | - include_once self::plugin_path() . '/images/icons.svg'; | |
| 1174 | + if ( self::$included_svg ) { | |
| 1175 | + return; | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + // Use readfile instead of include_once because of a default security rule in Snuffleupagus. | |
| 1179 | + readfile( self::plugin_path() . '/images/icons.svg' ); | |
| 1180 | + self::$included_svg = true; | |
| 1116 | 1181 | } |
| 1117 | 1182 | |
| 1118 | 1183 | /** |
| 1119 | 1184 | * Convert an associative array to HTML values. |
| @@ -1230,8 +1295,10 @@ | ||
| 1230 | 1295 | * Render a button for a new item (Form, Application, etc). |
| 1231 | 1296 | * |
| 1232 | 1297 | * @since 3.0 |
| 1233 | 1298 | * @param array $atts { |
| 1299 | + * Details about the button. | |
| 1300 | + * | |
| 1234 | 1301 | * @type array $link_hook Custom link hook, calls do_action and exits early. |
| 1235 | 1302 | * @type string $new_link Href value, default #. |
| 1236 | 1303 | * @type string $class Custom class names, space separated. |
| 1237 | 1304 | * @type string $button_text Button text. Default "Add New". |
| @@ -1243,9 +1310,9 @@ | ||
| 1243 | 1310 | do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] ); |
| 1244 | 1311 | return; |
| 1245 | 1312 | } |
| 1246 | 1313 | |
| 1247 | - if ( empty( $atts['new_link'] ) && empty( $atts['trigger_new_form_modal'] ) && empty( $atts['class'] ) ) { | |
| 1314 | + if ( empty( $atts['new_link'] ) && empty( $atts['create_form'] ) && empty( $atts['class'] ) ) { | |
| 1248 | 1315 | // Do not render a button if none of these attributes are set. |
| 1249 | 1316 | return; |
| 1250 | 1317 | } |
| 1251 | 1318 | |
| @@ -1251,12 +1318,8 @@ | ||
| 1251 | 1318 | |
| 1252 | 1319 | $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#'; |
| 1253 | 1320 | $class = 'button button-primary frm-button-primary'; |
| 1254 | 1321 | |
| 1255 | - if ( ! empty( $atts['trigger_new_form_modal'] ) ) { | |
| 1256 | - $class .= ' frm-trigger-new-form-modal'; | |
| 1257 | - } | |
| 1258 | - | |
| 1259 | 1322 | if ( ! empty( $atts['class'] ) ) { |
| 1260 | 1323 | $class .= ' ' . $atts['class']; |
| 1261 | 1324 | } |
| 1262 | 1325 | |
| @@ -1375,9 +1438,9 @@ | ||
| 1375 | 1438 | * True when value is 1, true, 'true', 'yes' |
| 1376 | 1439 | * |
| 1377 | 1440 | * @since 1.07.10 |
| 1378 | 1441 | * |
| 1379 | - * @param string $value The value to compare | |
| 1442 | + * @param string $value The value to compare. | |
| 1380 | 1443 | * |
| 1381 | 1444 | * @return boolean True or False |
| 1382 | 1445 | */ |
| 1383 | 1446 | public static function is_true( $value ) { |
| @@ -1600,11 +1663,11 @@ | ||
| 1600 | 1663 | return $link; |
| 1601 | 1664 | } |
| 1602 | 1665 | |
| 1603 | 1666 | /** |
| 1604 | - * @param string $field_name | |
| 1605 | - * @param string|array $capability | |
| 1606 | - * @param string $multiple 'single' and 'multiple' | |
| 1667 | + * @param string $field_name | |
| 1668 | + * @param string|array $capability | |
| 1669 | + * @param string $multiple 'single' and 'multiple'. | |
| 1607 | 1670 | */ |
| 1608 | 1671 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 1609 | 1672 | ?> |
| 1610 | 1673 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" |
| @@ -1617,9 +1680,9 @@ | ||
| 1617 | 1680 | |
| 1618 | 1681 | /** |
| 1619 | 1682 | * @since 4.07 |
| 1620 | 1683 | * @param array|string $selected |
| 1621 | - * @param string $current | |
| 1684 | + * @param string $current | |
| 1622 | 1685 | */ |
| 1623 | 1686 | private static function selected( $selected, $current ) { |
| 1624 | 1687 | if ( is_callable( 'FrmProAppHelper::selected' ) ) { |
| 1625 | 1688 | FrmProAppHelper::selected( $selected, $current ); |
| @@ -1665,9 +1728,8 @@ | ||
| 1665 | 1728 | $pro_cap = array( |
| 1666 | 1729 | 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ), |
| 1667 | 1730 | 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ), |
| 1668 | 1731 | 'frm_view_reports' => __( 'View Reports', 'formidable' ), |
| 1669 | - 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ), | |
| 1670 | 1732 | ); |
| 1671 | 1733 | /** |
| 1672 | 1734 | * @since 5.3.1 |
| 1673 | 1735 | * |
| @@ -1674,8 +1736,14 @@ | ||
| 1674 | 1736 | * @param array<string,string> $pro_cap |
| 1675 | 1737 | */ |
| 1676 | 1738 | $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap ); |
| 1677 | 1739 | |
| 1740 | + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) { | |
| 1741 | + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date. | |
| 1742 | + // This was added in 6.5.4. Remove this in the future. | |
| 1743 | + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); | |
| 1744 | + } | |
| 1745 | + | |
| 1678 | 1746 | if ( 'pro_only' === $type ) { |
| 1679 | 1747 | return $pro_cap; |
| 1680 | 1748 | } |
| 1681 | 1749 | |
| @@ -1690,9 +1758,9 @@ | ||
| 1690 | 1758 | * @return array<string,string> |
| 1691 | 1759 | */ |
| 1692 | 1760 | private static function get_lite_capabilities() { |
| 1693 | 1761 | return array( |
| 1694 | - 'frm_view_forms' => __( 'View Forms', 'formidable' ), | |
| 1762 | + 'frm_view_forms' => __( 'View Forms List', 'formidable' ), | |
| 1695 | 1763 | 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ), |
| 1696 | 1764 | 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ), |
| 1697 | 1765 | 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
| 1698 | 1766 | 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
| @@ -2069,9 +2137,9 @@ | ||
| 2069 | 2137 | ++$suffix; |
| 2070 | 2138 | } while ( in_array( $key_check, $similar_keys, true ) ); |
| 2071 | 2139 | |
| 2072 | 2140 | $key = $key_check; |
| 2073 | - } | |
| 2141 | + }//end if | |
| 2074 | 2142 | |
| 2075 | 2143 | return $key; |
| 2076 | 2144 | } |
| 2077 | 2145 | |
| @@ -2115,9 +2183,11 @@ | ||
| 2115 | 2183 | * @return string |
| 2116 | 2184 | */ |
| 2117 | 2185 | private static function generate_new_key( $num_chars ) { |
| 2118 | 2186 | $max_slug_value = pow( 36, $num_chars ); |
| 2119 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 2187 | + | |
| 2188 | + // We want to have at least 2 characters in the slug. | |
| 2189 | + $min_slug_value = 37; | |
| 2120 | 2190 | return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 2121 | 2191 | } |
| 2122 | 2192 | |
| 2123 | 2193 | /** |
| @@ -2146,9 +2216,14 @@ | ||
| 2146 | 2216 | |
| 2147 | 2217 | /** |
| 2148 | 2218 | * Editing a Form or Entry |
| 2149 | 2219 | * |
| 2150 | - * @param string $table | |
| 2220 | + * @param object $record | |
| 2221 | + * @param string $table | |
| 2222 | + * @param array|string $fields | |
| 2223 | + * @param bool $default | |
| 2224 | + * @param array $post_values | |
| 2225 | + * @param array $args | |
| 2151 | 2226 | * |
| 2152 | 2227 | * @return bool|array |
| 2153 | 2228 | */ |
| 2154 | 2229 | public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
| @@ -2222,9 +2297,9 @@ | ||
| 2222 | 2297 | ); |
| 2223 | 2298 | } else { |
| 2224 | 2299 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 2225 | 2300 | } |
| 2226 | - } | |
| 2301 | + }//end if | |
| 2227 | 2302 | |
| 2228 | 2303 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 2229 | 2304 | if ( isset( $post_values['item_meta'][ $field->id ] ) ) { |
| 2230 | 2305 | $new_value = $post_values['item_meta'][ $field->id ]; |
| @@ -2272,9 +2347,12 @@ | ||
| 2272 | 2347 | ); |
| 2273 | 2348 | } |
| 2274 | 2349 | |
| 2275 | 2350 | /** |
| 2351 | + * @param object $record | |
| 2276 | 2352 | * @param string $table |
| 2353 | + * @param array $post_values | |
| 2354 | + * @param array $values | |
| 2277 | 2355 | */ |
| 2278 | 2356 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 2279 | 2357 | if ( $table == 'entries' ) { |
| 2280 | 2358 | $form = $record->form_id; |
| @@ -2388,11 +2466,37 @@ | ||
| 2388 | 2466 | |
| 2389 | 2467 | unset( $total_len, $word ); |
| 2390 | 2468 | } |
| 2391 | 2469 | |
| 2470 | + $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length ); | |
| 2471 | + | |
| 2392 | 2472 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 2393 | 2473 | } |
| 2394 | 2474 | |
| 2475 | + /** | |
| 2476 | + * If the string is still too long because there may not have been any spaces, force truncate. | |
| 2477 | + * | |
| 2478 | + * @since 6.5.4 | |
| 2479 | + * | |
| 2480 | + * @param string $sub Current substring. | |
| 2481 | + * @param int $length The length limit. | |
| 2482 | + * @return string | |
| 2483 | + */ | |
| 2484 | + private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) { | |
| 2485 | + if ( strlen( $sub ) < $length + 50 ) { | |
| 2486 | + // If the string isn't way over the limit, leave it. | |
| 2487 | + return $sub; | |
| 2488 | + } | |
| 2489 | + | |
| 2490 | + $first_space = strpos( $sub, ' ', $length ); | |
| 2491 | + if ( false !== $first_space ) { | |
| 2492 | + // Ignore anything with spaces. | |
| 2493 | + return $sub; | |
| 2494 | + } | |
| 2495 | + | |
| 2496 | + return substr( $sub, 0, $length + 10 ); | |
| 2497 | + } | |
| 2498 | + | |
| 2395 | 2499 | public static function mb_function( $function_names, $args ) { |
| 2396 | 2500 | $mb_function_name = $function_names[0]; |
| 2397 | 2501 | $function_name = $function_names[1]; |
| 2398 | 2502 | if ( function_exists( $mb_function_name ) ) { |
| @@ -2449,12 +2553,12 @@ | ||
| 2449 | 2553 | return date_i18n( $date_format, strtotime( $date ) ); |
| 2450 | 2554 | } |
| 2451 | 2555 | |
| 2452 | 2556 | /** |
| 2453 | - * Gets the time ago in words | |
| 2557 | + * Gets the time ago in words. | |
| 2454 | 2558 | * |
| 2455 | - * @param int $from in seconds | |
| 2456 | - * @param int|string $to in seconds | |
| 2559 | + * @param int $from In seconds. | |
| 2560 | + * @param int|string $to In seconds. | |
| 2457 | 2561 | * |
| 2458 | 2562 | * @return string $time_ago |
| 2459 | 2563 | */ |
| 2460 | 2564 | public static function human_time_diff( $from, $to = '', $levels = 1 ) { |
| @@ -2617,9 +2721,12 @@ | ||
| 2617 | 2721 | |
| 2618 | 2722 | // Pagination Methods. |
| 2619 | 2723 | |
| 2620 | 2724 | /** |
| 2725 | + * @param integer $r_count | |
| 2621 | 2726 | * @param integer $current_p |
| 2727 | + * @param integer $p_size | |
| 2728 | + * @return int | |
| 2622 | 2729 | */ |
| 2623 | 2730 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 2624 | 2731 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 2625 | 2732 | } |
| @@ -2624,9 +2731,12 @@ | ||
| 2624 | 2731 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 2625 | 2732 | } |
| 2626 | 2733 | |
| 2627 | 2734 | /** |
| 2735 | + * @param integer $r_count | |
| 2628 | 2736 | * @param integer $current_p |
| 2737 | + * @param integer $p_size | |
| 2738 | + * @return int | |
| 2629 | 2739 | */ |
| 2630 | 2740 | public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
| 2631 | 2741 | if ( $current_p == 1 ) { |
| 2632 | 2742 | return 1; |
| @@ -2680,12 +2790,12 @@ | ||
| 2680 | 2790 | self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
| 2681 | 2791 | } |
| 2682 | 2792 | |
| 2683 | 2793 | unset( $this_val, $n ); |
| 2684 | - } | |
| 2794 | + }//end foreach | |
| 2685 | 2795 | |
| 2686 | 2796 | unset( $last, $jv ); |
| 2687 | - } | |
| 2797 | + }//end foreach | |
| 2688 | 2798 | |
| 2689 | 2799 | return $vars; |
| 2690 | 2800 | } |
| 2691 | 2801 | |
| @@ -2942,12 +3052,14 @@ | ||
| 2942 | 3052 | return $value; |
| 2943 | 3053 | } |
| 2944 | 3054 | |
| 2945 | 3055 | /** |
| 3056 | + * Echo The javascript to open and highlight the Formidable menu | |
| 3057 | + * | |
| 2946 | 3058 | * @since 1.07.10 |
| 2947 | 3059 | * |
| 2948 | - * @param string $post_type The name of the post type that may need to be highlighted | |
| 2949 | - * echo The javascript to open and highlight the Formidable menu | |
| 3060 | + * @param string $post_type The name of the post type that may need to be highlighted. | |
| 3061 | + * @return void | |
| 2950 | 3062 | */ |
| 2951 | 3063 | public static function maybe_highlight_menu( $post_type ) { |
| 2952 | 3064 | global $post; |
| 2953 | 3065 | |
| @@ -3070,13 +3182,22 @@ | ||
| 3070 | 3182 | 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ), |
| 3071 | 3183 | 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ), |
| 3072 | 3184 | 'install' => __( 'Install', 'formidable' ), |
| 3073 | 3185 | 'active' => __( 'Active', 'formidable' ), |
| 3186 | + 'installed' => __( 'Installed', 'formidable' ), | |
| 3187 | + 'not_installed' => __( 'Not Installed', 'formidable' ), | |
| 3074 | 3188 | 'select_a_field' => __( 'Select a Field', 'formidable' ), |
| 3075 | 3189 | 'no_items_found' => __( 'No items found.', 'formidable' ), |
| 3076 | 3190 | 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ), |
| 3077 | - 'saving' => '', // Deprecated in 6.0. | |
| 3078 | - 'saved' => '', // Deprecated in 6.0. | |
| 3191 | + | |
| 3192 | + // Deprecated in 6.0. | |
| 3193 | + 'saving' => '', | |
| 3194 | + | |
| 3195 | + // Deprecated in 6.0. | |
| 3196 | + 'saved' => '', | |
| 3197 | + | |
| 3198 | + // translators: %1$s: HTML open tag, %2$s: HTML end tag. | |
| 3199 | + 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ), | |
| 3079 | 3200 | ); |
| 3080 | 3201 | /** |
| 3081 | 3202 | * @param array $admin_script_strings |
| 3082 | 3203 | */ |
| @@ -3085,9 +3206,9 @@ | ||
| 3085 | 3206 | $data = $wp_scripts->get_data( 'formidable_admin', 'data' ); |
| 3086 | 3207 | if ( ! $data ) { |
| 3087 | 3208 | wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings ); |
| 3088 | 3209 | } |
| 3089 | - } | |
| 3210 | + }//end if | |
| 3090 | 3211 | } |
| 3091 | 3212 | |
| 3092 | 3213 | /** |
| 3093 | 3214 | * @since 6.5 |
| @@ -3131,9 +3252,9 @@ | ||
| 3131 | 3252 | * Echo the message on the plugins listing page |
| 3132 | 3253 | * |
| 3133 | 3254 | * @since 1.07.10 |
| 3134 | 3255 | * |
| 3135 | - * @param float $min_version The version the add-on requires | |
| 3256 | + * @param float $min_version The version the add-on requires. | |
| 3136 | 3257 | */ |
| 3137 | 3258 | public static function min_version_notice( $min_version ) { |
| 3138 | 3259 | $frm_version = self::plugin_version(); |
| 3139 | 3260 | |
| @@ -3459,8 +3580,18 @@ | ||
| 3459 | 3580 | return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args ); |
| 3460 | 3581 | } |
| 3461 | 3582 | |
| 3462 | 3583 | /** |
| 3584 | + * @since 6.7.1 | |
| 3585 | + */ | |
| 3586 | + public static function get_images_dropdown_atts( $option, $args ) { | |
| 3587 | + $image = self::get_images_dropdown_option_image( $option, $args ); | |
| 3588 | + $classes = self::get_images_dropdown_option_classes( $option, $args ); | |
| 3589 | + $custom_attrs = self::get_images_dropdown_option_html_attrs( $option, $args ); | |
| 3590 | + return compact( 'image', 'classes', 'custom_attrs' ); | |
| 3591 | + } | |
| 3592 | + | |
| 3593 | + /** | |
| 3463 | 3594 | * Gets the image of each option in images_dropdown() method. |
| 3464 | 3595 | * |
| 3465 | 3596 | * @since 5.0.04 |
| 3466 | 3597 | * |
| @@ -3617,9 +3748,9 @@ | ||
| 3617 | 3748 | * |
| 3618 | 3749 | * @since 5.0.13 |
| 3619 | 3750 | * |
| 3620 | 3751 | * @param string $value |
| 3621 | - * @param array|string $allowed 'all' for everything included as defaults | |
| 3752 | + * @param array|string $allowed 'all' for everything included as defaults. | |
| 3622 | 3753 | * @return string |
| 3623 | 3754 | */ |
| 3624 | 3755 | public static function maybe_kses( $value, $allowed = 'all' ) { |
| 3625 | 3756 | if ( self::should_never_allow_unfiltered_html() ) { |
| @@ -3665,9 +3796,9 @@ | ||
| 3665 | 3796 | |
| 3666 | 3797 | /** |
| 3667 | 3798 | * @since 5.0.17 |
| 3668 | 3799 | * |
| 3669 | - * @param string | |
| 3800 | + * @param string $feature | |
| 3670 | 3801 | * @return bool |
| 3671 | 3802 | */ |
| 3672 | 3803 | public static function show_new_feature( $feature ) { |
| 3673 | 3804 | $link = FrmAddonsController::install_link( $feature ); |
| @@ -3740,9 +3871,9 @@ | ||
| 3740 | 3871 | public static function show_pill_text( $text = null ) { |
| 3741 | 3872 | if ( null === $text ) { |
| 3742 | 3873 | $text = __( 'NEW', 'formidable' ); |
| 3743 | 3874 | } |
| 3744 | - echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>'; | |
| 3875 | + echo '<span class="frm-meta-tag frm-new-pill">' . esc_html( $text ) . '</span>'; | |
| 3745 | 3876 | } |
| 3746 | 3877 | |
| 3747 | 3878 | /** |
| 3748 | 3879 | * Count the number of decimals digits. |
| @@ -3984,6 +4115,28 @@ | ||
| 3984 | 4115 | update_option( $option, true, 'no' ); |
| 3985 | 4116 | } |
| 3986 | 4117 | |
| 3987 | 4118 | wp_send_json_success(); |
| 4119 | + } | |
| 4120 | + | |
| 4121 | + /** | |
| 4122 | + * Lite license copy. | |
| 4123 | + * Used in FrmDashboardController & FrmSettingsController | |
| 4124 | + * | |
| 4125 | + * @since 6.8 | |
| 4126 | + * | |
| 4127 | + * @return string | |
| 4128 | + */ | |
| 4129 | + public static function copy_for_lite_license() { | |
| 4130 | + $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂'; | |
| 4131 | + | |
| 4132 | + if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) { | |
| 4133 | + // Manage PRO versions without PRO dashboard functionality. | |
| 4134 | + $license_type = FrmProAddonsController::get_readable_license_type(); | |
| 4135 | + if ( 'lite' !== strtolower( $license_type ) ) { | |
| 4136 | + $message = 'Formidable Pro ' . $license_type; | |
| 4137 | + } | |
| 4138 | + } | |
| 4139 | + | |
| 4140 | + return apply_filters( 'frm_license_type_text', $message ); | |
| 3988 | 4141 | } |
| 3989 | 4142 | } |