| @@ -229,9 +229,9 @@ | ||
| 229 | 229 | wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | return self::get_edit_vars( $id, array(), $message ); |
| 233 | - } | |
| 233 | + }//end if | |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
| 237 | 237 | * Check if the value at the end of the form was included. |
| @@ -282,9 +282,10 @@ | ||
| 282 | 282 | $url = admin_url( 'admin.php?page=formidable' ); |
| 283 | 283 | $message = 'form_duplicate_error'; |
| 284 | 284 | |
| 285 | 285 | if ( $form ) { |
| 286 | - $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) ); | |
| 286 | + $new_template = FrmAppHelper::simple_get( 'new_template' ) ? '&new_template=true' : ''; | |
| 287 | + $url = admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form ) . $new_template ); | |
| 287 | 288 | $message = 'form_duplicated'; |
| 288 | 289 | } |
| 289 | 290 | |
| 290 | 291 | $url .= '&message=' . $message; |
| @@ -309,8 +310,10 @@ | ||
| 309 | 310 | } |
| 310 | 311 | |
| 311 | 312 | /** |
| 312 | 313 | * @since 3.0 |
| 314 | + * | |
| 315 | + * @return void | |
| 313 | 316 | */ |
| 314 | 317 | public static function show_page_preview() { |
| 315 | 318 | echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 316 | 319 | } |
| @@ -360,8 +363,13 @@ | ||
| 360 | 363 | return; |
| 361 | 364 | } |
| 362 | 365 | |
| 363 | 366 | $random_page = reset( $random_page ); |
| 367 | + if ( ! is_a( $random_page, 'WP_Post' ) ) { | |
| 368 | + // The return type can also be int. | |
| 369 | + return; | |
| 370 | + } | |
| 371 | + | |
| 364 | 372 | query_posts( |
| 365 | 373 | array( |
| 366 | 374 | 'post_type' => 'page', |
| 367 | 375 | 'page_id' => $random_page->ID, |
| @@ -377,9 +385,9 @@ | ||
| 377 | 385 | * Set the WP $post global object. Used for in-theme preview when defining a page. |
| 378 | 386 | * |
| 379 | 387 | * @since 5.5.2 |
| 380 | 388 | * |
| 381 | - * @param WP_Post $post | |
| 389 | + * @param WP_Post $page The page object. | |
| 382 | 390 | * @return void |
| 383 | 391 | */ |
| 384 | 392 | private static function set_post_global( $page ) { |
| 385 | 393 | global $post; |
| @@ -424,9 +432,10 @@ | ||
| 424 | 432 | */ |
| 425 | 433 | private static function fallback_when_page_template_part_is_not_supported_by_theme() { |
| 426 | 434 | if ( have_posts() ) { |
| 427 | 435 | the_post(); |
| 428 | - get_header( '' ); | |
| 436 | + self::get_template( 'header' ); | |
| 437 | + | |
| 429 | 438 | // add some generic class names to the container to add some natural padding to the content. |
| 430 | 439 | // .entry-content catches the WordPress TwentyTwenty theme. |
| 431 | 440 | // .container catches Customizr content. |
| 432 | 441 | echo '<div class="container entry-content">'; |
| @@ -431,13 +440,54 @@ | ||
| 431 | 440 | // .container catches Customizr content. |
| 432 | 441 | echo '<div class="container entry-content">'; |
| 433 | 442 | the_content(); |
| 434 | 443 | echo '</div>'; |
| 435 | - get_footer(); | |
| 444 | + | |
| 445 | + self::get_template( 'footer' ); | |
| 436 | 446 | } |
| 437 | 447 | } |
| 438 | 448 | |
| 439 | 449 | /** |
| 450 | + * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call | |
| 451 | + * and renders required html fragements calling required functions. | |
| 452 | + * | |
| 453 | + * @since 6.7.1 | |
| 454 | + * @param string $template | |
| 455 | + * @return void | |
| 456 | + */ | |
| 457 | + private static function get_template( $template ) { | |
| 458 | + if ( self::should_try_getting_template( $template ) ) { | |
| 459 | + call_user_func( 'get_' . $template ); | |
| 460 | + return; | |
| 461 | + } | |
| 462 | + | |
| 463 | + if ( 'header' === $template ) { | |
| 464 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/header.php'; | |
| 465 | + return; | |
| 466 | + } | |
| 467 | + | |
| 468 | + if ( 'footer' === $template ) { | |
| 469 | + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/preview/footer.php'; | |
| 470 | + } | |
| 471 | + } | |
| 472 | + | |
| 473 | + /** | |
| 474 | + * Returns true if calling a template function doesn't trigger deprecation warnings. | |
| 475 | + * | |
| 476 | + * @since 6.7.1 | |
| 477 | + * @param string $template | |
| 478 | + * @return bool | |
| 479 | + */ | |
| 480 | + private static function should_try_getting_template( $template ) { | |
| 481 | + $stylesheet_path = get_stylesheet_directory(); | |
| 482 | + $template_path = get_template_directory(); | |
| 483 | + $is_child_theme = $stylesheet_path !== $template_path; | |
| 484 | + $template_name = $template . '.php'; | |
| 485 | + | |
| 486 | + return file_exists( $stylesheet_path . '/' . $template_name ) || $is_child_theme && file_exists( $template_path . '/' . $template_name ); | |
| 487 | + } | |
| 488 | + | |
| 489 | + /** | |
| 440 | 490 | * Set the page title for the theme preview page |
| 441 | 491 | * |
| 442 | 492 | * @since 3.0 |
| 443 | 493 | */ |
| @@ -458,15 +508,20 @@ | ||
| 458 | 508 | return __( 'Form Preview', 'formidable' ); |
| 459 | 509 | } |
| 460 | 510 | |
| 461 | 511 | /** |
| 462 | - * Set the page content for the theme preview page | |
| 512 | + * Set the page content for the theme preview page. | |
| 463 | 513 | * |
| 464 | 514 | * @since 3.0 |
| 515 | + * | |
| 516 | + * @param string $content | |
| 517 | + * @return string | |
| 465 | 518 | */ |
| 466 | 519 | public static function preview_content( $content ) { |
| 467 | 520 | if ( in_the_loop() ) { |
| 468 | - $content = self::show_page_preview(); | |
| 521 | + self::show_page_preview(); | |
| 522 | + // Clear the content for the page we're using. | |
| 523 | + $content = ''; | |
| 469 | 524 | } |
| 470 | 525 | |
| 471 | 526 | return $content; |
| 472 | 527 | } |
| @@ -553,9 +608,9 @@ | ||
| 553 | 608 | FrmAppHelper::permission_check( $available_status[ $status ]['permission'] ); |
| 554 | 609 | |
| 555 | 610 | $params = FrmForm::list_page_params(); |
| 556 | 611 | |
| 557 | - //check nonce url | |
| 612 | + // Check nonce url. | |
| 558 | 613 | check_admin_referer( $status . '_form_' . $params['id'] ); |
| 559 | 614 | |
| 560 | 615 | $count = 0; |
| 561 | 616 | if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) { |
| @@ -636,15 +691,20 @@ | ||
| 636 | 691 | $count ++; |
| 637 | 692 | } |
| 638 | 693 | } |
| 639 | 694 | |
| 640 | - /* translators: %1$s: Number of forms */ | |
| 641 | - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); | |
| 695 | + if ( $count ) { | |
| 696 | + /* translators: %1$s: Number of forms */ | |
| 697 | + return sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); | |
| 698 | + } | |
| 642 | 699 | |
| 643 | - return $message; | |
| 700 | + return ''; | |
| 644 | 701 | } |
| 645 | 702 | |
| 646 | - private static function delete_all() { | |
| 703 | + /** | |
| 704 | + * @since 6.7.1 Function went from private to public. | |
| 705 | + */ | |
| 706 | + public static function delete_all() { | |
| 647 | 707 | // Check nonce url. |
| 648 | 708 | $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' ); |
| 649 | 709 | if ( $permission_error !== false ) { |
| 650 | 710 | self::display_forms_list( array(), '', array( $permission_error ) ); |
| @@ -651,14 +711,15 @@ | ||
| 651 | 711 | |
| 652 | 712 | return; |
| 653 | 713 | } |
| 654 | 714 | |
| 655 | - $count = FrmForm::scheduled_delete( time() ); | |
| 715 | + $count = FrmForm::scheduled_delete( time() ); | |
| 716 | + $url = remove_query_arg( array( 'delete_all' ) ); | |
| 656 | 717 | |
| 657 | - /* translators: %1$s: Number of forms */ | |
| 658 | - $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); | |
| 718 | + $url .= '&message=forms_permanently_deleted&forms_deleted=' . $count; | |
| 659 | 719 | |
| 660 | - self::display_forms_list( array(), $message ); | |
| 720 | + wp_safe_redirect( $url ); | |
| 721 | + die(); | |
| 661 | 722 | } |
| 662 | 723 | |
| 663 | 724 | /** |
| 664 | 725 | * Create a new form from the modal. |
| @@ -696,9 +757,9 @@ | ||
| 696 | 757 | self::create_default_on_submit_action( $form_id ); |
| 697 | 758 | self::create_default_email_action( $form_id ); |
| 698 | 759 | |
| 699 | 760 | $response = array( |
| 700 | - 'redirect' => FrmForm::get_edit_link( $form_id ), | |
| 761 | + 'redirect' => FrmForm::get_edit_link( $form_id ) . '&new_template=true', | |
| 701 | 762 | ); |
| 702 | 763 | |
| 703 | 764 | echo wp_json_encode( $response ); |
| 704 | 765 | wp_die(); |
| @@ -704,46 +765,13 @@ | ||
| 704 | 765 | wp_die(); |
| 705 | 766 | } |
| 706 | 767 | |
| 707 | 768 | /** |
| 708 | - * Create a custom template from a form | |
| 709 | - * | |
| 710 | - * @since 3.06 | |
| 711 | - */ | |
| 712 | - public static function build_template() { | |
| 713 | - global $wpdb; | |
| 714 | - | |
| 715 | - FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 716 | - check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 717 | - | |
| 718 | - $form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' ); | |
| 719 | - $new_form_id = FrmForm::duplicate( $form_id, 1, true ); | |
| 720 | - if ( ! $new_form_id ) { | |
| 721 | - $response = array( | |
| 722 | - 'message' => __( 'There was an error creating a template.', 'formidable' ), | |
| 723 | - ); | |
| 724 | - } else { | |
| 725 | - $new_values = self::get_modal_values(); | |
| 726 | - $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) ); | |
| 727 | - if ( $query_results ) { | |
| 728 | - FrmForm::clear_form_cache(); | |
| 729 | - } | |
| 730 | - | |
| 731 | - $response = array( | |
| 732 | - 'redirect' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . $new_form_id ) . '&_wpnonce=' . wp_create_nonce(), | |
| 733 | - ); | |
| 734 | - } | |
| 735 | - | |
| 736 | - echo wp_json_encode( $response ); | |
| 737 | - wp_die(); | |
| 738 | - } | |
| 739 | - | |
| 740 | - /** | |
| 741 | 769 | * Before creating a new form, get the name and description from the modal. |
| 742 | 770 | * |
| 743 | 771 | * @since 4.0 |
| 744 | 772 | */ |
| 745 | - private static function get_modal_values() { | |
| 773 | + public static function get_modal_values() { | |
| 746 | 774 | $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' ); |
| 747 | 775 | $desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' ); |
| 748 | 776 | |
| 749 | 777 | return array( |
| @@ -966,147 +994,43 @@ | ||
| 966 | 994 | |
| 967 | 995 | return $save; |
| 968 | 996 | } |
| 969 | 997 | |
| 970 | - /** | |
| 971 | - * @return bool | |
| 972 | - */ | |
| 973 | - public static function expired() { | |
| 974 | - global $frm_expired; | |
| 975 | - return $frm_expired; | |
| 976 | - } | |
| 998 | + private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { | |
| 999 | + global $frm_vars; | |
| 977 | 1000 | |
| 978 | - /** | |
| 979 | - * Get data from api before rendering it so that we can flag the modal as expired | |
| 980 | - * | |
| 981 | - * @return void | |
| 982 | - */ | |
| 983 | - public static function before_list_templates() { | |
| 984 | - global $frm_templates; | |
| 985 | - global $frm_expired; | |
| 986 | - global $frm_license_type; | |
| 987 | - | |
| 988 | - $api = new FrmFormTemplateApi(); | |
| 989 | - $frm_templates = $api->get_api_info(); | |
| 990 | - $expired = false; | |
| 991 | - $license_type = ''; | |
| 992 | - if ( isset( $frm_templates['error'] ) ) { | |
| 993 | - $error = $frm_templates['error']['message']; | |
| 994 | - $error = str_replace( 'utm_medium=addons', 'utm_medium=form-templates', $error ); | |
| 995 | - $expired = 'expired' === $frm_templates['error']['code']; | |
| 996 | - $license_type = isset( $frm_templates['error']['type'] ) ? $frm_templates['error']['type'] : ''; | |
| 997 | - unset( $frm_templates['error'] ); | |
| 998 | - } | |
| 999 | - | |
| 1000 | - $frm_expired = $expired; | |
| 1001 | - $frm_license_type = $license_type; | |
| 1002 | - } | |
| 1003 | - | |
| 1004 | - /** | |
| 1005 | - * @return void | |
| 1006 | - */ | |
| 1007 | - public static function list_templates() { | |
| 1008 | - global $frm_templates; | |
| 1009 | - global $frm_license_type; | |
| 1010 | - | |
| 1011 | - $templates = $frm_templates; | |
| 1012 | - $custom_templates = array(); | |
| 1013 | - $templates_by_category = array(); | |
| 1014 | - | |
| 1015 | - self::add_user_templates( $custom_templates ); | |
| 1016 | - | |
| 1017 | - foreach ( $templates as $template ) { | |
| 1018 | - if ( ! isset( $template['categories'] ) ) { | |
| 1019 | - continue; | |
| 1020 | - } | |
| 1021 | - | |
| 1022 | - foreach ( $template['categories'] as $category ) { | |
| 1023 | - if ( ! isset( $templates_by_category[ $category ] ) ) { | |
| 1024 | - $templates_by_category[ $category ] = array(); | |
| 1025 | - } | |
| 1026 | - | |
| 1027 | - $templates_by_category[ $category ][] = $template; | |
| 1028 | - } | |
| 1029 | - } | |
| 1030 | - unset( $template ); | |
| 1031 | - | |
| 1032 | - // Subcategories that are included elsewhere. | |
| 1033 | - $redundant_cats = array( 'PayPal', 'Stripe', 'Twilio' ); | |
| 1034 | - | |
| 1035 | - $categories = array_keys( $templates_by_category ); | |
| 1036 | - $categories = array_diff( $categories, FrmFormsHelper::ignore_template_categories() ); | |
| 1037 | - $categories = array_diff( $categories, $redundant_cats ); | |
| 1038 | - sort( $categories ); | |
| 1039 | - | |
| 1040 | - array_walk( | |
| 1041 | - $custom_templates, | |
| 1042 | - function( &$template ) { | |
| 1043 | - $template['custom'] = true; | |
| 1044 | - } | |
| 1001 | + $form = FrmForm::getOne( $id ); | |
| 1002 | + $error_args = array( | |
| 1003 | + 'title' => __( 'You can\'t edit the form', 'formidable' ), | |
| 1004 | + 'body' => __( 'You are trying to edit a form that does not exist', 'formidable' ), | |
| 1005 | + 'cancel_url' => admin_url( 'admin.php?page=formidable' ), | |
| 1006 | + 'continue_url' => add_query_arg( | |
| 1007 | + array( | |
| 1008 | + 'page' => 'formidable', | |
| 1009 | + ) | |
| 1010 | + ), | |
| 1045 | 1011 | ); |
| 1046 | - | |
| 1047 | - $my_templates_translation = __( 'My Templates', 'formidable' ); | |
| 1048 | - $categories = array_merge( array( $my_templates_translation ), $categories ); | |
| 1049 | - $pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' ); | |
| 1050 | - $license_type = $frm_license_type; | |
| 1051 | - $args = compact( 'pricing', 'license_type' ); | |
| 1052 | - $where = apply_filters( 'frm_forms_dropdown', array(), '' ); | |
| 1053 | - $forms = FrmForm::get_published_forms( $where ); | |
| 1054 | - $view_path = FrmAppHelper::plugin_path() . '/classes/views/frm-forms/'; | |
| 1055 | - | |
| 1056 | - $templates_by_category[ $my_templates_translation ] = $custom_templates; | |
| 1057 | - | |
| 1058 | - unset( $pricing, $license_type, $where ); | |
| 1059 | - wp_enqueue_script( 'accordion' ); // register accordion for template groups | |
| 1060 | - require $view_path . 'list-templates.php'; | |
| 1061 | - } | |
| 1062 | - | |
| 1063 | - /** | |
| 1064 | - * @since 4.03.01 | |
| 1065 | - */ | |
| 1066 | - private static function get_template_categories( $templates ) { | |
| 1067 | - $categories = array(); | |
| 1068 | - foreach ( $templates as $template ) { | |
| 1069 | - if ( isset( $template['categories'] ) ) { | |
| 1070 | - $categories = array_merge( $categories, $template['categories'] ); | |
| 1071 | - } | |
| 1012 | + if ( ! $form ) { | |
| 1013 | + FrmAppController::show_error_modal( $error_args ); | |
| 1014 | + return; | |
| 1072 | 1015 | } |
| 1073 | - $exclude_cats = FrmFormsHelper::ignore_template_categories(); | |
| 1074 | - $categories = array_unique( $categories ); | |
| 1075 | - $categories = array_diff( $categories, $exclude_cats ); | |
| 1076 | - sort( $categories ); | |
| 1077 | - return $categories; | |
| 1078 | - } | |
| 1079 | 1016 | |
| 1080 | - private static function add_user_templates( &$templates ) { | |
| 1081 | - $user_templates = array( | |
| 1082 | - 'is_template' => 1, | |
| 1083 | - 'default_template' => 0, | |
| 1084 | - ); | |
| 1085 | - $user_templates = FrmForm::getAll( $user_templates, 'name' ); | |
| 1086 | - foreach ( $user_templates as $template ) { | |
| 1087 | - $template = array( | |
| 1088 | - 'id' => $template->id, | |
| 1089 | - 'name' => $template->name, | |
| 1090 | - 'key' => $template->form_key, | |
| 1091 | - 'description' => $template->description, | |
| 1092 | - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ) ), | |
| 1093 | - 'released' => $template->created_at, | |
| 1094 | - 'installed' => 1, | |
| 1017 | + if ( 'trash' === $form->status ) { | |
| 1018 | + $error_args['body'] = __( 'The form you\'re trying to edit is in trash. You must restore it first before you can make changes', 'formidable' ); | |
| 1019 | + $error_args['continue_url'] = add_query_arg( | |
| 1020 | + array( | |
| 1021 | + 'page' => 'formidable', | |
| 1022 | + '_wpnonce' => wp_create_nonce( 'untrash_form_' . $id ), | |
| 1023 | + 'form_type' => 'trash', | |
| 1024 | + 'frm_action' => 'untrash', | |
| 1025 | + 'id' => $id, | |
| 1026 | + ) | |
| 1095 | 1027 | ); |
| 1096 | - array_unshift( $templates, $template ); | |
| 1097 | - unset( $template ); | |
| 1028 | + $error_args['continue_text'] = __( 'Restore form', 'formidable' ); | |
| 1029 | + FrmAppController::show_error_modal( $error_args ); | |
| 1030 | + return; | |
| 1098 | 1031 | } |
| 1099 | - } | |
| 1100 | 1032 | |
| 1101 | - private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) { | |
| 1102 | - global $frm_vars; | |
| 1103 | - | |
| 1104 | - $form = FrmForm::getOne( $id ); | |
| 1105 | - if ( ! $form ) { | |
| 1106 | - wp_die( esc_html__( 'You are trying to edit a form that does not exist.', 'formidable' ) ); | |
| 1107 | - } | |
| 1108 | - | |
| 1109 | 1033 | if ( $form->parent_form_id ) { |
| 1110 | 1034 | /* translators: %1$s: Start link HTML, %2$s: End link HTML */ |
| 1111 | 1035 | wp_die( sprintf( esc_html__( 'You are trying to edit a child form. Please edit from %1$shere%2$s', 'formidable' ), '<a href="' . esc_url( FrmForm::get_edit_link( $form->parent_form_id ) ) . '">', '</a>' ) ); |
| 1112 | 1036 | } |
| @@ -1342,9 +1266,9 @@ | ||
| 1342 | 1266 | $section['id'] = $section['anchor']; |
| 1343 | 1267 | } |
| 1344 | 1268 | |
| 1345 | 1269 | $sections[ $key ] = $section; |
| 1346 | - } | |
| 1270 | + }//end foreach | |
| 1347 | 1271 | |
| 1348 | 1272 | return $sections; |
| 1349 | 1273 | } |
| 1350 | 1274 | |
| @@ -1768,9 +1692,9 @@ | ||
| 1768 | 1692 | if ( isset( $_REQUEST['delete_all'] ) ) { |
| 1769 | 1693 | // Override the action for this page. |
| 1770 | 1694 | $action = 'delete_all'; |
| 1771 | 1695 | } |
| 1772 | - } | |
| 1696 | + }//end if | |
| 1773 | 1697 | |
| 1774 | 1698 | add_action( 'frm_load_form_hooks', 'FrmHooksController::trigger_load_form_hooks' ); |
| 1775 | 1699 | FrmAppHelper::trigger_hook_load( 'form' ); |
| 1776 | 1700 | |
| @@ -1782,9 +1706,8 @@ | ||
| 1782 | 1706 | case 'update': |
| 1783 | 1707 | case 'trash': |
| 1784 | 1708 | case 'untrash': |
| 1785 | 1709 | case 'destroy': |
| 1786 | - case 'delete_all': | |
| 1787 | 1710 | case 'settings': |
| 1788 | 1711 | case 'update_settings': |
| 1789 | 1712 | return self::$action( $vars ); |
| 1790 | 1713 | case 'lite-reports': |
| @@ -1814,14 +1737,47 @@ | ||
| 1814 | 1737 | self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) ); |
| 1815 | 1738 | return; |
| 1816 | 1739 | } |
| 1817 | 1740 | |
| 1741 | + if ( 'forms_permanently_deleted' === $message ) { | |
| 1742 | + $count = FrmAppHelper::get_param( 'forms_deleted', 0, 'get', 'absint' ); | |
| 1743 | + /* translators: %1$s: Number of forms */ | |
| 1744 | + $message = sprintf( _n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count ); | |
| 1745 | + self::display_forms_list( array(), $message, '' ); | |
| 1746 | + return; | |
| 1747 | + } | |
| 1748 | + | |
| 1818 | 1749 | self::display_forms_list(); |
| 1819 | 1750 | |
| 1820 | 1751 | return; |
| 1821 | - } | |
| 1752 | + }//end switch | |
| 1822 | 1753 | } |
| 1823 | 1754 | |
| 1755 | + /** | |
| 1756 | + * Rename a form. | |
| 1757 | + * | |
| 1758 | + * Handles the AJAX request for renaming a form. | |
| 1759 | + * | |
| 1760 | + * @since 6.7 | |
| 1761 | + * | |
| 1762 | + * @return void | |
| 1763 | + */ | |
| 1764 | + public static function rename_form() { | |
| 1765 | + // Check permission and nonce | |
| 1766 | + FrmAppHelper::permission_check( 'frm_edit_forms' ); | |
| 1767 | + check_ajax_referer( 'frm_ajax', 'nonce' ); | |
| 1768 | + | |
| 1769 | + // Get posted data | |
| 1770 | + $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' ); | |
| 1771 | + $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' ); | |
| 1772 | + | |
| 1773 | + // Update the form name and form key. | |
| 1774 | + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' ); | |
| 1775 | + FrmForm::update( $form_id, compact( 'name', 'form_key' ) ); | |
| 1776 | + | |
| 1777 | + wp_send_json_success( compact( 'form_key' ) ); | |
| 1778 | + } | |
| 1779 | + | |
| 1824 | 1780 | public static function json_error( $errors ) { |
| 1825 | 1781 | $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' ); |
| 1826 | 1782 | |
| 1827 | 1783 | return $errors; |
| @@ -1860,9 +1816,11 @@ | ||
| 1860 | 1816 | |
| 1861 | 1817 | include FrmAppHelper::plugin_path() . '/classes/views/shared/reports-info.php'; |
| 1862 | 1818 | } |
| 1863 | 1819 | |
| 1864 | - /* FRONT-END FORMS */ | |
| 1820 | + /** | |
| 1821 | + * FRONT-END FORMS. | |
| 1822 | + */ | |
| 1865 | 1823 | public static function admin_bar_css() { |
| 1866 | 1824 | if ( is_admin() || ! current_user_can( 'frm_edit_forms' ) ) { |
| 1867 | 1825 | return; |
| 1868 | 1826 | } |
| @@ -2050,9 +2008,10 @@ | ||
| 2050 | 2008 | */ |
| 2051 | 2009 | private static function maybe_get_form_to_show( $id ) { |
| 2052 | 2010 | $form = false; |
| 2053 | 2011 | |
| 2054 | - if ( ! empty( $id ) ) { // form id or key is set | |
| 2012 | + if ( ! empty( $id ) ) { | |
| 2013 | + // Form id or key is set. | |
| 2055 | 2014 | $form = FrmForm::getOne( $id ); |
| 2056 | 2015 | if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) { |
| 2057 | 2016 | $form = false; |
| 2058 | 2017 | } |
| @@ -2124,9 +2083,9 @@ | ||
| 2124 | 2083 | 'form' => $form, |
| 2125 | 2084 | ) |
| 2126 | 2085 | ); |
| 2127 | 2086 | } |
| 2128 | - } | |
| 2087 | + }//end if | |
| 2129 | 2088 | } |
| 2130 | 2089 | |
| 2131 | 2090 | /** |
| 2132 | 2091 | * If the form was processed earlier (init), get the generated errors |
| @@ -2326,9 +2285,10 @@ | ||
| 2326 | 2285 | |
| 2327 | 2286 | $action_type = FrmOnSubmitHelper::get_action_type( $action ); |
| 2328 | 2287 | |
| 2329 | 2288 | if ( 'redirect' === $action_type ) { |
| 2330 | - if ( $has_redirect ) { // Do not process because we run the first redirect action only. | |
| 2289 | + if ( $has_redirect ) { | |
| 2290 | + // Do not process because we run the first redirect action only. | |
| 2331 | 2291 | continue; |
| 2332 | 2292 | } |
| 2333 | 2293 | } |
| 2334 | 2294 | |
| @@ -2341,9 +2301,9 @@ | ||
| 2341 | 2301 | } |
| 2342 | 2302 | |
| 2343 | 2303 | $met_actions[] = $action; |
| 2344 | 2304 | unset( $action ); |
| 2345 | - } | |
| 2305 | + }//end foreach | |
| 2346 | 2306 | |
| 2347 | 2307 | $args['event'] = $event; |
| 2348 | 2308 | |
| 2349 | 2309 | /** |
| @@ -2532,9 +2492,9 @@ | ||
| 2532 | 2492 | add_filter( 'the_content', 'FrmFormsController::preview_content', 9999 ); |
| 2533 | 2493 | } |
| 2534 | 2494 | |
| 2535 | 2495 | $post = $old_post; |
| 2536 | - } | |
| 2496 | + }//end if | |
| 2537 | 2497 | } |
| 2538 | 2498 | |
| 2539 | 2499 | /** |
| 2540 | 2500 | * @since 3.0 |
| @@ -2555,14 +2515,16 @@ | ||
| 2555 | 2515 | $success_url = apply_filters( 'frm_redirect_url', $success_url, $args['form'], $args ); |
| 2556 | 2516 | |
| 2557 | 2517 | $doing_ajax = FrmAppHelper::doing_ajax(); |
| 2558 | 2518 | |
| 2559 | - if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { // Is AJAX submit and there is just one Redirect action runs. | |
| 2519 | + if ( ! empty( $args['ajax'] ) && $doing_ajax && empty( $args['force_delay_redirect'] ) ) { | |
| 2520 | + // Is AJAX submit and there is just one Redirect action runs. | |
| 2560 | 2521 | echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) ); |
| 2561 | 2522 | wp_die(); |
| 2562 | 2523 | } |
| 2563 | 2524 | |
| 2564 | - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { // Not AJAX submit, no headers sent, and there is just one Redirect action runs. | |
| 2525 | + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) { | |
| 2526 | + // Not AJAX submit, no headers sent, and there is just one Redirect action runs. | |
| 2565 | 2527 | if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) { |
| 2566 | 2528 | self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args ); |
| 2567 | 2529 | self::$redirected_in_new_tab[ $args['form']->id ] = 1; |
| 2568 | 2530 | return; |
| @@ -2568,9 +2530,10 @@ | ||
| 2568 | 2530 | return; |
| 2569 | 2531 | } |
| 2570 | 2532 | |
| 2571 | 2533 | wp_redirect( esc_url_raw( $success_url ) ); |
| 2572 | - die(); // do not use wp_die or redirect fails | |
| 2534 | + // Do not use wp_die or redirect fails. | |
| 2535 | + die(); | |
| 2573 | 2536 | } |
| 2574 | 2537 | |
| 2575 | 2538 | // Redirect with a delay. |
| 2576 | 2539 | self::redirect_after_submit_using_js( $args + compact( 'success_url', 'doing_ajax' ) ); |
| @@ -2661,9 +2624,10 @@ | ||
| 2661 | 2624 | add_filter( 'frm_use_wpautop', '__return_true' ); |
| 2662 | 2625 | |
| 2663 | 2626 | echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2664 | 2627 | echo '<script>'; |
| 2665 | - if ( empty( $args['doing_ajax'] ) ) { // Not AJAX submit, delay JS until window.load. | |
| 2628 | + if ( empty( $args['doing_ajax'] ) ) { | |
| 2629 | + // Not AJAX submit, delay JS until window.load. | |
| 2666 | 2630 | echo 'window.onload=function(){'; |
| 2667 | 2631 | } |
| 2668 | 2632 | echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 2669 | 2633 | if ( empty( $args['doing_ajax'] ) ) { |
| @@ -2676,9 +2640,9 @@ | ||
| 2676 | 2640 | * @since 3.0 |
| 2677 | 2641 | * |
| 2678 | 2642 | * @param string $success_url |
| 2679 | 2643 | * @param string $success_msg |
| 2680 | - * @param array $args | |
| 2644 | + * @param array $args | |
| 2681 | 2645 | */ |
| 2682 | 2646 | private static function get_redirect_message( $success_url, $success_msg, $args ) { |
| 2683 | 2647 | $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' . |
| 2684 | 2648 | self::get_redirect_fallback_message( $success_url, $args ) . |
| @@ -3015,9 +2979,9 @@ | ||
| 3015 | 2979 | * Create a page with an embedded formidable Gutenberg block. |
| 3016 | 2980 | * |
| 3017 | 2981 | * @since 5.2 |
| 3018 | 2982 | * |
| 3019 | - * @return never | |
| 2983 | + * @return void | |
| 3020 | 2984 | */ |
| 3021 | 2985 | public static function create_page_with_shortcode() { |
| 3022 | 2986 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3023 | 2987 | die( 0 ); |
| @@ -3062,10 +3026,9 @@ | ||
| 3062 | 3026 | |
| 3063 | 3027 | /** |
| 3064 | 3028 | * @since 5.3 |
| 3065 | 3029 | * |
| 3066 | - * @param string $content | |
| 3067 | - * @param int $form_id | |
| 3030 | + * @param int $form_id | |
| 3068 | 3031 | * @return string |
| 3069 | 3032 | */ |
| 3070 | 3033 | private static function get_page_shortcode_content_for_form( $form_id ) { |
| 3071 | 3034 | $shortcode = '[formidable id="' . $form_id . '"]'; |
| @@ -3076,9 +3039,9 @@ | ||
| 3076 | 3039 | |
| 3077 | 3040 | /** |
| 3078 | 3041 | * Get page dropdown for AJAX request for embedding form in an existing page. |
| 3079 | 3042 | * |
| 3080 | - * @return never | |
| 3043 | + * @return void | |
| 3081 | 3044 | */ |
| 3082 | 3045 | public static function get_page_dropdown() { |
| 3083 | 3046 | if ( ! current_user_can( 'publish_posts' ) ) { |
| 3084 | 3047 | die( 0 ); |
| @@ -3150,6 +3113,46 @@ | ||
| 3150 | 3113 | * @since 3.06 |
| 3151 | 3114 | */ |
| 3152 | 3115 | public static function add_new() { |
| 3153 | 3116 | _deprecated_function( __FUNCTION__, '4.08' ); |
| 3117 | + } | |
| 3118 | + | |
| 3119 | + /** | |
| 3120 | + * Create a custom template from a form | |
| 3121 | + * | |
| 3122 | + * @since 3.06 | |
| 3123 | + * @deprecated 6.7 | |
| 3124 | + */ | |
| 3125 | + public static function build_template() { | |
| 3126 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3127 | + } | |
| 3128 | + | |
| 3129 | + /** | |
| 3130 | + * @deprecated 6.7 | |
| 3131 | + * | |
| 3132 | + * @return bool | |
| 3133 | + */ | |
| 3134 | + public static function expired() { | |
| 3135 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3136 | + return FrmAddonsController::is_license_expired(); | |
| 3137 | + } | |
| 3138 | + | |
| 3139 | + /** | |
| 3140 | + * Get data from api before rendering it so that we can flag the modal as expired | |
| 3141 | + * | |
| 3142 | + * @deprecated 6.7 | |
| 3143 | + * | |
| 3144 | + * @return void | |
| 3145 | + */ | |
| 3146 | + public static function before_list_templates() { | |
| 3147 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3148 | + } | |
| 3149 | + | |
| 3150 | + /** | |
| 3151 | + * @deprecated 6.7 | |
| 3152 | + * | |
| 3153 | + * @return void | |
| 3154 | + */ | |
| 3155 | + public static function list_templates() { | |
| 3156 | + _deprecated_function( __METHOD__, '6.7' ); | |
| 3154 | 3157 | } |
| 3155 | 3158 | } |