| @@ -3,19 +3,23 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmAppHelper { |
| 7 | - | |
| 8 | 7 | /** |
| 9 | 8 | * Version of the database we are moving to. |
| 10 | 9 | * |
| 11 | 10 | * @var int |
| 12 | 11 | */ |
| 13 | - public static $db_version = 104; | |
| 12 | + public static $db_version = 101; | |
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | - * Used by the API add-on. | |
| 15 | + * Deprecated. | |
| 17 | 16 | * |
| 17 | + * @var int | |
| 18 | + */ | |
| 19 | + public static $pro_db_version = 37; | |
| 20 | + | |
| 21 | + /** | |
| 18 | 22 | * @var float |
| 19 | 23 | */ |
| 20 | 24 | public static $font_version = 7; |
| 21 | 25 | |
| @@ -28,9 +32,9 @@ | ||
| 28 | 32 | * @since 2.0 |
| 29 | 33 | * |
| 30 | 34 | * @var string |
| 31 | 35 | */ |
| 32 | - public static $plug_version = '6.26'; | |
| 36 | + public static $plug_version = '6.16.1'; | |
| 33 | 37 | |
| 34 | 38 | /** |
| 35 | 39 | * @var bool |
| 36 | 40 | */ |
| @@ -55,9 +59,9 @@ | ||
| 55 | 59 | /** |
| 56 | 60 | * @return string |
| 57 | 61 | */ |
| 58 | 62 | public static function plugin_path() { |
| 59 | - return dirname( __DIR__, 2 ); | |
| 63 | + return dirname( dirname( __DIR__ ) ); | |
| 60 | 64 | } |
| 61 | 65 | |
| 62 | 66 | /** |
| 63 | 67 | * @return string |
| @@ -85,9 +89,8 @@ | ||
| 85 | 89 | * Get the name of this site |
| 86 | 90 | * Used for [sitename] shortcode |
| 87 | 91 | * |
| 88 | 92 | * @since 2.0 |
| 89 | - * | |
| 90 | 93 | * @return string |
| 91 | 94 | */ |
| 92 | 95 | public static function site_name() { |
| 93 | 96 | return get_option( 'blogname' ); |
| @@ -94,14 +97,12 @@ | ||
| 94 | 97 | } |
| 95 | 98 | |
| 96 | 99 | /** |
| 97 | 100 | * @param string $url |
| 98 | - * | |
| 99 | 101 | * @return string |
| 100 | 102 | */ |
| 101 | 103 | public static function make_affiliate_url( $url ) { |
| 102 | 104 | $affiliate_id = self::get_affiliate(); |
| 103 | - | |
| 104 | 105 | if ( ! empty( $affiliate_id ) ) { |
| 105 | 106 | $url = str_replace( array( 'http://', 'https://' ), '', $url ); |
| 106 | 107 | $url = 'http://www.shareasale.com/r.cfm?u=' . absint( $affiliate_id ) . '&b=841990&m=64739&afftrack=plugin&urllink=' . urlencode( $url ); |
| 107 | 108 | } |
| @@ -117,178 +118,64 @@ | ||
| 117 | 118 | } |
| 118 | 119 | |
| 119 | 120 | /** |
| 120 | 121 | * @since 3.04.02 |
| 121 | - * | |
| 122 | - * @param array|string $args If a string is passed, it is used for the utm_campaign attribute. | |
| 122 | + * @param array|string $args | |
| 123 | 123 | * @param string $page |
| 124 | 124 | */ |
| 125 | 125 | public static function admin_upgrade_link( $args, $page = '' ) { |
| 126 | - if ( $page ) { | |
| 126 | + if ( empty( $page ) ) { | |
| 127 | + $page = 'https://formidableforms.com/lite-upgrade/'; | |
| 128 | + } else { | |
| 127 | 129 | $page = str_replace( 'https://formidableforms.com/', '', $page ); |
| 128 | 130 | $page = 'https://formidableforms.com/' . $page; |
| 129 | - } else { | |
| 130 | - $page = 'https://formidableforms.com/lite-upgrade/'; | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | + $anchor = ''; | |
| 133 | 134 | if ( is_array( $args ) ) { |
| 134 | - $args = self::adjust_legacy_utm_args( $args ); | |
| 135 | + $medium = $args['medium']; | |
| 136 | + if ( isset( $args['content'] ) ) { | |
| 137 | + $content = $args['content']; | |
| 138 | + } | |
| 139 | + if ( isset( $args['anchor'] ) ) { | |
| 140 | + $anchor = '#' . $args['anchor']; | |
| 141 | + } | |
| 135 | 142 | } else { |
| 136 | - $args = array( 'campaign' => $args ); | |
| 143 | + $medium = $args; | |
| 137 | 144 | } |
| 138 | 145 | |
| 139 | 146 | $query_args = array( |
| 140 | - 'utm_source' => 'plugin', | |
| 141 | - 'utm_medium' => self::get_utm_medium(), | |
| 147 | + 'utm_source' => 'WordPress', | |
| 148 | + 'utm_medium' => $medium, | |
| 149 | + 'utm_campaign' => 'liteplugin', | |
| 142 | 150 | ); |
| 143 | - $query_args = self::maybe_add_utm_license( $query_args ); | |
| 144 | 151 | |
| 145 | - if ( isset( $args['campaign'] ) ) { | |
| 146 | - $query_args['utm_campaign'] = $args['campaign']; | |
| 152 | + if ( isset( $content ) ) { | |
| 153 | + $query_args['utm_content'] = $content; | |
| 147 | 154 | } |
| 148 | 155 | |
| 149 | - if ( isset( $args['content'] ) ) { | |
| 150 | - $query_args['utm_content'] = $args['content']; | |
| 151 | - } | |
| 152 | - | |
| 153 | - if ( isset( $args['param'] ) ) { | |
| 156 | + if ( is_array( $args ) && isset( $args['param'] ) ) { | |
| 154 | 157 | $query_args['f'] = $args['param']; |
| 155 | 158 | } |
| 156 | 159 | |
| 157 | - if ( ! empty( $args['plan'] ) ) { | |
| 160 | + if ( is_array( $args ) && ! empty( $args['plan'] ) ) { | |
| 158 | 161 | $query_args['plan'] = $args['plan']; |
| 159 | 162 | } |
| 160 | 163 | |
| 161 | - $link = add_query_arg( $query_args, $page ); | |
| 162 | - | |
| 163 | - if ( isset( $args['anchor'] ) ) { | |
| 164 | - $link .= '#' . $args['anchor']; | |
| 165 | - } | |
| 166 | - | |
| 164 | + $link = add_query_arg( $query_args, $page ) . $anchor; | |
| 167 | 165 | return self::make_affiliate_url( $link ); |
| 168 | 166 | } |
| 169 | 167 | |
| 170 | 168 | /** |
| 171 | - * If medium is "pro", add an additional utm_license param with their active license type. | |
| 172 | - * | |
| 173 | - * @since 6.25.1 | |
| 174 | - * | |
| 175 | - * @param array $query_args | |
| 176 | - * @param string $link | |
| 177 | - * | |
| 178 | - * @return array | |
| 179 | - */ | |
| 180 | - private static function maybe_add_utm_license( $query_args, $link = '' ) { | |
| 181 | - if ( isset( $query_args['utm_medium'] ) ) { | |
| 182 | - $medium = $query_args['utm_medium']; | |
| 183 | - } else { | |
| 184 | - $medium = self::pull_medium_from_link( $link ); | |
| 185 | - } | |
| 186 | - | |
| 187 | - if ( 'pro' === $medium && is_callable( 'FrmProAddonsController::get_readable_license_type' ) ) { | |
| 188 | - $query_args['utm_license'] = strtolower( FrmProAddonsController::get_readable_license_type() ); | |
| 189 | - } | |
| 190 | - | |
| 191 | - return $query_args; | |
| 192 | - } | |
| 193 | - | |
| 194 | - /** | |
| 195 | - * @since 6.26 | |
| 196 | - * | |
| 197 | - * @param string $link | |
| 198 | - * | |
| 199 | - * @return string | |
| 200 | - */ | |
| 201 | - private static function pull_medium_from_link( $link ) { | |
| 202 | - if ( ! $link ) { | |
| 203 | - return ''; | |
| 204 | - } | |
| 205 | - | |
| 206 | - $parsed = parse_url( $link ); | |
| 207 | - | |
| 208 | - if ( ! is_array( $parsed ) || ! isset( $parsed['query'] ) ) { | |
| 209 | - return ''; | |
| 210 | - } | |
| 211 | - | |
| 212 | - $query_args = wp_parse_args( $parsed['query'] ); | |
| 213 | - | |
| 214 | - if ( empty( $query_args['utm_medium'] ) ) { | |
| 215 | - return ''; | |
| 216 | - } | |
| 217 | - | |
| 218 | - return $query_args['utm_medium']; | |
| 219 | - } | |
| 220 | - | |
| 221 | - /** | |
| 222 | - * @since 6.25.1 | |
| 223 | - * | |
| 224 | - * @return string | |
| 225 | - */ | |
| 226 | - private static function get_utm_medium() { | |
| 227 | - return self::pro_is_connected() ? 'pro' : 'lite'; | |
| 228 | - } | |
| 229 | - | |
| 230 | - /** | |
| 231 | - * Change campaign from "liteplugin" to what we're currently using for medium. | |
| 232 | - * | |
| 233 | - * @since 6.25.1 | |
| 234 | - * | |
| 235 | - * @param array $args | |
| 236 | - * | |
| 237 | - * @return array | |
| 238 | - */ | |
| 239 | - private static function adjust_legacy_utm_args( $args ) { | |
| 240 | - if ( isset( $args['medium'] ) ) { | |
| 241 | - $args['campaign'] = $args['medium']; | |
| 242 | - unset( $args['medium'] ); | |
| 243 | - } | |
| 244 | - | |
| 245 | - return $args; | |
| 246 | - } | |
| 247 | - | |
| 248 | - /** | |
| 249 | - * @since 6.21 | |
| 250 | - * | |
| 251 | - * @param string $cta_link | |
| 252 | - * @param array $utm | |
| 253 | - */ | |
| 254 | - public static function maybe_add_missing_utm( $cta_link, $utm ) { | |
| 255 | - $utm = self::adjust_legacy_utm_args( $utm ); | |
| 256 | - $query_args = array(); | |
| 257 | - | |
| 258 | - if ( false === strpos( $cta_link, 'utm_source' ) ) { | |
| 259 | - $query_args['utm_source'] = 'plugin'; | |
| 260 | - } | |
| 261 | - | |
| 262 | - if ( false === strpos( $cta_link, 'utm_medium' ) ) { | |
| 263 | - $query_args['utm_medium'] = self::get_utm_medium(); | |
| 264 | - } | |
| 265 | - | |
| 266 | - if ( false === strpos( $cta_link, 'utm_campaign' ) && isset( $utm['campaign'] ) ) { | |
| 267 | - $query_args['utm_campaign'] = $utm['campaign']; | |
| 268 | - } | |
| 269 | - | |
| 270 | - if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) { | |
| 271 | - $query_args['utm_content'] = $utm['content']; | |
| 272 | - } | |
| 273 | - | |
| 274 | - $query_args = self::maybe_add_utm_license( $query_args, $cta_link ); | |
| 275 | - | |
| 276 | - return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link; | |
| 277 | - } | |
| 278 | - | |
| 279 | - /** | |
| 280 | 169 | * Get the Formidable settings |
| 281 | 170 | * |
| 282 | 171 | * @since 2.0 |
| 283 | 172 | * |
| 284 | 173 | * @param array $args - May include the form id when values need translation. |
| 285 | - * | |
| 286 | 174 | * @return FrmSettings $frm_settings |
| 287 | 175 | */ |
| 288 | 176 | public static function get_settings( $args = array() ) { |
| 289 | 177 | global $frm_settings; |
| 290 | - | |
| 291 | 178 | if ( empty( $frm_settings ) ) { |
| 292 | 179 | $frm_settings = new FrmSettings( $args ); |
| 293 | 180 | } elseif ( isset( $args['current_form'] ) ) { |
| 294 | 181 | // If the global has already been set, allow strings to be filtered. |
| @@ -303,9 +190,9 @@ | ||
| 303 | 190 | */ |
| 304 | 191 | public static function get_menu_name() { |
| 305 | 192 | $frm_settings = self::get_settings(); |
| 306 | 193 | |
| 307 | - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu; | |
| 194 | + return FrmAddonsController::is_license_expired() ? 'Formidable' : $frm_settings->menu; | |
| 308 | 195 | } |
| 309 | 196 | |
| 310 | 197 | /** |
| 311 | 198 | * Determine if the current branding is set to 'formidable'. |
| @@ -327,9 +214,8 @@ | ||
| 327 | 214 | /** |
| 328 | 215 | * @since 3.05 |
| 329 | 216 | * |
| 330 | 217 | * @param array $atts |
| 331 | - * | |
| 332 | 218 | * @return string |
| 333 | 219 | */ |
| 334 | 220 | public static function svg_logo( $atts = array() ) { |
| 335 | 221 | $defaults = array( |
| @@ -349,9 +235,8 @@ | ||
| 349 | 235 | /** |
| 350 | 236 | * @since 4.0 |
| 351 | 237 | * |
| 352 | 238 | * @param array $atts |
| 353 | - * | |
| 354 | 239 | * @return void |
| 355 | 240 | */ |
| 356 | 241 | public static function show_logo( $atts = array() ) { |
| 357 | 242 | echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| @@ -370,9 +255,8 @@ | ||
| 370 | 255 | ) |
| 371 | 256 | ); |
| 372 | 257 | |
| 373 | 258 | $new_icon = apply_filters( 'frm_icon', $icon, true ); |
| 374 | - | |
| 375 | 259 | if ( $new_icon !== $icon ) { |
| 376 | 260 | if ( strpos( $new_icon, '<svg' ) === 0 ) { |
| 377 | 261 | $icon = str_replace( 'viewBox="0 0 20', 'width="30" height="35" style="color:#929699" viewBox="0 0 20', $new_icon ); |
| 378 | 262 | } else { |
| @@ -422,22 +306,14 @@ | ||
| 422 | 306 | } |
| 423 | 307 | |
| 424 | 308 | /** |
| 425 | 309 | * @since 4.06 |
| 426 | - * @since 6.16.2 Added $check_for_settings parameter | |
| 427 | 310 | * |
| 428 | - * @param bool $check_for_settings | |
| 429 | - * | |
| 430 | 311 | * @return bool |
| 431 | 312 | */ |
| 432 | - public static function is_form_builder_page( $check_for_settings = true ) { | |
| 433 | - $action = self::simple_get( 'frm_action', 'sanitize_title' ); | |
| 434 | - $check_actions = array( 'edit', 'duplicate' ); | |
| 435 | - | |
| 436 | - if ( $check_for_settings ) { | |
| 437 | - $check_actions[] = 'settings'; | |
| 438 | - } | |
| 439 | - return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true ); | |
| 313 | + public static function is_form_builder_page() { | |
| 314 | + $action = self::simple_get( 'frm_action', 'sanitize_title' ); | |
| 315 | + return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' ); | |
| 440 | 316 | } |
| 441 | 317 | |
| 442 | 318 | /** |
| 443 | 319 | * @return bool |
| @@ -444,9 +320,8 @@ | ||
| 444 | 320 | */ |
| 445 | 321 | public static function is_formidable_admin() { |
| 446 | 322 | $page = self::simple_get( 'page', 'sanitize_title' ); |
| 447 | 323 | $is_formidable = strpos( $page, 'formidable' ) !== false; |
| 448 | - | |
| 449 | 324 | if ( empty( $page ) ) { |
| 450 | 325 | $is_formidable = self::is_view_builder_page(); |
| 451 | 326 | } |
| 452 | 327 | |
| @@ -453,47 +328,8 @@ | ||
| 453 | 328 | return $is_formidable; |
| 454 | 329 | } |
| 455 | 330 | |
| 456 | 331 | /** |
| 457 | - * Checks if is a list page. | |
| 458 | - * | |
| 459 | - * @since 6.19 | |
| 460 | - * | |
| 461 | - * @param string $page The name of the page to check. | |
| 462 | - * | |
| 463 | - * @return bool | |
| 464 | - */ | |
| 465 | - public static function is_admin_list_page( $page = 'formidable' ) { | |
| 466 | - if ( 'formidable' === $page ) { | |
| 467 | - return self::on_form_listing_page(); | |
| 468 | - } | |
| 469 | - | |
| 470 | - if ( ! self::is_admin_page( $page ) ) { | |
| 471 | - return false; | |
| 472 | - } | |
| 473 | - | |
| 474 | - if ( 'formidable-entries' === $page ) { | |
| 475 | - $action = self::simple_get( 'frm_action' ); | |
| 476 | - | |
| 477 | - if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) { | |
| 478 | - return true; | |
| 479 | - } | |
| 480 | - } | |
| 481 | - | |
| 482 | - // Check edit or settings page. | |
| 483 | - return ! self::simple_get( 'frm_action' ); | |
| 484 | - } | |
| 485 | - | |
| 486 | - /** | |
| 487 | - * @since 6.20 | |
| 488 | - * | |
| 489 | - * @return array<string> | |
| 490 | - */ | |
| 491 | - private static function get_entries_listing_page_form_actions() { | |
| 492 | - return array( 'list', 'destroy' ); | |
| 493 | - } | |
| 494 | - | |
| 495 | - /** | |
| 496 | 332 | * Check for certain page in Formidable settings |
| 497 | 333 | * |
| 498 | 334 | * @since 2.0 |
| 499 | 335 | * |
| @@ -503,13 +339,11 @@ | ||
| 503 | 339 | */ |
| 504 | 340 | public static function is_admin_page( $page = 'formidable' ) { |
| 505 | 341 | global $pagenow; |
| 506 | 342 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 507 | - | |
| 508 | 343 | if ( $pagenow ) { |
| 509 | 344 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 510 | 345 | $is_page = ( $pagenow === 'admin.php' || $pagenow === 'admin-ajax.php' ) && $get_page === $page; |
| 511 | - | |
| 512 | 346 | if ( $is_page ) { |
| 513 | 347 | return true; |
| 514 | 348 | } |
| 515 | 349 | } |
| @@ -576,9 +410,8 @@ | ||
| 576 | 410 | } |
| 577 | 411 | |
| 578 | 412 | /** |
| 579 | 413 | * @since 2.0.8 |
| 580 | - * | |
| 581 | 414 | * @return bool |
| 582 | 415 | */ |
| 583 | 416 | public static function prevent_caching() { |
| 584 | 417 | global $frm_vars; |
| @@ -596,9 +429,8 @@ | ||
| 596 | 429 | $is_admin = is_admin() && ! wp_doing_ajax(); |
| 597 | 430 | |
| 598 | 431 | /** |
| 599 | 432 | * @since 6.0 |
| 600 | - * | |
| 601 | 433 | * @param bool $is_admin |
| 602 | 434 | */ |
| 603 | 435 | return apply_filters( 'frm_is_admin', $is_admin ); |
| 604 | 436 | } |
| @@ -619,9 +451,8 @@ | ||
| 619 | 451 | |
| 620 | 452 | /** |
| 621 | 453 | * @param mixed $value |
| 622 | 454 | * @param string $empty |
| 623 | - * | |
| 624 | 455 | * @return bool |
| 625 | 456 | */ |
| 626 | 457 | public static function is_not_empty_value( $value, $empty = '' ) { |
| 627 | 458 | return ! self::is_empty_value( $value, $empty ); |
| @@ -675,9 +506,8 @@ | ||
| 675 | 506 | continue; |
| 676 | 507 | } |
| 677 | 508 | |
| 678 | 509 | $key = self::get_server_value( $key ); |
| 679 | - | |
| 680 | 510 | foreach ( explode( ',', $key ) as $ip ) { |
| 681 | 511 | // Just to be safe. |
| 682 | 512 | $ip = trim( $ip ); |
| 683 | 513 | |
| @@ -733,16 +563,8 @@ | ||
| 733 | 563 | */ |
| 734 | 564 | return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip ); |
| 735 | 565 | } |
| 736 | 566 | |
| 737 | - /** | |
| 738 | - * @param string $param | |
| 739 | - * @param mixed $default | |
| 740 | - * @param string $src | |
| 741 | - * @param callable|string $sanitize | |
| 742 | - * | |
| 743 | - * @return mixed | |
| 744 | - */ | |
| 745 | 567 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 746 | 568 | if ( strpos( $param, '[' ) ) { |
| 747 | 569 | $params = explode( '[', $param ); |
| 748 | 570 | $param = $params[0]; |
| @@ -749,9 +571,8 @@ | ||
| 749 | 571 | } |
| 750 | 572 | |
| 751 | 573 | if ( $src === 'get' ) { |
| 752 | 574 | $value = isset( $_POST[ $param ] ) ? wp_unslash( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? wp_unslash( $_GET[ $param ] ) : $default ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 753 | - | |
| 754 | 575 | if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 755 | 576 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 756 | 577 | $value = htmlspecialchars_decode( wp_unslash( $_GET[ $param ] ) ); |
| 757 | 578 | } |
| @@ -773,9 +594,9 @@ | ||
| 773 | 594 | continue; |
| 774 | 595 | } |
| 775 | 596 | |
| 776 | 597 | $p = trim( $p, ']' ); |
| 777 | - $value = $value[ $p ] ?? $default; | |
| 598 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; | |
| 778 | 599 | } |
| 779 | 600 | } |
| 780 | 601 | |
| 781 | 602 | return $value; |
| @@ -787,9 +608,8 @@ | ||
| 787 | 608 | * @param string $param The key we are trying to access data from in $_POST. |
| 788 | 609 | * @param mixed $default The default if nothing is being sent. |
| 789 | 610 | * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default. |
| 790 | 611 | * @param bool $serialized |
| 791 | - * | |
| 792 | 612 | * @return mixed |
| 793 | 613 | */ |
| 794 | 614 | public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) { |
| 795 | 615 | return self::get_simple_request( |
| @@ -842,9 +662,8 @@ | ||
| 842 | 662 | ); |
| 843 | 663 | $args = wp_parse_args( $args, $defaults ); |
| 844 | 664 | |
| 845 | 665 | $value = $args['default']; |
| 846 | - | |
| 847 | 666 | if ( $args['type'] === 'get' ) { |
| 848 | 667 | if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
| 849 | 668 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 850 | 669 | $value = wp_unslash( $_GET[ $args['param'] ] ); |
| @@ -852,9 +671,8 @@ | ||
| 852 | 671 | } elseif ( $args['type'] === 'post' ) { |
| 853 | 672 | if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 854 | 673 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 855 | 674 | $value = wp_unslash( $_POST[ $args['param'] ] ); |
| 856 | - | |
| 857 | 675 | if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) { |
| 858 | 676 | self::unserialize_or_decode( $value ); |
| 859 | 677 | } |
| 860 | 678 | } |
| @@ -892,9 +710,8 @@ | ||
| 892 | 710 | * If $value is an array, the sanitize function will get called for each item. |
| 893 | 711 | * |
| 894 | 712 | * @param callable $sanitize |
| 895 | 713 | * @param mixed $value |
| 896 | - * | |
| 897 | 714 | * @return void |
| 898 | 715 | */ |
| 899 | 716 | public static function sanitize_value( $sanitize, &$value ) { |
| 900 | 717 | if ( ! $sanitize ) { |
| @@ -907,9 +724,8 @@ | ||
| 907 | 724 | } |
| 908 | 725 | |
| 909 | 726 | if ( is_array( $value ) ) { |
| 910 | 727 | $temp_values = $value; |
| 911 | - | |
| 912 | 728 | foreach ( $temp_values as $k => $v ) { |
| 913 | 729 | self::sanitize_value( $sanitize, $value[ $k ] ); |
| 914 | 730 | } |
| 915 | 731 | return; |
| @@ -917,17 +733,10 @@ | ||
| 917 | 733 | |
| 918 | 734 | $value = call_user_func( $sanitize, $value ); |
| 919 | 735 | } |
| 920 | 736 | |
| 921 | - /** | |
| 922 | - * @param array $sanitize_method | |
| 923 | - * @param array $values | |
| 924 | - * | |
| 925 | - * @return void | |
| 926 | - */ | |
| 927 | 737 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 928 | 738 | $temp_values = $values; |
| 929 | - | |
| 930 | 739 | foreach ( $temp_values as $k => $val ) { |
| 931 | 740 | if ( isset( $sanitize_method[ $k ] ) ) { |
| 932 | 741 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 933 | 742 | } |
| @@ -937,9 +746,8 @@ | ||
| 937 | 746 | /** |
| 938 | 747 | * @since 4.0.04 |
| 939 | 748 | * |
| 940 | 749 | * @param mixed $value |
| 941 | - * | |
| 942 | 750 | * @return void |
| 943 | 751 | */ |
| 944 | 752 | public static function sanitize_with_html( &$value ) { |
| 945 | 753 | if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) { |
| @@ -984,15 +792,12 @@ | ||
| 984 | 792 | * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&' |
| 985 | 793 | * this MUST be done, else we'll be back to the '& entity' problem. |
| 986 | 794 | * |
| 987 | 795 | * @since 4.0.04 |
| 988 | - * | |
| 989 | - * @param mixed $value Value to decode, passed by reference. | |
| 990 | 796 | */ |
| 991 | 797 | public static function decode_specialchars( &$value ) { |
| 992 | 798 | if ( is_array( $value ) ) { |
| 993 | 799 | $temp_values = $value; |
| 994 | - | |
| 995 | 800 | foreach ( $temp_values as $k => $v ) { |
| 996 | 801 | self::decode_specialchars( $value[ $k ] ); |
| 997 | 802 | } |
| 998 | 803 | } else { |
| @@ -1006,9 +811,9 @@ | ||
| 1006 | 811 | * Adapted from wp_specialchars_decode(). |
| 1007 | 812 | * |
| 1008 | 813 | * @since 4.03.01 |
| 1009 | 814 | * |
| 1010 | - * @param string $string The string to prep, passed by reference. | |
| 815 | + * @param string $string The string to prep. | |
| 1011 | 816 | */ |
| 1012 | 817 | private static function decode_amp( &$string ) { |
| 1013 | 818 | // Don't bother if there are no entities - saves a lot of processing |
| 1014 | 819 | if ( empty( $string ) || strpos( $string, '&' ) === false ) { |
| @@ -1050,10 +855,10 @@ | ||
| 1050 | 855 | * Sanitize the value, and allow some HTML |
| 1051 | 856 | * |
| 1052 | 857 | * @since 2.0 |
| 1053 | 858 | * |
| 1054 | - * @param string $value The value to sanitize. | |
| 1055 | - * @param array|string $allowed Allowed HTML tags and attributes, or 'all' for defaults. | |
| 859 | + * @param string $value | |
| 860 | + * @param array|string $allowed 'all' for everything included as defaults. | |
| 1056 | 861 | * |
| 1057 | 862 | * @return string |
| 1058 | 863 | */ |
| 1059 | 864 | public static function kses( $value, $allowed = array() ) { |
| @@ -1062,28 +867,13 @@ | ||
| 1062 | 867 | return wp_kses( $value, $allowed_html ); |
| 1063 | 868 | } |
| 1064 | 869 | |
| 1065 | 870 | /** |
| 1066 | - * Sanitizes and echoes a given value. | |
| 1067 | - * | |
| 1068 | - * @since 6.18 | |
| 1069 | - * | |
| 1070 | - * @param string $value The value to sanitize and output. | |
| 1071 | - * @param array|string $allowed Allowed HTML tags and attributes. | |
| 1072 | - * | |
| 1073 | - * @return void | |
| 1074 | - */ | |
| 1075 | - public static function kses_echo( $value, $allowed = array() ) { | |
| 1076 | - echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1077 | - } | |
| 1078 | - | |
| 1079 | - /** | |
| 1080 | 871 | * The regular kses function strips [button_action] from submit button HTML. |
| 1081 | 872 | * |
| 1082 | 873 | * @since 5.0.13 |
| 1083 | 874 | * |
| 1084 | 875 | * @param string $html |
| 1085 | - * | |
| 1086 | 876 | * @return string |
| 1087 | 877 | */ |
| 1088 | 878 | public static function kses_submit_button( $html ) { |
| 1089 | 879 | $included_button_action = false !== strpos( $html, '[button_action]' ); |
| @@ -1093,9 +883,8 @@ | ||
| 1093 | 883 | add_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' ); |
| 1094 | 884 | $html = self::kses( $html, 'all' ); |
| 1095 | 885 | remove_filter( 'safe_style_css', 'FrmAppHelper::allow_visibility_style' ); |
| 1096 | 886 | remove_filter( 'frm_striphtml_allowed_tags', 'FrmAppHelper::add_allowed_submit_button_tags' ); |
| 1097 | - | |
| 1098 | 887 | if ( $included_button_action ) { |
| 1099 | 888 | if ( false !== strpos( $html, '<input type="submit"' ) ) { |
| 1100 | 889 | $pattern = '/(<input type="submit")([^>]*)(\/>)/'; |
| 1101 | 890 | $html = preg_replace( $pattern, '$1$2[button_action] $3', $html, 1 ); |
| @@ -1103,13 +892,11 @@ | ||
| 1103 | 892 | $pattern = '/(<button)(.*)(class=")(.*)(frm_button_submit)(.*)(")(.*)([^>]+)(>)/'; |
| 1104 | 893 | $html = preg_replace( $pattern, '$1$2$3$4$5$6$7 [button_action]$8$9$10', $html, 1 ); |
| 1105 | 894 | } |
| 1106 | 895 | } |
| 1107 | - | |
| 1108 | 896 | if ( $included_back_hook ) { |
| 1109 | 897 | $html = str_replace( 'class="frm_prev_page"', 'class="frm_prev_page" [back_hook]', $html ); |
| 1110 | 898 | } |
| 1111 | - | |
| 1112 | 899 | if ( $included_draft_hook ) { |
| 1113 | 900 | $html = str_replace( 'class="frm_save_draft"', 'class="frm_save_draft" [draft_hook]', $html ); |
| 1114 | 901 | } |
| 1115 | 902 | return $html; |
| @@ -1118,9 +905,8 @@ | ||
| 1118 | 905 | /** |
| 1119 | 906 | * @since 5.0.13 |
| 1120 | 907 | * |
| 1121 | 908 | * @param array $allowed_attr |
| 1122 | - * | |
| 1123 | 909 | * @return array |
| 1124 | 910 | */ |
| 1125 | 911 | public static function allow_visibility_style( $allowed_attr ) { |
| 1126 | 912 | $allowed_attr[] = 'visibility'; |
| @@ -1130,9 +916,8 @@ | ||
| 1130 | 916 | /** |
| 1131 | 917 | * @since 5.0.13 |
| 1132 | 918 | * |
| 1133 | 919 | * @param array $allowed_html |
| 1134 | - * | |
| 1135 | 920 | * @return array |
| 1136 | 921 | */ |
| 1137 | 922 | public static function add_allowed_submit_button_tags( $allowed_html ) { |
| 1138 | 923 | $allowed_html['input'] = array( |
| @@ -1149,22 +934,17 @@ | ||
| 1149 | 934 | } |
| 1150 | 935 | |
| 1151 | 936 | /** |
| 1152 | 937 | * @since 2.05.03 |
| 1153 | - * | |
| 1154 | - * @param array|string $allowed | |
| 1155 | - * | |
| 1156 | - * @return array | |
| 1157 | 938 | */ |
| 1158 | 939 | private static function allowed_html( $allowed ) { |
| 1159 | 940 | $html = self::safe_html(); |
| 1160 | 941 | $allowed_html = array(); |
| 1161 | - | |
| 1162 | 942 | if ( $allowed === 'all' ) { |
| 1163 | 943 | $allowed_html = $html; |
| 1164 | 944 | } elseif ( ! empty( $allowed ) ) { |
| 1165 | 945 | foreach ( (array) $allowed as $a ) { |
| 1166 | - $allowed_html[ $a ] = $html[ $a ] ?? array(); | |
| 946 | + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); | |
| 1167 | 947 | } |
| 1168 | 948 | } |
| 1169 | 949 | |
| 1170 | 950 | return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html ); |
| @@ -1305,13 +1085,8 @@ | ||
| 1305 | 1085 | ), |
| 1306 | 1086 | 'legend' => array( |
| 1307 | 1087 | 'class' => true, |
| 1308 | 1088 | ), |
| 1309 | - 'option' => array( | |
| 1310 | - 'class' => true, | |
| 1311 | - 'value' => true, | |
| 1312 | - 'selected' => true, | |
| 1313 | - ), | |
| 1314 | 1089 | ); |
| 1315 | 1090 | } |
| 1316 | 1091 | |
| 1317 | 1092 | /** |
| @@ -1324,15 +1099,13 @@ | ||
| 1324 | 1099 | return; |
| 1325 | 1100 | } |
| 1326 | 1101 | |
| 1327 | 1102 | $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' ); |
| 1328 | - | |
| 1329 | 1103 | if ( empty( $action_name ) ) { |
| 1330 | 1104 | return; |
| 1331 | 1105 | } |
| 1332 | 1106 | |
| 1333 | 1107 | $new_action = self::get_param( $action_name, '', 'get', 'sanitize_text_field' ); |
| 1334 | - | |
| 1335 | 1108 | if ( ! empty( $new_action ) ) { |
| 1336 | 1109 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) ); |
| 1337 | 1110 | } |
| 1338 | 1111 | } |
| @@ -1340,12 +1113,8 @@ | ||
| 1340 | 1113 | /** |
| 1341 | 1114 | * Check the WP query for a parameter |
| 1342 | 1115 | * |
| 1343 | 1116 | * @since 2.0 |
| 1344 | - * | |
| 1345 | - * @param array|string $value | |
| 1346 | - * @param string $param | |
| 1347 | - * | |
| 1348 | 1117 | * @return array|string |
| 1349 | 1118 | */ |
| 1350 | 1119 | public static function get_query_var( $value, $param ) { |
| 1351 | 1120 | if ( $value != '' ) { |
| @@ -1352,9 +1121,8 @@ | ||
| 1352 | 1121 | return $value; |
| 1353 | 1122 | } |
| 1354 | 1123 | |
| 1355 | 1124 | global $wp_query; |
| 1356 | - | |
| 1357 | 1125 | if ( isset( $wp_query->query_vars[ $param ] ) ) { |
| 1358 | 1126 | $value = $wp_query->query_vars[ $param ]; |
| 1359 | 1127 | } |
| 1360 | 1128 | |
| @@ -1367,14 +1135,12 @@ | ||
| 1367 | 1135 | * @since 4.0.02 |
| 1368 | 1136 | * |
| 1369 | 1137 | * @param string $class |
| 1370 | 1138 | * @param array $atts |
| 1371 | - * | |
| 1372 | 1139 | * @return string|null |
| 1373 | 1140 | */ |
| 1374 | 1141 | public static function icon_by_class( $class, $atts = array() ) { |
| 1375 | 1142 | $echo = ! isset( $atts['echo'] ) || $atts['echo']; |
| 1376 | - | |
| 1377 | 1143 | if ( isset( $atts['echo'] ) ) { |
| 1378 | 1144 | unset( $atts['echo'] ); |
| 1379 | 1145 | } |
| 1380 | 1146 | |
| @@ -1387,9 +1153,8 @@ | ||
| 1387 | 1153 | 'frm_clone_solid_icon' => 'frm_clone_icon', |
| 1388 | 1154 | 'frm_keyalt_icon' => 'frm_key_icon', |
| 1389 | 1155 | 'frm_keyalt_solid_icon' => 'frm_key_solid_icon', |
| 1390 | 1156 | ); |
| 1391 | - | |
| 1392 | 1157 | if ( isset( $deprecated[ $icon ] ) ) { |
| 1393 | 1158 | $icon = $deprecated[ $icon ]; |
| 1394 | 1159 | $class = str_replace( $icon, $deprecated[ $icon ], $class ); |
| 1395 | 1160 | } |
| @@ -1397,14 +1162,12 @@ | ||
| 1397 | 1162 | if ( $icon === $class ) { |
| 1398 | 1163 | $icon = '<i class="' . esc_attr( $class ) . '"' . $html_atts . '></i>'; |
| 1399 | 1164 | } else { |
| 1400 | 1165 | $class = strpos( $icon, ' ' ) === false ? '' : ' ' . $icon; |
| 1401 | - | |
| 1402 | 1166 | if ( strpos( $icon, ' ' ) ) { |
| 1403 | 1167 | $icon = explode( ' ', $icon ); |
| 1404 | 1168 | $icon = reset( $icon ); |
| 1405 | 1169 | } |
| 1406 | - | |
| 1407 | 1170 | $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>'; |
| 1408 | 1171 | } |
| 1409 | 1172 | |
| 1410 | 1173 | if ( $echo ) { |
| @@ -1419,9 +1182,8 @@ | ||
| 1419 | 1182 | * |
| 1420 | 1183 | * @since 5.0.13 |
| 1421 | 1184 | * |
| 1422 | 1185 | * @param string $icon |
| 1423 | - * | |
| 1424 | 1186 | * @return string |
| 1425 | 1187 | */ |
| 1426 | 1188 | public static function kses_icon( $icon ) { |
| 1427 | 1189 | add_filter( 'safe_style_css', 'FrmAppHelper::allow_vars_in_styles' ); |
| @@ -1437,15 +1199,13 @@ | ||
| 1437 | 1199 | /** |
| 1438 | 1200 | * @since 5.0.13.1 |
| 1439 | 1201 | * |
| 1440 | 1202 | * @param array $allowed_html |
| 1441 | - * | |
| 1442 | 1203 | * @return array |
| 1443 | 1204 | */ |
| 1444 | 1205 | public static function add_allowed_icon_tags( $allowed_html ) { |
| 1445 | 1206 | $allowed_html['svg']['data-open'] = true; |
| 1446 | 1207 | $allowed_html['svg']['title'] = true; |
| 1447 | - $allowed_html['svg']['tabindex'] = true; | |
| 1448 | 1208 | return $allowed_html; |
| 1449 | 1209 | } |
| 1450 | 1210 | |
| 1451 | 1211 | /** |
| @@ -1451,9 +1211,8 @@ | ||
| 1451 | 1211 | /** |
| 1452 | 1212 | * @since 5.0.13 |
| 1453 | 1213 | * |
| 1454 | 1214 | * @param array $allowed_attr |
| 1455 | - * | |
| 1456 | 1215 | * @return array |
| 1457 | 1216 | */ |
| 1458 | 1217 | public static function allow_vars_in_styles( $allowed_attr ) { |
| 1459 | 1218 | $allowed_attr[] = '--primary-700'; |
| @@ -1477,14 +1236,12 @@ | ||
| 1477 | 1236 | /** |
| 1478 | 1237 | * @since 5.0.13 |
| 1479 | 1238 | * |
| 1480 | 1239 | * @param string $value |
| 1481 | - * | |
| 1482 | 1240 | * @return bool |
| 1483 | 1241 | */ |
| 1484 | 1242 | private static function is_a_valid_color( $value ) { |
| 1485 | 1243 | $match = 0; |
| 1486 | - | |
| 1487 | 1244 | if ( 0 === strpos( $value, 'rgba(' ) ) { |
| 1488 | 1245 | $match = preg_match( '/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/', $value ); |
| 1489 | 1246 | } elseif ( 0 === strpos( $value, 'rgb(' ) ) { |
| 1490 | 1247 | $match = preg_match( '/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/', $value ); |
| @@ -1497,9 +1254,8 @@ | ||
| 1497 | 1254 | /** |
| 1498 | 1255 | * Include svg images. |
| 1499 | 1256 | * |
| 1500 | 1257 | * @since 4.0.02 |
| 1501 | - * | |
| 1502 | 1258 | * @return void |
| 1503 | 1259 | */ |
| 1504 | 1260 | public static function include_svg() { |
| 1505 | 1261 | if ( self::$included_svg ) { |
| @@ -1518,9 +1274,8 @@ | ||
| 1518 | 1274 | * @since 5.0.13 added $echo parameter. |
| 1519 | 1275 | * |
| 1520 | 1276 | * @param array $atts |
| 1521 | 1277 | * @param bool $echo |
| 1522 | - * | |
| 1523 | 1278 | * @return string|void |
| 1524 | 1279 | */ |
| 1525 | 1280 | public static function array_to_html_params( $atts, $echo = false ) { |
| 1526 | 1281 | $callback = function () use ( $atts ) { |
| @@ -1539,9 +1294,8 @@ | ||
| 1539 | 1294 | * @since 5.0.13 |
| 1540 | 1295 | * |
| 1541 | 1296 | * @param Closure $echo_function |
| 1542 | 1297 | * @param bool $echo |
| 1543 | - * | |
| 1544 | 1298 | * @return string|null |
| 1545 | 1299 | */ |
| 1546 | 1300 | public static function clip( $echo_function, $echo = false ) { |
| 1547 | 1301 | if ( ! $echo ) { |
| @@ -1562,18 +1316,15 @@ | ||
| 1562 | 1316 | /** |
| 1563 | 1317 | * @since 3.0 |
| 1564 | 1318 | * |
| 1565 | 1319 | * @param array $atts |
| 1566 | - * | |
| 1567 | 1320 | * @return void |
| 1568 | 1321 | */ |
| 1569 | 1322 | public static function get_admin_header( $atts ) { |
| 1570 | 1323 | $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] ); |
| 1571 | - | |
| 1572 | 1324 | if ( empty( $atts['close'] ) ) { |
| 1573 | 1325 | $atts['close'] = admin_url( 'admin.php?page=formidable' ); |
| 1574 | 1326 | } |
| 1575 | - | |
| 1576 | 1327 | if ( ! isset( $atts['import_link'] ) ) { |
| 1577 | 1328 | $atts['import_link'] = false; |
| 1578 | 1329 | } |
| 1579 | 1330 | |
| @@ -1583,9 +1334,8 @@ | ||
| 1583 | 1334 | /** |
| 1584 | 1335 | * @since 6.0 |
| 1585 | 1336 | * |
| 1586 | 1337 | * @param string $type |
| 1587 | - * | |
| 1588 | 1338 | * @return void |
| 1589 | 1339 | */ |
| 1590 | 1340 | public static function import_link( $type = 'secondary' ) { |
| 1591 | 1341 | ?> |
| @@ -1600,9 +1350,8 @@ | ||
| 1600 | 1350 | * |
| 1601 | 1351 | * @since 5.4.2 |
| 1602 | 1352 | * |
| 1603 | 1353 | * @param bool $should_show_lite_upgrade |
| 1604 | - * | |
| 1605 | 1354 | * @return void |
| 1606 | 1355 | */ |
| 1607 | 1356 | public static function print_admin_banner( $should_show_lite_upgrade ) { |
| 1608 | 1357 | if ( ! current_user_can( 'administrator' ) ) { |
| @@ -1609,9 +1358,9 @@ | ||
| 1609 | 1358 | FrmInbox::maybe_show_banner(); |
| 1610 | 1359 | return; |
| 1611 | 1360 | } |
| 1612 | 1361 | |
| 1613 | - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) { | |
| 1362 | + if ( self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) { | |
| 1614 | 1363 | // Print license warning or inbox banner and exit if either prints. |
| 1615 | 1364 | // And exit before printing the upgrade bar if it shouldn't be shown. |
| 1616 | 1365 | return; |
| 1617 | 1366 | } |
| @@ -1616,37 +1365,22 @@ | ||
| 1616 | 1365 | return; |
| 1617 | 1366 | } |
| 1618 | 1367 | ?> |
| 1619 | 1368 | <div class="frm-upgrade-bar"> |
| 1620 | - <div class="frm-upgrade-bar-inner"> | |
| 1621 | 1369 | <?php |
| 1622 | - $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' ); | |
| 1623 | - | |
| 1624 | - if ( ! $cta_text ) { | |
| 1625 | - $cta_text = __( 'upgrading to PRO', 'formidable' ); | |
| 1626 | - } | |
| 1627 | - | |
| 1628 | - $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' ); | |
| 1629 | - $utm = array( | |
| 1630 | - 'campaign' => 'settings-license', | |
| 1631 | - 'content' => 'lite-banner', | |
| 1370 | + $upgrade_link = self::admin_upgrade_link( | |
| 1371 | + array( | |
| 1372 | + 'medium' => 'settings-license', | |
| 1373 | + 'content' => 'lite-banner', | |
| 1374 | + ) | |
| 1632 | 1375 | ); |
| 1633 | - | |
| 1634 | - if ( $upgrade_link ) { | |
| 1635 | - $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm ); | |
| 1636 | - } else { | |
| 1637 | - $upgrade_link = self::admin_upgrade_link( $utm ); | |
| 1638 | - } | |
| 1639 | - | |
| 1640 | 1376 | printf( |
| 1641 | - /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */ | |
| 1642 | - esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ), | |
| 1377 | + /* translators: %1$s: Start link HTML, %2$s: End link HTML */ | |
| 1378 | + esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$supgrading to PRO%2$s.', 'formidable' ), | |
| 1643 | 1379 | '<a href="' . esc_url( $upgrade_link ) . '">', |
| 1644 | - esc_html( $cta_text ), | |
| 1645 | 1380 | '</a>' |
| 1646 | 1381 | ); |
| 1647 | 1382 | ?> |
| 1648 | - </div> | |
| 1649 | 1383 | </div> |
| 1650 | 1384 | <?php |
| 1651 | 1385 | } |
| 1652 | 1386 | |
| @@ -1662,9 +1396,8 @@ | ||
| 1662 | 1396 | /** |
| 1663 | 1397 | * Render a button for a new item (Form, Application, etc). |
| 1664 | 1398 | * |
| 1665 | 1399 | * @since 3.0 |
| 1666 | - * | |
| 1667 | 1400 | * @param array $atts { |
| 1668 | 1401 | * Details about the button. |
| 1669 | 1402 | * |
| 1670 | 1403 | * @type array $link_hook Custom link hook, calls do_action and exits early. |
| @@ -1671,9 +1404,8 @@ | ||
| 1671 | 1404 | * @type string $new_link Href value, default #. |
| 1672 | 1405 | * @type string $class Custom class names, space separated. |
| 1673 | 1406 | * @type string $button_text Button text. Default "Add New". |
| 1674 | 1407 | * } |
| 1675 | - * | |
| 1676 | 1408 | * @return void |
| 1677 | 1409 | */ |
| 1678 | 1410 | public static function add_new_item_link( $atts ) { |
| 1679 | 1411 | if ( isset( $atts['link_hook'] ) ) { |
| @@ -1699,12 +1431,8 @@ | ||
| 1699 | 1431 | } |
| 1700 | 1432 | |
| 1701 | 1433 | /** |
| 1702 | 1434 | * @since 3.06 |
| 1703 | - * | |
| 1704 | - * @param array $atts | |
| 1705 | - * | |
| 1706 | - * @return void | |
| 1707 | 1435 | */ |
| 1708 | 1436 | public static function show_search_box( $atts ) { |
| 1709 | 1437 | $defaults = array( |
| 1710 | 1438 | 'placeholder' => '', |
| @@ -1711,9 +1439,8 @@ | ||
| 1711 | 1439 | 'tosearch' => '', |
| 1712 | 1440 | 'text' => __( 'Search', 'formidable' ), |
| 1713 | 1441 | 'input_id' => '', |
| 1714 | 1442 | 'value' => false, |
| 1715 | - 'class' => '', | |
| 1716 | 1443 | ); |
| 1717 | 1444 | $atts = array_merge( $defaults, $atts ); |
| 1718 | 1445 | |
| 1719 | 1446 | if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) { |
| @@ -1720,9 +1447,8 @@ | ||
| 1720 | 1447 | $atts['tosearch'] = 'frm-card'; |
| 1721 | 1448 | } |
| 1722 | 1449 | |
| 1723 | 1450 | $class = 'frm-search-input'; |
| 1724 | - | |
| 1725 | 1451 | if ( ! empty( $atts['tosearch'] ) ) { |
| 1726 | 1452 | $class .= ' frm-auto-search'; |
| 1727 | 1453 | } |
| 1728 | 1454 | |
| @@ -1747,13 +1473,13 @@ | ||
| 1747 | 1473 | if ( ! empty( $atts['tosearch'] ) ) { |
| 1748 | 1474 | $input_atts['autocomplete'] = 'off'; |
| 1749 | 1475 | } |
| 1750 | 1476 | ?> |
| 1751 | - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>"> | |
| 1477 | + <p class="frm-search"> | |
| 1752 | 1478 | <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"> |
| 1753 | 1479 | <?php echo esc_html( $atts['text'] ); ?>: |
| 1754 | 1480 | </label> |
| 1755 | - <?php self::icon_by_class( 'frm_icon_font frm_search_icon frm_svg20' ); ?> | |
| 1481 | + <span class="frmfont frm_search_icon"></span> | |
| 1756 | 1482 | <input <?php self::array_to_html_params( $input_atts, true ); ?> /> |
| 1757 | 1483 | <?php |
| 1758 | 1484 | if ( empty( $atts['tosearch'] ) ) { |
| 1759 | 1485 | submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) ); |
| @@ -1763,17 +1489,14 @@ | ||
| 1763 | 1489 | <?php |
| 1764 | 1490 | } |
| 1765 | 1491 | |
| 1766 | 1492 | /** |
| 1767 | - * @param string $type Hook type slug. | |
| 1768 | - * @param object|null $object Optional related object. | |
| 1769 | - * | |
| 1493 | + * @param string $type | |
| 1770 | 1494 | * @return void |
| 1771 | 1495 | */ |
| 1772 | 1496 | public static function trigger_hook_load( $type, $object = null ) { |
| 1773 | 1497 | // Only load the form hooks once. |
| 1774 | 1498 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 1775 | - | |
| 1776 | 1499 | if ( ! $hooks_loaded ) { |
| 1777 | 1500 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 1778 | 1501 | } |
| 1779 | 1502 | } |
| @@ -1847,9 +1570,8 @@ | ||
| 1847 | 1570 | * |
| 1848 | 1571 | * @since 4.10.01 Add `$post_type` argument. |
| 1849 | 1572 | * |
| 1850 | 1573 | * @param string $post_type Post type to query. Default is `page`. |
| 1851 | - * | |
| 1852 | 1574 | * @return WP_Post[] |
| 1853 | 1575 | */ |
| 1854 | 1576 | public static function get_pages( $post_type = 'page' ) { |
| 1855 | 1577 | $query = array( |
| @@ -1868,9 +1590,8 @@ | ||
| 1868 | 1590 | * |
| 1869 | 1591 | * @since 5.0.09 |
| 1870 | 1592 | * |
| 1871 | 1593 | * @param string $post_type Post type to query. Default is `page`. |
| 1872 | - * | |
| 1873 | 1594 | * @return array |
| 1874 | 1595 | */ |
| 1875 | 1596 | public static function get_post_ids_and_titles( $post_type = 'page' ) { |
| 1876 | 1597 | return FrmDb::get_results( |
| @@ -1899,9 +1620,9 @@ | ||
| 1899 | 1620 | $args = self::preformat_selection_args( $args ); |
| 1900 | 1621 | |
| 1901 | 1622 | $pages_count = wp_count_posts( $args['post_type'] ); |
| 1902 | 1623 | |
| 1903 | - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) { | |
| 1624 | + if ( $pages_count->publish <= 50 ) { | |
| 1904 | 1625 | self::wp_pages_dropdown( $args ); |
| 1905 | 1626 | return; |
| 1906 | 1627 | } |
| 1907 | 1628 | |
| @@ -1925,107 +1646,8 @@ | ||
| 1925 | 1646 | <?php |
| 1926 | 1647 | } |
| 1927 | 1648 | |
| 1928 | 1649 | /** |
| 1929 | - * Maybe show an HTML select or autocomplete input based on the number of options. | |
| 1930 | - * | |
| 1931 | - * @since 6.21 | |
| 1932 | - * | |
| 1933 | - * @param array $args Args. See the method for details. | |
| 1934 | - */ | |
| 1935 | - public static function maybe_autocomplete_options( $args ) { | |
| 1936 | - $defaults = array( | |
| 1937 | - 'truncate' => false, | |
| 1938 | - 'placeholder' => ' ', | |
| 1939 | - 'name' => '', | |
| 1940 | - 'id' => '', | |
| 1941 | - 'selected' => '', | |
| 1942 | - 'source' => array(), | |
| 1943 | - 'dropdown_limit' => 50, | |
| 1944 | - 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ), | |
| 1945 | - 'value_key' => 'value', | |
| 1946 | - 'label_key' => 'label', | |
| 1947 | - ); | |
| 1948 | - | |
| 1949 | - $args = wp_parse_args( $args, $defaults ); | |
| 1950 | - | |
| 1951 | - $html_attrs = array(); | |
| 1952 | - | |
| 1953 | - if ( ! empty( $args['name'] ) ) { | |
| 1954 | - $html_attrs['name'] = $args['name']; | |
| 1955 | - } | |
| 1956 | - | |
| 1957 | - if ( ! empty( $args['id'] ) ) { | |
| 1958 | - $html_attrs['id'] = $args['id']; | |
| 1959 | - } | |
| 1960 | - | |
| 1961 | - if ( count( $args['source'] ) <= $args['dropdown_limit'] ) { | |
| 1962 | - ?> | |
| 1963 | - <select <?php self::array_to_html_params( $html_attrs, true ); ?>> | |
| 1964 | - <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option> | |
| 1965 | - <?php | |
| 1966 | - foreach ( $args['source'] as $key => $source ) : | |
| 1967 | - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args ); | |
| 1968 | - | |
| 1969 | - if ( ! empty( $args['truncate'] ) ) { | |
| 1970 | - $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] ); | |
| 1971 | - } | |
| 1972 | - ?> | |
| 1973 | - <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option> | |
| 1974 | - <?php endforeach; ?> | |
| 1975 | - </select> | |
| 1976 | - <?php | |
| 1977 | - } else { | |
| 1978 | - $options = array(); | |
| 1979 | - $autocomplete_value = ''; | |
| 1980 | - | |
| 1981 | - foreach ( $args['source'] as $key => $source ) { | |
| 1982 | - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args ); | |
| 1983 | - | |
| 1984 | - if ( $value_label['value'] === $args['selected'] ) { | |
| 1985 | - $autocomplete_value = $value_label['label']; | |
| 1986 | - } | |
| 1987 | - | |
| 1988 | - $options[] = $value_label; | |
| 1989 | - } | |
| 1990 | - | |
| 1991 | - $html_attrs['type'] = 'hidden'; | |
| 1992 | - $html_attrs['class'] = 'frm_autocomplete_value_input'; | |
| 1993 | - $html_attrs['value'] = $args['selected']; | |
| 1994 | - ?> | |
| 1995 | - <input type="text" class="frm-custom-search" | |
| 1996 | - data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>" | |
| 1997 | - placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>" | |
| 1998 | - value="<?php echo esc_attr( $autocomplete_value ); ?>" /> | |
| 1999 | - <input <?php self::array_to_html_params( $html_attrs, true ); ?> /> | |
| 2000 | - <?php | |
| 2001 | - }//end if | |
| 2002 | - } | |
| 2003 | - | |
| 2004 | - /** | |
| 2005 | - * Gets dropdown value and label from autodropdown option. | |
| 2006 | - * | |
| 2007 | - * @since 6.21 | |
| 2008 | - * | |
| 2009 | - * @param array|string $option Autocomplete option. | |
| 2010 | - * @param string $key Array key of the option. | |
| 2011 | - * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}. | |
| 2012 | - * | |
| 2013 | - * @return array | |
| 2014 | - */ | |
| 2015 | - private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) { | |
| 2016 | - if ( is_array( $option ) ) { | |
| 2017 | - $value = $option[ $args['value_key'] ] ?? ''; | |
| 2018 | - $label = $option[ $args['label_key'] ] ?? ''; | |
| 2019 | - } else { | |
| 2020 | - $value = $key; | |
| 2021 | - $label = $option; | |
| 2022 | - } | |
| 2023 | - | |
| 2024 | - return compact( 'value', 'label' ); | |
| 2025 | - } | |
| 2026 | - | |
| 2027 | - /** | |
| 2028 | 1650 | * @param array $args |
| 2029 | 1651 | * @param string $page_id Deprecated. |
| 2030 | 1652 | * @param bool $truncate Deprecated. |
| 2031 | 1653 | */ |
| @@ -2033,8 +1655,9 @@ | ||
| 2033 | 1655 | self::prep_page_dropdown_params( $page_id, $truncate, $args ); |
| 2034 | 1656 | |
| 2035 | 1657 | $pages = self::get_post_ids_and_titles( $args['post_type'] ); |
| 2036 | 1658 | $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' ); |
| 1659 | + | |
| 2037 | 1660 | ?> |
| 2038 | 1661 | <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown"> |
| 2039 | 1662 | <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option> |
| 2040 | 1663 | <?php foreach ( $pages as $page ) { ?> |
| @@ -2050,14 +1673,8 @@ | ||
| 2050 | 1673 | * Fill in missing parameters passed to wp_pages_dropdown(). |
| 2051 | 1674 | * This is for reverse compatibility with switching 3 params to 1. |
| 2052 | 1675 | * |
| 2053 | 1676 | * @since 4.03.06 |
| 2054 | - * | |
| 2055 | - * @param string $page_id Deprecated. | |
| 2056 | - * @param bool $truncate Deprecated. | |
| 2057 | - * @param mixed $args | |
| 2058 | - * | |
| 2059 | - * @return void | |
| 2060 | 1677 | */ |
| 2061 | 1678 | private static function prep_page_dropdown_params( $page_id, $truncate, &$args ) { |
| 2062 | 1679 | if ( ! is_array( $args ) ) { |
| 2063 | 1680 | $args = array( |
| @@ -2074,12 +1691,8 @@ | ||
| 2074 | 1691 | * Filter to format args for page dropdown or autocomplete |
| 2075 | 1692 | * |
| 2076 | 1693 | * @since 4.03.06 |
| 2077 | 1694 | * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array. |
| 2078 | - * | |
| 2079 | - * @param array $args | |
| 2080 | - * | |
| 2081 | - * @return array | |
| 2082 | 1695 | */ |
| 2083 | 1696 | private static function preformat_selection_args( $args ) { |
| 2084 | 1697 | $defaults = array( |
| 2085 | 1698 | 'truncate' => false, |
| @@ -2092,16 +1705,10 @@ | ||
| 2092 | 1705 | |
| 2093 | 1706 | return array_merge( $defaults, $args ); |
| 2094 | 1707 | } |
| 2095 | 1708 | |
| 2096 | - /** | |
| 2097 | - * @param int $post_id | |
| 2098 | - * | |
| 2099 | - * @return string | |
| 2100 | - */ | |
| 2101 | 1709 | public static function post_edit_link( $post_id ) { |
| 2102 | 1710 | $post = get_post( $post_id ); |
| 2103 | - | |
| 2104 | 1711 | if ( $post ) { |
| 2105 | 1712 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 2106 | 1713 | |
| 2107 | 1714 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| @@ -2131,9 +1738,8 @@ | ||
| 2131 | 1738 | * @since 5.5.3 |
| 2132 | 1739 | * @since 6.0 Added the $view parameter. Previously there was only a 'edit' view. |
| 2133 | 1740 | * |
| 2134 | 1741 | * @param string $view Supports 'edit', 'list', and ''. If '', both 'edit' and 'list' will match. |
| 2135 | - * | |
| 2136 | 1742 | * @return bool |
| 2137 | 1743 | */ |
| 2138 | 1744 | public static function is_style_editor_page( $view = '' ) { |
| 2139 | 1745 | if ( ! self::is_admin_page( 'formidable-styles' ) && ! self::is_admin_page( 'formidable-styles2' ) ) { |
| @@ -2181,9 +1787,8 @@ | ||
| 2181 | 1787 | } |
| 2182 | 1788 | |
| 2183 | 1789 | /** |
| 2184 | 1790 | * @since 4.07 |
| 2185 | - * | |
| 2186 | 1791 | * @param array|string $selected |
| 2187 | 1792 | * @param string $current |
| 2188 | 1793 | */ |
| 2189 | 1794 | private static function selected( $selected, $current ) { |
| @@ -2198,9 +1803,8 @@ | ||
| 2198 | 1803 | * @param array|string $capability |
| 2199 | 1804 | */ |
| 2200 | 1805 | public static function roles_options( $capability ) { |
| 2201 | 1806 | global $frm_vars; |
| 2202 | - | |
| 2203 | 1807 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 2204 | 1808 | $editable_roles = $frm_vars['editable_roles']; |
| 2205 | 1809 | } else { |
| 2206 | 1810 | $editable_roles = get_editable_roles(); |
| @@ -2209,9 +1813,9 @@ | ||
| 2209 | 1813 | |
| 2210 | 1814 | foreach ( $editable_roles as $role => $details ) { |
| 2211 | 1815 | $name = translate_user_role( $details['name'] ); |
| 2212 | 1816 | ?> |
| 2213 | - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option> | |
| 1817 | + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?> </option> | |
| 2214 | 1818 | <?php |
| 2215 | 1819 | unset( $role, $details ); |
| 2216 | 1820 | } |
| 2217 | 1821 | } |
| @@ -2221,9 +1825,8 @@ | ||
| 2221 | 1825 | * |
| 2222 | 1826 | * @since 5.0 Parameter `$type` supports `pro_only` value. |
| 2223 | 1827 | * |
| 2224 | 1828 | * @param string $type Supports `auto`, `pro`, or `pro_only`. |
| 2225 | - * | |
| 2226 | 1829 | * @return array |
| 2227 | 1830 | */ |
| 2228 | 1831 | public static function frm_capabilities( $type = 'auto' ) { |
| 2229 | 1832 | if ( ! self::pro_is_installed() && ! in_array( $type, array( 'pro', 'pro_only' ), true ) ) { |
| @@ -2241,8 +1844,14 @@ | ||
| 2241 | 1844 | * @param array<string,string> $pro_cap |
| 2242 | 1845 | */ |
| 2243 | 1846 | $pro_cap = apply_filters( 'frm_pro_capabilities', $pro_cap ); |
| 2244 | 1847 | |
| 1848 | + if ( ! array_key_exists( 'frm_edit_displays', $pro_cap ) && is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed() ) { | |
| 1849 | + // For backward compatibility, add the Add/Edit Views permission if Pro is not up to date. | |
| 1850 | + // This was added in 6.5.4. Remove this in the future. | |
| 1851 | + $pro_cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); | |
| 1852 | + } | |
| 1853 | + | |
| 2245 | 1854 | if ( 'pro_only' === $type ) { |
| 2246 | 1855 | return $pro_cap; |
| 2247 | 1856 | } |
| 2248 | 1857 | |
| @@ -2301,9 +1910,8 @@ | ||
| 2301 | 1910 | } |
| 2302 | 1911 | |
| 2303 | 1912 | /** |
| 2304 | 1913 | * @param array|string $needed_role |
| 2305 | - * | |
| 2306 | 1914 | * @return bool |
| 2307 | 1915 | */ |
| 2308 | 1916 | public static function user_has_permission( $needed_role ) { |
| 2309 | 1917 | if ( is_array( $needed_role ) ) { |
| @@ -2322,14 +1930,12 @@ | ||
| 2322 | 1930 | return $can; |
| 2323 | 1931 | } |
| 2324 | 1932 | |
| 2325 | 1933 | $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
| 2326 | - | |
| 2327 | 1934 | foreach ( $roles as $role ) { |
| 2328 | 1935 | if ( current_user_can( $role ) ) { |
| 2329 | 1936 | return true; |
| 2330 | 1937 | } |
| 2331 | - | |
| 2332 | 1938 | if ( $role == $needed_role ) { |
| 2333 | 1939 | break; |
| 2334 | 1940 | } |
| 2335 | 1941 | } |
| @@ -2351,9 +1957,8 @@ | ||
| 2351 | 1957 | |
| 2352 | 1958 | $user_id = get_current_user_id(); |
| 2353 | 1959 | $user = new WP_User( $user_id ); |
| 2354 | 1960 | $frm_roles = self::frm_capabilities(); |
| 2355 | - | |
| 2356 | 1961 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 2357 | 1962 | $user->add_cap( $frm_role ); |
| 2358 | 1963 | unset( $frm_role, $frm_role_description ); |
| 2359 | 1964 | } |
| @@ -2364,9 +1969,8 @@ | ||
| 2364 | 1969 | * |
| 2365 | 1970 | * @since 2.0.6 |
| 2366 | 1971 | * |
| 2367 | 1972 | * @param string $cap |
| 2368 | - * | |
| 2369 | 1973 | * @return void |
| 2370 | 1974 | */ |
| 2371 | 1975 | public static function force_capability( $cap = 'frm_change_settings' ) { |
| 2372 | 1976 | if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) { |
| @@ -2371,9 +1975,8 @@ | ||
| 2371 | 1975 | public static function force_capability( $cap = 'frm_change_settings' ) { |
| 2372 | 1976 | if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) { |
| 2373 | 1977 | $role = get_role( 'administrator' ); |
| 2374 | 1978 | $frm_roles = self::frm_capabilities(); |
| 2375 | - | |
| 2376 | 1979 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 2377 | 1980 | $role->add_cap( $frm_role ); |
| 2378 | 1981 | } |
| 2379 | 1982 | } |
| @@ -2385,13 +1988,11 @@ | ||
| 2385 | 1988 | * |
| 2386 | 1989 | * @since 2.0 |
| 2387 | 1990 | * |
| 2388 | 1991 | * @param string $permission |
| 2389 | - * @param string $show_message | |
| 2390 | 1992 | */ |
| 2391 | 1993 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 2392 | 1994 | $permission_error = self::permission_nonce_error( $permission ); |
| 2393 | - | |
| 2394 | 1995 | if ( $permission_error !== false ) { |
| 2395 | 1996 | if ( 'hide' == $show_message ) { |
| 2396 | 1997 | $permission_error = ''; |
| 2397 | 1998 | } |
| @@ -2404,10 +2005,8 @@ | ||
| 2404 | 2005 | * |
| 2405 | 2006 | * @since 2.0 |
| 2406 | 2007 | * |
| 2407 | 2008 | * @param string $permission |
| 2408 | - * @param string $nonce_name | |
| 2409 | - * @param string $nonce | |
| 2410 | 2009 | * |
| 2411 | 2010 | * @return false|string The permission message or false if allowed |
| 2412 | 2011 | */ |
| 2413 | 2012 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| @@ -2417,15 +2016,13 @@ | ||
| 2417 | 2016 | return $frm_settings->admin_permission; |
| 2418 | 2017 | } |
| 2419 | 2018 | |
| 2420 | 2019 | $error = false; |
| 2421 | - | |
| 2422 | 2020 | if ( empty( $nonce_name ) ) { |
| 2423 | 2021 | return $error; |
| 2424 | 2022 | } |
| 2425 | 2023 | |
| 2426 | 2024 | $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : ''; |
| 2427 | - | |
| 2428 | 2025 | if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) { |
| 2429 | 2026 | $frm_settings = self::get_settings(); |
| 2430 | 2027 | $error = $frm_settings->admin_permission; |
| 2431 | 2028 | } |
| @@ -2432,14 +2029,8 @@ | ||
| 2432 | 2029 | |
| 2433 | 2030 | return $error; |
| 2434 | 2031 | } |
| 2435 | 2032 | |
| 2436 | - /** | |
| 2437 | - * @param array|string $values | |
| 2438 | - * @param string $current | |
| 2439 | - * | |
| 2440 | - * @return void | |
| 2441 | - */ | |
| 2442 | 2033 | public static function checked( $values, $current ) { |
| 2443 | 2034 | if ( self::check_selected( $values, $current ) ) { |
| 2444 | 2035 | echo ' checked="checked"'; |
| 2445 | 2036 | } |
| @@ -2444,14 +2035,8 @@ | ||
| 2444 | 2035 | echo ' checked="checked"'; |
| 2445 | 2036 | } |
| 2446 | 2037 | } |
| 2447 | 2038 | |
| 2448 | - /** | |
| 2449 | - * @param array|string $values | |
| 2450 | - * @param string $current | |
| 2451 | - * | |
| 2452 | - * @return bool | |
| 2453 | - */ | |
| 2454 | 2039 | public static function check_selected( $values, $current ) { |
| 2455 | 2040 | $values = self::recursive_function_map( $values, 'trim' ); |
| 2456 | 2041 | $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' ); |
| 2457 | 2042 | |
| @@ -2459,24 +2044,16 @@ | ||
| 2459 | 2044 | |
| 2460 | 2045 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 2461 | 2046 | } |
| 2462 | 2047 | |
| 2463 | - /** | |
| 2464 | - * @param array|string $value | |
| 2465 | - * @param callable|string $function | |
| 2466 | - * | |
| 2467 | - * @return array|string | |
| 2468 | - */ | |
| 2469 | 2048 | public static function recursive_function_map( $value, $function ) { |
| 2470 | 2049 | if ( is_array( $value ) ) { |
| 2471 | 2050 | $original_function = $function; |
| 2472 | - | |
| 2473 | 2051 | if ( count( $value ) ) { |
| 2474 | 2052 | $function = explode( ', ', FrmDb::prepare_array_values( $value, $function ) ); |
| 2475 | 2053 | } else { |
| 2476 | 2054 | $function = array( $function ); |
| 2477 | 2055 | } |
| 2478 | - | |
| 2479 | 2056 | if ( ! self::is_assoc( $value ) ) { |
| 2480 | 2057 | $value = array_map( array( 'FrmAppHelper', 'recursive_function_map' ), $value, $function ); |
| 2481 | 2058 | } else { |
| 2482 | 2059 | foreach ( $value as $k => $v ) { |
| @@ -2487,9 +2064,9 @@ | ||
| 2487 | 2064 | } |
| 2488 | 2065 | } else { |
| 2489 | 2066 | $value = self::maybe_update_value_if_null( $value, $function ); |
| 2490 | 2067 | $value = call_user_func( $function, $value ); |
| 2491 | - }//end if | |
| 2068 | + } | |
| 2492 | 2069 | |
| 2493 | 2070 | return $value; |
| 2494 | 2071 | } |
| 2495 | 2072 | |
| @@ -2496,12 +2073,10 @@ | ||
| 2496 | 2073 | /** |
| 2497 | 2074 | * Updates value to empty string if it is null and being passed to a string function. |
| 2498 | 2075 | * |
| 2499 | 2076 | * @since 6.8.4 |
| 2500 | - * | |
| 2501 | 2077 | * @param mixed $value |
| 2502 | 2078 | * @param string $function |
| 2503 | - * | |
| 2504 | 2079 | * @return mixed |
| 2505 | 2080 | */ |
| 2506 | 2081 | private static function maybe_update_value_if_null( $value, $function ) { |
| 2507 | 2082 | if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) { |
| @@ -2510,13 +2085,8 @@ | ||
| 2510 | 2085 | |
| 2511 | 2086 | return $value; |
| 2512 | 2087 | } |
| 2513 | 2088 | |
| 2514 | - /** | |
| 2515 | - * @param array $array | |
| 2516 | - * | |
| 2517 | - * @return bool | |
| 2518 | - */ | |
| 2519 | 2089 | public static function is_assoc( $array ) { |
| 2520 | 2090 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 2521 | 2091 | } |
| 2522 | 2092 | |
| @@ -2521,17 +2091,11 @@ | ||
| 2521 | 2091 | } |
| 2522 | 2092 | |
| 2523 | 2093 | /** |
| 2524 | 2094 | * Flatten a multi-dimensional array |
| 2525 | - * | |
| 2526 | - * @param array $array | |
| 2527 | - * @param string $keys | |
| 2528 | - * | |
| 2529 | - * @return array | |
| 2530 | 2095 | */ |
| 2531 | 2096 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 2532 | 2097 | $return = array(); |
| 2533 | - | |
| 2534 | 2098 | foreach ( $array as $key => $value ) { |
| 2535 | 2099 | if ( is_array( $value ) ) { |
| 2536 | 2100 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 2537 | 2101 | } elseif ( $keys === 'keep' ) { |
| @@ -2550,9 +2114,8 @@ | ||
| 2550 | 2114 | * @since 6.16.1 |
| 2551 | 2115 | * |
| 2552 | 2116 | * @param string $sep |
| 2553 | 2117 | * @param array $array |
| 2554 | - * | |
| 2555 | 2118 | * @return string |
| 2556 | 2119 | */ |
| 2557 | 2120 | public static function safe_implode( $sep, $array ) { |
| 2558 | 2121 | $array = self::array_flatten( $array ); |
| @@ -2561,18 +2124,15 @@ | ||
| 2561 | 2124 | |
| 2562 | 2125 | /** |
| 2563 | 2126 | * @param string $text |
| 2564 | 2127 | * @param bool $is_rich_text |
| 2565 | - * | |
| 2566 | 2128 | * @return string |
| 2567 | 2129 | */ |
| 2568 | 2130 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 2569 | 2131 | $safe_text = str_replace( '"', '"', $text ); |
| 2570 | - | |
| 2571 | 2132 | if ( ! $is_rich_text ) { |
| 2572 | 2133 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
| 2573 | 2134 | } |
| 2574 | - | |
| 2575 | 2135 | $safe_text = str_replace( '& ', '& ', $safe_text ); |
| 2576 | 2136 | |
| 2577 | 2137 | /** |
| 2578 | 2138 | * @param string $safe_text |
| @@ -2584,15 +2144,11 @@ | ||
| 2584 | 2144 | /** |
| 2585 | 2145 | * Add auto paragraphs to text areas |
| 2586 | 2146 | * |
| 2587 | 2147 | * @since 2.0 |
| 2588 | - * | |
| 2589 | - * @param mixed $content | |
| 2590 | - * | |
| 2591 | - * @return mixed | |
| 2592 | 2148 | */ |
| 2593 | 2149 | public static function use_wpautop( $content ) { |
| 2594 | - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) { | |
| 2150 | + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) { | |
| 2595 | 2151 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
| 2596 | 2152 | } |
| 2597 | 2153 | |
| 2598 | 2154 | return $content; |
| @@ -2597,15 +2153,8 @@ | ||
| 2597 | 2153 | |
| 2598 | 2154 | return $content; |
| 2599 | 2155 | } |
| 2600 | 2156 | |
| 2601 | - /** | |
| 2602 | - * Replace quotes with their HTML entities. | |
| 2603 | - * | |
| 2604 | - * @param string $val | |
| 2605 | - * | |
| 2606 | - * @return string | |
| 2607 | - */ | |
| 2608 | 2157 | public static function replace_quotes( $val ) { |
| 2609 | 2158 | // Replace double quotes. |
| 2610 | 2159 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 2611 | 2160 | |
| @@ -2615,28 +2164,22 @@ | ||
| 2615 | 2164 | return $val; |
| 2616 | 2165 | } |
| 2617 | 2166 | |
| 2618 | 2167 | /** |
| 2619 | - * @param string $handle | |
| 2620 | - * @param int|string $default | |
| 2621 | - * | |
| 2622 | - * @return int|string | |
| 2168 | + * @param string $handle | |
| 2623 | 2169 | */ |
| 2624 | 2170 | public static function script_version( $handle, $default = 0 ) { |
| 2625 | 2171 | global $wp_scripts; |
| 2626 | - | |
| 2627 | 2172 | if ( ! $wp_scripts ) { |
| 2628 | 2173 | return $default; |
| 2629 | 2174 | } |
| 2630 | 2175 | |
| 2631 | 2176 | $ver = $default; |
| 2632 | - | |
| 2633 | 2177 | if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
| 2634 | 2178 | return $ver; |
| 2635 | 2179 | } |
| 2636 | 2180 | |
| 2637 | 2181 | $query = $wp_scripts->registered[ $handle ]; |
| 2638 | - | |
| 2639 | 2182 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
| 2640 | 2183 | $ver = $query->ver; |
| 2641 | 2184 | } |
| 2642 | 2185 | |
| @@ -2647,9 +2190,8 @@ | ||
| 2647 | 2190 | * @since 5.0.13 added $echo param. |
| 2648 | 2191 | * |
| 2649 | 2192 | * @param string $url |
| 2650 | 2193 | * @param bool $echo |
| 2651 | - * | |
| 2652 | 2194 | * @return string|null |
| 2653 | 2195 | */ |
| 2654 | 2196 | public static function js_redirect( $url, $echo = false ) { |
| 2655 | 2197 | $callback = function () use ( $url ) { |
| @@ -2657,13 +2199,8 @@ | ||
| 2657 | 2199 | }; |
| 2658 | 2200 | return self::clip( $callback, $echo ); |
| 2659 | 2201 | } |
| 2660 | 2202 | |
| 2661 | - /** | |
| 2662 | - * @param int|string $user_id | |
| 2663 | - * | |
| 2664 | - * @return int|string | |
| 2665 | - */ | |
| 2666 | 2203 | public static function get_user_id_param( $user_id ) { |
| 2667 | 2204 | if ( ! $user_id || is_numeric( $user_id ) ) { |
| 2668 | 2205 | return $user_id; |
| 2669 | 2206 | } |
| @@ -2668,9 +2205,8 @@ | ||
| 2668 | 2205 | return $user_id; |
| 2669 | 2206 | } |
| 2670 | 2207 | |
| 2671 | 2208 | $user_id = sanitize_text_field( $user_id ); |
| 2672 | - | |
| 2673 | 2209 | if ( $user_id === 'current' ) { |
| 2674 | 2210 | $user_id = get_current_user_id(); |
| 2675 | 2211 | } else { |
| 2676 | 2212 | if ( is_email( $user_id ) ) { |
| @@ -2690,9 +2226,8 @@ | ||
| 2690 | 2226 | |
| 2691 | 2227 | /** |
| 2692 | 2228 | * @param string $filename |
| 2693 | 2229 | * @param array $atts |
| 2694 | - * | |
| 2695 | 2230 | * @return false|string |
| 2696 | 2231 | */ |
| 2697 | 2232 | public static function get_file_contents( $filename, $atts = array() ) { |
| 2698 | 2233 | if ( ! is_file( $filename ) ) { |
| @@ -2716,9 +2251,8 @@ | ||
| 2716 | 2251 | * @param int $num_chars |
| 2717 | 2252 | */ |
| 2718 | 2253 | public static function get_unique_key( $name, $table_name, $column, $id = 0, $num_chars = 5 ) { |
| 2719 | 2254 | $key = ''; |
| 2720 | - | |
| 2721 | 2255 | if ( $name ) { |
| 2722 | 2256 | $key = sanitize_key( $name ); |
| 2723 | 2257 | $key = self::maybe_clear_long_key( $key, $column ); |
| 2724 | 2258 | } |
| @@ -2769,18 +2303,15 @@ | ||
| 2769 | 2303 | * The database limit is 100 for form and field keys so we want to avoid getting too close. |
| 2770 | 2304 | * |
| 2771 | 2305 | * @param string $column |
| 2772 | 2306 | * @param string $key |
| 2773 | - * | |
| 2774 | 2307 | * @return string |
| 2775 | 2308 | */ |
| 2776 | 2309 | private static function maybe_truncate_key_before_appending( $column, $key ) { |
| 2777 | 2310 | if ( in_array( $column, array( 'form_key', 'field_key' ), true ) ) { |
| 2778 | 2311 | $max_key_length_before_truncating = 60; |
| 2779 | - | |
| 2780 | 2312 | if ( strlen( $key ) > $max_key_length_before_truncating ) { |
| 2781 | 2313 | $key = substr( $key, 0, $max_key_length_before_truncating ); |
| 2782 | - | |
| 2783 | 2314 | if ( is_numeric( $key ) ) { |
| 2784 | 2315 | $key .= 'a'; |
| 2785 | 2316 | } |
| 2786 | 2317 | } |
| @@ -2792,9 +2323,8 @@ | ||
| 2792 | 2323 | * Possibly reset a key to avoid conflicts with column size limits. |
| 2793 | 2324 | * |
| 2794 | 2325 | * @param string $key |
| 2795 | 2326 | * @param string $column |
| 2796 | - * | |
| 2797 | 2327 | * @return string either the original key value, or an empty string if the key was too long. |
| 2798 | 2328 | */ |
| 2799 | 2329 | private static function maybe_clear_long_key( $key, $column ) { |
| 2800 | 2330 | if ( 'field_key' === $column && strlen( $key ) >= 70 ) { |
| @@ -2803,25 +2333,21 @@ | ||
| 2803 | 2333 | return $key; |
| 2804 | 2334 | } |
| 2805 | 2335 | |
| 2806 | 2336 | /** |
| 2807 | - * @since 6.21 This is changed from `private` to `public`. | |
| 2808 | - * | |
| 2809 | 2337 | * @param int $num_chars |
| 2810 | - * | |
| 2811 | 2338 | * @return string |
| 2812 | 2339 | */ |
| 2813 | - public static function generate_new_key( $num_chars ) { | |
| 2814 | - $max_slug_value = 36 ** $num_chars; | |
| 2340 | + private static function generate_new_key( $num_chars ) { | |
| 2341 | + $max_slug_value = pow( 36, $num_chars ); | |
| 2815 | 2342 | |
| 2816 | 2343 | // We want to have at least 2 characters in the slug. |
| 2817 | 2344 | $min_slug_value = 37; |
| 2818 | - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 2345 | + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 2819 | 2346 | } |
| 2820 | 2347 | |
| 2821 | 2348 | /** |
| 2822 | 2349 | * @param string $key |
| 2823 | - * | |
| 2824 | 2350 | * @return string |
| 2825 | 2351 | */ |
| 2826 | 2352 | private static function prevent_numeric_and_reserved_keys( $key ) { |
| 2827 | 2353 | if ( is_numeric( $key ) ) { |
| @@ -2835,9 +2361,8 @@ | ||
| 2835 | 2361 | 'editlink', |
| 2836 | 2362 | 'siteurl', |
| 2837 | 2363 | 'evenodd', |
| 2838 | 2364 | ); |
| 2839 | - | |
| 2840 | 2365 | if ( in_array( $key, $not_allowed, true ) ) { |
| 2841 | 2366 | $key .= 'a'; |
| 2842 | 2367 | } |
| 2843 | 2368 | } |
| @@ -2870,9 +2395,9 @@ | ||
| 2870 | 2395 | 'fields' => array(), |
| 2871 | 2396 | ); |
| 2872 | 2397 | |
| 2873 | 2398 | foreach ( array( 'name', 'description' ) as $var ) { |
| 2874 | - $default_val = $record->{$var} ?? ''; | |
| 2399 | + $default_val = isset( $record->{$var} ) ? $record->{$var} : ''; | |
| 2875 | 2400 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 2876 | 2401 | unset( $var, $default_val ); |
| 2877 | 2402 | } |
| 2878 | 2403 | |
| @@ -2890,16 +2415,8 @@ | ||
| 2890 | 2415 | |
| 2891 | 2416 | return $values; |
| 2892 | 2417 | } |
| 2893 | 2418 | |
| 2894 | - /** | |
| 2895 | - * @param array|string $fields | |
| 2896 | - * @param object $record | |
| 2897 | - * @param array $values | |
| 2898 | - * @param array $args | |
| 2899 | - * | |
| 2900 | - * @return void | |
| 2901 | - */ | |
| 2902 | 2419 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 2903 | 2420 | if ( ! empty( $fields ) ) { |
| 2904 | 2421 | foreach ( (array) $fields as $field ) { |
| 2905 | 2422 | if ( ! self::is_admin_page() ) { |
| @@ -2905,22 +2422,14 @@ | ||
| 2905 | 2422 | if ( ! self::is_admin_page() ) { |
| 2906 | 2423 | // Don't prep default values on the form settings page. |
| 2907 | 2424 | $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
| 2908 | 2425 | } |
| 2909 | - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id; | |
| 2426 | + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; | |
| 2910 | 2427 | self::fill_field_defaults( $field, $record, $values, $args ); |
| 2911 | 2428 | } |
| 2912 | 2429 | } |
| 2913 | 2430 | } |
| 2914 | 2431 | |
| 2915 | - /** | |
| 2916 | - * @param object $field | |
| 2917 | - * @param object $record | |
| 2918 | - * @param array $values | |
| 2919 | - * @param array $args | |
| 2920 | - * | |
| 2921 | - * @return void | |
| 2922 | - */ | |
| 2923 | 2432 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 2924 | 2433 | $post_values = $args['post_values']; |
| 2925 | 2434 | |
| 2926 | 2435 | if ( $args['default'] ) { |
| @@ -2928,9 +2437,8 @@ | ||
| 2928 | 2437 | } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 2929 | 2438 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 2930 | 2439 | $field->field_options['custom_field'] = ''; |
| 2931 | 2440 | } |
| 2932 | - | |
| 2933 | 2441 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 2934 | 2442 | $record->post_id, |
| 2935 | 2443 | $field->field_options['post_field'], |
| 2936 | 2444 | $field->field_options['custom_field'], |
| @@ -2944,10 +2452,9 @@ | ||
| 2944 | 2452 | } else { |
| 2945 | 2453 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 2946 | 2454 | }//end if |
| 2947 | 2455 | |
| 2948 | - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type; | |
| 2949 | - | |
| 2456 | + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; | |
| 2950 | 2457 | if ( isset( $post_values['item_meta'][ $field->id ] ) ) { |
| 2951 | 2458 | $new_value = $post_values['item_meta'][ $field->id ]; |
| 2952 | 2459 | self::unserialize_or_decode( $new_value ); |
| 2953 | 2460 | } else { |
| @@ -3031,13 +2538,8 @@ | ||
| 3031 | 2538 | } |
| 3032 | 2539 | |
| 3033 | 2540 | /** |
| 3034 | 2541 | * Set to POST value or default |
| 3035 | - * | |
| 3036 | - * @param array $post_values | |
| 3037 | - * @param array $values | |
| 3038 | - * | |
| 3039 | - * @return void | |
| 3040 | 2542 | */ |
| 3041 | 2543 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 3042 | 2544 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 3043 | 2545 | |
| @@ -3054,9 +2556,9 @@ | ||
| 3054 | 2556 | } |
| 3055 | 2557 | |
| 3056 | 2558 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 3057 | 2559 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 3058 | - $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) ); | |
| 2560 | + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); | |
| 3059 | 2561 | } |
| 3060 | 2562 | unset( $h ); |
| 3061 | 2563 | } |
| 3062 | 2564 | } |
| @@ -3083,9 +2585,8 @@ | ||
| 3083 | 2585 | * @param mixed $original_string |
| 3084 | 2586 | * @param int|string $length |
| 3085 | 2587 | * @param int $minword |
| 3086 | 2588 | * @param string $continue |
| 3087 | - * | |
| 3088 | 2589 | * @return string |
| 3089 | 2590 | */ |
| 3090 | 2591 | public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) { |
| 3091 | 2592 | if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) { |
| @@ -3114,11 +2615,10 @@ | ||
| 3114 | 2615 | return $original_string; |
| 3115 | 2616 | } |
| 3116 | 2617 | |
| 3117 | 2618 | foreach ( $words as $word ) { |
| 3118 | - $part = ( $sub !== '' ? ' ' : '' ) . $word; | |
| 2619 | + $part = ( $sub != '' ? ' ' : '' ) . $word; | |
| 3119 | 2620 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 3120 | - | |
| 3121 | 2621 | if ( $total_len > $length && substr_count( $sub, ' ' ) ) { |
| 3122 | 2622 | break; |
| 3123 | 2623 | } |
| 3124 | 2624 | |
| @@ -3143,9 +2643,8 @@ | ||
| 3143 | 2643 | * @since 6.5.4 |
| 3144 | 2644 | * |
| 3145 | 2645 | * @param string $sub Current substring. |
| 3146 | 2646 | * @param int $length The length limit. |
| 3147 | - * | |
| 3148 | 2647 | * @return string |
| 3149 | 2648 | */ |
| 3150 | 2649 | private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) { |
| 3151 | 2650 | if ( strlen( $sub ) < $length + 50 ) { |
| @@ -3153,9 +2652,8 @@ | ||
| 3153 | 2652 | return $sub; |
| 3154 | 2653 | } |
| 3155 | 2654 | |
| 3156 | 2655 | $first_space = strpos( $sub, ' ', $length ); |
| 3157 | - | |
| 3158 | 2656 | if ( false !== $first_space ) { |
| 3159 | 2657 | // Ignore anything with spaces. |
| 3160 | 2658 | return $sub; |
| 3161 | 2659 | } |
| @@ -3162,18 +2660,11 @@ | ||
| 3162 | 2660 | |
| 3163 | 2661 | return substr( $sub, 0, $length + 10 ); |
| 3164 | 2662 | } |
| 3165 | 2663 | |
| 3166 | - /** | |
| 3167 | - * @param array $function_names | |
| 3168 | - * @param array $args | |
| 3169 | - * | |
| 3170 | - * @return mixed | |
| 3171 | - */ | |
| 3172 | 2664 | public static function mb_function( $function_names, $args ) { |
| 3173 | 2665 | $mb_function_name = $function_names[0]; |
| 3174 | 2666 | $function_name = $function_names[1]; |
| 3175 | - | |
| 3176 | 2667 | if ( function_exists( $mb_function_name ) ) { |
| 3177 | 2668 | $function_name = $mb_function_name; |
| 3178 | 2669 | } |
| 3179 | 2670 | |
| @@ -3179,15 +2670,8 @@ | ||
| 3179 | 2670 | |
| 3180 | 2671 | return call_user_func_array( $function_name, $args ); |
| 3181 | 2672 | } |
| 3182 | 2673 | |
| 3183 | - /** | |
| 3184 | - * @param string $date | |
| 3185 | - * @param string $date_format | |
| 3186 | - * @param string $time_format | |
| 3187 | - * | |
| 3188 | - * @return string | |
| 3189 | - */ | |
| 3190 | 2674 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 3191 | 2675 | if ( empty( $date ) ) { |
| 3192 | 2676 | return $date; |
| 3193 | 2677 | } |
| @@ -3202,10 +2686,9 @@ | ||
| 3202 | 2686 | } |
| 3203 | 2687 | |
| 3204 | 2688 | $formatted = self::get_localized_date( $date_format, $date ); |
| 3205 | 2689 | |
| 3206 | - $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) !== '00:00:00' ); | |
| 3207 | - | |
| 2690 | + $do_time = ( gmdate( 'H:i:s', strtotime( $date ) ) != '00:00:00' ); | |
| 3208 | 2691 | if ( $do_time ) { |
| 3209 | 2692 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 3210 | 2693 | } |
| 3211 | 2694 | |
| @@ -3211,14 +2694,8 @@ | ||
| 3211 | 2694 | |
| 3212 | 2695 | return $formatted; |
| 3213 | 2696 | } |
| 3214 | 2697 | |
| 3215 | - /** | |
| 3216 | - * @param string $time_format | |
| 3217 | - * @param string $date | |
| 3218 | - * | |
| 3219 | - * @return string | |
| 3220 | - */ | |
| 3221 | 2698 | private static function add_time_to_date( $time_format, $date ) { |
| 3222 | 2699 | if ( empty( $time_format ) ) { |
| 3223 | 2700 | $time_format = get_option( 'time_format' ); |
| 3224 | 2701 | } |
| @@ -3224,9 +2701,8 @@ | ||
| 3224 | 2701 | } |
| 3225 | 2702 | |
| 3226 | 2703 | $trimmed_format = trim( $time_format ); |
| 3227 | 2704 | $time = ''; |
| 3228 | - | |
| 3229 | 2705 | if ( $time_format && ! empty( $trimmed_format ) ) { |
| 3230 | 2706 | $time = ' ' . __( 'at', 'formidable' ) . ' ' . self::get_localized_date( $time_format, $date ); |
| 3231 | 2707 | } |
| 3232 | 2708 | |
| @@ -3234,13 +2710,8 @@ | ||
| 3234 | 2710 | } |
| 3235 | 2711 | |
| 3236 | 2712 | /** |
| 3237 | 2713 | * @since 2.0.8 |
| 3238 | - * | |
| 3239 | - * @param string $date_format | |
| 3240 | - * @param string $date | |
| 3241 | - * | |
| 3242 | - * @return string | |
| 3243 | 2714 | */ |
| 3244 | 2715 | public static function get_localized_date( $date_format, $date ) { |
| 3245 | 2716 | $date = get_date_from_gmt( $date ); |
| 3246 | 2717 | |
| @@ -3249,11 +2720,10 @@ | ||
| 3249 | 2720 | |
| 3250 | 2721 | /** |
| 3251 | 2722 | * Gets the time ago in words. |
| 3252 | 2723 | * |
| 3253 | - * @param int $from In seconds. | |
| 3254 | - * @param int|string $to In seconds. | |
| 3255 | - * @param int|string $levels Number of time units to include or a specific unit. | |
| 2724 | + * @param int $from In seconds. | |
| 2725 | + * @param int|string $to In seconds. | |
| 3256 | 2726 | * |
| 3257 | 2727 | * @return string $time_ago |
| 3258 | 2728 | */ |
| 3259 | 2729 | public static function human_time_diff( $from, $to = '', $levels = 1 ) { |
| @@ -3261,9 +2731,8 @@ | ||
| 3261 | 2731 | $now = new DateTime(); |
| 3262 | 2732 | } else { |
| 3263 | 2733 | $now = new DateTime( '@' . $to ); |
| 3264 | 2734 | } |
| 3265 | - | |
| 3266 | 2735 | $ago = new DateTime( '@' . $from ); |
| 3267 | 2736 | |
| 3268 | 2737 | // Get the time difference |
| 3269 | 2738 | $diff_object = $now->diff( $ago ); |
| @@ -3277,9 +2746,8 @@ | ||
| 3277 | 2746 | |
| 3278 | 2747 | if ( ! is_numeric( $levels ) ) { |
| 3279 | 2748 | // Show time in specified unit. |
| 3280 | 2749 | $levels = self::get_unit( $levels ); |
| 3281 | - | |
| 3282 | 2750 | if ( isset( $time_strings[ $levels ] ) ) { |
| 3283 | 2751 | $diff = array( |
| 3284 | 2752 | $levels => self::time_format( $levels, $diff ), |
| 3285 | 2753 | ); |
| @@ -3286,9 +2754,8 @@ | ||
| 3286 | 2754 | $time_strings = array( |
| 3287 | 2755 | $levels => $time_strings[ $levels ], |
| 3288 | 2756 | ); |
| 3289 | 2757 | } |
| 3290 | - | |
| 3291 | 2758 | $levels = 1; |
| 3292 | 2759 | } |
| 3293 | 2760 | |
| 3294 | 2761 | foreach ( $time_strings as $k => $v ) { |
| @@ -3310,13 +2777,8 @@ | ||
| 3310 | 2777 | } |
| 3311 | 2778 | |
| 3312 | 2779 | /** |
| 3313 | 2780 | * @since 4.05.01 |
| 3314 | - * | |
| 3315 | - * @param string $unit | |
| 3316 | - * @param array $diff | |
| 3317 | - * | |
| 3318 | - * @return int | |
| 3319 | 2781 | */ |
| 3320 | 2782 | private static function time_format( $unit, $diff ) { |
| 3321 | 2783 | $return = array( |
| 3322 | 2784 | 'y' => 'y', |
| @@ -3321,9 +2783,8 @@ | ||
| 3321 | 2783 | $return = array( |
| 3322 | 2784 | 'y' => 'y', |
| 3323 | 2785 | 'd' => 'days', |
| 3324 | 2786 | ); |
| 3325 | - | |
| 3326 | 2787 | if ( isset( $return[ $unit ] ) ) { |
| 3327 | 2788 | return $diff[ $return[ $unit ] ]; |
| 3328 | 2789 | } |
| 3329 | 2790 | |
| @@ -3343,13 +2804,8 @@ | ||
| 3343 | 2804 | } |
| 3344 | 2805 | |
| 3345 | 2806 | /** |
| 3346 | 2807 | * @since 4.05.01 |
| 3347 | - * | |
| 3348 | - * @param string $from | |
| 3349 | - * @param string $to | |
| 3350 | - * | |
| 3351 | - * @return int | |
| 3352 | 2808 | */ |
| 3353 | 2809 | private static function convert_time( $from, $to ) { |
| 3354 | 2810 | $convert = array( |
| 3355 | 2811 | 's' => 1, |
| @@ -3365,16 +2821,11 @@ | ||
| 3365 | 2821 | } |
| 3366 | 2822 | |
| 3367 | 2823 | /** |
| 3368 | 2824 | * @since 4.05.01 |
| 3369 | - * | |
| 3370 | - * @param string $unit | |
| 3371 | - * | |
| 3372 | - * @return int|string | |
| 3373 | 2825 | */ |
| 3374 | 2826 | private static function get_unit( $unit ) { |
| 3375 | 2827 | $units = self::get_time_strings(); |
| 3376 | - | |
| 3377 | 2828 | if ( isset( $units[ $unit ] ) || is_numeric( $unit ) ) { |
| 3378 | 2829 | return $unit; |
| 3379 | 2830 | } |
| 3380 | 2831 | |
| @@ -3390,9 +2841,8 @@ | ||
| 3390 | 2841 | * Get the translatable time strings. The untranslated version is a failsafe |
| 3391 | 2842 | * in case languages are changing for the unit set in the shortcode. |
| 3392 | 2843 | * |
| 3393 | 2844 | * @since 2.0.20 |
| 3394 | - * | |
| 3395 | 2845 | * @return array |
| 3396 | 2846 | */ |
| 3397 | 2847 | private static function get_time_strings() { |
| 3398 | 2848 | return array( |
| @@ -3439,9 +2889,8 @@ | ||
| 3439 | 2889 | /** |
| 3440 | 2890 | * @param int $r_count |
| 3441 | 2891 | * @param int $current_p |
| 3442 | 2892 | * @param int $p_size |
| 3443 | - * | |
| 3444 | 2893 | * @return int |
| 3445 | 2894 | */ |
| 3446 | 2895 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 3447 | 2896 | return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size ); |
| @@ -3450,9 +2899,8 @@ | ||
| 3450 | 2899 | /** |
| 3451 | 2900 | * @param int $r_count |
| 3452 | 2901 | * @param int $current_p |
| 3453 | 2902 | * @param int $p_size |
| 3454 | - * | |
| 3455 | 2903 | * @return int |
| 3456 | 2904 | */ |
| 3457 | 2905 | public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
| 3458 | 2906 | if ( $current_p == 1 ) { |
| @@ -3461,22 +2909,17 @@ | ||
| 3461 | 2909 | return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1; |
| 3462 | 2910 | } |
| 3463 | 2911 | |
| 3464 | 2912 | /** |
| 3465 | - * @param array $json_vars | |
| 3466 | - * | |
| 3467 | 2913 | * @return array |
| 3468 | 2914 | */ |
| 3469 | 2915 | public static function json_to_array( $json_vars ) { |
| 3470 | 2916 | $vars = array(); |
| 3471 | - | |
| 3472 | 2917 | foreach ( $json_vars as $jv ) { |
| 3473 | 2918 | $jv_name = explode( '[', $jv['name'] ); |
| 3474 | 2919 | $last = count( $jv_name ) - 1; |
| 3475 | - | |
| 3476 | 2920 | foreach ( $jv_name as $p => $n ) { |
| 3477 | 2921 | $name = trim( $n, ']' ); |
| 3478 | - | |
| 3479 | 2922 | if ( ! isset( $l1 ) ) { |
| 3480 | 2923 | $l1 = $name; |
| 3481 | 2924 | } |
| 3482 | 2925 | |
| @@ -3522,12 +2965,8 @@ | ||
| 3522 | 2965 | |
| 3523 | 2966 | /** |
| 3524 | 2967 | * @param string $name |
| 3525 | 2968 | * @param string $l1 |
| 3526 | - * @param mixed $val | |
| 3527 | - * @param array $vars | |
| 3528 | - * | |
| 3529 | - * @return void | |
| 3530 | 2969 | */ |
| 3531 | 2970 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 3532 | 2971 | if ( $name == '' ) { |
| 3533 | 2972 | $vars[] = $val; |
| @@ -3535,19 +2974,12 @@ | ||
| 3535 | 2974 | $vars[ $l1 ] = $val; |
| 3536 | 2975 | } |
| 3537 | 2976 | } |
| 3538 | 2977 | |
| 3539 | - /** | |
| 3540 | - * @param string $name | |
| 3541 | - * @param string $class | |
| 3542 | - * @param string $form_name | |
| 3543 | - * | |
| 3544 | - * @return void | |
| 3545 | - */ | |
| 3546 | 2978 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 3547 | 2979 | $tooltips = array( |
| 3548 | 2980 | 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
| 3549 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [default-email] is the address set in the global "Default Email Address" settings.', 'formidable' ), | |
| 2981 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com. [admin_email] is the address set in WP General Settings.', 'formidable' ), | |
| 3550 | 2982 | 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), |
| 3551 | 2983 | 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), |
| 3552 | 2984 | 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), |
| 3553 | 2985 | 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ), |
| @@ -3574,14 +3006,8 @@ | ||
| 3574 | 3006 | } |
| 3575 | 3007 | |
| 3576 | 3008 | /** |
| 3577 | 3009 | * Add the current_page class to that page in the form nav |
| 3578 | - * | |
| 3579 | - * @param int|string $page | |
| 3580 | - * @param int|string $current_page | |
| 3581 | - * @param array $action | |
| 3582 | - * | |
| 3583 | - * @return void | |
| 3584 | 3010 | */ |
| 3585 | 3011 | public static function select_current_page( $page, $current_page, $action = array() ) { |
| 3586 | 3012 | if ( $current_page != $page ) { |
| 3587 | 3013 | return; |
| @@ -3587,9 +3013,8 @@ | ||
| 3587 | 3013 | return; |
| 3588 | 3014 | } |
| 3589 | 3015 | |
| 3590 | 3016 | $frm_action = self::simple_get( 'frm_action', 'sanitize_title' ); |
| 3591 | - | |
| 3592 | 3017 | if ( 'lite-reports' === $frm_action ) { |
| 3593 | 3018 | $frm_action = 'reports'; |
| 3594 | 3019 | } |
| 3595 | 3020 | |
| @@ -3630,15 +3055,8 @@ | ||
| 3630 | 3055 | |
| 3631 | 3056 | return $post_content; |
| 3632 | 3057 | } |
| 3633 | 3058 | |
| 3634 | - /** | |
| 3635 | - * @param array|string $val | |
| 3636 | - * @param int|string $key | |
| 3637 | - * @param array $post_content | |
| 3638 | - * | |
| 3639 | - * @return void | |
| 3640 | - */ | |
| 3641 | 3059 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 3642 | 3060 | if ( ! isset( $post_content[ $key ] ) || is_numeric( $val ) ) { |
| 3643 | 3061 | return; |
| 3644 | 3062 | } |
| @@ -3663,9 +3081,8 @@ | ||
| 3663 | 3081 | * |
| 3664 | 3082 | * @since 4.02.03 |
| 3665 | 3083 | * |
| 3666 | 3084 | * @param array|string $value |
| 3667 | - * | |
| 3668 | 3085 | * @return void |
| 3669 | 3086 | */ |
| 3670 | 3087 | public static function unserialize_or_decode( &$value ) { |
| 3671 | 3088 | if ( is_array( $value ) ) { |
| @@ -3685,9 +3102,8 @@ | ||
| 3685 | 3102 | * |
| 3686 | 3103 | * @since 6.2 |
| 3687 | 3104 | * |
| 3688 | 3105 | * @param mixed $value |
| 3689 | - * | |
| 3690 | 3106 | * @return mixed |
| 3691 | 3107 | */ |
| 3692 | 3108 | public static function maybe_unserialize_array( $value ) { |
| 3693 | 3109 | if ( ! is_string( $value ) ) { |
| @@ -3699,9 +3115,8 @@ | ||
| 3699 | 3115 | return $value; |
| 3700 | 3116 | } |
| 3701 | 3117 | |
| 3702 | 3118 | $parsed = FrmSerializedStringParserHelper::get()->parse( $value ); |
| 3703 | - | |
| 3704 | 3119 | if ( is_array( $parsed ) ) { |
| 3705 | 3120 | $value = $parsed; |
| 3706 | 3121 | } |
| 3707 | 3122 | |
| @@ -3713,9 +3128,8 @@ | ||
| 3713 | 3128 | * Do not switch shortcodes like [24] to array unless intentional ie XML values. |
| 3714 | 3129 | * |
| 3715 | 3130 | * @param mixed $string |
| 3716 | 3131 | * @param bool $single_to_array |
| 3717 | - * | |
| 3718 | 3132 | * @return mixed |
| 3719 | 3133 | */ |
| 3720 | 3134 | public static function maybe_json_decode( $string, $single_to_array = true ) { |
| 3721 | 3135 | if ( is_array( $string ) || is_null( $string ) ) { |
| @@ -3722,17 +3136,14 @@ | ||
| 3722 | 3136 | return $string; |
| 3723 | 3137 | } |
| 3724 | 3138 | |
| 3725 | 3139 | $new_string = json_decode( $string, true ); |
| 3726 | - | |
| 3727 | 3140 | if ( function_exists( 'json_last_error' ) ) { |
| 3728 | 3141 | // php 5.3+ |
| 3729 | 3142 | $single_value = false; |
| 3730 | - | |
| 3731 | 3143 | if ( ! $single_to_array ) { |
| 3732 | 3144 | $single_value = is_array( $new_string ) && count( $new_string ) === 1 && isset( $new_string[0] ); |
| 3733 | 3145 | } |
| 3734 | - | |
| 3735 | 3146 | if ( json_last_error() == JSON_ERROR_NONE && is_array( $new_string ) && ! $single_value ) { |
| 3736 | 3147 | $string = $new_string; |
| 3737 | 3148 | } |
| 3738 | 3149 | } |
| @@ -3743,9 +3154,8 @@ | ||
| 3743 | 3154 | /** |
| 3744 | 3155 | * @since 6.2.3 |
| 3745 | 3156 | * |
| 3746 | 3157 | * @param string $value |
| 3747 | - * | |
| 3748 | 3158 | * @return string |
| 3749 | 3159 | */ |
| 3750 | 3160 | public static function maybe_utf8_encode( $value ) { |
| 3751 | 3161 | $from_format = 'ISO-8859-1'; |
| @@ -3759,9 +3169,8 @@ | ||
| 3759 | 3169 | } |
| 3760 | 3170 | |
| 3761 | 3171 | if ( function_exists( 'iconv' ) ) { |
| 3762 | 3172 | $converted = iconv( $from_format, $to_format, $value ); |
| 3763 | - | |
| 3764 | 3173 | // Value is false if $value is not ISO-8859-1. |
| 3765 | 3174 | if ( false !== $converted ) { |
| 3766 | 3175 | return $converted; |
| 3767 | 3176 | } |
| @@ -3773,12 +3182,8 @@ | ||
| 3773 | 3182 | /** |
| 3774 | 3183 | * Reformat the json serialized array in name => value array. |
| 3775 | 3184 | * |
| 3776 | 3185 | * @since 4.02.03 |
| 3777 | - * | |
| 3778 | - * @param array $form | |
| 3779 | - * | |
| 3780 | - * @return void | |
| 3781 | 3186 | */ |
| 3782 | 3187 | public static function format_form_data( &$form ) { |
| 3783 | 3188 | $formatted = array(); |
| 3784 | 3189 | |
| @@ -3785,11 +3190,9 @@ | ||
| 3785 | 3190 | foreach ( $form as $input ) { |
| 3786 | 3191 | if ( ! isset( $input['name'] ) ) { |
| 3787 | 3192 | continue; |
| 3788 | 3193 | } |
| 3789 | - | |
| 3790 | 3194 | $key = $input['name']; |
| 3791 | - | |
| 3792 | 3195 | if ( isset( $formatted[ $key ] ) ) { |
| 3793 | 3196 | if ( is_array( $formatted[ $key ] ) ) { |
| 3794 | 3197 | $formatted[ $key ][] = $input['value']; |
| 3795 | 3198 | } else { |
| @@ -3806,9 +3209,8 @@ | ||
| 3806 | 3209 | /** |
| 3807 | 3210 | * @since 4.02.03 |
| 3808 | 3211 | * |
| 3809 | 3212 | * @param array|string $value |
| 3810 | - * | |
| 3811 | 3213 | * @return string |
| 3812 | 3214 | */ |
| 3813 | 3215 | public static function maybe_json_encode( $value ) { |
| 3814 | 3216 | if ( is_array( $value ) ) { |
| @@ -3822,9 +3224,8 @@ | ||
| 3822 | 3224 | * |
| 3823 | 3225 | * @since 1.07.10 |
| 3824 | 3226 | * |
| 3825 | 3227 | * @param string $post_type The name of the post type that may need to be highlighted. |
| 3826 | - * | |
| 3827 | 3228 | * @return void |
| 3828 | 3229 | */ |
| 3829 | 3230 | public static function maybe_highlight_menu( $post_type ) { |
| 3830 | 3231 | global $post; |
| @@ -3846,9 +3247,8 @@ | ||
| 3846 | 3247 | * |
| 3847 | 3248 | * @since 2.0 |
| 3848 | 3249 | * |
| 3849 | 3250 | * @param bool $load |
| 3850 | - * | |
| 3851 | 3251 | * @return void |
| 3852 | 3252 | */ |
| 3853 | 3253 | public static function load_admin_wide_js( $load = true ) { |
| 3854 | 3254 | $version = self::plugin_version(); |
| @@ -3874,9 +3274,8 @@ | ||
| 3874 | 3274 | } |
| 3875 | 3275 | |
| 3876 | 3276 | /** |
| 3877 | 3277 | * @since 2.0.9 |
| 3878 | - * | |
| 3879 | 3278 | * @return void |
| 3880 | 3279 | */ |
| 3881 | 3280 | public static function load_font_style() { |
| 3882 | 3281 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| @@ -3883,9 +3282,8 @@ | ||
| 3883 | 3282 | } |
| 3884 | 3283 | |
| 3885 | 3284 | /** |
| 3886 | 3285 | * @param string $location |
| 3887 | - * | |
| 3888 | 3286 | * @return void |
| 3889 | 3287 | */ |
| 3890 | 3288 | public static function localize_script( $location ) { |
| 3891 | 3289 | global $wp_scripts, $wp_version; |
| @@ -3908,9 +3306,8 @@ | ||
| 3908 | 3306 | 'include_resend_email' => false, |
| 3909 | 3307 | ); |
| 3910 | 3308 | |
| 3911 | 3309 | $data = $wp_scripts->get_data( 'formidable', 'data' ); |
| 3912 | - | |
| 3913 | 3310 | if ( ! $data ) { |
| 3914 | 3311 | wp_localize_script( 'formidable', 'frm_js', $script_strings ); |
| 3915 | 3312 | } |
| 3916 | 3313 | |
| @@ -3917,9 +3314,9 @@ | ||
| 3917 | 3314 | if ( $location === 'admin' ) { |
| 3918 | 3315 | $admin_script_strings = array( |
| 3919 | 3316 | 'desc' => __( '(Click to add description)', 'formidable' ), |
| 3920 | 3317 | 'blank' => __( '(Blank)', 'formidable' ), |
| 3921 | - 'no_label' => self::get_no_label_text(), | |
| 3318 | + 'no_label' => __( '(no label)', 'formidable' ), | |
| 3922 | 3319 | 'ok' => __( 'OK', 'formidable' ), |
| 3923 | 3320 | 'cancel' => __( 'Cancel', 'formidable' ), |
| 3924 | 3321 | 'default_label' => __( 'Default', 'formidable' ), |
| 3925 | 3322 | 'clear_default' => __( 'Clear default value when typing', 'formidable' ), |
| @@ -3987,9 +3384,8 @@ | ||
| 3987 | 3384 | */ |
| 3988 | 3385 | $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings ); |
| 3989 | 3386 | |
| 3990 | 3387 | $data = $wp_scripts->get_data( 'formidable_admin', 'data' ); |
| 3991 | - | |
| 3992 | 3388 | if ( ! $data ) { |
| 3993 | 3389 | wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings ); |
| 3994 | 3390 | } |
| 3995 | 3391 | }//end if |
| @@ -3995,19 +3391,8 @@ | ||
| 3995 | 3391 | }//end if |
| 3996 | 3392 | } |
| 3997 | 3393 | |
| 3998 | 3394 | /** |
| 3999 | - * Get the no label text. | |
| 4000 | - * | |
| 4001 | - * @since 6.25.1 | |
| 4002 | - * | |
| 4003 | - * @return string | |
| 4004 | - */ | |
| 4005 | - public static function get_no_label_text() { | |
| 4006 | - return __( '(no label)', 'formidable' ); | |
| 4007 | - } | |
| 4008 | - | |
| 4009 | - /** | |
| 4010 | 3395 | * @since 6.5 |
| 4011 | 3396 | * |
| 4012 | 3397 | * @return string |
| 4013 | 3398 | */ |
| @@ -4049,9 +3434,8 @@ | ||
| 4049 | 3434 | * |
| 4050 | 3435 | * @since 1.07.10 |
| 4051 | 3436 | * |
| 4052 | 3437 | * @param float $min_version The version the add-on requires. |
| 4053 | - * | |
| 4054 | 3438 | * @return void |
| 4055 | 3439 | */ |
| 4056 | 3440 | public static function min_version_notice( $min_version ) { |
| 4057 | 3441 | $frm_version = self::plugin_version(); |
| @@ -4071,10 +3455,8 @@ | ||
| 4071 | 3455 | * If Pro is far outdated, show a message. |
| 4072 | 3456 | * |
| 4073 | 3457 | * @since 4.0.01 |
| 4074 | 3458 | * |
| 4075 | - * @param string $min_version | |
| 4076 | - * | |
| 4077 | 3459 | * @return void |
| 4078 | 3460 | */ |
| 4079 | 3461 | public static function min_pro_version_notice( $min_version ) { |
| 4080 | 3462 | if ( ! self::is_formidable_admin() ) { |
| @@ -4084,14 +3466,25 @@ | ||
| 4084 | 3466 | |
| 4085 | 3467 | self::php_version_notice(); |
| 4086 | 3468 | |
| 4087 | 3469 | $is_pro = self::pro_is_installed() && class_exists( 'FrmProDb' ); |
| 4088 | - | |
| 4089 | 3470 | if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) { |
| 4090 | 3471 | return; |
| 4091 | 3472 | } |
| 4092 | 3473 | |
| 4093 | - include self::plugin_path() . '/classes/views/addons/min-version-notice.php'; | |
| 3474 | + $expired = FrmAddonsController::is_license_expired(); | |
| 3475 | + ?> | |
| 3476 | + <div class="frm-banner-alert frm_error_style frm_previous_install"> | |
| 3477 | + <?php | |
| 3478 | + esc_html_e( 'You are running a version of Formidable Forms that may not be compatible with your version of Formidable Forms Pro.', 'formidable' ); | |
| 3479 | + if ( empty( $expired ) ) { | |
| 3480 | + echo ' Please <a href="' . esc_url( admin_url( 'plugins.php?s=formidable%20forms%20pro' ) ) . '">update now</a>.'; | |
| 3481 | + } else { | |
| 3482 | + echo '<br/>Please <a href="https://formidableforms.com/account/downloads/?utm_source=WordPress&utm_medium=outdated">renew now</a> to get the latest version.'; | |
| 3483 | + } | |
| 3484 | + ?> | |
| 3485 | + </div> | |
| 3486 | + <?php | |
| 4094 | 3487 | } |
| 4095 | 3488 | |
| 4096 | 3489 | /** |
| 4097 | 3490 | * If Pro is installed, check the version number. |
| @@ -4098,9 +3491,8 @@ | ||
| 4098 | 3491 | * |
| 4099 | 3492 | * @since 4.0.01 |
| 4100 | 3493 | * |
| 4101 | 3494 | * @param string $min_version |
| 4102 | - * | |
| 4103 | 3495 | * @return bool |
| 4104 | 3496 | */ |
| 4105 | 3497 | public static function meets_min_pro_version( $min_version ) { |
| 4106 | 3498 | return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' ); |
| @@ -4109,14 +3501,12 @@ | ||
| 4109 | 3501 | /** |
| 4110 | 3502 | * Show a message if the PHP version is below the recommendations. |
| 4111 | 3503 | * |
| 4112 | 3504 | * @since 4.0.02 |
| 4113 | - * | |
| 4114 | 3505 | * @return void |
| 4115 | 3506 | */ |
| 4116 | 3507 | private static function php_version_notice() { |
| 4117 | 3508 | $message = array(); |
| 4118 | - | |
| 4119 | 3509 | if ( version_compare( phpversion(), '7.0', '<' ) ) { |
| 4120 | 3510 | $message[] = __( 'The version of PHP on your server is too low. If this is not corrected, you may see issues with Formidable Forms. Please contact your web host and ask to be updated to PHP 7.0+.', 'formidable' ); |
| 4121 | 3511 | } |
| 4122 | 3512 | |
| @@ -4130,9 +3520,8 @@ | ||
| 4130 | 3520 | } |
| 4131 | 3521 | |
| 4132 | 3522 | /** |
| 4133 | 3523 | * @param string $type |
| 4134 | - * | |
| 4135 | 3524 | * @return array<string,string> |
| 4136 | 3525 | */ |
| 4137 | 3526 | public static function locales( $type = 'date' ) { |
| 4138 | 3527 | $locales = array( |
| @@ -4242,9 +3631,8 @@ | ||
| 4242 | 3631 | * @since 5.4.5 Added $args parameter with type. |
| 4243 | 3632 | * |
| 4244 | 3633 | * @param array<string,string> $locales |
| 4245 | 3634 | * @param array $args { |
| 4246 | - * | |
| 4247 | 3635 | * @type string $type |
| 4248 | 3636 | * } |
| 4249 | 3637 | */ |
| 4250 | 3638 | $locales = apply_filters( 'frm_locales', $locales, compact( 'type' ) ); |
| @@ -4257,9 +3645,8 @@ | ||
| 4257 | 3645 | */ |
| 4258 | 3646 | public static function get_menu_icon_class() { |
| 4259 | 3647 | if ( is_callable( 'FrmProAppHelper::get_settings' ) ) { |
| 4260 | 3648 | $settings = FrmProAppHelper::get_settings(); |
| 4261 | - | |
| 4262 | 3649 | if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) { |
| 4263 | 3650 | return $settings->menu_icon; |
| 4264 | 3651 | } |
| 4265 | 3652 | } |
| @@ -4305,9 +3692,8 @@ | ||
| 4305 | 3692 | * |
| 4306 | 3693 | * @since 5.0.04 |
| 4307 | 3694 | * |
| 4308 | 3695 | * @param array $args The arguments. |
| 4309 | - * | |
| 4310 | 3696 | * @return array |
| 4311 | 3697 | */ |
| 4312 | 3698 | private static function fill_default_images_dropdown_args( $args ) { |
| 4313 | 3699 | $defaults = array( |
| @@ -4320,8 +3706,14 @@ | ||
| 4320 | 3706 | |
| 4321 | 3707 | $new_args['options'] = (array) $new_args['options']; |
| 4322 | 3708 | $new_args['input_attrs'] = (array) $new_args['input_attrs']; |
| 4323 | 3709 | |
| 3710 | + // Set the number of columns. | |
| 3711 | + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) ); | |
| 3712 | + if ( $new_args['col_class'] > 6 ) { | |
| 3713 | + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 ); | |
| 3714 | + } | |
| 3715 | + | |
| 4324 | 3716 | /** |
| 4325 | 3717 | * Allows modifying the arguments of images_dropdown() method. |
| 4326 | 3718 | * |
| 4327 | 3719 | * @since 5.0.04 |
| @@ -4337,9 +3729,8 @@ | ||
| 4337 | 3729 | * |
| 4338 | 3730 | * @since 5.0.04 |
| 4339 | 3731 | * |
| 4340 | 3732 | * @param array $args The arguments. |
| 4341 | - * | |
| 4342 | 3733 | * @return string |
| 4343 | 3734 | */ |
| 4344 | 3735 | private static function get_images_dropdown_input_attrs( $args ) { |
| 4345 | 3736 | $input_attrs = $args['input_attrs']; |
| @@ -4346,9 +3737,8 @@ | ||
| 4346 | 3737 | $input_attrs['type'] = 'radio'; |
| 4347 | 3738 | $input_attrs['name'] = $args['name']; |
| 4348 | 3739 | |
| 4349 | 3740 | $input_attrs_str = ''; |
| 4350 | - | |
| 4351 | 3741 | foreach ( $input_attrs as $key => $input_attr ) { |
| 4352 | 3742 | $input_attrs_str .= ' ' . sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $input_attr ) ); |
| 4353 | 3743 | } |
| 4354 | 3744 | |
| @@ -4364,13 +3754,8 @@ | ||
| 4364 | 3754 | } |
| 4365 | 3755 | |
| 4366 | 3756 | /** |
| 4367 | 3757 | * @since 6.7.1 |
| 4368 | - * | |
| 4369 | - * @param array $option Option data. | |
| 4370 | - * @param array $args The arguments of images_dropdown() method. | |
| 4371 | - * | |
| 4372 | - * @return array | |
| 4373 | 3758 | */ |
| 4374 | 3759 | public static function get_images_dropdown_atts( $option, $args ) { |
| 4375 | 3760 | $image = self::get_images_dropdown_option_image( $option, $args ); |
| 4376 | 3761 | $classes = self::get_images_dropdown_option_classes( $option, $args ); |
| @@ -4384,9 +3769,8 @@ | ||
| 4384 | 3769 | * @since 5.0.04 |
| 4385 | 3770 | * |
| 4386 | 3771 | * @param array $option Option data. |
| 4387 | 3772 | * @param array $args The arguments of images_dropdown() method. |
| 4388 | - * | |
| 4389 | 3773 | * @return string |
| 4390 | 3774 | */ |
| 4391 | 3775 | private static function get_images_dropdown_option_image( $option, $args ) { |
| 4392 | 3776 | $image = self::icon_by_class( |
| @@ -4415,9 +3799,8 @@ | ||
| 4415 | 3799 | * @since 5.0.04 |
| 4416 | 3800 | * |
| 4417 | 3801 | * @param array $option Option data. |
| 4418 | 3802 | * @param array $args The arguments of images_dropdown() method. |
| 4419 | - * | |
| 4420 | 3803 | * @return string |
| 4421 | 3804 | */ |
| 4422 | 3805 | private static function get_images_dropdown_option_classes( $option, $args ) { |
| 4423 | 3806 | $classes = ''; |
| @@ -4445,14 +3828,12 @@ | ||
| 4445 | 3828 | * @since 5.0.04 |
| 4446 | 3829 | * |
| 4447 | 3830 | * @param array $option Option data. |
| 4448 | 3831 | * @param array $args The arguments of images_dropdown() method. |
| 4449 | - * | |
| 4450 | 3832 | * @return string |
| 4451 | 3833 | */ |
| 4452 | 3834 | private static function get_images_dropdown_option_html_attrs( $option, $args ) { |
| 4453 | 3835 | $html_attrs = ''; |
| 4454 | - | |
| 4455 | 3836 | if ( ! empty( $option['custom_attrs'] ) && is_array( $option['custom_attrs'] ) ) { |
| 4456 | 3837 | $html_attrs_arr = array(); |
| 4457 | 3838 | |
| 4458 | 3839 | foreach ( $option['custom_attrs'] as $key => $value ) { |
| @@ -4515,9 +3896,8 @@ | ||
| 4515 | 3896 | * @since 5.0.07 |
| 4516 | 3897 | * |
| 4517 | 3898 | * @param array $values |
| 4518 | 3899 | * @param array $keys |
| 4519 | - * | |
| 4520 | 3900 | * @return array |
| 4521 | 3901 | */ |
| 4522 | 3902 | public static function maybe_filter_array( $values, $keys ) { |
| 4523 | 3903 | $allow_unfiltered_html = self::allow_unfiltered_html(); |
| @@ -4542,9 +3922,8 @@ | ||
| 4542 | 3922 | * @since 5.0.13 |
| 4543 | 3923 | * |
| 4544 | 3924 | * @param string $value |
| 4545 | 3925 | * @param array|string $allowed 'all' for everything included as defaults. |
| 4546 | - * | |
| 4547 | 3926 | * @return string |
| 4548 | 3927 | */ |
| 4549 | 3928 | public static function maybe_kses( $value, $allowed = 'all' ) { |
| 4550 | 3929 | if ( self::should_never_allow_unfiltered_html() ) { |
| @@ -4559,9 +3938,8 @@ | ||
| 4559 | 3938 | * @since 6.11.2 |
| 4560 | 3939 | * |
| 4561 | 3940 | * @param string $key |
| 4562 | 3941 | * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed. |
| 4563 | - * | |
| 4564 | 3942 | * @return bool |
| 4565 | 3943 | */ |
| 4566 | 3944 | public static function input_key_is_safe( $key, $context = 'display' ) { |
| 4567 | 3945 | if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) { |
| @@ -4612,9 +3990,16 @@ | ||
| 4612 | 3990 | |
| 4613 | 3991 | /** |
| 4614 | 3992 | * @since 5.0.16 |
| 4615 | 3993 | * |
| 4616 | - * @param string $medium | |
| 3994 | + * @return bool | |
| 3995 | + */ | |
| 3996 | + public static function show_landing_pages() { | |
| 3997 | + return self::show_new_feature( 'landing' ); | |
| 3998 | + } | |
| 3999 | + | |
| 4000 | + /** | |
| 4001 | + * @since 5.0.16 | |
| 4617 | 4002 | * |
| 4618 | 4003 | * @return array |
| 4619 | 4004 | */ |
| 4620 | 4005 | public static function get_landing_page_upgrade_data_params( $medium = 'landing' ) { |
| @@ -4622,9 +4007,8 @@ | ||
| 4622 | 4007 | 'medium' => $medium, |
| 4623 | 4008 | 'upgrade' => __( 'Form Landing Pages', 'formidable' ), |
| 4624 | 4009 | 'message' => __( 'Easily manage a landing page for your form. Upgrade to get form landing pages.', 'formidable' ), |
| 4625 | 4010 | 'screenshot' => 'landing.png', |
| 4626 | - 'learn-more' => self::get_doc_url( 'landing-page-forms', 'form-landing-page-settings', false ), | |
| 4627 | 4011 | ); |
| 4628 | 4012 | return self::get_upgrade_data_params( 'landing', $params ); |
| 4629 | 4013 | } |
| 4630 | 4014 | |
| @@ -4631,9 +4015,8 @@ | ||
| 4631 | 4015 | /** |
| 4632 | 4016 | * @since 5.0.17 |
| 4633 | 4017 | * |
| 4634 | 4018 | * @param string $feature |
| 4635 | - * | |
| 4636 | 4019 | * @return bool |
| 4637 | 4020 | */ |
| 4638 | 4021 | public static function show_new_feature( $feature ) { |
| 4639 | 4022 | $link = FrmAddonsController::install_link( $feature ); |
| @@ -4640,21 +4023,16 @@ | ||
| 4640 | 4023 | return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link ); |
| 4641 | 4024 | } |
| 4642 | 4025 | |
| 4643 | 4026 | /** |
| 4644 | - * Enhances upgrade data parameters with installation link and plan requirement information. | |
| 4645 | - * | |
| 4646 | 4027 | * @since 5.0.17 |
| 4647 | 4028 | * |
| 4648 | - * @param string $plugin The plugin slug to get installation data for. | |
| 4649 | - * @param array $params Initial parameters for the upgrade data. | |
| 4650 | - * @param bool $detailed Whether to include detailed information. | |
| 4651 | - * | |
| 4652 | - * @return array Modified parameters with installation data. | |
| 4029 | + * @param string $plugin | |
| 4030 | + * @param array $params | |
| 4031 | + * @return array | |
| 4653 | 4032 | */ |
| 4654 | - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) { | |
| 4033 | + public static function get_upgrade_data_params( $plugin, $params ) { | |
| 4655 | 4034 | $link = FrmAddonsController::install_link( $plugin ); |
| 4656 | - | |
| 4657 | 4035 | if ( ! $link ) { |
| 4658 | 4036 | return $params; |
| 4659 | 4037 | } |
| 4660 | 4038 | |
| @@ -4660,20 +4038,15 @@ | ||
| 4660 | 4038 | |
| 4661 | 4039 | if ( ! empty( $link['url'] ) && self::pro_is_installed() ) { |
| 4662 | 4040 | $params['oneclick'] = json_encode( $link ); |
| 4663 | 4041 | unset( $params['message'] ); |
| 4664 | - | |
| 4665 | 4042 | if ( ! isset( $params['medium'] ) ) { |
| 4666 | 4043 | $params['medium'] = $plugin; |
| 4667 | 4044 | } |
| 4668 | 4045 | } else { |
| 4669 | - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link ); | |
| 4046 | + $params['requires'] = FrmFormsHelper::get_plan_required( $link ); | |
| 4670 | 4047 | } |
| 4671 | 4048 | |
| 4672 | - if ( $detailed ) { | |
| 4673 | - $params['plugin-status'] = $link['status'] ?? ''; | |
| 4674 | - } | |
| 4675 | - | |
| 4676 | 4049 | return $params; |
| 4677 | 4050 | } |
| 4678 | 4051 | |
| 4679 | 4052 | /** |
| @@ -4682,9 +4055,8 @@ | ||
| 4682 | 4055 | * |
| 4683 | 4056 | * @since 5.0.17 |
| 4684 | 4057 | * |
| 4685 | 4058 | * @param string $text |
| 4686 | - * | |
| 4687 | 4059 | * @return bool |
| 4688 | 4060 | */ |
| 4689 | 4061 | public static function ctype_xdigit( $text ) { |
| 4690 | 4062 | if ( function_exists( 'ctype_xdigit' ) ) { |
| @@ -4699,9 +4071,8 @@ | ||
| 4699 | 4071 | * @since 5.2.01 |
| 4700 | 4072 | */ |
| 4701 | 4073 | public static function set_current_screen_and_hook_suffix() { |
| 4702 | 4074 | global $hook_suffix; |
| 4703 | - | |
| 4704 | 4075 | if ( is_null( $hook_suffix ) ) { |
| 4705 | 4076 | // $hook_suffix gets used in substr so make sure it's not null. PHP 8.1 deprecates null in substr. |
| 4706 | 4077 | $hook_suffix = ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 4707 | 4078 | } |
| @@ -4727,9 +4098,8 @@ | ||
| 4727 | 4098 | * |
| 4728 | 4099 | * @since 5.2.07 |
| 4729 | 4100 | * |
| 4730 | 4101 | * @param mixed $num Number. |
| 4731 | - * | |
| 4732 | 4102 | * @return false|int Returns `false` if the passed parameter is not number. |
| 4733 | 4103 | */ |
| 4734 | 4104 | public static function count_decimals( $num ) { |
| 4735 | 4105 | if ( ! is_numeric( $num ) ) { |
| @@ -4737,9 +4107,8 @@ | ||
| 4737 | 4107 | } |
| 4738 | 4108 | |
| 4739 | 4109 | $num = (string) $num; |
| 4740 | 4110 | $parts = explode( '.', $num ); |
| 4741 | - | |
| 4742 | 4111 | if ( 1 === count( $parts ) ) { |
| 4743 | 4112 | return 0; |
| 4744 | 4113 | } |
| 4745 | 4114 | |
| @@ -4821,20 +4190,17 @@ | ||
| 4821 | 4190 | * @since 5.5.5 |
| 4822 | 4191 | * |
| 4823 | 4192 | * @param string $url |
| 4824 | 4193 | * @param string $expected_extension |
| 4825 | - * | |
| 4826 | 4194 | * @return bool |
| 4827 | 4195 | */ |
| 4828 | 4196 | public static function validate_url_is_in_s3_bucket( $url, $expected_extension ) { |
| 4829 | 4197 | $file_is_in_expected_s3_bucket = 0 === strpos( $url, 'https://s3.amazonaws.com/fp.strategy11.com' ); |
| 4830 | - | |
| 4831 | 4198 | if ( ! $file_is_in_expected_s3_bucket ) { |
| 4832 | 4199 | return false; |
| 4833 | 4200 | } |
| 4834 | 4201 | |
| 4835 | 4202 | $parsed = parse_url( $url ); |
| 4836 | - | |
| 4837 | 4203 | if ( ! is_array( $parsed ) ) { |
| 4838 | 4204 | // URL is malformed. |
| 4839 | 4205 | return false; |
| 4840 | 4206 | } |
| @@ -4840,9 +4206,8 @@ | ||
| 4840 | 4206 | } |
| 4841 | 4207 | |
| 4842 | 4208 | $path = $parsed['path']; |
| 4843 | 4209 | $ext = pathinfo( $path, PATHINFO_EXTENSION ); |
| 4844 | - | |
| 4845 | 4210 | if ( $expected_extension !== $ext ) { |
| 4846 | 4211 | // The URL isn't to an XML file. |
| 4847 | 4212 | return false; |
| 4848 | 4213 | } |
| @@ -4856,9 +4221,8 @@ | ||
| 4856 | 4221 | * @since 6.3 |
| 4857 | 4222 | * |
| 4858 | 4223 | * @param string $message The warning message to display. |
| 4859 | 4224 | * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action. |
| 4860 | - * | |
| 4861 | 4225 | * @return void |
| 4862 | 4226 | */ |
| 4863 | 4227 | public static function add_dismissable_warning_message( $message = '', $option = '' ) { |
| 4864 | 4228 | if ( ! $message || ! $option ) { |
| @@ -4901,9 +4265,8 @@ | ||
| 4901 | 4265 | * |
| 4902 | 4266 | * @since 6.3 |
| 4903 | 4267 | * |
| 4904 | 4268 | * @param string $option The unique identifier for the dismissal state of the message. |
| 4905 | - * | |
| 4906 | 4269 | * @return void |
| 4907 | 4270 | */ |
| 4908 | 4271 | public static function dismiss_warning_message( $option = '' ) { |
| 4909 | 4272 | self::permission_check( 'frm_change_settings' ); |
| @@ -4926,8 +4289,16 @@ | ||
| 4926 | 4289 | */ |
| 4927 | 4290 | public static function copy_for_lite_license() { |
| 4928 | 4291 | $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂'; |
| 4929 | 4292 | |
| 4293 | + if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) { | |
| 4294 | + // Manage PRO versions without PRO dashboard functionality. | |
| 4295 | + $license_type = FrmProAddonsController::get_readable_license_type(); | |
| 4296 | + if ( 'lite' !== strtolower( $license_type ) ) { | |
| 4297 | + $message = 'Formidable Pro ' . $license_type; | |
| 4298 | + } | |
| 4299 | + } | |
| 4300 | + | |
| 4930 | 4301 | return apply_filters( 'frm_license_type_text', $message ); |
| 4931 | 4302 | } |
| 4932 | 4303 | |
| 4933 | 4304 | /** |
| @@ -4933,9 +4304,8 @@ | ||
| 4933 | 4304 | /** |
| 4934 | 4305 | * Removes scripts that are unnecessarily loaded across the pages! |
| 4935 | 4306 | * |
| 4936 | 4307 | * @since 6.9 |
| 4937 | - * | |
| 4938 | 4308 | * @return void |
| 4939 | 4309 | */ |
| 4940 | 4310 | public static function dequeue_extra_global_scripts() { |
| 4941 | 4311 | wp_dequeue_script( 'frm-surveys-admin' ); |
| @@ -4953,9 +4323,8 @@ | ||
| 4953 | 4323 | * @return void |
| 4954 | 4324 | */ |
| 4955 | 4325 | public static function tooltip_icon( $tooltip_text, $atts = array() ) { |
| 4956 | 4326 | $atts['title'] = $tooltip_text; |
| 4957 | - | |
| 4958 | 4327 | if ( isset( $atts['class'] ) ) { |
| 4959 | 4328 | $atts['class'] .= ' frm_help'; |
| 4960 | 4329 | } else { |
| 4961 | 4330 | $atts['class'] = 'frm_help'; |
| @@ -5001,84 +4370,6 @@ | ||
| 5001 | 4370 | } |
| 5002 | 4371 | ?> |
| 5003 | 4372 | </span> |
| 5004 | 4373 | <?php |
| 5005 | - } | |
| 5006 | - | |
| 5007 | - /** | |
| 5008 | - * Check if GDPR is enabled. | |
| 5009 | - * | |
| 5010 | - * @since 6.19 | |
| 5011 | - * | |
| 5012 | - * @return bool | |
| 5013 | - */ | |
| 5014 | - public static function is_gdpr_enabled() { | |
| 5015 | - $frm_settings = self::get_settings(); | |
| 5016 | - return $frm_settings->enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies; | |
| 5017 | - } | |
| 5018 | - | |
| 5019 | - /** | |
| 5020 | - * Check if GDPR cookies are disabled. | |
| 5021 | - * | |
| 5022 | - * @since 6.19 | |
| 5023 | - * | |
| 5024 | - * @return bool | |
| 5025 | - */ | |
| 5026 | - public static function no_gdpr_cookies() { | |
| 5027 | - $frm_settings = self::get_settings(); | |
| 5028 | - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies; | |
| 5029 | - } | |
| 5030 | - | |
| 5031 | - /** | |
| 5032 | - * Check if a string is valid UTF-8. | |
| 5033 | - * | |
| 5034 | - * @since 6.24 | |
| 5035 | - * | |
| 5036 | - * @param string $string The string to check. | |
| 5037 | - * | |
| 5038 | - * @return bool | |
| 5039 | - */ | |
| 5040 | - public static function is_valid_utf8( $string ) { | |
| 5041 | - // wp_is_valid_utf8 is added in WP 6.9. | |
| 5042 | - if ( function_exists( 'wp_is_valid_utf8' ) ) { | |
| 5043 | - return wp_is_valid_utf8( $string ); | |
| 5044 | - } | |
| 5045 | - | |
| 5046 | - // As of WP 6.9, seems_utf8 is deprecated. | |
| 5047 | - if ( function_exists( 'seems_utf8' ) ) { | |
| 5048 | - return seems_utf8( $string ); | |
| 5049 | - } | |
| 5050 | - return false; | |
| 5051 | - } | |
| 5052 | - | |
| 5053 | - /** | |
| 5054 | - * Get a documentation URL with UTM parameters and affiliate tracking. | |
| 5055 | - * | |
| 5056 | - * @since 6.26 | |
| 5057 | - * | |
| 5058 | - * @param string $path The relative path to append to the base URL. | |
| 5059 | - * @param string $campaign The campaign to use for UTM parameters. | |
| 5060 | - * @param bool $add_kb_base Whether to prepend 'knowledgebase/' to the path. Default true. | |
| 5061 | - * | |
| 5062 | - * @return string The processed URL with UTM parameters and affiliate tracking. | |
| 5063 | - */ | |
| 5064 | - public static function get_doc_url( $path, $campaign, $add_kb_base = true ) { | |
| 5065 | - $path = trim( $path, '/' ); | |
| 5066 | - | |
| 5067 | - if ( $add_kb_base ) { | |
| 5068 | - $path = 'knowledgebase/' . $path; | |
| 5069 | - } | |
| 5070 | - | |
| 5071 | - return self::maybe_add_missing_utm( 'https://formidableforms.com/' . $path, array( 'campaign' => $campaign ) ); | |
| 5072 | - } | |
| 5073 | - | |
| 5074 | - /** | |
| 5075 | - * @since 5.0.16 | |
| 5076 | - * @deprecated 6.26 | |
| 5077 | - * | |
| 5078 | - * @return bool | |
| 5079 | - */ | |
| 5080 | - public static function show_landing_pages() { | |
| 5081 | - _deprecated_function( __METHOD__, '6.26' ); | |
| 5082 | - return true; | |
| 5083 | 4374 | } |
| 5084 | 4375 | } |