| @@ -3,43 +3,27 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmAppHelper { |
| 7 | + public static $db_version = 98; // Version of the database we are moving to. | |
| 8 | + public static $pro_db_version = 37; //deprecated | |
| 9 | + public static $font_version = 7; | |
| 7 | 10 | |
| 8 | 11 | /** |
| 9 | - * Version of the database we are moving to. | |
| 10 | - * | |
| 11 | - * @var int | |
| 12 | + * @var bool $added_gmt_offset_filter | |
| 12 | 13 | */ |
| 13 | - public static $db_version = 104; | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * Used by the API add-on. | |
| 17 | - * | |
| 18 | - * @var float | |
| 19 | - */ | |
| 20 | - public static $font_version = 7; | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * @var bool | |
| 24 | - */ | |
| 25 | 14 | private static $added_gmt_offset_filter = false; |
| 26 | 15 | |
| 27 | 16 | /** |
| 28 | 17 | * @since 2.0 |
| 29 | - * | |
| 30 | - * @var string | |
| 31 | 18 | */ |
| 32 | - public static $plug_version = '6.25'; | |
| 19 | + public static $plug_version = '6.0'; | |
| 33 | 20 | |
| 34 | 21 | /** |
| 35 | - * @var bool | |
| 36 | - */ | |
| 37 | - private static $included_svg = false; | |
| 38 | - | |
| 39 | - /** | |
| 40 | 22 | * @since 1.07.02 |
| 41 | 23 | * |
| 24 | + * @param none | |
| 25 | + * | |
| 42 | 26 | * @return string The version of this plugin |
| 43 | 27 | */ |
| 44 | 28 | public static function plugin_version() { |
| 45 | 29 | return self::$plug_version; |
| @@ -44,33 +28,21 @@ | ||
| 44 | 28 | public static function plugin_version() { |
| 45 | 29 | return self::$plug_version; |
| 46 | 30 | } |
| 47 | 31 | |
| 48 | - /** | |
| 49 | - * @return string | |
| 50 | - */ | |
| 51 | 32 | public static function plugin_folder() { |
| 52 | 33 | return basename( self::plugin_path() ); |
| 53 | 34 | } |
| 54 | 35 | |
| 55 | - /** | |
| 56 | - * @return string | |
| 57 | - */ | |
| 58 | 36 | public static function plugin_path() { |
| 59 | - return dirname( __DIR__, 2 ); | |
| 37 | + return dirname( dirname( dirname( __FILE__ ) ) ); | |
| 60 | 38 | } |
| 61 | 39 | |
| 62 | - /** | |
| 63 | - * @return string | |
| 64 | - */ | |
| 65 | 40 | public static function plugin_url() { |
| 66 | - // Previously FRM_URL constant. | |
| 41 | + // Prevously FRM_URL constant. | |
| 67 | 42 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 68 | 43 | } |
| 69 | 44 | |
| 70 | - /** | |
| 71 | - * @return string | |
| 72 | - */ | |
| 73 | 45 | public static function relative_plugin_url() { |
| 74 | 46 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 75 | 47 | } |
| 76 | 48 | |
| @@ -91,12 +63,8 @@ | ||
| 91 | 63 | public static function site_name() { |
| 92 | 64 | return get_option( 'blogname' ); |
| 93 | 65 | } |
| 94 | 66 | |
| 95 | - /** | |
| 96 | - * @param string $url | |
| 97 | - * @return string | |
| 98 | - */ | |
| 99 | 67 | public static function make_affiliate_url( $url ) { |
| 100 | 68 | $affiliate_id = self::get_affiliate(); |
| 101 | 69 | if ( ! empty( $affiliate_id ) ) { |
| 102 | 70 | $url = str_replace( array( 'http://', 'https://' ), '', $url ); |
| @@ -105,11 +73,8 @@ | ||
| 105 | 73 | |
| 106 | 74 | return $url; |
| 107 | 75 | } |
| 108 | 76 | |
| 109 | - /** | |
| 110 | - * @return int | |
| 111 | - */ | |
| 112 | 77 | public static function get_affiliate() { |
| 113 | 78 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 114 | 79 | } |
| 115 | 80 | |
| @@ -127,9 +92,9 @@ | ||
| 127 | 92 | } |
| 128 | 93 | |
| 129 | 94 | $anchor = ''; |
| 130 | 95 | if ( is_array( $args ) ) { |
| 131 | - $medium = $args['medium'] ?? ''; | |
| 96 | + $medium = $args['medium']; | |
| 132 | 97 | if ( isset( $args['content'] ) ) { |
| 133 | 98 | $content = $args['content']; |
| 134 | 99 | } |
| 135 | 100 | if ( isset( $args['anchor'] ) ) { |
| @@ -161,42 +126,14 @@ | ||
| 161 | 126 | return self::make_affiliate_url( $link ); |
| 162 | 127 | } |
| 163 | 128 | |
| 164 | 129 | /** |
| 165 | - * @since 6.21 | |
| 166 | - * | |
| 167 | - * @param string $cta_link | |
| 168 | - * @param array $utm | |
| 169 | - */ | |
| 170 | - public static function maybe_add_missing_utm( $cta_link, $utm ) { | |
| 171 | - $query_args = array(); | |
| 172 | - | |
| 173 | - if ( false === strpos( $cta_link, 'utm_source' ) ) { | |
| 174 | - $query_args['utm_source'] = 'WordPress'; | |
| 175 | - } | |
| 176 | - | |
| 177 | - if ( false === strpos( $cta_link, 'utm_campaign' ) ) { | |
| 178 | - $query_args['utm_campaign'] = 'liteplugin'; | |
| 179 | - } | |
| 180 | - | |
| 181 | - if ( false === strpos( $cta_link, 'utm_medium' ) && isset( $utm['medium'] ) ) { | |
| 182 | - $query_args['utm_medium'] = $utm['medium']; | |
| 183 | - } | |
| 184 | - | |
| 185 | - if ( false === strpos( $cta_link, 'utm_content' ) && isset( $utm['content'] ) ) { | |
| 186 | - $query_args['utm_content'] = $utm['content']; | |
| 187 | - } | |
| 188 | - | |
| 189 | - return $query_args ? add_query_arg( $query_args, $cta_link ) : $cta_link; | |
| 190 | - } | |
| 191 | - | |
| 192 | - /** | |
| 193 | 130 | * Get the Formidable settings |
| 194 | 131 | * |
| 195 | 132 | * @since 2.0 |
| 196 | 133 | * |
| 197 | 134 | * @param array $args - May include the form id when values need translation. |
| 198 | - * @return FrmSettings $frm_settings | |
| 135 | + * @return FrmSettings $frm_setings | |
| 199 | 136 | */ |
| 200 | 137 | public static function get_settings( $args = array() ) { |
| 201 | 138 | global $frm_settings; |
| 202 | 139 | if ( empty( $frm_settings ) ) { |
| @@ -208,39 +145,16 @@ | ||
| 208 | 145 | |
| 209 | 146 | return $frm_settings; |
| 210 | 147 | } |
| 211 | 148 | |
| 212 | - /** | |
| 213 | - * @return string | |
| 214 | - */ | |
| 215 | 149 | public static function get_menu_name() { |
| 216 | 150 | $frm_settings = self::get_settings(); |
| 217 | 151 | |
| 218 | - return FrmAddonsController::is_license_expired() || ! self::pro_is_installed() ? 'Formidable' : $frm_settings->menu; | |
| 152 | + return $frm_settings->menu; | |
| 219 | 153 | } |
| 220 | 154 | |
| 221 | 155 | /** |
| 222 | - * Determine if the current branding is set to 'formidable'. | |
| 223 | - * Checks the menu icon, and verifies if it matches the formidable branding. | |
| 224 | - * | |
| 225 | - * @since 6.4.2 | |
| 226 | - * | |
| 227 | - * @return bool True if the menu icon is the logo, false otherwise. | |
| 228 | - */ | |
| 229 | - public static function is_formidable_branding() { | |
| 230 | - if ( ! self::pro_is_installed() ) { | |
| 231 | - return true; | |
| 232 | - } | |
| 233 | - | |
| 234 | - $menu_icon = self::get_menu_icon_class(); | |
| 235 | - return strpos( $menu_icon, 'frm_logo_icon' ) !== false; | |
| 236 | - } | |
| 237 | - | |
| 238 | - /** | |
| 239 | 156 | * @since 3.05 |
| 240 | - * | |
| 241 | - * @param array $atts | |
| 242 | - * @return string | |
| 243 | 157 | */ |
| 244 | 158 | public static function svg_logo( $atts = array() ) { |
| 245 | 159 | $defaults = array( |
| 246 | 160 | 'height' => 18, |
| @@ -257,11 +171,8 @@ | ||
| 257 | 171 | } |
| 258 | 172 | |
| 259 | 173 | /** |
| 260 | 174 | * @since 4.0 |
| 261 | - * | |
| 262 | - * @param array $atts | |
| 263 | - * @return void | |
| 264 | 175 | */ |
| 265 | 176 | public static function show_logo( $atts = array() ) { |
| 266 | 177 | echo self::kses( self::svg_logo( $atts ), 'all' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 267 | 178 | } |
| @@ -267,10 +178,8 @@ | ||
| 267 | 178 | } |
| 268 | 179 | |
| 269 | 180 | /** |
| 270 | 181 | * @since 4.03.02 |
| 271 | - * | |
| 272 | - * @return void | |
| 273 | 182 | */ |
| 274 | 183 | public static function show_header_logo() { |
| 275 | 184 | $icon = self::svg_logo( |
| 276 | 185 | array( |
| @@ -292,38 +201,21 @@ | ||
| 292 | 201 | } |
| 293 | 202 | |
| 294 | 203 | /** |
| 295 | 204 | * @since 2.02.04 |
| 296 | - * | |
| 297 | - * @return bool | |
| 298 | 205 | */ |
| 299 | 206 | public static function ips_saved() { |
| 300 | 207 | $frm_settings = self::get_settings(); |
| 208 | + | |
| 301 | 209 | return ! $frm_settings->no_ips; |
| 302 | 210 | } |
| 303 | 211 | |
| 304 | - /** | |
| 305 | - * @return bool | |
| 306 | - */ | |
| 307 | 212 | public static function pro_is_installed() { |
| 308 | - return (bool) apply_filters( 'frm_pro_installed', false ); | |
| 213 | + return apply_filters( 'frm_pro_installed', false ); | |
| 309 | 214 | } |
| 310 | 215 | |
| 311 | 216 | /** |
| 312 | - * Check if the Pro plugin is installed, whether authorized or not. | |
| 313 | - * | |
| 314 | - * @since 6.8.3 | |
| 315 | - * | |
| 316 | - * @return bool | |
| 317 | - */ | |
| 318 | - public static function pro_is_included() { | |
| 319 | - return function_exists( 'load_formidable_pro' ); | |
| 320 | - } | |
| 321 | - | |
| 322 | - /** | |
| 323 | 217 | * @since 4.06.02 |
| 324 | - * | |
| 325 | - * @return bool | |
| 326 | 218 | */ |
| 327 | 219 | public static function pro_is_connected() { |
| 328 | 220 | global $frm_vars; |
| 329 | 221 | return self::pro_is_installed() && $frm_vars['pro_is_authorized']; |
| @@ -330,26 +222,14 @@ | ||
| 330 | 222 | } |
| 331 | 223 | |
| 332 | 224 | /** |
| 333 | 225 | * @since 4.06 |
| 334 | - * @since 6.16.2 Added $check_for_settings parameter | |
| 335 | - * | |
| 336 | - * @param bool $check_for_settings | |
| 337 | - * | |
| 338 | - * @return bool | |
| 339 | 226 | */ |
| 340 | - public static function is_form_builder_page( $check_for_settings = true ) { | |
| 341 | - $action = self::simple_get( 'frm_action', 'sanitize_title' ); | |
| 342 | - $check_actions = array( 'edit', 'duplicate' ); | |
| 343 | - if ( $check_for_settings ) { | |
| 344 | - $check_actions[] = 'settings'; | |
| 345 | - } | |
| 346 | - return self::is_admin_page( 'formidable' ) && in_array( $action, $check_actions, true ); | |
| 227 | + public static function is_form_builder_page() { | |
| 228 | + $action = self::simple_get( 'frm_action', 'sanitize_title' ); | |
| 229 | + return self::is_admin_page( 'formidable' ) && ( $action === 'edit' || $action === 'settings' || $action === 'duplicate' ); | |
| 347 | 230 | } |
| 348 | 231 | |
| 349 | - /** | |
| 350 | - * @return bool | |
| 351 | - */ | |
| 352 | 232 | public static function is_formidable_admin() { |
| 353 | 233 | $page = self::simple_get( 'page', 'sanitize_title' ); |
| 354 | 234 | $is_formidable = strpos( $page, 'formidable' ) !== false; |
| 355 | 235 | if ( empty( $page ) ) { |
| @@ -359,52 +239,15 @@ | ||
| 359 | 239 | return $is_formidable; |
| 360 | 240 | } |
| 361 | 241 | |
| 362 | 242 | /** |
| 363 | - * Checks if is a list page. | |
| 364 | - * | |
| 365 | - * @since 6.19 | |
| 366 | - * | |
| 367 | - * @param string $page The name of the page to check. | |
| 368 | - * @return bool | |
| 369 | - */ | |
| 370 | - public static function is_admin_list_page( $page = 'formidable' ) { | |
| 371 | - if ( 'formidable' === $page ) { | |
| 372 | - return self::on_form_listing_page(); | |
| 373 | - } | |
| 374 | - | |
| 375 | - if ( ! self::is_admin_page( $page ) ) { | |
| 376 | - return false; | |
| 377 | - } | |
| 378 | - | |
| 379 | - if ( 'formidable-entries' === $page ) { | |
| 380 | - $action = self::simple_get( 'frm_action' ); | |
| 381 | - if ( ! $action || in_array( $action, self::get_entries_listing_page_form_actions(), true ) ) { | |
| 382 | - return true; | |
| 383 | - } | |
| 384 | - } | |
| 385 | - | |
| 386 | - // Check edit or settings page. | |
| 387 | - return ! self::simple_get( 'frm_action' ); | |
| 388 | - } | |
| 389 | - | |
| 390 | - /** | |
| 391 | - * @since 6.20 | |
| 392 | - * | |
| 393 | - * @return array<string> | |
| 394 | - */ | |
| 395 | - private static function get_entries_listing_page_form_actions() { | |
| 396 | - return array( 'list', 'destroy' ); | |
| 397 | - } | |
| 398 | - | |
| 399 | - /** | |
| 400 | 243 | * Check for certain page in Formidable settings |
| 401 | 244 | * |
| 402 | 245 | * @since 2.0 |
| 403 | 246 | * |
| 404 | - * @param string $page The name of the page to check. | |
| 247 | + * @param string $page The name of the page to check | |
| 405 | 248 | * |
| 406 | - * @return bool | |
| 249 | + * @return boolean | |
| 407 | 250 | */ |
| 408 | 251 | public static function is_admin_page( $page = 'formidable' ) { |
| 409 | 252 | global $pagenow; |
| 410 | 253 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| @@ -423,10 +266,8 @@ | ||
| 423 | 266 | * If the current page is for editing or creating a view. |
| 424 | 267 | * Returns false for the views listing page. |
| 425 | 268 | * |
| 426 | 269 | * @since 4.0 |
| 427 | - * | |
| 428 | - * @return bool | |
| 429 | 270 | */ |
| 430 | 271 | public static function is_view_builder_page() { |
| 431 | 272 | global $pagenow; |
| 432 | 273 | |
| @@ -436,10 +277,10 @@ | ||
| 436 | 277 | |
| 437 | 278 | $post_type = self::simple_get( 'post_type', 'sanitize_title' ); |
| 438 | 279 | |
| 439 | 280 | if ( empty( $post_type ) ) { |
| 440 | - $post_id = self::simple_get( 'post', 'absint' ); | |
| 441 | - $post = get_post( $post_id ); | |
| 281 | + $post_id = self::simple_get( 'post', 'absint' ); | |
| 282 | + $post = get_post( $post_id ); | |
| 442 | 283 | $post_type = $post ? $post->post_type : ''; |
| 443 | 284 | } |
| 444 | 285 | |
| 445 | 286 | return $post_type === 'frm_display'; |
| @@ -449,15 +290,17 @@ | ||
| 449 | 290 | * Check for the form preview page |
| 450 | 291 | * |
| 451 | 292 | * @since 2.0 |
| 452 | 293 | * |
| 453 | - * @return bool | |
| 294 | + * @param None | |
| 295 | + * | |
| 296 | + * @return boolean | |
| 454 | 297 | */ |
| 455 | 298 | public static function is_preview_page() { |
| 456 | 299 | global $pagenow; |
| 457 | 300 | $action = self::simple_get( 'action', 'sanitize_title' ); |
| 458 | 301 | |
| 459 | - return $pagenow && $pagenow === 'admin-ajax.php' && $action === 'frm_forms_preview'; | |
| 302 | + return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; | |
| 460 | 303 | } |
| 461 | 304 | |
| 462 | 305 | /** |
| 463 | 306 | * Check for ajax except the form preview page |
| @@ -463,17 +306,16 @@ | ||
| 463 | 306 | * Check for ajax except the form preview page |
| 464 | 307 | * |
| 465 | 308 | * @since 2.0 |
| 466 | 309 | * |
| 467 | - * @return bool | |
| 310 | + * @param None | |
| 311 | + * | |
| 312 | + * @return boolean | |
| 468 | 313 | */ |
| 469 | 314 | public static function doing_ajax() { |
| 470 | 315 | return wp_doing_ajax() && ! self::is_preview_page(); |
| 471 | 316 | } |
| 472 | 317 | |
| 473 | - /** | |
| 474 | - * @return string | |
| 475 | - */ | |
| 476 | 318 | public static function js_suffix() { |
| 477 | 319 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 478 | 320 | } |
| 479 | 321 | |
| @@ -478,13 +320,13 @@ | ||
| 478 | 320 | } |
| 479 | 321 | |
| 480 | 322 | /** |
| 481 | 323 | * @since 2.0.8 |
| 482 | - * @return bool | |
| 483 | 324 | */ |
| 484 | 325 | public static function prevent_caching() { |
| 485 | 326 | global $frm_vars; |
| 486 | - return ! empty( $frm_vars['prevent_caching'] ); | |
| 327 | + | |
| 328 | + return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; | |
| 487 | 329 | } |
| 488 | 330 | |
| 489 | 331 | /** |
| 490 | 332 | * Check if on an admin page |
| @@ -490,9 +332,9 @@ | ||
| 490 | 332 | * Check if on an admin page |
| 491 | 333 | * |
| 492 | 334 | * @since 2.0 |
| 493 | 335 | * |
| 494 | - * @return bool | |
| 336 | + * @return boolean | |
| 495 | 337 | */ |
| 496 | 338 | public static function is_admin() { |
| 497 | 339 | $is_admin = is_admin() && ! wp_doing_ajax(); |
| 498 | 340 | |
| @@ -507,22 +349,17 @@ | ||
| 507 | 349 | * Check if value contains blank value or empty array |
| 508 | 350 | * |
| 509 | 351 | * @since 2.0 |
| 510 | 352 | * |
| 511 | - * @param mixed $value Value to check. | |
| 512 | - * @param string $empty | |
| 353 | + * @param mixed $value - value to check | |
| 354 | + * @param string | |
| 513 | 355 | * |
| 514 | - * @return bool | |
| 356 | + * @return boolean | |
| 515 | 357 | */ |
| 516 | 358 | public static function is_empty_value( $value, $empty = '' ) { |
| 517 | 359 | return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
| 518 | 360 | } |
| 519 | 361 | |
| 520 | - /** | |
| 521 | - * @param mixed $value | |
| 522 | - * @param string $empty | |
| 523 | - * @return bool | |
| 524 | - */ | |
| 525 | 362 | public static function is_not_empty_value( $value, $empty = '' ) { |
| 526 | 363 | return ! self::is_empty_value( $value, $empty ); |
| 527 | 364 | } |
| 528 | 365 | |
| @@ -539,37 +376,26 @@ | ||
| 539 | 376 | return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( wp_unslash( $_SERVER[ $value ] ) ) : ''; |
| 540 | 377 | } |
| 541 | 378 | |
| 542 | 379 | /** |
| 543 | - * Get the server OS | |
| 380 | + * Check for the IP address in several places | |
| 381 | + * Used by [ip] shortcode | |
| 544 | 382 | * |
| 545 | - * @since 6.4.2 | |
| 546 | - * | |
| 547 | - * @return string | |
| 548 | - */ | |
| 549 | - public static function get_server_os() { | |
| 550 | - if ( function_exists( 'php_uname' ) ) { | |
| 551 | - return php_uname( 's' ); | |
| 552 | - } | |
| 553 | - | |
| 554 | - if ( ! defined( 'PHP_OS' ) ) { | |
| 555 | - return ''; | |
| 556 | - } | |
| 557 | - | |
| 558 | - // match the same response for Windows server as php_uname('s') | |
| 559 | - return in_array( PHP_OS, array( 'WIN32', 'WINNT', 'Windows_NT' ), true ) ? 'Windows NT' : PHP_OS; | |
| 560 | - } | |
| 561 | - | |
| 562 | - /** | |
| 563 | - * Check for the IP address in several places (when custom headers are enabled). | |
| 564 | - * Used by [ip] shortcode. | |
| 565 | - * | |
| 566 | 383 | * @return string The IP address of the current user |
| 567 | 384 | */ |
| 568 | 385 | public static function get_ip_address() { |
| 569 | - $ip_options = self::should_use_custom_header_ip() ? self::get_custom_header_keys_for_ip() : array( 'REMOTE_ADDR' ); | |
| 570 | - $ip = ''; | |
| 571 | - | |
| 386 | + $ip_options = array( | |
| 387 | + 'HTTP_CLIENT_IP', | |
| 388 | + 'HTTP_CF_CONNECTING_IP', | |
| 389 | + 'HTTP_X_FORWARDED_FOR', | |
| 390 | + 'HTTP_X_FORWARDED', | |
| 391 | + 'HTTP_X_CLUSTER_CLIENT_IP', | |
| 392 | + 'HTTP_X_REAL_IP', | |
| 393 | + 'HTTP_FORWARDED_FOR', | |
| 394 | + 'HTTP_FORWARDED', | |
| 395 | + 'REMOTE_ADDR', | |
| 396 | + ); | |
| 397 | + $ip = ''; | |
| 572 | 398 | foreach ( $ip_options as $key ) { |
| 573 | 399 | if ( ! isset( $_SERVER[ $key ] ) ) { |
| 574 | 400 | continue; |
| 575 | 401 | } |
| @@ -575,10 +401,9 @@ | ||
| 575 | 401 | } |
| 576 | 402 | |
| 577 | 403 | $key = self::get_server_value( $key ); |
| 578 | 404 | foreach ( explode( ',', $key ) as $ip ) { |
| 579 | - // Just to be safe. | |
| 580 | - $ip = trim( $ip ); | |
| 405 | + $ip = trim( $ip ); // just to be safe. | |
| 581 | 406 | |
| 582 | 407 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 583 | 408 | return sanitize_text_field( $ip ); |
| 584 | 409 | } |
| @@ -587,52 +412,8 @@ | ||
| 587 | 412 | |
| 588 | 413 | return sanitize_text_field( $ip ); |
| 589 | 414 | } |
| 590 | 415 | |
| 591 | - /** | |
| 592 | - * @since 6.1 | |
| 593 | - * | |
| 594 | - * @return array | |
| 595 | - */ | |
| 596 | - public static function get_custom_header_keys_for_ip() { | |
| 597 | - return array( | |
| 598 | - 'HTTP_CLIENT_IP', | |
| 599 | - 'HTTP_CF_CONNECTING_IP', | |
| 600 | - 'HTTP_X_FORWARDED_FOR', | |
| 601 | - 'HTTP_X_FORWARDED', | |
| 602 | - 'HTTP_X_CLUSTER_CLIENT_IP', | |
| 603 | - 'HTTP_X_REAL_IP', | |
| 604 | - 'HTTP_FORWARDED_FOR', | |
| 605 | - 'HTTP_FORWARDED', | |
| 606 | - 'REMOTE_ADDR', | |
| 607 | - ); | |
| 608 | - } | |
| 609 | - | |
| 610 | - /** | |
| 611 | - * Check if we should check every HTTP header or just $_SERVER['REMOTE_ADDR']. | |
| 612 | - * The other HTTP headers can be spoofed so this isn't recommended. | |
| 613 | - * But in some cases (like reverse proxies), the IP may be empty if you use $_SERVER['REMOTE_ADDR']. | |
| 614 | - * | |
| 615 | - * @since 6.1 | |
| 616 | - * | |
| 617 | - * @return bool | |
| 618 | - */ | |
| 619 | - private static function should_use_custom_header_ip() { | |
| 620 | - $settings = self::get_settings(); | |
| 621 | - $should_use_custom_header_ip = ! $settings->no_ips && $settings->custom_header_ip; | |
| 622 | - | |
| 623 | - /** | |
| 624 | - * Filter whether to check spoofable HTTP headers. | |
| 625 | - * This uses the custom_header_ip setting, but it is hidden if the GDPR option is also on. | |
| 626 | - * As the IP is still checked for blacklist checks, someone with the GDPR option may still want to enable this when behind a reverse proxy. | |
| 627 | - * | |
| 628 | - * @since 6.1 | |
| 629 | - * | |
| 630 | - * @param bool $should_use_custom_header_ip | |
| 631 | - */ | |
| 632 | - return apply_filters( 'frm_use_custom_header_ip', $should_use_custom_header_ip ); | |
| 633 | - } | |
| 634 | - | |
| 635 | 416 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 636 | 417 | if ( strpos( $param, '[' ) ) { |
| 637 | 418 | $params = explode( '[', $param ); |
| 638 | 419 | $param = $params[0]; |
| @@ -662,9 +443,9 @@ | ||
| 662 | 443 | continue; |
| 663 | 444 | } |
| 664 | 445 | |
| 665 | 446 | $p = trim( $p, ']' ); |
| 666 | - $value = $value[ $p ] ?? $default; | |
| 447 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; | |
| 667 | 448 | } |
| 668 | 449 | } |
| 669 | 450 | |
| 670 | 451 | return $value; |
| @@ -669,24 +450,15 @@ | ||
| 669 | 450 | |
| 670 | 451 | return $value; |
| 671 | 452 | } |
| 672 | 453 | |
| 673 | - /** | |
| 674 | - * Get a value from $_POST data. | |
| 675 | - * | |
| 676 | - * @param string $param The key we are trying to access data from in $_POST. | |
| 677 | - * @param mixed $default The default if nothing is being sent. | |
| 678 | - * @param callable|string $sanitize Make sure to pass a sanitize method here. This function will NOT sanitize by default. | |
| 679 | - * @param bool $serialized | |
| 680 | - * @return mixed | |
| 681 | - */ | |
| 682 | 454 | public static function get_post_param( $param, $default = '', $sanitize = '', $serialized = false ) { |
| 683 | 455 | return self::get_simple_request( |
| 684 | 456 | array( |
| 685 | - 'type' => 'post', | |
| 686 | - 'param' => $param, | |
| 687 | - 'default' => $default, | |
| 688 | - 'sanitize' => $sanitize, | |
| 457 | + 'type' => 'post', | |
| 458 | + 'param' => $param, | |
| 459 | + 'default' => $default, | |
| 460 | + 'sanitize' => $sanitize, | |
| 689 | 461 | 'serialized' => $serialized, |
| 690 | 462 | ) |
| 691 | 463 | ); |
| 692 | 464 | } |
| @@ -697,9 +469,9 @@ | ||
| 697 | 469 | * @param string $param |
| 698 | 470 | * @param string $sanitize |
| 699 | 471 | * @param string $default |
| 700 | 472 | * |
| 701 | - * @return array|string | |
| 473 | + * @return string|array | |
| 702 | 474 | */ |
| 703 | 475 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 704 | 476 | return self::get_simple_request( |
| 705 | 477 | array( |
| @@ -717,27 +489,27 @@ | ||
| 717 | 489 | * @since 2.0.6 |
| 718 | 490 | * |
| 719 | 491 | * @param array $args |
| 720 | 492 | * |
| 721 | - * @return array|string | |
| 493 | + * @return string|array | |
| 722 | 494 | */ |
| 723 | 495 | public static function get_simple_request( $args ) { |
| 724 | 496 | $defaults = array( |
| 725 | - 'param' => '', | |
| 726 | - 'default' => '', | |
| 727 | - 'type' => 'get', | |
| 728 | - 'sanitize' => 'sanitize_text_field', | |
| 497 | + 'param' => '', | |
| 498 | + 'default' => '', | |
| 499 | + 'type' => 'get', | |
| 500 | + 'sanitize' => 'sanitize_text_field', | |
| 729 | 501 | 'serialized' => false, |
| 730 | 502 | ); |
| 731 | 503 | $args = wp_parse_args( $args, $defaults ); |
| 732 | 504 | |
| 733 | 505 | $value = $args['default']; |
| 734 | - if ( $args['type'] === 'get' ) { | |
| 506 | + if ( $args['type'] == 'get' ) { | |
| 735 | 507 | if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
| 736 | 508 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 737 | 509 | $value = wp_unslash( $_GET[ $args['param'] ] ); |
| 738 | 510 | } |
| 739 | - } elseif ( $args['type'] === 'post' ) { | |
| 511 | + } elseif ( $args['type'] == 'post' ) { | |
| 740 | 512 | if ( isset( $_POST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 741 | 513 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 742 | 514 | $value = wp_unslash( $_POST[ $args['param'] ] ); |
| 743 | 515 | if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) { |
| @@ -743,12 +515,13 @@ | ||
| 743 | 515 | if ( $args['serialized'] === true && is_serialized_string( $value ) && is_serialized( $value ) ) { |
| 744 | 516 | self::unserialize_or_decode( $value ); |
| 745 | 517 | } |
| 746 | 518 | } |
| 747 | - } elseif ( isset( $_REQUEST[ $args['param'] ] ) ) { | |
| 748 | - // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 519 | + } else { | |
| 520 | + if ( isset( $_REQUEST[ $args['param'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 749 | 521 | // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 750 | 522 | $value = wp_unslash( $_REQUEST[ $args['param'] ] ); |
| 523 | + } | |
| 751 | 524 | } |
| 752 | 525 | |
| 753 | 526 | self::sanitize_value( $args['sanitize'], $value ); |
| 754 | 527 | |
| @@ -772,35 +545,19 @@ | ||
| 772 | 545 | |
| 773 | 546 | return $value; |
| 774 | 547 | } |
| 775 | 548 | |
| 776 | - /** | |
| 777 | - * Sanitize a value in-place. | |
| 778 | - * If $value is an array, the sanitize function will get called for each item. | |
| 779 | - * | |
| 780 | - * @param callable $sanitize | |
| 781 | - * @param mixed $value | |
| 782 | - * @return void | |
| 783 | - */ | |
| 784 | 549 | public static function sanitize_value( $sanitize, &$value ) { |
| 785 | - if ( ! $sanitize ) { | |
| 786 | - return; | |
| 787 | - } | |
| 788 | - | |
| 789 | - if ( is_object( $value ) ) { | |
| 790 | - $value = ''; | |
| 791 | - return; | |
| 792 | - } | |
| 793 | - | |
| 794 | - if ( is_array( $value ) ) { | |
| 795 | - $temp_values = $value; | |
| 796 | - foreach ( $temp_values as $k => $v ) { | |
| 797 | - self::sanitize_value( $sanitize, $value[ $k ] ); | |
| 550 | + if ( ! empty( $sanitize ) ) { | |
| 551 | + if ( is_array( $value ) ) { | |
| 552 | + $temp_values = $value; | |
| 553 | + foreach ( $temp_values as $k => $v ) { | |
| 554 | + self::sanitize_value( $sanitize, $value[ $k ] ); | |
| 555 | + } | |
| 556 | + } else { | |
| 557 | + $value = call_user_func( $sanitize, $value ); | |
| 798 | 558 | } |
| 799 | - return; | |
| 800 | 559 | } |
| 801 | - | |
| 802 | - $value = call_user_func( $sanitize, $value ); | |
| 803 | 560 | } |
| 804 | 561 | |
| 805 | 562 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 806 | 563 | $temp_values = $values; |
| @@ -812,52 +569,15 @@ | ||
| 812 | 569 | } |
| 813 | 570 | |
| 814 | 571 | /** |
| 815 | 572 | * @since 4.0.04 |
| 816 | - * | |
| 817 | - * @param mixed $value | |
| 818 | - * @return void | |
| 819 | 573 | */ |
| 820 | 574 | public static function sanitize_with_html( &$value ) { |
| 821 | - if ( current_user_can( 'frm_edit_entries' ) || current_user_can( 'administrator' ) ) { | |
| 822 | - // Only strip unsafe HTML like scripts for a privileged user submitting a form. | |
| 823 | - self::sanitize_value( 'wp_kses_post', $value ); | |
| 824 | - } else { | |
| 825 | - self::sanitize_value( self::class . '::strip_most_html', $value ); | |
| 826 | - } | |
| 575 | + self::sanitize_value( 'wp_kses_post', $value ); | |
| 827 | 576 | self::decode_specialchars( $value ); |
| 828 | 577 | } |
| 829 | 578 | |
| 830 | 579 | /** |
| 831 | - * Allow only a small set of very basic HTML for unprivileged users. | |
| 832 | - * | |
| 833 | - * @since 6.7.1 | |
| 834 | - * | |
| 835 | - * @param string $value | |
| 836 | - */ | |
| 837 | - public static function strip_most_html( $value ) { | |
| 838 | - $allowed_html = array( | |
| 839 | - 'b' => array(), | |
| 840 | - 'br' => array(), | |
| 841 | - 'strong' => array(), | |
| 842 | - 'p' => array(), | |
| 843 | - 'i' => array(), | |
| 844 | - 'ul' => array(), | |
| 845 | - 'ol' => array(), | |
| 846 | - 'li' => array(), | |
| 847 | - ); | |
| 848 | - | |
| 849 | - /** | |
| 850 | - * @since 6.7.1 | |
| 851 | - * | |
| 852 | - * @param array $allowed_html | |
| 853 | - */ | |
| 854 | - $allowed_html = apply_filters( 'frm_allowed_form_input_html', $allowed_html ); | |
| 855 | - | |
| 856 | - return wp_kses( $value, $allowed_html ); | |
| 857 | - } | |
| 858 | - | |
| 859 | - /** | |
| 860 | 580 | * Do wp_specialchars_decode to get back '&' that wp_kses_post might have turned to '&' |
| 861 | 581 | * this MUST be done, else we'll be back to the '& entity' problem. |
| 862 | 582 | * |
| 863 | 583 | * @since 4.0.04 |
| @@ -891,12 +611,10 @@ | ||
| 891 | 611 | $translation = array( |
| 892 | 612 | '"' => '"', |
| 893 | 613 | '"' => '"', |
| 894 | 614 | '"' => '"', |
| 895 | - // The space preserves the HTML. | |
| 896 | - '< ' => '< ', | |
| 897 | - // The space preserves the HTML. | |
| 898 | - '< ' => '< ', | |
| 615 | + '< ' => '< ', // The space preserves the HTML. | |
| 616 | + '< ' => '< ', // The space preserves the HTML. | |
| 899 | 617 | '>' => '>', |
| 900 | 618 | '>' => '>', |
| 901 | 619 | '&' => '&', |
| 902 | 620 | '&' => '&', |
| @@ -923,10 +641,10 @@ | ||
| 923 | 641 | * Sanitize the value, and allow some HTML |
| 924 | 642 | * |
| 925 | 643 | * @since 2.0 |
| 926 | 644 | * |
| 927 | - * @param string $value | |
| 928 | - * @param array|string $allowed 'all' for everything included as defaults. | |
| 645 | + * @param string $value | |
| 646 | + * @param array|string $allowed 'all' for everything included as defaults | |
| 929 | 647 | * |
| 930 | 648 | * @return string |
| 931 | 649 | */ |
| 932 | 650 | public static function kses( $value, $allowed = array() ) { |
| @@ -935,21 +653,8 @@ | ||
| 935 | 653 | return wp_kses( $value, $allowed_html ); |
| 936 | 654 | } |
| 937 | 655 | |
| 938 | 656 | /** |
| 939 | - * Sanitizes and echoes a given value. | |
| 940 | - * | |
| 941 | - * @since 6.18 | |
| 942 | - * | |
| 943 | - * @param string $value The value to sanitize and output. | |
| 944 | - * @param array|string $allowed Allowed HTML tags and attributes. | |
| 945 | - * @return void | |
| 946 | - */ | |
| 947 | - public static function kses_echo( $value, $allowed = array() ) { | |
| 948 | - echo self::kses( $value, $allowed ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 949 | - } | |
| 950 | - | |
| 951 | - /** | |
| 952 | 657 | * The regular kses function strips [button_action] from submit button HTML. |
| 953 | 658 | * |
| 954 | 659 | * @since 5.0.13 |
| 955 | 660 | * |
| @@ -1023,9 +728,9 @@ | ||
| 1023 | 728 | if ( $allowed === 'all' ) { |
| 1024 | 729 | $allowed_html = $html; |
| 1025 | 730 | } elseif ( ! empty( $allowed ) ) { |
| 1026 | 731 | foreach ( (array) $allowed as $a ) { |
| 1027 | - $allowed_html[ $a ] = $html[ $a ] ?? array(); | |
| 732 | + $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); | |
| 1028 | 733 | } |
| 1029 | 734 | } |
| 1030 | 735 | |
| 1031 | 736 | return apply_filters( 'frm_striphtml_allowed_tags', $allowed_html ); |
| @@ -1040,9 +745,9 @@ | ||
| 1040 | 745 | 'id' => true, |
| 1041 | 746 | ); |
| 1042 | 747 | |
| 1043 | 748 | return array( |
| 1044 | - 'a' => array( | |
| 749 | + 'a' => array( | |
| 1045 | 750 | 'class' => true, |
| 1046 | 751 | 'href' => true, |
| 1047 | 752 | 'id' => true, |
| 1048 | 753 | 'rel' => true, |
| @@ -1111,16 +816,16 @@ | ||
| 1111 | 816 | 'cite' => true, |
| 1112 | 817 | 'title' => true, |
| 1113 | 818 | ), |
| 1114 | 819 | 'rect' => array( |
| 1115 | - 'class' => true, | |
| 1116 | - 'fill' => true, | |
| 1117 | - 'height' => true, | |
| 1118 | - 'width' => true, | |
| 1119 | - 'x' => true, | |
| 1120 | - 'y' => true, | |
| 1121 | - 'rx' => true, | |
| 1122 | - 'stroke' => true, | |
| 820 | + 'class' => true, | |
| 821 | + 'fill' => true, | |
| 822 | + 'height' => true, | |
| 823 | + 'width' => true, | |
| 824 | + 'x' => true, | |
| 825 | + 'y' => true, | |
| 826 | + 'rx' => true, | |
| 827 | + 'stroke' => true, | |
| 1123 | 828 | 'stroke-opacity' => true, |
| 1124 | 829 | 'stroke-width' => true, |
| 1125 | 830 | ), |
| 1126 | 831 | 'section' => $allow_class, |
| @@ -1155,9 +860,9 @@ | ||
| 1155 | 860 | 'xlink:href' => true, |
| 1156 | 861 | ), |
| 1157 | 862 | 'ul' => $allow_class, |
| 1158 | 863 | 'label' => array( |
| 1159 | - 'for' => true, | |
| 864 | + 'for' => true, | |
| 1160 | 865 | 'class' => true, |
| 1161 | 866 | 'id' => true, |
| 1162 | 867 | ), |
| 1163 | 868 | 'button' => array( |
| @@ -1166,13 +871,8 @@ | ||
| 1166 | 871 | ), |
| 1167 | 872 | 'legend' => array( |
| 1168 | 873 | 'class' => true, |
| 1169 | 874 | ), |
| 1170 | - 'option' => array( | |
| 1171 | - 'class' => true, | |
| 1172 | - 'value' => true, | |
| 1173 | - 'selected' => true, | |
| 1174 | - ), | |
| 1175 | 875 | ); |
| 1176 | 876 | } |
| 1177 | 877 | |
| 1178 | 878 | /** |
| @@ -1180,9 +880,9 @@ | ||
| 1180 | 880 | * |
| 1181 | 881 | * @since 2.0 |
| 1182 | 882 | */ |
| 1183 | 883 | public static function remove_get_action() { |
| 1184 | - if ( empty( $_GET ) ) { | |
| 884 | + if ( ! isset( $_GET ) ) { | |
| 1185 | 885 | return; |
| 1186 | 886 | } |
| 1187 | 887 | |
| 1188 | 888 | $action_name = isset( $_GET['action'] ) ? 'action' : ( isset( $_GET['action2'] ) ? 'action2' : '' ); |
| @@ -1199,9 +899,9 @@ | ||
| 1199 | 899 | /** |
| 1200 | 900 | * Check the WP query for a parameter |
| 1201 | 901 | * |
| 1202 | 902 | * @since 2.0 |
| 1203 | - * @return array|string | |
| 903 | + * @return string|array | |
| 1204 | 904 | */ |
| 1205 | 905 | public static function get_query_var( $value, $param ) { |
| 1206 | 906 | if ( $value != '' ) { |
| 1207 | 907 | return $value; |
| @@ -1218,12 +918,10 @@ | ||
| 1218 | 918 | /** |
| 1219 | 919 | * Try to show the SVG if possible. Otherwise, use the font icon. |
| 1220 | 920 | * |
| 1221 | 921 | * @since 4.0.02 |
| 1222 | - * | |
| 1223 | 922 | * @param string $class |
| 1224 | 923 | * @param array $atts |
| 1225 | - * @return string|null | |
| 1226 | 924 | */ |
| 1227 | 925 | public static function icon_by_class( $class, $atts = array() ) { |
| 1228 | 926 | $echo = ! isset( $atts['echo'] ) || $atts['echo']; |
| 1229 | 927 | if ( isset( $atts['echo'] ) ) { |
| @@ -1233,16 +931,14 @@ | ||
| 1233 | 931 | $html_atts = self::array_to_html_params( $atts ); |
| 1234 | 932 | |
| 1235 | 933 | $icon = trim( str_replace( array( 'frm_icon_font', 'frmfont ' ), '', $class ) ); |
| 1236 | 934 | |
| 1237 | - // Replace icons that have been removed or renamed. | |
| 935 | + // Replace icons that have been removed. | |
| 1238 | 936 | $deprecated = array( |
| 1239 | - 'frm_clone_solid_icon' => 'frm_clone_icon', | |
| 1240 | - 'frm_keyalt_icon' => 'frm_key_icon', | |
| 1241 | - 'frm_keyalt_solid_icon' => 'frm_key_solid_icon', | |
| 937 | + 'frm_clone_solid_icon' => 'frm_clone_icon', | |
| 1242 | 938 | ); |
| 1243 | 939 | if ( isset( $deprecated[ $icon ] ) ) { |
| 1244 | - $icon = $deprecated[ $icon ]; | |
| 940 | + $icon = $deprecated[ $icon ]; | |
| 1245 | 941 | $class = str_replace( $icon, $deprecated[ $icon ], $class ); |
| 1246 | 942 | } |
| 1247 | 943 | |
| 1248 | 944 | if ( $icon === $class ) { |
| @@ -1252,9 +948,11 @@ | ||
| 1252 | 948 | if ( strpos( $icon, ' ' ) ) { |
| 1253 | 949 | $icon = explode( ' ', $icon ); |
| 1254 | 950 | $icon = reset( $icon ); |
| 1255 | 951 | } |
| 1256 | - $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>'; | |
| 952 | + $icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '> | |
| 953 | + <use xlink:href="#' . esc_attr( $icon ) . '" /> | |
| 954 | + </svg>'; | |
| 1257 | 955 | } |
| 1258 | 956 | |
| 1259 | 957 | if ( $echo ) { |
| 1260 | 958 | echo self::kses_icon( $icon ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| @@ -1290,9 +988,8 @@ | ||
| 1290 | 988 | */ |
| 1291 | 989 | public static function add_allowed_icon_tags( $allowed_html ) { |
| 1292 | 990 | $allowed_html['svg']['data-open'] = true; |
| 1293 | 991 | $allowed_html['svg']['title'] = true; |
| 1294 | - $allowed_html['svg']['tabindex'] = true; | |
| 1295 | 992 | return $allowed_html; |
| 1296 | 993 | } |
| 1297 | 994 | |
| 1298 | 995 | /** |
| @@ -1341,18 +1038,11 @@ | ||
| 1341 | 1038 | /** |
| 1342 | 1039 | * Include svg images. |
| 1343 | 1040 | * |
| 1344 | 1041 | * @since 4.0.02 |
| 1345 | - * @return void | |
| 1346 | 1042 | */ |
| 1347 | 1043 | public static function include_svg() { |
| 1348 | - if ( self::$included_svg ) { | |
| 1349 | - return; | |
| 1350 | - } | |
| 1351 | - | |
| 1352 | - // Use readfile instead of include_once because of a default security rule in Snuffleupagus. | |
| 1353 | - readfile( self::plugin_path() . '/images/icons.svg' ); | |
| 1354 | - self::$included_svg = true; | |
| 1044 | + include_once self::plugin_path() . '/images/icons.svg'; | |
| 1355 | 1045 | } |
| 1356 | 1046 | |
| 1357 | 1047 | /** |
| 1358 | 1048 | * Convert an associative array to HTML values. |
| @@ -1364,9 +1054,9 @@ | ||
| 1364 | 1054 | * @param bool $echo |
| 1365 | 1055 | * @return string|void |
| 1366 | 1056 | */ |
| 1367 | 1057 | public static function array_to_html_params( $atts, $echo = false ) { |
| 1368 | - $callback = function () use ( $atts ) { | |
| 1058 | + $callback = function() use ( $atts ) { | |
| 1369 | 1059 | if ( $atts ) { |
| 1370 | 1060 | foreach ( $atts as $key => $value ) { |
| 1371 | 1061 | echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
| 1372 | 1062 | } |
| @@ -1381,9 +1071,9 @@ | ||
| 1381 | 1071 | * @since 5.0.13 |
| 1382 | 1072 | * |
| 1383 | 1073 | * @param Closure $echo_function |
| 1384 | 1074 | * @param bool $echo |
| 1385 | - * @return string|null | |
| 1075 | + * @return string|void | |
| 1386 | 1076 | */ |
| 1387 | 1077 | public static function clip( $echo_function, $echo = false ) { |
| 1388 | 1078 | if ( ! $echo ) { |
| 1389 | 1079 | ob_start(); |
| @@ -1388,11 +1078,9 @@ | ||
| 1388 | 1078 | if ( ! $echo ) { |
| 1389 | 1079 | ob_start(); |
| 1390 | 1080 | } |
| 1391 | 1081 | |
| 1392 | - if ( is_callable( $echo_function ) ) { | |
| 1393 | - $echo_function(); | |
| 1394 | - } | |
| 1082 | + $echo_function(); | |
| 1395 | 1083 | |
| 1396 | 1084 | if ( ! $echo ) { |
| 1397 | 1085 | $return = ob_get_contents(); |
| 1398 | 1086 | ob_end_clean(); |
| @@ -1401,15 +1089,12 @@ | ||
| 1401 | 1089 | } |
| 1402 | 1090 | |
| 1403 | 1091 | /** |
| 1404 | 1092 | * @since 3.0 |
| 1405 | - * | |
| 1406 | - * @param array $atts | |
| 1407 | - * @return void | |
| 1408 | 1093 | */ |
| 1409 | 1094 | public static function get_admin_header( $atts ) { |
| 1410 | - $has_nav = ! empty( $atts['form'] ) && empty( $atts['is_template'] ); | |
| 1411 | - if ( empty( $atts['close'] ) ) { | |
| 1095 | + $has_nav = ( isset( $atts['form'] ) && ! empty( $atts['form'] ) && ( ! isset( $atts['is_template'] ) || ! $atts['is_template'] ) ); | |
| 1096 | + if ( ! isset( $atts['close'] ) || empty( $atts['close'] ) ) { | |
| 1412 | 1097 | $atts['close'] = admin_url( 'admin.php?page=formidable' ); |
| 1413 | 1098 | } |
| 1414 | 1099 | if ( ! isset( $atts['import_link'] ) ) { |
| 1415 | 1100 | $atts['import_link'] = false; |
| @@ -1414,9 +1099,9 @@ | ||
| 1414 | 1099 | if ( ! isset( $atts['import_link'] ) ) { |
| 1415 | 1100 | $atts['import_link'] = false; |
| 1416 | 1101 | } |
| 1417 | 1102 | |
| 1418 | - include self::plugin_path() . '/classes/views/shared/admin-header.php'; | |
| 1103 | + include( self::plugin_path() . '/classes/views/shared/admin-header.php' ); | |
| 1419 | 1104 | } |
| 1420 | 1105 | |
| 1421 | 1106 | /** |
| 1422 | 1107 | * @since 6.0 |
| @@ -1445,9 +1130,9 @@ | ||
| 1445 | 1130 | FrmInbox::maybe_show_banner(); |
| 1446 | 1131 | return; |
| 1447 | 1132 | } |
| 1448 | 1133 | |
| 1449 | - if ( FrmSalesApi::maybe_show_banner() || self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) { | |
| 1134 | + if ( self::maybe_show_license_warning() || FrmInbox::maybe_show_banner() || ! $should_show_lite_upgrade || self::pro_is_installed() ) { | |
| 1450 | 1135 | // Print license warning or inbox banner and exit if either prints. |
| 1451 | 1136 | // And exit before printing the upgrade bar if it shouldn't be shown. |
| 1452 | 1137 | return; |
| 1453 | 1138 | } |
| @@ -1452,36 +1137,10 @@ | ||
| 1452 | 1137 | return; |
| 1453 | 1138 | } |
| 1454 | 1139 | ?> |
| 1455 | 1140 | <div class="frm-upgrade-bar"> |
| 1456 | - <div class="frm-upgrade-bar-inner"> | |
| 1457 | - <?php | |
| 1458 | - $cta_text = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_text' ); | |
| 1459 | - if ( ! $cta_text ) { | |
| 1460 | - $cta_text = __( 'upgrading to PRO', 'formidable' ); | |
| 1461 | - } | |
| 1462 | - | |
| 1463 | - $upgrade_link = FrmSalesApi::get_best_sale_value( 'lite_banner_cta_link' ); | |
| 1464 | - $utm = array( | |
| 1465 | - 'medium' => 'settings-license', | |
| 1466 | - 'content' => 'lite-banner', | |
| 1467 | - ); | |
| 1468 | - | |
| 1469 | - if ( $upgrade_link ) { | |
| 1470 | - $upgrade_link = self::maybe_add_missing_utm( $upgrade_link, $utm ); | |
| 1471 | - } else { | |
| 1472 | - $upgrade_link = self::admin_upgrade_link( $utm ); | |
| 1473 | - } | |
| 1474 | - | |
| 1475 | - printf( | |
| 1476 | - /* translators: %1$s: Start link HTML, %2$s: CTA text ("upgrading to PRO" by default), %3$s: End link HTML */ | |
| 1477 | - esc_html__( 'You\'re using Formidable Forms Lite. To unlock more features consider %1$s%2$s%3$s.', 'formidable' ), | |
| 1478 | - '<a href="' . esc_url( $upgrade_link ) . '">', | |
| 1479 | - esc_html( $cta_text ), | |
| 1480 | - '</a>' | |
| 1481 | - ); | |
| 1482 | - ?> | |
| 1483 | - </div> | |
| 1141 | + <span>You're using Formidable Forms Lite. To unlock more features consider</span> | |
| 1142 | + <a href="<?php echo esc_url( self::admin_upgrade_link( 'top-bar' ) ); ?>" target="_blank" rel="noopener">upgrading to Pro</a>. | |
| 1484 | 1143 | </div> |
| 1485 | 1144 | <?php |
| 1486 | 1145 | } |
| 1487 | 1146 | |
| @@ -1498,10 +1157,8 @@ | ||
| 1498 | 1157 | * Render a button for a new item (Form, Application, etc). |
| 1499 | 1158 | * |
| 1500 | 1159 | * @since 3.0 |
| 1501 | 1160 | * @param array $atts { |
| 1502 | - * Details about the button. | |
| 1503 | - * | |
| 1504 | 1161 | * @type array $link_hook Custom link hook, calls do_action and exits early. |
| 1505 | 1162 | * @type string $new_link Href value, default #. |
| 1506 | 1163 | * @type string $class Custom class names, space separated. |
| 1507 | 1164 | * @type string $button_text Button text. Default "Add New". |
| @@ -1513,9 +1170,9 @@ | ||
| 1513 | 1170 | do_action( $atts['link_hook']['hook'], $atts['link_hook']['param'] ); |
| 1514 | 1171 | return; |
| 1515 | 1172 | } |
| 1516 | 1173 | |
| 1517 | - if ( empty( $atts['new_link'] ) && empty( $atts['create_form'] ) && empty( $atts['class'] ) ) { | |
| 1174 | + if ( empty( $atts['new_link'] ) && empty( $atts['trigger_new_form_modal'] ) && empty( $atts['class'] ) ) { | |
| 1518 | 1175 | // Do not render a button if none of these attributes are set. |
| 1519 | 1176 | return; |
| 1520 | 1177 | } |
| 1521 | 1178 | |
| @@ -1521,8 +1178,12 @@ | ||
| 1521 | 1178 | |
| 1522 | 1179 | $href = ! empty( $atts['new_link'] ) ? esc_url( $atts['new_link'] ) : '#'; |
| 1523 | 1180 | $class = 'button button-primary frm-button-primary'; |
| 1524 | 1181 | |
| 1182 | + if ( ! empty( $atts['trigger_new_form_modal'] ) ) { | |
| 1183 | + $class .= ' frm-trigger-new-form-modal'; | |
| 1184 | + } | |
| 1185 | + | |
| 1525 | 1186 | if ( ! empty( $atts['class'] ) ) { |
| 1526 | 1187 | $class .= ' ' . $atts['class']; |
| 1527 | 1188 | } |
| 1528 | 1189 | |
| @@ -1539,12 +1200,10 @@ | ||
| 1539 | 1200 | 'placeholder' => '', |
| 1540 | 1201 | 'tosearch' => '', |
| 1541 | 1202 | 'text' => __( 'Search', 'formidable' ), |
| 1542 | 1203 | 'input_id' => '', |
| 1543 | - 'value' => false, | |
| 1544 | - 'class' => '', | |
| 1545 | 1204 | ); |
| 1546 | - $atts = array_merge( $defaults, $atts ); | |
| 1205 | + $atts = array_merge( $defaults, $atts ); | |
| 1547 | 1206 | |
| 1548 | 1207 | if ( $atts['input_id'] === 'template' && empty( $atts['tosearch'] ) ) { |
| 1549 | 1208 | $atts['tosearch'] = 'frm-card'; |
| 1550 | 1209 | } |
| @@ -1555,34 +1214,21 @@ | ||
| 1555 | 1214 | } |
| 1556 | 1215 | |
| 1557 | 1216 | $input_id = $atts['input_id'] . '-search-input'; |
| 1558 | 1217 | |
| 1559 | - $input_atts = array( | |
| 1560 | - 'type' => 'search', | |
| 1561 | - 'id' => $input_id, | |
| 1562 | - 'name' => 's', | |
| 1563 | - 'placeholder' => $atts['placeholder'], | |
| 1564 | - 'class' => $class, | |
| 1565 | - 'data-tosearch' => $atts['tosearch'], | |
| 1566 | - ); | |
| 1567 | - | |
| 1568 | - if ( is_string( $atts['value'] ) ) { | |
| 1569 | - $input_atts['value'] = $atts['value']; | |
| 1570 | - } elseif ( isset( $_REQUEST['s'] ) ) { | |
| 1571 | - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 1572 | - $input_atts['value'] = wp_unslash( $_REQUEST['s'] ); | |
| 1573 | - } | |
| 1574 | - | |
| 1575 | - if ( ! empty( $atts['tosearch'] ) ) { | |
| 1576 | - $input_atts['autocomplete'] = 'off'; | |
| 1577 | - } | |
| 1578 | 1218 | ?> |
| 1579 | - <p class="frm-search <?php echo esc_attr( $atts['class'] ); ?>"> | |
| 1219 | + <p class="frm-search"> | |
| 1580 | 1220 | <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"> |
| 1581 | 1221 | <?php echo esc_html( $atts['text'] ); ?>: |
| 1582 | 1222 | </label> |
| 1583 | - <?php self::icon_by_class( 'frm_icon_font frm_search_icon frm_svg20' ); ?> | |
| 1584 | - <input <?php self::array_to_html_params( $input_atts, true ); ?> /> | |
| 1223 | + <span class="frmfont frm_search_icon"></span> | |
| 1224 | + <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" | |
| 1225 | + value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( $atts['placeholder'] ); ?>" | |
| 1226 | + class="<?php echo esc_attr( $class ); ?>" data-tosearch="<?php echo esc_attr( $atts['tosearch'] ); ?>" | |
| 1227 | + <?php if ( ! empty( $atts['tosearch'] ) ) { ?> | |
| 1228 | + autocomplete="off" | |
| 1229 | + <?php } ?> | |
| 1230 | + /> | |
| 1585 | 1231 | <?php |
| 1586 | 1232 | if ( empty( $atts['tosearch'] ) ) { |
| 1587 | 1233 | submit_button( $atts['text'], 'button-secondary', '', false, array( 'id' => 'search-submit' ) ); |
| 1588 | 1234 | } |
| @@ -1592,9 +1238,8 @@ | ||
| 1592 | 1238 | } |
| 1593 | 1239 | |
| 1594 | 1240 | /** |
| 1595 | 1241 | * @param string $type |
| 1596 | - * @return void | |
| 1597 | 1242 | */ |
| 1598 | 1243 | public static function trigger_hook_load( $type, $object = null ) { |
| 1599 | 1244 | // Only load the form hooks once. |
| 1600 | 1245 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| @@ -1603,14 +1248,11 @@ | ||
| 1603 | 1248 | } |
| 1604 | 1249 | } |
| 1605 | 1250 | |
| 1606 | 1251 | /** |
| 1607 | - * Save all front-end js scripts into a single file. | |
| 1608 | - * And save an additional single file of all front-end Stripe JS scripts. | |
| 1252 | + * Save all front-end js scripts into a single file | |
| 1609 | 1253 | * |
| 1610 | 1254 | * @since 3.0 |
| 1611 | - * | |
| 1612 | - * @return void | |
| 1613 | 1255 | */ |
| 1614 | 1256 | public static function save_combined_js() { |
| 1615 | 1257 | $file_atts = apply_filters( |
| 1616 | 1258 | 'frm_js_location', |
| @@ -1623,34 +1265,10 @@ | ||
| 1623 | 1265 | |
| 1624 | 1266 | $files = array( |
| 1625 | 1267 | self::plugin_path() . '/js/formidable.min.js', |
| 1626 | 1268 | ); |
| 1627 | - /** | |
| 1628 | - * @param array $files | |
| 1629 | - */ | |
| 1630 | 1269 | $files = apply_filters( 'frm_combined_js_files', $files ); |
| 1631 | 1270 | $new_file->combine_files( $files ); |
| 1632 | - | |
| 1633 | - // Create the minified Stripe Script. | |
| 1634 | - $file_atts = apply_filters( | |
| 1635 | - 'frm_stripe_js_location', | |
| 1636 | - array( | |
| 1637 | - 'file_name' => 'frmstrp.min.js', | |
| 1638 | - 'new_file_path' => self::plugin_path() . '/js', | |
| 1639 | - ) | |
| 1640 | - ); | |
| 1641 | - $new_file = new FrmCreateFile( $file_atts ); | |
| 1642 | - $files = array( | |
| 1643 | - FrmStrpLiteAppHelper::plugin_path() . 'js/frmstrp.min.js', | |
| 1644 | - ); | |
| 1645 | - | |
| 1646 | - /** | |
| 1647 | - * @since 6.5 | |
| 1648 | - * | |
| 1649 | - * @param array $files | |
| 1650 | - */ | |
| 1651 | - $files = apply_filters( 'frm_stripe_combined_js_files', $files ); | |
| 1652 | - $new_file->combine_files( $files ); | |
| 1653 | 1271 | } |
| 1654 | 1272 | |
| 1655 | 1273 | /** |
| 1656 | 1274 | * Check a value from a shortcode to see if true or false. |
| @@ -1657,14 +1275,14 @@ | ||
| 1657 | 1275 | * True when value is 1, true, 'true', 'yes' |
| 1658 | 1276 | * |
| 1659 | 1277 | * @since 1.07.10 |
| 1660 | 1278 | * |
| 1661 | - * @param string $value The value to compare. | |
| 1279 | + * @param string $value The value to compare | |
| 1662 | 1280 | * |
| 1663 | - * @return bool | |
| 1281 | + * @return boolean True or False | |
| 1664 | 1282 | */ |
| 1665 | 1283 | public static function is_true( $value ) { |
| 1666 | - return true === $value || 1 == $value || 'true' === $value || 'yes' === $value; | |
| 1284 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); | |
| 1667 | 1285 | } |
| 1668 | 1286 | |
| 1669 | 1287 | /** |
| 1670 | 1288 | * Gets all post from a specific post type. |
| @@ -1722,9 +1340,9 @@ | ||
| 1722 | 1340 | $args = self::preformat_selection_args( $args ); |
| 1723 | 1341 | |
| 1724 | 1342 | $pages_count = wp_count_posts( $args['post_type'] ); |
| 1725 | 1343 | |
| 1726 | - if ( ! isset( $pages_count->publish ) || $pages_count->publish <= 50 ) { | |
| 1344 | + if ( $pages_count->publish <= 50 ) { | |
| 1727 | 1345 | self::wp_pages_dropdown( $args ); |
| 1728 | 1346 | return; |
| 1729 | 1347 | } |
| 1730 | 1348 | |
| @@ -1730,9 +1348,9 @@ | ||
| 1730 | 1348 | |
| 1731 | 1349 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 1732 | 1350 | |
| 1733 | 1351 | $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' ); |
| 1734 | - $title = ''; | |
| 1352 | + $title = ''; | |
| 1735 | 1353 | |
| 1736 | 1354 | if ( $selected ) { |
| 1737 | 1355 | $title = get_the_title( $selected ); |
| 1738 | 1356 | } |
| @@ -1748,112 +1366,18 @@ | ||
| 1748 | 1366 | <?php |
| 1749 | 1367 | } |
| 1750 | 1368 | |
| 1751 | 1369 | /** |
| 1752 | - * Maybe show an HTML select or autocomplete input based on the number of options. | |
| 1753 | - * | |
| 1754 | - * @since 6.21 | |
| 1755 | - * | |
| 1756 | - * @param array $args Args. See the method for details. | |
| 1370 | + * @param array $args | |
| 1371 | + * @param string $page_id Deprecated. | |
| 1372 | + * @param boolean $truncate Deprecated. | |
| 1757 | 1373 | */ |
| 1758 | - public static function maybe_autocomplete_options( $args ) { | |
| 1759 | - $defaults = array( | |
| 1760 | - 'truncate' => false, | |
| 1761 | - 'placeholder' => ' ', | |
| 1762 | - 'name' => '', | |
| 1763 | - 'id' => '', | |
| 1764 | - 'selected' => '', | |
| 1765 | - 'source' => array(), | |
| 1766 | - 'dropdown_limit' => 50, | |
| 1767 | - 'autocomplete_placeholder' => __( 'Select an option', 'formidable' ), | |
| 1768 | - 'value_key' => 'value', | |
| 1769 | - 'label_key' => 'label', | |
| 1770 | - ); | |
| 1771 | - | |
| 1772 | - $args = wp_parse_args( $args, $defaults ); | |
| 1773 | - | |
| 1774 | - $html_attrs = array(); | |
| 1775 | - if ( ! empty( $args['name'] ) ) { | |
| 1776 | - $html_attrs['name'] = $args['name']; | |
| 1777 | - } | |
| 1778 | - | |
| 1779 | - if ( ! empty( $args['id'] ) ) { | |
| 1780 | - $html_attrs['id'] = $args['id']; | |
| 1781 | - } | |
| 1782 | - | |
| 1783 | - if ( count( $args['source'] ) <= $args['dropdown_limit'] ) { | |
| 1784 | - ?> | |
| 1785 | - <select <?php self::array_to_html_params( $html_attrs, true ); ?>> | |
| 1786 | - <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option> | |
| 1787 | - <?php | |
| 1788 | - foreach ( $args['source'] as $key => $source ) : | |
| 1789 | - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args ); | |
| 1790 | - if ( ! empty( $args['truncate'] ) ) { | |
| 1791 | - $value_label['label'] = self::truncate( $value_label['label'], $args['truncate'] ); | |
| 1792 | - } | |
| 1793 | - ?> | |
| 1794 | - <option value="<?php echo esc_attr( $value_label['value'] ); ?>" <?php selected( $value_label['value'], $args['selected'] ); ?>><?php echo esc_html( $value_label['label'] ); ?></option> | |
| 1795 | - <?php endforeach; ?> | |
| 1796 | - </select> | |
| 1797 | - <?php | |
| 1798 | - } else { | |
| 1799 | - $options = array(); | |
| 1800 | - $autocomplete_value = ''; | |
| 1801 | - foreach ( $args['source'] as $key => $source ) { | |
| 1802 | - $value_label = self::get_dropdown_value_and_label_from_option( $source, $key, $args ); | |
| 1803 | - | |
| 1804 | - if ( $value_label['value'] === $args['selected'] ) { | |
| 1805 | - $autocomplete_value = $value_label['label']; | |
| 1806 | - } | |
| 1807 | - | |
| 1808 | - $options[] = $value_label; | |
| 1809 | - } | |
| 1810 | - | |
| 1811 | - $html_attrs['type'] = 'hidden'; | |
| 1812 | - $html_attrs['class'] = 'frm_autocomplete_value_input'; | |
| 1813 | - $html_attrs['value'] = $args['selected']; | |
| 1814 | - ?> | |
| 1815 | - <input type="text" class="frm-custom-search" | |
| 1816 | - data-source="<?php echo esc_attr( wp_json_encode( $options ) ); ?>" | |
| 1817 | - placeholder="<?php echo esc_attr( $args['autocomplete_placeholder'] ); ?>" | |
| 1818 | - value="<?php echo esc_attr( $autocomplete_value ); ?>" /> | |
| 1819 | - <input <?php self::array_to_html_params( $html_attrs, true ); ?> /> | |
| 1820 | - <?php | |
| 1821 | - }//end if | |
| 1822 | - } | |
| 1823 | - | |
| 1824 | - /** | |
| 1825 | - * Gets dropdown value and label from autodropdown option. | |
| 1826 | - * | |
| 1827 | - * @since 6.21 | |
| 1828 | - * | |
| 1829 | - * @param array|string $option Autocomplete option. | |
| 1830 | - * @param string $key Array key of the option. | |
| 1831 | - * @param array $args See {@see FrmAppHelper::maybe_autocomplete_options()}. | |
| 1832 | - * @return array | |
| 1833 | - */ | |
| 1834 | - private static function get_dropdown_value_and_label_from_option( $option, $key, $args ) { | |
| 1835 | - if ( is_array( $option ) ) { | |
| 1836 | - $value = $option[ $args['value_key'] ] ?? ''; | |
| 1837 | - $label = $option[ $args['label_key'] ] ?? ''; | |
| 1838 | - } else { | |
| 1839 | - $value = $key; | |
| 1840 | - $label = $option; | |
| 1841 | - } | |
| 1842 | - | |
| 1843 | - return compact( 'value', 'label' ); | |
| 1844 | - } | |
| 1845 | - | |
| 1846 | - /** | |
| 1847 | - * @param array $args | |
| 1848 | - * @param string $page_id Deprecated. | |
| 1849 | - * @param bool $truncate Deprecated. | |
| 1850 | - */ | |
| 1851 | 1374 | public static function wp_pages_dropdown( $args = array(), $page_id = '', $truncate = false ) { |
| 1852 | 1375 | self::prep_page_dropdown_params( $page_id, $truncate, $args ); |
| 1853 | 1376 | |
| 1854 | 1377 | $pages = self::get_post_ids_and_titles( $args['post_type'] ); |
| 1855 | 1378 | $selected = self::get_post_param( $args['field_name'], $args['page_id'], 'absint' ); |
| 1379 | + | |
| 1856 | 1380 | ?> |
| 1857 | 1381 | <select name="<?php echo esc_attr( $args['field_name'] ); ?>" id="<?php echo esc_attr( $args['field_name'] ); ?>" class="frm-pages-dropdown"> |
| 1858 | 1382 | <option value=""><?php echo esc_html( $args['placeholder'] ); ?></option> |
| 1859 | 1383 | <?php foreach ( $pages as $page ) { ?> |
| @@ -1890,13 +1414,13 @@ | ||
| 1890 | 1414 | * @since 4.10.01 Added `post_type` and `autocomplete_placeholder` to the arguments array. |
| 1891 | 1415 | */ |
| 1892 | 1416 | private static function preformat_selection_args( $args ) { |
| 1893 | 1417 | $defaults = array( |
| 1894 | - 'truncate' => false, | |
| 1895 | - 'placeholder' => ' ', | |
| 1896 | - 'field_name' => '', | |
| 1897 | - 'page_id' => '', | |
| 1898 | - 'post_type' => 'page', | |
| 1418 | + 'truncate' => false, | |
| 1419 | + 'placeholder' => ' ', | |
| 1420 | + 'field_name' => '', | |
| 1421 | + 'page_id' => '', | |
| 1422 | + 'post_type' => 'page', | |
| 1899 | 1423 | 'autocomplete_placeholder' => __( 'Select a Page', 'formidable' ), |
| 1900 | 1424 | ); |
| 1901 | 1425 | |
| 1902 | 1426 | return array_merge( $defaults, $args ); |
| @@ -1967,16 +1491,25 @@ | ||
| 1967 | 1491 | return self::is_admin_page( 'formidable-views-editor' ); |
| 1968 | 1492 | } |
| 1969 | 1493 | |
| 1970 | 1494 | /** |
| 1971 | - * @param string $field_name | |
| 1972 | - * @param array|string $capability | |
| 1973 | - * @param string $multiple 'single' and 'multiple'. | |
| 1495 | + * @since 4.0 | |
| 1496 | + * @deprecated 5.5.3 | |
| 1974 | 1497 | */ |
| 1498 | + public static function maybe_full_screen_link( $link ) { | |
| 1499 | + _deprecated_function( __METHOD__, '5.5.3' ); | |
| 1500 | + return $link; | |
| 1501 | + } | |
| 1502 | + | |
| 1503 | + /** | |
| 1504 | + * @param string $field_name | |
| 1505 | + * @param string|array $capability | |
| 1506 | + * @param string $multiple 'single' and 'multiple' | |
| 1507 | + */ | |
| 1975 | 1508 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 1976 | 1509 | ?> |
| 1977 | 1510 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" |
| 1978 | - <?php echo 'multiple' === $multiple ? 'multiple="multiple"' : ''; ?> | |
| 1511 | + <?php echo ( 'multiple' === $multiple ) ? 'multiple="multiple"' : ''; ?> | |
| 1979 | 1512 | class="frm_multiselect"> |
| 1980 | 1513 | <?php self::roles_options( $capability ); ?> |
| 1981 | 1514 | </select> |
| 1982 | 1515 | <?php |
| @@ -1984,9 +1517,9 @@ | ||
| 1984 | 1517 | |
| 1985 | 1518 | /** |
| 1986 | 1519 | * @since 4.07 |
| 1987 | 1520 | * @param array|string $selected |
| 1988 | - * @param string $current | |
| 1521 | + * @param string $current | |
| 1989 | 1522 | */ |
| 1990 | 1523 | private static function selected( $selected, $current ) { |
| 1991 | 1524 | if ( is_callable( 'FrmProAppHelper::selected' ) ) { |
| 1992 | 1525 | FrmProAppHelper::selected( $selected, $current ); |
| @@ -1995,9 +1528,9 @@ | ||
| 1995 | 1528 | } |
| 1996 | 1529 | } |
| 1997 | 1530 | |
| 1998 | 1531 | /** |
| 1999 | - * @param array|string $capability | |
| 1532 | + * @param string|array $capability | |
| 2000 | 1533 | */ |
| 2001 | 1534 | public static function roles_options( $capability ) { |
| 2002 | 1535 | global $frm_vars; |
| 2003 | 1536 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| @@ -2009,9 +1542,9 @@ | ||
| 2009 | 1542 | |
| 2010 | 1543 | foreach ( $editable_roles as $role => $details ) { |
| 2011 | 1544 | $name = translate_user_role( $details['name'] ); |
| 2012 | 1545 | ?> |
| 2013 | - <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_html( $name ); ?></option> | |
| 1546 | + <option value="<?php echo esc_attr( $role ); ?>" <?php self::selected( $capability, $role ); ?>><?php echo esc_attr( $name ); ?> </option> | |
| 2014 | 1547 | <?php |
| 2015 | 1548 | unset( $role, $details ); |
| 2016 | 1549 | } |
| 2017 | 1550 | } |
| @@ -2032,8 +1565,9 @@ | ||
| 2032 | 1565 | $pro_cap = array( |
| 2033 | 1566 | 'frm_create_entries' => __( 'Add Entries from Admin Area', 'formidable' ), |
| 2034 | 1567 | 'frm_edit_entries' => __( 'Edit Entries from Admin Area', 'formidable' ), |
| 2035 | 1568 | 'frm_view_reports' => __( 'View Reports', 'formidable' ), |
| 1569 | + 'frm_edit_displays' => __( 'Add/Edit Views', 'formidable' ), | |
| 2036 | 1570 | ); |
| 2037 | 1571 | /** |
| 2038 | 1572 | * @since 5.3.1 |
| 2039 | 1573 | * |
| @@ -2056,9 +1590,9 @@ | ||
| 2056 | 1590 | * @return array<string,string> |
| 2057 | 1591 | */ |
| 2058 | 1592 | private static function get_lite_capabilities() { |
| 2059 | 1593 | return array( |
| 2060 | - 'frm_view_forms' => __( 'View Forms List', 'formidable' ), | |
| 1594 | + 'frm_view_forms' => __( 'View Forms', 'formidable' ), | |
| 2061 | 1595 | 'frm_edit_forms' => __( 'Add and Edit Forms', 'formidable' ), |
| 2062 | 1596 | 'frm_delete_forms' => __( 'Delete Forms', 'formidable' ), |
| 2063 | 1597 | 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
| 2064 | 1598 | 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
| @@ -2099,9 +1633,9 @@ | ||
| 2099 | 1633 | return current_user_can( $role ); |
| 2100 | 1634 | } |
| 2101 | 1635 | |
| 2102 | 1636 | /** |
| 2103 | - * @param array|string $needed_role | |
| 1637 | + * @param string|array $needed_role | |
| 2104 | 1638 | * @return bool |
| 2105 | 1639 | */ |
| 2106 | 1640 | public static function user_has_permission( $needed_role ) { |
| 2107 | 1641 | if ( is_array( $needed_role ) ) { |
| @@ -2157,11 +1691,8 @@ | ||
| 2157 | 1691 | /** |
| 2158 | 1692 | * Make sure admins have permission to see the menu items |
| 2159 | 1693 | * |
| 2160 | 1694 | * @since 2.0.6 |
| 2161 | - * | |
| 2162 | - * @param string $cap | |
| 2163 | - * @return void | |
| 2164 | 1695 | */ |
| 2165 | 1696 | public static function force_capability( $cap = 'frm_change_settings' ) { |
| 2166 | 1697 | if ( current_user_can( 'administrator' ) && ! current_user_can( $cap ) ) { |
| 2167 | 1698 | $role = get_role( 'administrator' ); |
| @@ -2172,9 +1703,9 @@ | ||
| 2172 | 1703 | } |
| 2173 | 1704 | } |
| 2174 | 1705 | |
| 2175 | 1706 | /** |
| 2176 | - * Check if the user has permission for action. | |
| 1707 | + * Check if the user has permision for action. | |
| 2177 | 1708 | * Return permission message and stop the action if no permission |
| 2178 | 1709 | * |
| 2179 | 1710 | * @since 2.0 |
| 2180 | 1711 | * |
| @@ -2210,9 +1741,9 @@ | ||
| 2210 | 1741 | if ( empty( $nonce_name ) ) { |
| 2211 | 1742 | return $error; |
| 2212 | 1743 | } |
| 2213 | 1744 | |
| 2214 | - $nonce_value = $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : ''; | |
| 1745 | + $nonce_value = ( $_REQUEST && isset( $_REQUEST[ $nonce_name ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce_name ] ) ) : ''; | |
| 2215 | 1746 | if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $nonce_value, $nonce ) ) ) { |
| 2216 | 1747 | $frm_settings = self::get_settings(); |
| 2217 | 1748 | $error = $frm_settings->admin_permission; |
| 2218 | 1749 | } |
| @@ -2226,13 +1757,12 @@ | ||
| 2226 | 1757 | } |
| 2227 | 1758 | } |
| 2228 | 1759 | |
| 2229 | 1760 | public static function check_selected( $values, $current ) { |
| 2230 | - $values = self::recursive_function_map( $values, 'trim' ); | |
| 2231 | - $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' ); | |
| 1761 | + $values = self::recursive_function_map( $values, 'trim' ); | |
| 1762 | + $values = self::recursive_function_map( $values, 'htmlspecialchars_decode' ); | |
| 1763 | + $current = htmlspecialchars_decode( trim( $current ) ); | |
| 2232 | 1764 | |
| 2233 | - $current = is_null( $current ) ? '' : htmlspecialchars_decode( trim( $current ) ); | |
| 2234 | - | |
| 2235 | 1765 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 2236 | 1766 | } |
| 2237 | 1767 | |
| 2238 | 1768 | public static function recursive_function_map( $value, $function ) { |
| @@ -2252,9 +1782,8 @@ | ||
| 2252 | 1782 | } |
| 2253 | 1783 | } |
| 2254 | 1784 | } |
| 2255 | 1785 | } else { |
| 2256 | - $value = self::maybe_update_value_if_null( $value, $function ); | |
| 2257 | 1786 | $value = call_user_func( $function, $value ); |
| 2258 | 1787 | } |
| 2259 | 1788 | |
| 2260 | 1789 | return $value; |
| @@ -2259,24 +1788,8 @@ | ||
| 2259 | 1788 | |
| 2260 | 1789 | return $value; |
| 2261 | 1790 | } |
| 2262 | 1791 | |
| 2263 | - /** | |
| 2264 | - * Updates value to empty string if it is null and being passed to a string function. | |
| 2265 | - * | |
| 2266 | - * @since 6.8.4 | |
| 2267 | - * @param mixed $value | |
| 2268 | - * @param string $function | |
| 2269 | - * @return mixed | |
| 2270 | - */ | |
| 2271 | - private static function maybe_update_value_if_null( $value, $function ) { | |
| 2272 | - if ( null === $value && in_array( $function, array( 'trim', 'strlen' ), true ) ) { | |
| 2273 | - $value = ''; | |
| 2274 | - } | |
| 2275 | - | |
| 2276 | - return $value; | |
| 2277 | - } | |
| 2278 | - | |
| 2279 | 1792 | public static function is_assoc( $array ) { |
| 2280 | 1793 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 2281 | 1794 | } |
| 2282 | 1795 | |
| @@ -2287,12 +1800,14 @@ | ||
| 2287 | 1800 | $return = array(); |
| 2288 | 1801 | foreach ( $array as $key => $value ) { |
| 2289 | 1802 | if ( is_array( $value ) ) { |
| 2290 | 1803 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 2291 | - } elseif ( $keys === 'keep' ) { | |
| 1804 | + } else { | |
| 1805 | + if ( $keys == 'keep' ) { | |
| 2292 | 1806 | $return[ $key ] = $value; |
| 2293 | - } else { | |
| 2294 | - $return[] = $value; | |
| 1807 | + } else { | |
| 1808 | + $return[] = $value; | |
| 1809 | + } | |
| 2295 | 1810 | } |
| 2296 | 1811 | } |
| 2297 | 1812 | |
| 2298 | 1813 | return $return; |
| @@ -2297,27 +1812,8 @@ | ||
| 2297 | 1812 | |
| 2298 | 1813 | return $return; |
| 2299 | 1814 | } |
| 2300 | 1815 | |
| 2301 | - /** | |
| 2302 | - * Flatten an array before imploding it to avoid Array to string conversion warnings. | |
| 2303 | - * | |
| 2304 | - * @since 6.16.1 | |
| 2305 | - * | |
| 2306 | - * @param string $sep | |
| 2307 | - * @param array $array | |
| 2308 | - * @return string | |
| 2309 | - */ | |
| 2310 | - public static function safe_implode( $sep, $array ) { | |
| 2311 | - $array = self::array_flatten( $array ); | |
| 2312 | - return implode( $sep, $array ); | |
| 2313 | - } | |
| 2314 | - | |
| 2315 | - /** | |
| 2316 | - * @param string $text | |
| 2317 | - * @param bool $is_rich_text | |
| 2318 | - * @return string | |
| 2319 | - */ | |
| 2320 | 1816 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 2321 | 1817 | $safe_text = str_replace( '"', '"', $text ); |
| 2322 | 1818 | if ( ! $is_rich_text ) { |
| 2323 | 1819 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
| @@ -2323,13 +1819,9 @@ | ||
| 2323 | 1819 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
| 2324 | 1820 | } |
| 2325 | 1821 | $safe_text = str_replace( '& ', '& ', $safe_text ); |
| 2326 | 1822 | |
| 2327 | - /** | |
| 2328 | - * @param string $safe_text | |
| 2329 | - * @param string $text | |
| 2330 | - */ | |
| 2331 | - return (string) apply_filters( 'esc_textarea', $safe_text, $text ); | |
| 1823 | + return apply_filters( 'esc_textarea', $safe_text, $text ); | |
| 2332 | 1824 | } |
| 2333 | 1825 | |
| 2334 | 1826 | /** |
| 2335 | 1827 | * Add auto paragraphs to text areas |
| @@ -2336,9 +1828,9 @@ | ||
| 2336 | 1828 | * |
| 2337 | 1829 | * @since 2.0 |
| 2338 | 1830 | */ |
| 2339 | 1831 | public static function use_wpautop( $content ) { |
| 2340 | - if ( apply_filters( 'frm_use_wpautop', true ) && is_string( $content ) ) { | |
| 1832 | + if ( apply_filters( 'frm_use_wpautop', true ) && ! is_array( $content ) ) { | |
| 2341 | 1833 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
| 2342 | 1834 | } |
| 2343 | 1835 | |
| 2344 | 1836 | return $content; |
| @@ -2380,12 +1872,12 @@ | ||
| 2380 | 1872 | * @since 5.0.13 added $echo param. |
| 2381 | 1873 | * |
| 2382 | 1874 | * @param string $url |
| 2383 | 1875 | * @param bool $echo |
| 2384 | - * @return string|null | |
| 1876 | + * @return string|void | |
| 2385 | 1877 | */ |
| 2386 | 1878 | public static function js_redirect( $url, $echo = false ) { |
| 2387 | - $callback = function () use ( $url ) { | |
| 1879 | + $callback = function() use ( $url ) { | |
| 2388 | 1880 | echo '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 2389 | 1881 | }; |
| 2390 | 1882 | return self::clip( $callback, $echo ); |
| 2391 | 1883 | } |
| @@ -2395,9 +1887,9 @@ | ||
| 2395 | 1887 | return $user_id; |
| 2396 | 1888 | } |
| 2397 | 1889 | |
| 2398 | 1890 | $user_id = sanitize_text_field( $user_id ); |
| 2399 | - if ( $user_id === 'current' ) { | |
| 1891 | + if ( $user_id == 'current' ) { | |
| 2400 | 1892 | $user_id = get_current_user_id(); |
| 2401 | 1893 | } else { |
| 2402 | 1894 | if ( is_email( $user_id ) ) { |
| 2403 | 1895 | $user = get_user_by( 'email', $user_id ); |
| @@ -2413,13 +1905,8 @@ | ||
| 2413 | 1905 | |
| 2414 | 1906 | return $user_id; |
| 2415 | 1907 | } |
| 2416 | 1908 | |
| 2417 | - /** | |
| 2418 | - * @param string $filename | |
| 2419 | - * @param array $atts | |
| 2420 | - * @return false|string | |
| 2421 | - */ | |
| 2422 | 1909 | public static function get_file_contents( $filename, $atts = array() ) { |
| 2423 | 1910 | if ( ! is_file( $filename ) ) { |
| 2424 | 1911 | return false; |
| 2425 | 1912 | } |
| @@ -2425,9 +1912,9 @@ | ||
| 2425 | 1912 | } |
| 2426 | 1913 | |
| 2427 | 1914 | extract( $atts ); // phpcs:ignore WordPress.PHP.DontExtract |
| 2428 | 1915 | ob_start(); |
| 2429 | - include $filename; | |
| 1916 | + include( $filename ); | |
| 2430 | 1917 | $contents = ob_get_contents(); |
| 2431 | 1918 | ob_end_clean(); |
| 2432 | 1919 | |
| 2433 | 1920 | return $contents; |
| @@ -2482,9 +1969,9 @@ | ||
| 2482 | 1969 | ++$suffix; |
| 2483 | 1970 | } while ( in_array( $key_check, $similar_keys, true ) ); |
| 2484 | 1971 | |
| 2485 | 1972 | $key = $key_check; |
| 2486 | - }//end if | |
| 1973 | + } | |
| 2487 | 1974 | |
| 2488 | 1975 | return $key; |
| 2489 | 1976 | } |
| 2490 | 1977 | |
| @@ -2523,19 +2010,15 @@ | ||
| 2523 | 2010 | return $key; |
| 2524 | 2011 | } |
| 2525 | 2012 | |
| 2526 | 2013 | /** |
| 2527 | - * @since 6.21 This is changed from `private` to `public`. | |
| 2528 | - * | |
| 2529 | 2014 | * @param int $num_chars |
| 2530 | 2015 | * @return string |
| 2531 | 2016 | */ |
| 2532 | - public static function generate_new_key( $num_chars ) { | |
| 2533 | - $max_slug_value = 36 ** $num_chars; | |
| 2534 | - | |
| 2535 | - // We want to have at least 2 characters in the slug. | |
| 2536 | - $min_slug_value = 37; | |
| 2537 | - return base_convert( random_int( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 2017 | + private static function generate_new_key( $num_chars ) { | |
| 2018 | + $max_slug_value = pow( 36, $num_chars ); | |
| 2019 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug | |
| 2020 | + return base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); | |
| 2538 | 2021 | } |
| 2539 | 2022 | |
| 2540 | 2023 | /** |
| 2541 | 2024 | * @param string $key |
| @@ -2563,16 +2046,11 @@ | ||
| 2563 | 2046 | |
| 2564 | 2047 | /** |
| 2565 | 2048 | * Editing a Form or Entry |
| 2566 | 2049 | * |
| 2567 | - * @param object $record | |
| 2568 | - * @param string $table | |
| 2569 | - * @param array|string $fields | |
| 2570 | - * @param bool $default | |
| 2571 | - * @param array $post_values | |
| 2572 | - * @param array $args | |
| 2050 | + * @param string $table | |
| 2573 | 2051 | * |
| 2574 | - * @return array|bool | |
| 2052 | + * @return bool|array | |
| 2575 | 2053 | */ |
| 2576 | 2054 | public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
| 2577 | 2055 | if ( ! $record ) { |
| 2578 | 2056 | return false; |
| @@ -2587,9 +2065,9 @@ | ||
| 2587 | 2065 | 'fields' => array(), |
| 2588 | 2066 | ); |
| 2589 | 2067 | |
| 2590 | 2068 | foreach ( array( 'name', 'description' ) as $var ) { |
| 2591 | - $default_val = $record->{$var} ?? ''; | |
| 2069 | + $default_val = isset( $record->{$var} ) ? $record->{$var} : ''; | |
| 2592 | 2070 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 2593 | 2071 | unset( $var, $default_val ); |
| 2594 | 2072 | } |
| 2595 | 2073 | |
| @@ -2614,9 +2092,9 @@ | ||
| 2614 | 2092 | if ( ! self::is_admin_page() ) { |
| 2615 | 2093 | // Don't prep default values on the form settings page. |
| 2616 | 2094 | $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
| 2617 | 2095 | } |
| 2618 | - $args['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id; | |
| 2096 | + $args['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; | |
| 2619 | 2097 | self::fill_field_defaults( $field, $record, $values, $args ); |
| 2620 | 2098 | } |
| 2621 | 2099 | } |
| 2622 | 2100 | } |
| @@ -2625,12 +2103,13 @@ | ||
| 2625 | 2103 | $post_values = $args['post_values']; |
| 2626 | 2104 | |
| 2627 | 2105 | if ( $args['default'] ) { |
| 2628 | 2106 | $meta_value = $field->default_value; |
| 2629 | - } elseif ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { | |
| 2630 | - if ( ! isset( $field->field_options['custom_field'] ) ) { | |
| 2631 | - $field->field_options['custom_field'] = ''; | |
| 2632 | - } | |
| 2107 | + } else { | |
| 2108 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { | |
| 2109 | + if ( ! isset( $field->field_options['custom_field'] ) ) { | |
| 2110 | + $field->field_options['custom_field'] = ''; | |
| 2111 | + } | |
| 2633 | 2112 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 2634 | 2113 | $record->post_id, |
| 2635 | 2114 | $field->field_options['post_field'], |
| 2636 | 2115 | $field->field_options['custom_field'], |
| @@ -2640,13 +2119,14 @@ | ||
| 2640 | 2119 | 'form_id' => $field->form_id, |
| 2641 | 2120 | 'field' => $field, |
| 2642 | 2121 | ) |
| 2643 | 2122 | ); |
| 2644 | - } else { | |
| 2645 | - $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); | |
| 2646 | - }//end if | |
| 2123 | + } else { | |
| 2124 | + $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); | |
| 2125 | + } | |
| 2126 | + } | |
| 2647 | 2127 | |
| 2648 | - $field_type = $post_values['field_options'][ 'type_' . $field->id ] ?? $field->type; | |
| 2128 | + $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; | |
| 2649 | 2129 | if ( isset( $post_values['item_meta'][ $field->id ] ) ) { |
| 2650 | 2130 | $new_value = $post_values['item_meta'][ $field->id ]; |
| 2651 | 2131 | self::unserialize_or_decode( $new_value ); |
| 2652 | 2132 | } else { |
| @@ -2692,15 +2172,12 @@ | ||
| 2692 | 2172 | ); |
| 2693 | 2173 | } |
| 2694 | 2174 | |
| 2695 | 2175 | /** |
| 2696 | - * @param object $record | |
| 2697 | 2176 | * @param string $table |
| 2698 | - * @param array $post_values | |
| 2699 | - * @param array $values | |
| 2700 | 2177 | */ |
| 2701 | 2178 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 2702 | - if ( $table === 'entries' ) { | |
| 2179 | + if ( $table == 'entries' ) { | |
| 2703 | 2180 | $form = $record->form_id; |
| 2704 | 2181 | FrmForm::maybe_get_form( $form ); |
| 2705 | 2182 | } else { |
| 2706 | 2183 | $form = $record; |
| @@ -2736,9 +2213,9 @@ | ||
| 2736 | 2213 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 2737 | 2214 | |
| 2738 | 2215 | foreach ( $form_defaults as $opt => $default ) { |
| 2739 | 2216 | if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
| 2740 | - $values[ $opt ] = $post_values && isset( $post_values['options'][ $opt ] ) ? $post_values['options'][ $opt ] : $default; | |
| 2217 | + $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; | |
| 2741 | 2218 | } |
| 2742 | 2219 | |
| 2743 | 2220 | unset( $opt, $default ); |
| 2744 | 2221 | } |
| @@ -2748,9 +2225,9 @@ | ||
| 2748 | 2225 | } |
| 2749 | 2226 | |
| 2750 | 2227 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 2751 | 2228 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 2752 | - $values[ $h . '_html' ] = ( $post_values['options'][ $h . '_html' ] ?? FrmFormsHelper::get_default_html( $h ) ); | |
| 2229 | + $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); | |
| 2753 | 2230 | } |
| 2754 | 2231 | unset( $h ); |
| 2755 | 2232 | } |
| 2756 | 2233 | } |
| @@ -2759,9 +2236,9 @@ | ||
| 2759 | 2236 | * @since 2.2.10 |
| 2760 | 2237 | * |
| 2761 | 2238 | * @param array $post_values |
| 2762 | 2239 | * |
| 2763 | - * @return bool|int | |
| 2240 | + * @return boolean|int | |
| 2764 | 2241 | */ |
| 2765 | 2242 | public static function custom_style_value( $post_values ) { |
| 2766 | 2243 | if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) { |
| 2767 | 2244 | $custom_style = absint( $post_values['options']['custom_style'] ); |
| @@ -2766,37 +2243,29 @@ | ||
| 2766 | 2243 | if ( ! empty( $post_values ) && isset( $post_values['options']['custom_style'] ) ) { |
| 2767 | 2244 | $custom_style = absint( $post_values['options']['custom_style'] ); |
| 2768 | 2245 | } else { |
| 2769 | 2246 | $frm_settings = self::get_settings(); |
| 2770 | - $custom_style = ( $frm_settings->load_style !== 'none' ); | |
| 2247 | + $custom_style = ( $frm_settings->load_style != 'none' ); | |
| 2771 | 2248 | } |
| 2772 | 2249 | |
| 2773 | 2250 | return $custom_style; |
| 2774 | 2251 | } |
| 2775 | 2252 | |
| 2776 | - /** | |
| 2777 | - * @param mixed $original_string | |
| 2778 | - * @param int|string $length | |
| 2779 | - * @param int $minword | |
| 2780 | - * @param string $continue | |
| 2781 | - * @return string | |
| 2782 | - */ | |
| 2783 | - public static function truncate( $original_string, $length, $minword = 3, $continue = '...' ) { | |
| 2784 | - if ( ! is_string( $original_string ) && ! is_int( $original_string ) ) { | |
| 2253 | + public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { | |
| 2254 | + if ( is_array( $str ) ) { | |
| 2785 | 2255 | return ''; |
| 2786 | 2256 | } |
| 2787 | 2257 | |
| 2788 | 2258 | $length = (int) $length; |
| 2789 | - $str = wp_strip_all_tags( (string) $original_string ); | |
| 2259 | + $str = wp_strip_all_tags( $str ); | |
| 2790 | 2260 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 2791 | 2261 | |
| 2792 | 2262 | if ( $length == 0 ) { |
| 2793 | 2263 | return ''; |
| 2794 | - } | |
| 2264 | + } elseif ( $length <= 10 ) { | |
| 2265 | + $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); | |
| 2795 | 2266 | |
| 2796 | - if ( $length <= 10 ) { | |
| 2797 | - $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); | |
| 2798 | - return $sub . ( $length < $original_len ? $continue : '' ); | |
| 2267 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); | |
| 2799 | 2268 | } |
| 2800 | 2269 | |
| 2801 | 2270 | $sub = ''; |
| 2802 | 2271 | $len = 0; |
| @@ -2802,14 +2271,10 @@ | ||
| 2802 | 2271 | $len = 0; |
| 2803 | 2272 | |
| 2804 | 2273 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 2805 | 2274 | |
| 2806 | - if ( ! is_array( $words ) ) { | |
| 2807 | - return $original_string; | |
| 2808 | - } | |
| 2809 | - | |
| 2810 | 2275 | foreach ( $words as $word ) { |
| 2811 | - $part = ( $sub != '' ? ' ' : '' ) . $word; | |
| 2276 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; | |
| 2812 | 2277 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 2813 | 2278 | if ( $total_len > $length && substr_count( $sub, ' ' ) ) { |
| 2814 | 2279 | break; |
| 2815 | 2280 | } |
| @@ -2823,37 +2288,11 @@ | ||
| 2823 | 2288 | |
| 2824 | 2289 | unset( $total_len, $word ); |
| 2825 | 2290 | } |
| 2826 | 2291 | |
| 2827 | - $sub = self::maybe_force_truncate_on_string_with_no_spaces( $sub, $length ); | |
| 2828 | - | |
| 2829 | - return $sub . ( $len < $original_len ? $continue : '' ); | |
| 2292 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); | |
| 2830 | 2293 | } |
| 2831 | 2294 | |
| 2832 | - /** | |
| 2833 | - * If the string is still too long because there may not have been any spaces, force truncate. | |
| 2834 | - * | |
| 2835 | - * @since 6.5.4 | |
| 2836 | - * | |
| 2837 | - * @param string $sub Current substring. | |
| 2838 | - * @param int $length The length limit. | |
| 2839 | - * @return string | |
| 2840 | - */ | |
| 2841 | - private static function maybe_force_truncate_on_string_with_no_spaces( $sub, $length ) { | |
| 2842 | - if ( strlen( $sub ) < $length + 50 ) { | |
| 2843 | - // If the string isn't way over the limit, leave it. | |
| 2844 | - return $sub; | |
| 2845 | - } | |
| 2846 | - | |
| 2847 | - $first_space = strpos( $sub, ' ', $length ); | |
| 2848 | - if ( false !== $first_space ) { | |
| 2849 | - // Ignore anything with spaces. | |
| 2850 | - return $sub; | |
| 2851 | - } | |
| 2852 | - | |
| 2853 | - return substr( $sub, 0, $length + 10 ); | |
| 2854 | - } | |
| 2855 | - | |
| 2856 | 2295 | public static function mb_function( $function_names, $args ) { |
| 2857 | 2296 | $mb_function_name = $function_names[0]; |
| 2858 | 2297 | $function_name = $function_names[1]; |
| 2859 | 2298 | if ( function_exists( $mb_function_name ) ) { |
| @@ -2886,13 +2325,8 @@ | ||
| 2886 | 2325 | |
| 2887 | 2326 | return $formatted; |
| 2888 | 2327 | } |
| 2889 | 2328 | |
| 2890 | - /** | |
| 2891 | - * @param string $time_format | |
| 2892 | - * @param string $date | |
| 2893 | - * @return string | |
| 2894 | - */ | |
| 2895 | 2329 | private static function add_time_to_date( $time_format, $date ) { |
| 2896 | 2330 | if ( empty( $time_format ) ) { |
| 2897 | 2331 | $time_format = get_option( 'time_format' ); |
| 2898 | 2332 | } |
| @@ -2915,17 +2349,17 @@ | ||
| 2915 | 2349 | return date_i18n( $date_format, strtotime( $date ) ); |
| 2916 | 2350 | } |
| 2917 | 2351 | |
| 2918 | 2352 | /** |
| 2919 | - * Gets the time ago in words. | |
| 2353 | + * Gets the time ago in words | |
| 2920 | 2354 | * |
| 2921 | - * @param int $from In seconds. | |
| 2922 | - * @param int|string $to In seconds. | |
| 2355 | + * @param int $from in seconds | |
| 2356 | + * @param int|string $to in seconds | |
| 2923 | 2357 | * |
| 2924 | 2358 | * @return string $time_ago |
| 2925 | 2359 | */ |
| 2926 | 2360 | public static function human_time_diff( $from, $to = '', $levels = 1 ) { |
| 2927 | - if ( empty( $to ) && 0 !== $to ) { | |
| 2361 | + if ( empty( $to ) ) { | |
| 2928 | 2362 | $now = new DateTime(); |
| 2929 | 2363 | } else { |
| 2930 | 2364 | $now = new DateTime( '@' . $to ); |
| 2931 | 2365 | } |
| @@ -2935,9 +2369,9 @@ | ||
| 2935 | 2369 | $diff_object = $now->diff( $ago ); |
| 2936 | 2370 | $diff = get_object_vars( $diff_object ); |
| 2937 | 2371 | |
| 2938 | 2372 | // Add week amount and update day amount |
| 2939 | - $diff['w'] = floor( $diff['d'] / 7 ); | |
| 2373 | + $diff['w'] = floor( $diff['d'] / 7 ); | |
| 2940 | 2374 | $diff['d'] -= $diff['w'] * 7; |
| 2941 | 2375 | |
| 2942 | 2376 | $time_strings = self::get_time_strings(); |
| 2943 | 2377 | |
| @@ -2944,9 +2378,9 @@ | ||
| 2944 | 2378 | if ( ! is_numeric( $levels ) ) { |
| 2945 | 2379 | // Show time in specified unit. |
| 2946 | 2380 | $levels = self::get_unit( $levels ); |
| 2947 | 2381 | if ( isset( $time_strings[ $levels ] ) ) { |
| 2948 | - $diff = array( | |
| 2382 | + $diff = array( | |
| 2949 | 2383 | $levels => self::time_format( $levels, $diff ), |
| 2950 | 2384 | ); |
| 2951 | 2385 | $time_strings = array( |
| 2952 | 2386 | $levels => $time_strings[ $levels ], |
| @@ -3035,9 +2469,9 @@ | ||
| 3035 | 2469 | } |
| 3036 | 2470 | |
| 3037 | 2471 | /** |
| 3038 | 2472 | * Get the translatable time strings. The untranslated version is a failsafe |
| 3039 | - * in case languages are changing for the unit set in the shortcode. | |
| 2473 | + * in case langauges are changing for the unit set in the shortcode. | |
| 3040 | 2474 | * |
| 3041 | 2475 | * @since 2.0.20 |
| 3042 | 2476 | * @return array |
| 3043 | 2477 | */ |
| @@ -3083,28 +2517,23 @@ | ||
| 3083 | 2517 | |
| 3084 | 2518 | // Pagination Methods. |
| 3085 | 2519 | |
| 3086 | 2520 | /** |
| 3087 | - * @param int $r_count | |
| 3088 | - * @param int $current_p | |
| 3089 | - * @param int $p_size | |
| 3090 | - * @return int | |
| 2521 | + * @param integer $current_p | |
| 3091 | 2522 | */ |
| 3092 | 2523 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 3093 | - return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size ); | |
| 2524 | + return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); | |
| 3094 | 2525 | } |
| 3095 | 2526 | |
| 3096 | 2527 | /** |
| 3097 | - * @param int $r_count | |
| 3098 | - * @param int $current_p | |
| 3099 | - * @param int $p_size | |
| 3100 | - * @return int | |
| 2528 | + * @param integer $current_p | |
| 3101 | 2529 | */ |
| 3102 | 2530 | public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
| 3103 | 2531 | if ( $current_p == 1 ) { |
| 3104 | 2532 | return 1; |
| 2533 | + } else { | |
| 2534 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); | |
| 3105 | 2535 | } |
| 3106 | - return self::get_last_record_num( $r_count, $current_p - 1, $p_size ) + 1; | |
| 3107 | 2536 | } |
| 3108 | 2537 | |
| 3109 | 2538 | /** |
| 3110 | 2539 | * @return array |
| @@ -3127,9 +2556,9 @@ | ||
| 3127 | 2556 | if ( ! isset( $l3 ) ) { |
| 3128 | 2557 | $l3 = $name; |
| 3129 | 2558 | } |
| 3130 | 2559 | |
| 3131 | - $this_val = $p == $last ? $jv['value'] : array(); | |
| 2560 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); | |
| 3132 | 2561 | |
| 3133 | 2562 | switch ( $p ) { |
| 3134 | 2563 | case 0: |
| 3135 | 2564 | $l1 = $name; |
| @@ -3151,12 +2580,12 @@ | ||
| 3151 | 2580 | self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
| 3152 | 2581 | } |
| 3153 | 2582 | |
| 3154 | 2583 | unset( $this_val, $n ); |
| 3155 | - }//end foreach | |
| 2584 | + } | |
| 3156 | 2585 | |
| 3157 | 2586 | unset( $last, $jv ); |
| 3158 | - }//end foreach | |
| 2587 | + } | |
| 3159 | 2588 | |
| 3160 | 2589 | return $vars; |
| 3161 | 2590 | } |
| 3162 | 2591 | |
| @@ -3174,9 +2603,9 @@ | ||
| 3174 | 2603 | |
| 3175 | 2604 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 3176 | 2605 | $tooltips = array( |
| 3177 | 2606 | 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
| 3178 | - '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' ), | |
| 2607 | + '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' ), | |
| 3179 | 2608 | 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), |
| 3180 | 2609 | 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <name@email.com> or name@email.com.', 'formidable' ), |
| 3181 | 2610 | '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' ), |
| 3182 | 2611 | 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ), |
| @@ -3181,9 +2610,8 @@ | ||
| 3181 | 2610 | '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' ), |
| 3182 | 2611 | 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <john@example.com> or john@example.com.', 'formidable' ), |
| 3183 | 2612 | /* translators: %1$s: Form name, %2$s: Date */ |
| 3184 | 2613 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
| 3185 | - 'new_tab' => __( 'This option will open the link in a new browser tab. Please note that some popup blockers may prevent this from happening, in which case the link will be displayed.', 'formidable' ), | |
| 3186 | 2614 | ); |
| 3187 | 2615 | |
| 3188 | 2616 | if ( ! isset( $tooltips[ $name ] ) ) { |
| 3189 | 2617 | return; |
| @@ -3276,11 +2704,8 @@ | ||
| 3276 | 2704 | * Check for either json or serialized data. This is temporary while transitioning |
| 3277 | 2705 | * all data to json. |
| 3278 | 2706 | * |
| 3279 | 2707 | * @since 4.02.03 |
| 3280 | - * | |
| 3281 | - * @param array|string $value | |
| 3282 | - * @return void | |
| 3283 | 2708 | */ |
| 3284 | 2709 | public static function unserialize_or_decode( &$value ) { |
| 3285 | 2710 | if ( is_array( $value ) ) { |
| 3286 | 2711 | return; |
| @@ -3286,9 +2711,9 @@ | ||
| 3286 | 2711 | return; |
| 3287 | 2712 | } |
| 3288 | 2713 | |
| 3289 | 2714 | if ( is_serialized( $value ) ) { |
| 3290 | - $value = self::maybe_unserialize_array( $value ); | |
| 2715 | + $value = maybe_unserialize( $value ); | |
| 3291 | 2716 | } else { |
| 3292 | 2717 | $value = self::maybe_json_decode( $value, false ); |
| 3293 | 2718 | } |
| 3294 | 2719 | } |
| @@ -3293,35 +2718,8 @@ | ||
| 3293 | 2718 | } |
| 3294 | 2719 | } |
| 3295 | 2720 | |
| 3296 | 2721 | /** |
| 3297 | - * Safely unserialize an array if necessary. | |
| 3298 | - * This function doesn't actually use unserialize. The string is parsed instead. | |
| 3299 | - * | |
| 3300 | - * @since 6.2 | |
| 3301 | - * | |
| 3302 | - * @param mixed $value | |
| 3303 | - * @return mixed | |
| 3304 | - */ | |
| 3305 | - public static function maybe_unserialize_array( $value ) { | |
| 3306 | - if ( ! is_string( $value ) ) { | |
| 3307 | - return $value; | |
| 3308 | - } | |
| 3309 | - | |
| 3310 | - // Since we only expect an array, skip anything that doesn't start with a:. | |
| 3311 | - if ( ! is_serialized( $value ) || 'a:' !== substr( $value, 0, 2 ) ) { | |
| 3312 | - return $value; | |
| 3313 | - } | |
| 3314 | - | |
| 3315 | - $parsed = FrmSerializedStringParserHelper::get()->parse( $value ); | |
| 3316 | - if ( is_array( $parsed ) ) { | |
| 3317 | - $value = $parsed; | |
| 3318 | - } | |
| 3319 | - | |
| 3320 | - return $value; | |
| 3321 | - } | |
| 3322 | - | |
| 3323 | - /** | |
| 3324 | 2722 | * Decode a JSON string. |
| 3325 | 2723 | * Do not switch shortcodes like [24] to array unless intentional ie XML values. |
| 3326 | 2724 | * |
| 3327 | 2725 | * @param mixed $string |
| @@ -3348,36 +2746,8 @@ | ||
| 3348 | 2746 | return $string; |
| 3349 | 2747 | } |
| 3350 | 2748 | |
| 3351 | 2749 | /** |
| 3352 | - * @since 6.2.3 | |
| 3353 | - * | |
| 3354 | - * @param string $value | |
| 3355 | - * @return string | |
| 3356 | - */ | |
| 3357 | - public static function maybe_utf8_encode( $value ) { | |
| 3358 | - $from_format = 'ISO-8859-1'; | |
| 3359 | - $to_format = 'UTF-8'; | |
| 3360 | - | |
| 3361 | - if ( function_exists( 'mb_check_encoding' ) && function_exists( 'mb_convert_encoding' ) ) { | |
| 3362 | - if ( mb_check_encoding( $value, $from_format ) ) { | |
| 3363 | - return mb_convert_encoding( $value, $to_format, $from_format ); | |
| 3364 | - } | |
| 3365 | - return $value; | |
| 3366 | - } | |
| 3367 | - | |
| 3368 | - if ( function_exists( 'iconv' ) ) { | |
| 3369 | - $converted = iconv( $from_format, $to_format, $value ); | |
| 3370 | - // Value is false if $value is not ISO-8859-1. | |
| 3371 | - if ( false !== $converted ) { | |
| 3372 | - return $converted; | |
| 3373 | - } | |
| 3374 | - } | |
| 3375 | - | |
| 3376 | - return $value; | |
| 3377 | - } | |
| 3378 | - | |
| 3379 | - /** | |
| 3380 | 2750 | * Reformat the json serialized array in name => value array. |
| 3381 | 2751 | * |
| 3382 | 2752 | * @since 4.02.03 |
| 3383 | 2753 | */ |
| @@ -3404,11 +2774,8 @@ | ||
| 3404 | 2774 | } |
| 3405 | 2775 | |
| 3406 | 2776 | /** |
| 3407 | 2777 | * @since 4.02.03 |
| 3408 | - * | |
| 3409 | - * @param array|string $value | |
| 3410 | - * @return string | |
| 3411 | 2778 | */ |
| 3412 | 2779 | public static function maybe_json_encode( $value ) { |
| 3413 | 2780 | if ( is_array( $value ) ) { |
| 3414 | 2781 | $value = wp_json_encode( $value ); |
| @@ -3416,14 +2783,12 @@ | ||
| 3416 | 2783 | return $value; |
| 3417 | 2784 | } |
| 3418 | 2785 | |
| 3419 | 2786 | /** |
| 3420 | - * Echo The javascript to open and highlight the Formidable menu | |
| 3421 | - * | |
| 3422 | 2787 | * @since 1.07.10 |
| 3423 | 2788 | * |
| 3424 | - * @param string $post_type The name of the post type that may need to be highlighted. | |
| 3425 | - * @return void | |
| 2789 | + * @param string $post_type The name of the post type that may need to be highlighted | |
| 2790 | + * echo The javascript to open and highlight the Formidable menu | |
| 3426 | 2791 | */ |
| 3427 | 2792 | public static function maybe_highlight_menu( $post_type ) { |
| 3428 | 2793 | global $post; |
| 3429 | 2794 | |
| @@ -3442,11 +2807,8 @@ | ||
| 3442 | 2807 | /** |
| 3443 | 2808 | * Load the JS file on non-Formidable pages in the admin area |
| 3444 | 2809 | * |
| 3445 | 2810 | * @since 2.0 |
| 3446 | - * | |
| 3447 | - * @param bool $load | |
| 3448 | - * @return void | |
| 3449 | 2811 | */ |
| 3450 | 2812 | public static function load_admin_wide_js( $load = true ) { |
| 3451 | 2813 | $version = self::plugin_version(); |
| 3452 | 2814 | wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| @@ -3460,9 +2822,8 @@ | ||
| 3460 | 2822 | 'canAccessApplicationDashboard' => current_user_can( is_callable( 'FrmProApplicationsHelper::get_required_templates_capability' ) ? FrmProApplicationsHelper::get_required_templates_capability() : 'frm_edit_forms' ), |
| 3461 | 2823 | 'loading' => __( 'Loading…', 'formidable' ), |
| 3462 | 2824 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 3463 | 2825 | 'proIncludesSliderJs' => is_callable( 'FrmProFormsHelper::prepare_custom_currency' ), |
| 3464 | - 'inboxSlideIn' => FrmInbox::get_inbox_slide_in_value_for_js(), | |
| 3465 | 2826 | ); |
| 3466 | 2827 | wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings ); |
| 3467 | 2828 | |
| 3468 | 2829 | if ( $load ) { |
| @@ -3471,9 +2832,8 @@ | ||
| 3471 | 2832 | } |
| 3472 | 2833 | |
| 3473 | 2834 | /** |
| 3474 | 2835 | * @since 2.0.9 |
| 3475 | - * @return void | |
| 3476 | 2836 | */ |
| 3477 | 2837 | public static function load_font_style() { |
| 3478 | 2838 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 3479 | 2839 | } |
| @@ -3479,133 +2839,99 @@ | ||
| 3479 | 2839 | } |
| 3480 | 2840 | |
| 3481 | 2841 | /** |
| 3482 | 2842 | * @param string $location |
| 3483 | - * @return void | |
| 3484 | 2843 | */ |
| 3485 | 2844 | public static function localize_script( $location ) { |
| 3486 | - global $wp_scripts, $wp_version; | |
| 2845 | + global $wp_scripts; | |
| 3487 | 2846 | |
| 2847 | + $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); | |
| 2848 | + $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); | |
| 2849 | + | |
| 3488 | 2850 | $script_strings = array( |
| 3489 | - 'ajax_url' => esc_url_raw( self::get_ajax_url() ), | |
| 3490 | - 'images_url' => self::plugin_url() . '/images', | |
| 3491 | - 'loading' => __( 'Loading…', 'formidable' ), | |
| 3492 | - 'remove' => __( 'Remove', 'formidable' ), | |
| 3493 | - 'offset' => apply_filters( 'frm_scroll_offset', 4 ), | |
| 3494 | - 'nonce' => wp_create_nonce( 'frm_ajax' ), | |
| 3495 | - 'id' => __( 'ID', 'formidable' ), | |
| 3496 | - 'no_results' => __( 'No results match', 'formidable' ), | |
| 3497 | - 'file_spam' => __( 'That file looks like Spam.', 'formidable' ), | |
| 3498 | - 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ), | |
| 3499 | - 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ), | |
| 3500 | - 'focus_first_error' => self::should_focus_first_error(), | |
| 3501 | - 'include_alert_role' => self::should_include_alert_role_on_field_errors(), | |
| 3502 | - // We need to keep this setting for a few versions because Pro checks for this. | |
| 3503 | - 'include_resend_email' => false, | |
| 2851 | + 'ajax_url' => $ajax_url, | |
| 2852 | + 'images_url' => self::plugin_url() . '/images', | |
| 2853 | + 'loading' => __( 'Loading…', 'formidable' ), | |
| 2854 | + 'remove' => __( 'Remove', 'formidable' ), | |
| 2855 | + 'offset' => apply_filters( 'frm_scroll_offset', 4 ), | |
| 2856 | + 'nonce' => wp_create_nonce( 'frm_ajax' ), | |
| 2857 | + 'id' => __( 'ID', 'formidable' ), | |
| 2858 | + 'no_results' => __( 'No results match', 'formidable' ), | |
| 2859 | + 'file_spam' => __( 'That file looks like Spam.', 'formidable' ), | |
| 2860 | + 'calc_error' => __( 'There is an error in the calculation in the field with key', 'formidable' ), | |
| 2861 | + 'empty_fields' => __( 'Please complete the preceding required fields before uploading a file.', 'formidable' ), | |
| 2862 | + 'focus_first_error' => self::should_focus_first_error(), | |
| 2863 | + 'include_alert_role' => self::should_include_alert_role_on_field_errors(), | |
| 3504 | 2864 | ); |
| 3505 | 2865 | |
| 3506 | 2866 | $data = $wp_scripts->get_data( 'formidable', 'data' ); |
| 3507 | - if ( ! $data ) { | |
| 2867 | + if ( empty( $data ) ) { | |
| 3508 | 2868 | wp_localize_script( 'formidable', 'frm_js', $script_strings ); |
| 3509 | 2869 | } |
| 3510 | 2870 | |
| 3511 | - if ( $location === 'admin' ) { | |
| 2871 | + if ( $location == 'admin' ) { | |
| 2872 | + $frm_settings = self::get_settings(); | |
| 3512 | 2873 | $admin_script_strings = array( |
| 3513 | - 'desc' => __( '(Click to add description)', 'formidable' ), | |
| 3514 | - 'blank' => __( '(Blank)', 'formidable' ), | |
| 3515 | - 'no_label' => __( '(no label)', 'formidable' ), | |
| 3516 | - 'ok' => __( 'OK', 'formidable' ), | |
| 3517 | - 'cancel' => __( 'Cancel', 'formidable' ), | |
| 3518 | - 'default_label' => __( 'Default', 'formidable' ), | |
| 3519 | - 'clear_default' => __( 'Clear default value when typing', 'formidable' ), | |
| 3520 | - 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ), | |
| 3521 | - 'valid_default' => __( 'Default value will pass form validation', 'formidable' ), | |
| 3522 | - 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ), | |
| 3523 | - 'confirm' => __( 'Are you sure?', 'formidable' ), | |
| 3524 | - 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ), | |
| 3525 | - 'conf_delete_sec' => __( 'All fields inside this Section will be deleted along with their data. Are you sure you want to delete this group of fields?', 'formidable' ), | |
| 3526 | - 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ), | |
| 3527 | - 'default_unique' => FrmFieldsHelper::default_unique_msg(), | |
| 3528 | - 'default_conf' => __( 'The entered values do not match', 'formidable' ), | |
| 3529 | - 'enter_email' => __( 'Enter Email', 'formidable' ), | |
| 3530 | - 'confirm_email' => __( 'Confirm Email', 'formidable' ), | |
| 3531 | - 'conditional_text' => __( 'Conditional content here', 'formidable' ), | |
| 3532 | - 'new_option' => __( 'New Option', 'formidable' ), | |
| 3533 | - 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ), | |
| 3534 | - 'enter_password' => __( 'Enter Password', 'formidable' ), | |
| 3535 | - 'confirm_password' => __( 'Confirm Password', 'formidable' ), | |
| 3536 | - 'import_complete' => __( 'Import Complete', 'formidable' ), | |
| 3537 | - 'updating' => __( 'Please wait while your site updates.', 'formidable' ), | |
| 3538 | - 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ), | |
| 3539 | - 'private_label' => __( 'Private', 'formidable' ), | |
| 3540 | - 'jquery_ui_url' => '', | |
| 3541 | - 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '', | |
| 3542 | - 'no_licenses' => __( 'No new licenses were found', 'formidable' ), | |
| 3543 | - 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ), | |
| 3544 | - 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ), | |
| 3545 | - 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ), | |
| 3546 | - /* translators: %d is the number of allowed actions per form */ | |
| 3547 | - 'only_one_action' => sprintf( __( 'This form action is limited to %d per form.', 'formidable' ), 1 ), | |
| 3548 | - 'edit_action_text' => __( 'Please edit the existing form action.', 'formidable' ), | |
| 3549 | - 'unsafe_params' => FrmFormsHelper::reserved_words(), | |
| 2874 | + 'desc' => __( '(Click to add description)', 'formidable' ), | |
| 2875 | + 'blank' => __( '(Blank)', 'formidable' ), | |
| 2876 | + 'no_label' => __( '(no label)', 'formidable' ), | |
| 2877 | + 'saving' => '', // Deprecated in 6.0. | |
| 2878 | + 'saved' => '', // Deprecated in 6.0. | |
| 2879 | + 'ok' => __( 'OK', 'formidable' ), | |
| 2880 | + 'cancel' => __( 'Cancel', 'formidable' ), | |
| 2881 | + 'default_label' => __( 'Default', 'formidable' ), | |
| 2882 | + 'clear_default' => __( 'Clear default value when typing', 'formidable' ), | |
| 2883 | + 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ), | |
| 2884 | + 'valid_default' => __( 'Default value will pass form validation', 'formidable' ), | |
| 2885 | + 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ), | |
| 2886 | + 'confirm' => __( 'Are you sure?', 'formidable' ), | |
| 2887 | + 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ), | |
| 2888 | + 'conf_delete_sec' => __( 'All fields inside this Section will be deleted along with their data. Are you sure you want to delete this group of fields?', 'formidable' ), | |
| 2889 | + 'conf_no_repeat' => __( 'Warning: If you have entries with multiple rows, all but the first row will be lost.', 'formidable' ), | |
| 2890 | + 'default_unique' => $frm_settings->unique_msg, | |
| 2891 | + 'default_conf' => __( 'The entered values do not match', 'formidable' ), | |
| 2892 | + 'enter_email' => __( 'Enter Email', 'formidable' ), | |
| 2893 | + 'confirm_email' => __( 'Confirm Email', 'formidable' ), | |
| 2894 | + 'conditional_text' => __( 'Conditional content here', 'formidable' ), | |
| 2895 | + 'new_option' => __( 'New Option', 'formidable' ), | |
| 2896 | + 'css_invalid_size' => __( 'In certain browsers (e.g. Firefox) text will not display correctly if the field height is too small relative to the field padding and text size. Please increase your field height or decrease your field padding.', 'formidable' ), | |
| 2897 | + 'enter_password' => __( 'Enter Password', 'formidable' ), | |
| 2898 | + 'confirm_password' => __( 'Confirm Password', 'formidable' ), | |
| 2899 | + 'import_complete' => __( 'Import Complete', 'formidable' ), | |
| 2900 | + 'updating' => __( 'Please wait while your site updates.', 'formidable' ), | |
| 2901 | + 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ), | |
| 2902 | + 'private_label' => __( 'Private', 'formidable' ), | |
| 2903 | + 'jquery_ui_url' => '', | |
| 2904 | + 'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '', | |
| 2905 | + 'no_licenses' => __( 'No new licenses were found', 'formidable' ), | |
| 2906 | + 'unmatched_parens' => __( 'This calculation has at least one unmatched ( ) { } [ ].', 'formidable' ), | |
| 2907 | + 'view_shortcodes' => __( 'This calculation may have shortcodes that work in Views but not forms.', 'formidable' ), | |
| 2908 | + 'text_shortcodes' => __( 'This calculation may have shortcodes that work in text calculations but not numeric calculations.', 'formidable' ), | |
| 2909 | + 'only_one_action' => __( 'This form action is limited to one per form. Please edit the existing form action.', 'formidable' ), | |
| 2910 | + 'unsafe_params' => FrmFormsHelper::reserved_words(), | |
| 3550 | 2911 | /* Translators: %s is the name of a Detail Page Slug that is a reserved word.*/ |
| 3551 | - 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ), | |
| 2912 | + 'slug_is_reserved' => sprintf( __( 'The Detail Page Slug "%s" is reserved by WordPress. This may cause problems. Is this intentional?', 'formidable' ), '****' ), | |
| 3552 | 2913 | /* Translators: %s is the name of a parameter that is a reserved word. More than one word could be listed here, though that would not be common. */ |
| 3553 | - 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ), | |
| 3554 | - 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ), | |
| 3555 | - 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ), | |
| 3556 | - 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ), | |
| 3557 | - 'install' => __( 'Install', 'formidable' ), | |
| 3558 | - 'active' => __( 'Active', 'formidable' ), | |
| 3559 | - 'installed' => __( 'Installed', 'formidable' ), | |
| 3560 | - 'not_installed' => __( 'Not Installed', 'formidable' ), | |
| 3561 | - 'select_a_field' => __( 'Select a Field', 'formidable' ), | |
| 3562 | - 'no_items_found' => __( 'No items found.', 'formidable' ), | |
| 3563 | - 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ), | |
| 3564 | - | |
| 3565 | - // Deprecated in 6.0. | |
| 3566 | - 'saving' => '', | |
| 3567 | - | |
| 3568 | - // Deprecated in 6.0. | |
| 3569 | - 'saved' => '', | |
| 3570 | - | |
| 3571 | - // translators: %1$s: HTML open tag, %2$s: HTML end tag. | |
| 3572 | - 'holdShiftMsg' => esc_html__( 'You can hold %1$sShift%2$s on your keyboard to select multiple fields', 'formidable' ), | |
| 3573 | - 'noTitleText' => FrmFormsHelper::get_no_title_text(), | |
| 3574 | - | |
| 3575 | - // In older versions this event listener causes the section to immediately close again | |
| 3576 | - // when the h3 element is clicked. It's only required in WP 6.7+. | |
| 3577 | - 'requireAccordionTitleClickListener' => version_compare( $wp_version, '6.7', '>=' ), | |
| 2914 | + 'param_is_reserved' => sprintf( __( 'The parameter "%s" is reserved by WordPress. This may cause problems when included in the URL. Is this intentional? ', 'formidable' ), '****' ), | |
| 2915 | + 'reserved_words' => __( 'See the list of reserved words in WordPress.', 'formidable' ), | |
| 2916 | + 'repeat_limit_min' => __( 'Please enter a Repeat Limit that is greater than 1.', 'formidable' ), | |
| 2917 | + 'checkbox_limit' => __( 'Please select a limit between 0 and 200.', 'formidable' ), | |
| 2918 | + 'install' => __( 'Install', 'formidable' ), | |
| 2919 | + 'active' => __( 'Active', 'formidable' ), | |
| 2920 | + 'select_a_field' => __( 'Select a Field', 'formidable' ), | |
| 2921 | + 'no_items_found' => __( 'No items found.', 'formidable' ), | |
| 2922 | + 'field_already_used' => __( 'Oops. You have already used that field.', 'formidable' ), | |
| 3578 | 2923 | ); |
| 3579 | - /** | |
| 3580 | - * @param array $admin_script_strings | |
| 3581 | - */ | |
| 3582 | 2924 | $admin_script_strings = apply_filters( 'frm_admin_script_strings', $admin_script_strings ); |
| 3583 | 2925 | |
| 3584 | 2926 | $data = $wp_scripts->get_data( 'formidable_admin', 'data' ); |
| 3585 | - if ( ! $data ) { | |
| 2927 | + if ( empty( $data ) ) { | |
| 3586 | 2928 | wp_localize_script( 'formidable_admin', 'frm_admin_js', $admin_script_strings ); |
| 3587 | 2929 | } |
| 3588 | - }//end if | |
| 2930 | + } | |
| 3589 | 2931 | } |
| 3590 | 2932 | |
| 3591 | 2933 | /** |
| 3592 | - * @since 6.5 | |
| 3593 | - * | |
| 3594 | - * @return string | |
| 3595 | - */ | |
| 3596 | - public static function get_ajax_url() { | |
| 3597 | - $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); | |
| 3598 | - | |
| 3599 | - /** | |
| 3600 | - * @since 2.0.13 | |
| 3601 | - * | |
| 3602 | - * @param string $ajax_url | |
| 3603 | - */ | |
| 3604 | - return apply_filters( 'frm_ajax_url', $ajax_url ); | |
| 3605 | - } | |
| 3606 | - | |
| 3607 | - /** | |
| 3608 | 2934 | * Returns whether or not the first errored input should be auto-focused (default true). |
| 3609 | 2935 | * |
| 3610 | 2936 | * @since 5.2.05 |
| 3611 | 2937 | * |
| @@ -3630,10 +2956,9 @@ | ||
| 3630 | 2956 | * Echo the message on the plugins listing page |
| 3631 | 2957 | * |
| 3632 | 2958 | * @since 1.07.10 |
| 3633 | 2959 | * |
| 3634 | - * @param float $min_version The version the add-on requires. | |
| 3635 | - * @return void | |
| 2960 | + * @param float $min_version The version the add-on requires | |
| 3636 | 2961 | */ |
| 3637 | 2962 | public static function min_version_notice( $min_version ) { |
| 3638 | 2963 | $frm_version = self::plugin_version(); |
| 3639 | 2964 | |
| @@ -3667,8 +2992,9 @@ | ||
| 3667 | 2992 | if ( ! $is_pro || self::meets_min_pro_version( $min_version ) ) { |
| 3668 | 2993 | return; |
| 3669 | 2994 | } |
| 3670 | 2995 | |
| 2996 | + $pro_version = FrmProDb::$plug_version; | |
| 3671 | 2997 | $expired = FrmAddonsController::is_license_expired(); |
| 3672 | 2998 | ?> |
| 3673 | 2999 | <div class="frm-banner-alert frm_error_style frm_previous_install"> |
| 3674 | 3000 | <?php |
| @@ -3686,11 +3012,8 @@ | ||
| 3686 | 3012 | /** |
| 3687 | 3013 | * If Pro is installed, check the version number. |
| 3688 | 3014 | * |
| 3689 | 3015 | * @since 4.0.01 |
| 3690 | - * | |
| 3691 | - * @param string $min_version | |
| 3692 | - * @return bool | |
| 3693 | 3016 | */ |
| 3694 | 3017 | public static function meets_min_pro_version( $min_version ) { |
| 3695 | 3018 | return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' ); |
| 3696 | 3019 | } |
| @@ -3695,19 +3018,24 @@ | ||
| 3695 | 3018 | return ! class_exists( 'FrmProDb' ) || version_compare( FrmProDb::$plug_version, $min_version, '>=' ); |
| 3696 | 3019 | } |
| 3697 | 3020 | |
| 3698 | 3021 | /** |
| 3699 | - * Show a message if the PHP version is below the recommendations. | |
| 3022 | + * Show a message if the browser or PHP version is below the recommendations. | |
| 3700 | 3023 | * |
| 3701 | 3024 | * @since 4.0.02 |
| 3702 | - * @return void | |
| 3703 | 3025 | */ |
| 3704 | 3026 | private static function php_version_notice() { |
| 3705 | 3027 | $message = array(); |
| 3706 | - if ( version_compare( phpversion(), '7.0', '<' ) ) { | |
| 3028 | + if ( version_compare( phpversion(), '5.6', '<' ) ) { | |
| 3707 | 3029 | $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' ); |
| 3708 | 3030 | } |
| 3709 | 3031 | |
| 3032 | + $browser = self::get_server_value( 'HTTP_USER_AGENT' ); | |
| 3033 | + $is_ie = strpos( $browser, 'MSIE' ) !== false; | |
| 3034 | + if ( $is_ie ) { | |
| 3035 | + $message[] = __( 'You are using an outdated browser that is not compatible with Formidable Forms. Please update to a more current browser (we recommend Chrome).', 'formidable' ); | |
| 3036 | + } | |
| 3037 | + | |
| 3710 | 3038 | foreach ( $message as $m ) { |
| 3711 | 3039 | ?> |
| 3712 | 3040 | <div class="frm-banner-alert frm_error_style frm_previous_install"> |
| 3713 | 3041 | <?php echo esc_html( $m ); ?> |
| @@ -3837,10 +3165,16 @@ | ||
| 3837 | 3165 | return $locales; |
| 3838 | 3166 | } |
| 3839 | 3167 | |
| 3840 | 3168 | /** |
| 3841 | - * @return string | |
| 3169 | + * Output HTML containing reference text for accessibility | |
| 3170 | + * | |
| 3171 | + * @deprecated 5.1 | |
| 3842 | 3172 | */ |
| 3173 | + public static function multiselect_accessibility() { | |
| 3174 | + _deprecated_function( __METHOD__, '5.1' ); | |
| 3175 | + } | |
| 3176 | + | |
| 3843 | 3177 | public static function get_menu_icon_class() { |
| 3844 | 3178 | if ( is_callable( 'FrmProAppHelper::get_settings' ) ) { |
| 3845 | 3179 | $settings = FrmProAppHelper::get_settings(); |
| 3846 | 3180 | if ( is_object( $settings ) && ! empty( $settings->menu_icon ) ) { |
| @@ -3903,8 +3237,14 @@ | ||
| 3903 | 3237 | |
| 3904 | 3238 | $new_args['options'] = (array) $new_args['options']; |
| 3905 | 3239 | $new_args['input_attrs'] = (array) $new_args['input_attrs']; |
| 3906 | 3240 | |
| 3241 | + // Set the number of columns. | |
| 3242 | + $new_args['col_class'] = ceil( 12 / count( $new_args['options'] ) ); | |
| 3243 | + if ( $new_args['col_class'] > 6 ) { | |
| 3244 | + $new_args['col_class'] = ceil( $new_args['col_class'] / 2 ); | |
| 3245 | + } | |
| 3246 | + | |
| 3907 | 3247 | /** |
| 3908 | 3248 | * Allows modifying the arguments of images_dropdown() method. |
| 3909 | 3249 | * |
| 3910 | 3250 | * @since 5.0.04 |
| @@ -3944,18 +3284,8 @@ | ||
| 3944 | 3284 | return apply_filters( 'frm_images_dropdown_input_attrs', $input_attrs_str, $args ); |
| 3945 | 3285 | } |
| 3946 | 3286 | |
| 3947 | 3287 | /** |
| 3948 | - * @since 6.7.1 | |
| 3949 | - */ | |
| 3950 | - public static function get_images_dropdown_atts( $option, $args ) { | |
| 3951 | - $image = self::get_images_dropdown_option_image( $option, $args ); | |
| 3952 | - $classes = self::get_images_dropdown_option_classes( $option, $args ); | |
| 3953 | - $custom_attrs = self::get_images_dropdown_option_html_attrs( $option, $args ); | |
| 3954 | - return compact( 'image', 'classes', 'custom_attrs' ); | |
| 3955 | - } | |
| 3956 | - | |
| 3957 | - /** | |
| 3958 | 3288 | * Gets the image of each option in images_dropdown() method. |
| 3959 | 3289 | * |
| 3960 | 3290 | * @since 5.0.04 |
| 3961 | 3291 | * |
| @@ -3966,9 +3296,9 @@ | ||
| 3966 | 3296 | private static function get_images_dropdown_option_image( $option, $args ) { |
| 3967 | 3297 | $image = self::icon_by_class( |
| 3968 | 3298 | 'frmfont ' . $option['svg'], |
| 3969 | 3299 | array( |
| 3970 | - 'echo' => false, | |
| 3300 | + 'echo' => false, | |
| 3971 | 3301 | ) |
| 3972 | 3302 | ); |
| 3973 | 3303 | |
| 3974 | 3304 | $args['option'] = $option; |
| @@ -4106,15 +3436,15 @@ | ||
| 4106 | 3436 | return $values; |
| 4107 | 3437 | } |
| 4108 | 3438 | |
| 4109 | 3439 | /** |
| 4110 | - * Some back end fields allow privileged users to add scripts. | |
| 3440 | + * Some back end fields allow privleged users to add scripts. | |
| 4111 | 3441 | * A site that uses the DISALLOW_UNFILTERED_HTML always remove scripts on echo. |
| 4112 | 3442 | * |
| 4113 | 3443 | * @since 5.0.13 |
| 4114 | 3444 | * |
| 4115 | 3445 | * @param string $value |
| 4116 | - * @param array|string $allowed 'all' for everything included as defaults. | |
| 3446 | + * @param array|string $allowed 'all' for everything included as defaults | |
| 4117 | 3447 | * @return string |
| 4118 | 3448 | */ |
| 4119 | 3449 | public static function maybe_kses( $value, $allowed = 'all' ) { |
| 4120 | 3450 | if ( self::should_never_allow_unfiltered_html() ) { |
| @@ -4123,64 +3453,8 @@ | ||
| 4123 | 3453 | return $value; |
| 4124 | 3454 | } |
| 4125 | 3455 | |
| 4126 | 3456 | /** |
| 4127 | - * Check if an option attribute used in an [input] shortcode is safe. | |
| 4128 | - * | |
| 4129 | - * @since 6.11.2 | |
| 4130 | - * | |
| 4131 | - * @param string $key | |
| 4132 | - * @param string $context Either 'display' or 'update'. On update, we want to allow a few keys that are never displayed. | |
| 4133 | - * @return bool | |
| 4134 | - */ | |
| 4135 | - public static function input_key_is_safe( $key, $context = 'display' ) { | |
| 4136 | - if ( 'update' === $context && in_array( $key, array( 'opt', 'label' ), true ) ) { | |
| 4137 | - $safe = true; | |
| 4138 | - } elseif ( 0 === strpos( $key, 'data-' ) ) { | |
| 4139 | - // Allow all data attributes. | |
| 4140 | - $safe = true; | |
| 4141 | - } elseif ( 0 === strpos( $key, 'aria-' ) ) { | |
| 4142 | - // Allow all aria attributes. | |
| 4143 | - $safe = true; | |
| 4144 | - } else { | |
| 4145 | - $safe_keys = array( | |
| 4146 | - 'class', | |
| 4147 | - 'required', | |
| 4148 | - 'title', | |
| 4149 | - 'placeholder', | |
| 4150 | - 'value', | |
| 4151 | - 'readonly', | |
| 4152 | - 'disabled', | |
| 4153 | - 'size', | |
| 4154 | - 'maxlength', | |
| 4155 | - 'min', | |
| 4156 | - 'max', | |
| 4157 | - 'pattern', | |
| 4158 | - 'step', | |
| 4159 | - 'autofocus', | |
| 4160 | - 'width', | |
| 4161 | - 'height', | |
| 4162 | - 'autocomplete', | |
| 4163 | - 'tabindex', | |
| 4164 | - 'role', | |
| 4165 | - 'style', | |
| 4166 | - ); | |
| 4167 | - $safe = in_array( $key, $safe_keys, true ); | |
| 4168 | - }//end if | |
| 4169 | - | |
| 4170 | - /** | |
| 4171 | - * Filter the $safe value so additional keys can be allowed or disallowed. | |
| 4172 | - * | |
| 4173 | - * @since 6.11.2 | |
| 4174 | - * | |
| 4175 | - * @param bool $safe True if the key is considered safe. | |
| 4176 | - * @param string $key | |
| 4177 | - * @param string $context Either 'display' or 'update'. | |
| 4178 | - */ | |
| 4179 | - return (bool) apply_filters( 'frm_input_key_is_safe', $safe, $key, $context ); | |
| 4180 | - } | |
| 4181 | - | |
| 4182 | - /** | |
| 4183 | 3457 | * @since 5.0.16 |
| 4184 | 3458 | * |
| 4185 | 3459 | * @return bool |
| 4186 | 3460 | */ |
| @@ -4205,9 +3479,20 @@ | ||
| 4205 | 3479 | |
| 4206 | 3480 | /** |
| 4207 | 3481 | * @since 5.0.17 |
| 4208 | 3482 | * |
| 4209 | - * @param string $feature | |
| 3483 | + * @param string $plugin | |
| 3484 | + * @return string|false | |
| 3485 | + */ | |
| 3486 | + private static function get_plan_required( $plugin ) { | |
| 3487 | + $link = FrmAddonsController::install_link( $plugin ); | |
| 3488 | + return FrmFormsHelper::get_plan_required( $link ); | |
| 3489 | + } | |
| 3490 | + | |
| 3491 | + /** | |
| 3492 | + * @since 5.0.17 | |
| 3493 | + * | |
| 3494 | + * @param string | |
| 4210 | 3495 | * @return bool |
| 4211 | 3496 | */ |
| 4212 | 3497 | public static function show_new_feature( $feature ) { |
| 4213 | 3498 | $link = FrmAddonsController::install_link( $feature ); |
| @@ -4214,18 +3499,15 @@ | ||
| 4214 | 3499 | return array_key_exists( 'status', $link ) || array_key_exists( 'class', $link ); |
| 4215 | 3500 | } |
| 4216 | 3501 | |
| 4217 | 3502 | /** |
| 4218 | - * Enhances upgrade data parameters with installation link and plan requirement information. | |
| 4219 | - * | |
| 4220 | 3503 | * @since 5.0.17 |
| 4221 | 3504 | * |
| 4222 | - * @param string $plugin The plugin slug to get installation data for. | |
| 4223 | - * @param array $params Initial parameters for the upgrade data. | |
| 4224 | - * @param bool $detailed Whether to include detailed information. | |
| 4225 | - * @return array Modified parameters with installation data. | |
| 3505 | + * @param string $plugin | |
| 3506 | + * @param array $params | |
| 3507 | + * @return array | |
| 4226 | 3508 | */ |
| 4227 | - public static function get_upgrade_data_params( $plugin, $params, $detailed = false ) { | |
| 3509 | + public static function get_upgrade_data_params( $plugin, $params ) { | |
| 4228 | 3510 | $link = FrmAddonsController::install_link( $plugin ); |
| 4229 | 3511 | if ( ! $link ) { |
| 4230 | 3512 | return $params; |
| 4231 | 3513 | } |
| @@ -4236,15 +3518,11 @@ | ||
| 4236 | 3518 | if ( ! isset( $params['medium'] ) ) { |
| 4237 | 3519 | $params['medium'] = $plugin; |
| 4238 | 3520 | } |
| 4239 | 3521 | } else { |
| 4240 | - $params['requires'] = $params['requires'] ?? FrmFormsHelper::get_plan_required( $link ); | |
| 3522 | + $params['requires'] = FrmFormsHelper::get_plan_required( $link ); | |
| 4241 | 3523 | } |
| 4242 | 3524 | |
| 4243 | - if ( $detailed ) { | |
| 4244 | - $params['plugin-status'] = $link['status'] ?? ''; | |
| 4245 | - } | |
| 4246 | - | |
| 4247 | 3525 | return $params; |
| 4248 | 3526 | } |
| 4249 | 3527 | |
| 4250 | 3528 | /** |
| @@ -4287,9 +3565,9 @@ | ||
| 4287 | 3565 | public static function show_pill_text( $text = null ) { |
| 4288 | 3566 | if ( null === $text ) { |
| 4289 | 3567 | $text = __( 'NEW', 'formidable' ); |
| 4290 | 3568 | } |
| 4291 | - echo '<span class="frm-meta-tag frm-new-pill">' . esc_html( $text ) . '</span>'; | |
| 3569 | + echo '<span class="frm-new-pill">' . esc_html( $text ) . '</span>'; | |
| 4292 | 3570 | } |
| 4293 | 3571 | |
| 4294 | 3572 | /** |
| 4295 | 3573 | * Count the number of decimals digits. |
| @@ -4296,9 +3574,9 @@ | ||
| 4296 | 3574 | * |
| 4297 | 3575 | * @since 5.2.07 |
| 4298 | 3576 | * |
| 4299 | 3577 | * @param mixed $num Number. |
| 4300 | - * @return false|int Returns `false` if the passed parameter is not number. | |
| 3578 | + * @return int|false Returns `false` if the passed parameter is not number. | |
| 4301 | 3579 | */ |
| 4302 | 3580 | public static function count_decimals( $num ) { |
| 4303 | 3581 | if ( ! is_numeric( $num ) ) { |
| 4304 | 3582 | return false; |
| @@ -4329,9 +3607,9 @@ | ||
| 4329 | 3607 | } |
| 4330 | 3608 | |
| 4331 | 3609 | add_filter( |
| 4332 | 3610 | 'option_gmt_offset', |
| 4333 | - function ( $offset ) { | |
| 3611 | + function( $offset ) { | |
| 4334 | 3612 | if ( ! is_string( $offset ) || is_numeric( $offset ) ) { |
| 4335 | 3613 | // Leave a valid value alone. |
| 4336 | 3614 | return $offset; |
| 4337 | 3615 | } |
| @@ -4413,205 +3691,221 @@ | ||
| 4413 | 3691 | return true; |
| 4414 | 3692 | } |
| 4415 | 3693 | |
| 4416 | 3694 | /** |
| 4417 | - * Display a dismissable warning message and save its dismissal state. | |
| 4418 | - * | |
| 4419 | - * @since 6.3 | |
| 4420 | - * | |
| 4421 | - * @param string $message The warning message to display. | |
| 4422 | - * @param string $option The unique identifier for the dismissal state of the message and the WP Ajax action. | |
| 4423 | - * @return void | |
| 3695 | + * @since 4.08 | |
| 3696 | + * @deprecated 4.09.01 | |
| 4424 | 3697 | */ |
| 4425 | - public static function add_dismissable_warning_message( $message = '', $option = '' ) { | |
| 4426 | - if ( ! $message || ! $option ) { | |
| 4427 | - return; | |
| 3698 | + public static function expiring_message() { | |
| 3699 | + _deprecated_function( __METHOD__, '4.09.01', 'FrmProAddonsController::expiring_message' ); | |
| 3700 | + if ( is_callable( 'FrmProAddonsController::expiring_message' ) ) { | |
| 3701 | + FrmProAddonsController::expiring_message(); | |
| 4428 | 3702 | } |
| 3703 | + } | |
| 4429 | 3704 | |
| 4430 | - $ajax_callback = function () use ( $option ) { | |
| 4431 | - self::dismiss_warning_message( $option ); | |
| 4432 | - }; | |
| 3705 | + /** | |
| 3706 | + * Use the WP 4.7 wp_doing_ajax function | |
| 3707 | + * | |
| 3708 | + * @since 2.05.07 | |
| 3709 | + * @deprecated 4.04.04 | |
| 3710 | + */ | |
| 3711 | + public static function wp_doing_ajax() { | |
| 3712 | + _deprecated_function( __METHOD__, '4.04.04', 'wp_doing_ajax' ); | |
| 3713 | + return wp_doing_ajax(); | |
| 3714 | + } | |
| 4433 | 3715 | |
| 4434 | - // We're handling JS codes with `doJsonPost` and it adds 'frm_' to the beginning of the action. | |
| 4435 | - // To prevent any issues, we add 'frm_' from the beginning of the action. | |
| 4436 | - add_action( 'wp_ajax_frm_' . $option, $ajax_callback ); | |
| 3716 | + /** | |
| 3717 | + * @deprecated 4.0 | |
| 3718 | + */ | |
| 3719 | + public static function insert_opt_html( $args ) { | |
| 3720 | + _deprecated_function( __METHOD__, '4.0', 'FrmFormsHelper::insert_opt_html' ); | |
| 3721 | + FrmFormsHelper::insert_opt_html( $args ); | |
| 3722 | + } | |
| 4437 | 3723 | |
| 4438 | - add_filter( | |
| 4439 | - 'frm_message_list', | |
| 4440 | - function ( $show_messages ) use ( $message, $option ) { | |
| 4441 | - if ( get_option( $option, false ) ) { | |
| 4442 | - return $show_messages; | |
| 4443 | - } | |
| 3724 | + /** | |
| 3725 | + * Used to filter shortcode in text widgets | |
| 3726 | + * | |
| 3727 | + * @deprecated 2.5.4 | |
| 3728 | + * @codeCoverageIgnore | |
| 3729 | + */ | |
| 3730 | + public static function widget_text_filter_callback( $matches ) { | |
| 3731 | + return FrmDeprecated::widget_text_filter_callback( $matches ); | |
| 3732 | + } | |
| 4444 | 3733 | |
| 4445 | - $dismiss_icon = self::icon_by_class( | |
| 4446 | - 'frmfont frm_close_icon', | |
| 4447 | - array( | |
| 4448 | - 'aria-label' => _x( 'Dismiss', 'warning message: close icon label', 'formidable' ), | |
| 4449 | - 'echo' => false, | |
| 4450 | - ) | |
| 4451 | - ); | |
| 3734 | + /** | |
| 3735 | + * @deprecated 3.01 | |
| 3736 | + * @codeCoverageIgnore | |
| 3737 | + */ | |
| 3738 | + public static function sanitize_array( &$values ) { | |
| 3739 | + FrmDeprecated::sanitize_array( $values ); | |
| 3740 | + } | |
| 4452 | 3741 | |
| 4453 | - $show_messages[] = $message; | |
| 4454 | - $show_messages[] = '<span class="frm-warning-dismiss frmsvg" data-action="' . esc_attr( $option ) . '">' . $dismiss_icon . '</span>'; | |
| 3742 | + /** | |
| 3743 | + * @param array $settings | |
| 3744 | + * @param string $group | |
| 3745 | + * | |
| 3746 | + * @since 2.0.6 | |
| 3747 | + * @deprecated 2.05.06 | |
| 3748 | + * @codeCoverageIgnore | |
| 3749 | + */ | |
| 3750 | + public static function save_settings( $settings, $group ) { | |
| 3751 | + return FrmDeprecated::save_settings( $settings, $group ); | |
| 3752 | + } | |
| 4455 | 3753 | |
| 4456 | - return $show_messages; | |
| 4457 | - } | |
| 4458 | - ); | |
| 3754 | + /** | |
| 3755 | + * @since 2.0.4 | |
| 3756 | + * @deprecated 2.05.06 | |
| 3757 | + * @codeCoverageIgnore | |
| 3758 | + */ | |
| 3759 | + public static function save_json_post( $settings ) { | |
| 3760 | + return FrmDeprecated::save_json_post( $settings ); | |
| 4459 | 3761 | } |
| 4460 | 3762 | |
| 4461 | 3763 | /** |
| 4462 | - * Dismiss a warning message and update the dismissal state. | |
| 3764 | + * @since 2.0 | |
| 3765 | + * @deprecated 2.05.06 | |
| 3766 | + * @codeCoverageIgnore | |
| 4463 | 3767 | * |
| 4464 | - * @since 6.3 | |
| 3768 | + * @param string $cache_key The unique name for this cache | |
| 3769 | + * @param string $group The name of the cache group | |
| 3770 | + * @param string $query If blank, don't run a db call | |
| 3771 | + * @param string $type The wpdb function to use with this query | |
| 4465 | 3772 | * |
| 4466 | - * @param string $option The unique identifier for the dismissal state of the message. | |
| 4467 | - * @return void | |
| 3773 | + * @return mixed $results The cache or query results | |
| 4468 | 3774 | */ |
| 4469 | - public static function dismiss_warning_message( $option = '' ) { | |
| 4470 | - self::permission_check( 'frm_change_settings' ); | |
| 4471 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 3775 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { | |
| 3776 | + return FrmDeprecated::check_cache( $cache_key, $group, $query, $type, $time ); | |
| 3777 | + } | |
| 4472 | 3778 | |
| 4473 | - if ( $option ) { | |
| 4474 | - update_option( $option, true, 'no' ); | |
| 4475 | - } | |
| 3779 | + /** | |
| 3780 | + * @deprecated 2.05.06 | |
| 3781 | + * @codeCoverageIgnore | |
| 3782 | + */ | |
| 3783 | + public static function set_cache( $cache_key, $results, $group = '', $time = 300 ) { | |
| 3784 | + return FrmDeprecated::set_cache( $cache_key, $results, $group, $time ); | |
| 3785 | + } | |
| 4476 | 3786 | |
| 4477 | - wp_send_json_success(); | |
| 3787 | + /** | |
| 3788 | + * @deprecated 2.05.06 | |
| 3789 | + * @codeCoverageIgnore | |
| 3790 | + */ | |
| 3791 | + public static function add_key_to_group_cache( $key, $group ) { | |
| 3792 | + FrmDeprecated::add_key_to_group_cache( $key, $group ); | |
| 4478 | 3793 | } |
| 4479 | 3794 | |
| 4480 | 3795 | /** |
| 4481 | - * Lite license copy. | |
| 4482 | - * Used in FrmDashboardController & FrmSettingsController | |
| 4483 | - * | |
| 4484 | - * @since 6.8 | |
| 4485 | - * | |
| 4486 | - * @return string | |
| 3796 | + * @deprecated 2.05.06 | |
| 3797 | + * @codeCoverageIgnore | |
| 4487 | 3798 | */ |
| 4488 | - public static function copy_for_lite_license() { | |
| 4489 | - $message = __( 'You\'re using Formidable Forms Lite - no license needed. Enjoy!', 'formidable' ) . ' 🙂'; | |
| 3799 | + public static function get_group_cached_keys( $group ) { | |
| 3800 | + return FrmDeprecated::get_group_cached_keys( $group ); | |
| 3801 | + } | |
| 4490 | 3802 | |
| 4491 | - if ( is_callable( 'FrmProAddonsController::get_readable_license_type' ) && ! class_exists( 'FrmProDashboardController' ) ) { | |
| 4492 | - // Manage PRO versions without PRO dashboard functionality. | |
| 4493 | - $license_type = FrmProAddonsController::get_readable_license_type(); | |
| 4494 | - if ( 'lite' !== strtolower( $license_type ) ) { | |
| 4495 | - $message = 'Formidable Pro ' . $license_type; | |
| 4496 | - } | |
| 4497 | - } | |
| 3803 | + /** | |
| 3804 | + * @since 2.0 | |
| 3805 | + * @deprecated 2.05.06 | |
| 3806 | + * @codeCoverageIgnore | |
| 3807 | + * @return mixed The cached value or false | |
| 3808 | + */ | |
| 3809 | + public static function check_cache_and_transient( $cache_key ) { | |
| 3810 | + return FrmDeprecated::check_cache( $cache_key ); | |
| 3811 | + } | |
| 4498 | 3812 | |
| 4499 | - return apply_filters( 'frm_license_type_text', $message ); | |
| 3813 | + /** | |
| 3814 | + * @since 2.0 | |
| 3815 | + * @deprecated 2.05.06 | |
| 3816 | + * @codeCoverageIgnore | |
| 3817 | + * | |
| 3818 | + * @param string $cache_key | |
| 3819 | + */ | |
| 3820 | + public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { | |
| 3821 | + FrmDeprecated::delete_cache_and_transient( $cache_key, $group ); | |
| 4500 | 3822 | } |
| 4501 | 3823 | |
| 4502 | 3824 | /** |
| 4503 | - * Removes scripts that are unnecessarily loaded across the pages! | |
| 3825 | + * @since 2.0 | |
| 3826 | + * @deprecated 2.05.06 | |
| 3827 | + * @codeCoverageIgnore | |
| 4504 | 3828 | * |
| 4505 | - * @since 6.9 | |
| 4506 | - * @return void | |
| 3829 | + * @param string $group The name of the cache group | |
| 4507 | 3830 | */ |
| 4508 | - public static function dequeue_extra_global_scripts() { | |
| 4509 | - wp_dequeue_script( 'frm-surveys-admin' ); | |
| 4510 | - wp_dequeue_script( 'frm-quizzes-form-action' ); | |
| 3831 | + public static function cache_delete_group( $group ) { | |
| 3832 | + FrmDeprecated::cache_delete_group( $group ); | |
| 4511 | 3833 | } |
| 4512 | 3834 | |
| 4513 | 3835 | /** |
| 4514 | - * Shows tooltip icon. | |
| 3836 | + * @since 1.07.10 | |
| 3837 | + * @deprecated 2.05.06 | |
| 3838 | + * @codeCoverageIgnore | |
| 4515 | 3839 | * |
| 4516 | - * @since 6.12 | |
| 3840 | + * @param string $term The value to escape | |
| 4517 | 3841 | * |
| 4518 | - * @param string $tooltip_text Tooltip text. | |
| 4519 | - * @param array $atts Tooltip wrapper HTML attributes. | |
| 3842 | + * @return string The escaped value | |
| 3843 | + */ | |
| 3844 | + public static function esc_like( $term ) { | |
| 3845 | + return FrmDeprecated::esc_like( $term ); | |
| 3846 | + } | |
| 3847 | + | |
| 3848 | + /** | |
| 3849 | + * @param string $order_query | |
| 4520 | 3850 | * |
| 4521 | - * @return void | |
| 3851 | + * @deprecated 2.05.06 | |
| 3852 | + * @codeCoverageIgnore | |
| 4522 | 3853 | */ |
| 4523 | - public static function tooltip_icon( $tooltip_text, $atts = array() ) { | |
| 4524 | - $atts['title'] = $tooltip_text; | |
| 4525 | - if ( isset( $atts['class'] ) ) { | |
| 4526 | - $atts['class'] .= ' frm_help'; | |
| 4527 | - } else { | |
| 4528 | - $atts['class'] = 'frm_help'; | |
| 4529 | - } | |
| 4530 | - ?> | |
| 4531 | - <span <?php self::array_to_html_params( $atts, true ); ?>> | |
| 4532 | - <?php self::icon_by_class( 'frmfont frm_tooltip_icon' ); ?> | |
| 4533 | - </span> | |
| 4534 | - <?php | |
| 3854 | + public static function esc_order( $order_query ) { | |
| 3855 | + return FrmDeprecated::esc_order( $order_query ); | |
| 4535 | 3856 | } |
| 4536 | 3857 | |
| 4537 | 3858 | /** |
| 4538 | - * Prints errors for settings in onboarding wizard or template settings. | |
| 3859 | + * @deprecated 2.05.06 | |
| 3860 | + * @codeCoverageIgnore | |
| 3861 | + */ | |
| 3862 | + public static function esc_order_by( &$order_by ) { | |
| 3863 | + FrmDeprecated::esc_order_by( $order_by ); | |
| 3864 | + } | |
| 3865 | + | |
| 3866 | + /** | |
| 3867 | + * @param string $limit | |
| 4539 | 3868 | * |
| 4540 | - * @since 6.15 | |
| 4541 | - * | |
| 4542 | - * @param array $args Args. | |
| 4543 | - * | |
| 4544 | - * @return void | |
| 3869 | + * @deprecated 2.05.06 | |
| 3870 | + * @codeCoverageIgnore | |
| 4545 | 3871 | */ |
| 4546 | - public static function print_setting_error( $args ) { | |
| 4547 | - $args = wp_parse_args( | |
| 4548 | - $args, | |
| 4549 | - array( | |
| 4550 | - 'id' => '', | |
| 4551 | - 'errors' => array(), | |
| 4552 | - 'class' => '', | |
| 4553 | - ) | |
| 4554 | - ); | |
| 3872 | + public static function esc_limit( $limit ) { | |
| 3873 | + return FrmDeprecated::esc_limit( $limit ); | |
| 3874 | + } | |
| 4555 | 3875 | |
| 4556 | - $args['class'] .= ' frm-validation-error frm-mt-xs frm_hidden'; | |
| 4557 | - ?> | |
| 4558 | - <span id="<?php echo esc_attr( $args['id'] ); ?>" class="<?php echo esc_attr( $args['class'] ); ?>"> | |
| 4559 | - <?php | |
| 4560 | - if ( is_array( $args['errors'] ) ) { | |
| 4561 | - foreach ( $args['errors'] as $key => $msg ) { | |
| 4562 | - ?> | |
| 4563 | - <span frm-error="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $msg ); ?></span> | |
| 4564 | - <?php | |
| 4565 | - } | |
| 4566 | - } else { | |
| 4567 | - echo '<span>' . esc_html( $args['errors'] ) . '</span>'; | |
| 4568 | - } | |
| 4569 | - ?> | |
| 4570 | - </span> | |
| 4571 | - <?php | |
| 3876 | + /** | |
| 3877 | + * @since 2.0 | |
| 3878 | + * @deprecated 2.05.06 | |
| 3879 | + * @codeCoverageIgnore | |
| 3880 | + */ | |
| 3881 | + public static function prepare_array_values( $array, $type = '%s' ) { | |
| 3882 | + return FrmDeprecated::prepare_array_values( $array, $type ); | |
| 4572 | 3883 | } |
| 4573 | 3884 | |
| 4574 | 3885 | /** |
| 4575 | - * Check if GDPR is enabled. | |
| 4576 | - * | |
| 4577 | - * @since 6.19 | |
| 4578 | - * | |
| 4579 | - * @return bool | |
| 3886 | + * @deprecated 2.05.06 | |
| 3887 | + * @codeCoverageIgnore | |
| 4580 | 3888 | */ |
| 4581 | - public static function is_gdpr_enabled() { | |
| 4582 | - $frm_settings = self::get_settings(); | |
| 4583 | - return $frm_settings->enable_gdpr || $frm_settings->no_ips || $frm_settings->custom_header_ip || $frm_settings->no_gdpr_cookies; | |
| 3889 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { | |
| 3890 | + return FrmDeprecated::prepend_and_or_where( $starts_with, $where ); | |
| 4584 | 3891 | } |
| 4585 | 3892 | |
| 4586 | 3893 | /** |
| 4587 | - * Check if GDPR cookies are disabled. | |
| 3894 | + * @since 2.0 | |
| 3895 | + * @deprecated 5.0.13 | |
| 4588 | 3896 | * |
| 4589 | - * @since 6.19 | |
| 4590 | - * | |
| 4591 | - * @return bool | |
| 3897 | + * @return string The base Google APIS url for the current version of jQuery UI | |
| 4592 | 3898 | */ |
| 4593 | - public static function no_gdpr_cookies() { | |
| 4594 | - $frm_settings = self::get_settings(); | |
| 4595 | - return $frm_settings->enable_gdpr && $frm_settings->no_gdpr_cookies; | |
| 3899 | + public static function jquery_ui_base_url() { | |
| 3900 | + _deprecated_function( __FUNCTION__, '5.0.13', 'FrmProAppHelper::jquery_ui_base_url' ); | |
| 3901 | + return is_callable( 'FrmProAppHelper::jquery_ui_base_url' ) ? FrmProAppHelper::jquery_ui_base_url() : ''; | |
| 4596 | 3902 | } |
| 4597 | 3903 | |
| 4598 | 3904 | /** |
| 4599 | - * Check if a string is valid UTF-8. | |
| 4600 | - * | |
| 4601 | - * @since 6.24 | |
| 4602 | - * | |
| 4603 | - * @param string $string The string to check. | |
| 4604 | - * @return bool | |
| 3905 | + * @since 4.07 | |
| 3906 | + * @deprecated x.x | |
| 4605 | 3907 | */ |
| 4606 | - public static function is_valid_utf8( $string ) { | |
| 4607 | - // wp_is_valid_utf8 is added in WP 6.9. | |
| 4608 | - if ( function_exists( 'wp_is_valid_utf8' ) ) { | |
| 4609 | - return wp_is_valid_utf8( $string ); | |
| 4610 | - } | |
| 4611 | - // As of WP 6.9, seems_utf8 is deprecated. | |
| 4612 | - if ( function_exists( 'seems_utf8' ) ) { | |
| 4613 | - return seems_utf8( $string ); | |
| 4614 | - } | |
| 4615 | - return false; | |
| 3908 | + public static function renewal_message() { | |
| 3909 | + _deprecated_function( __METHOD__, 'x.x', 'FrmProAddonsController::renewal_message' ); | |
| 4616 | 3910 | } |
| 4617 | 3911 | } |