From 4f1928acf9b2f5d5e691909f04466d6ceab33394 Mon Sep 17 00:00:00 2001 From: "Kyle B. Johnson" Date: Mon, 31 Jul 2023 15:01:16 -0400 Subject: [PATCH 1/3] wip: Add shortcode redirects --- includes/shortcodes.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/shortcodes.php b/includes/shortcodes.php index 18e68d65b2..4dc32bb975 100644 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -133,7 +133,7 @@ function give_donation_history( $atts, $content = false ) { * * @since 2.30.0 Add short-circuit filter to allow for custom output. * @since 1.0 - + * @param array $atts Shortcode attributes * * @return string @@ -149,6 +149,8 @@ function give_form_shortcode( $atts ) { $atts['id'] = $atts['id'] ?: FrontendFormTemplateUtils::getFormId(); $formId = absint( $atts['id'] ); + give_redirect_form_id($formId, $atts['id']); + // Short-circuit the shortcode output if the filter returns a non-empty string. $output = apply_filters('givewp_form_shortcode_output', '', $atts); @@ -212,6 +214,8 @@ function give_goal_shortcode( $atts ) { Give_Notices::print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true ); } + give_redirect_form_id($atts['id']); + // Sanity check 2: Check the form even has Goals enabled. if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) { @@ -607,6 +611,8 @@ function give_totals_shortcode( $atts ) { 'give_totals' ); + give_redirect_form_id($atts['ids']); + // Total Goal. $total_goal = give_maybe_sanitize_amount( $atts['total_goal'] ); @@ -846,6 +852,8 @@ function give_form_grid_shortcode( $atts ) { $atts ); + give_redirect_form_id($atts['ids']); + // Validate integer attributes. $atts['forms_per_page'] = intval( $atts['forms_per_page'] ); $atts['excerpt_length'] = intval( $atts['excerpt_length'] ); From 288bd46bcce708c247918636e571120fc10e33ba Mon Sep 17 00:00:00 2001 From: "Kyle B. Johnson" Date: Tue, 1 Aug 2023 10:47:37 -0400 Subject: [PATCH 2/3] wip: Add ignore comments --- src/DonationForms/V2/Endpoints/ListDonationForms.php | 4 ++-- tests/Unit/DonationForms/Endpoints/TestListDonationForms.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DonationForms/V2/Endpoints/ListDonationForms.php b/src/DonationForms/V2/Endpoints/ListDonationForms.php index f17be954d5..f52aa73d4c 100644 --- a/src/DonationForms/V2/Endpoints/ListDonationForms.php +++ b/src/DonationForms/V2/Endpoints/ListDonationForms.php @@ -130,8 +130,8 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response foreach ($items as &$item) { $v2form = defined('GIVE_NEXT_GEN_VERSION') && ! get_post_meta($item['id'], 'formBuilderFields'); - $canMigrate = $v2form && ! give_is_form_migrated($item['id']); - $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($item['id']); + $canMigrate = $v2form && ! give_is_form_migrated($item['id']); // @phpstan-ignore + $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($item['id']); // @phpstan-ignore $item['name'] = get_the_title($item['id']); $item['edit'] = get_edit_post_link($item['id'], 'edit'); diff --git a/tests/Unit/DonationForms/Endpoints/TestListDonationForms.php b/tests/Unit/DonationForms/Endpoints/TestListDonationForms.php index 743967e993..734305d65a 100644 --- a/tests/Unit/DonationForms/Endpoints/TestListDonationForms.php +++ b/tests/Unit/DonationForms/Endpoints/TestListDonationForms.php @@ -109,8 +109,8 @@ public function getMockColumns(array $donationForms, string $sortDirection = 'de $expectedItem[$column::getId()] = $column->getCellValue($donationForm); } $v2form = defined('GIVE_NEXT_GEN_VERSION') && ! get_post_meta($donationForm->id, 'formBuilderFields'); - $canMigrate = $v2form && ! give_is_form_migrated($donationForm->id); - $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($donationForm->id); + $canMigrate = $v2form && ! give_is_form_migrated($donationForm->id); // @phpstan-ignore + $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($donationForm->id); // @phpstan-ignore $expectedItem['name'] = $donationForm->title; $expectedItem['edit'] = get_edit_post_link($donationForm->id, 'edit'); From 218de8c555c14b6fa9e036dedab577d1e8e36ada Mon Sep 17 00:00:00 2001 From: "Kyle B. Johnson" Date: Tue, 1 Aug 2023 11:51:01 -0400 Subject: [PATCH 3/3] wip: Update ignore comment --- src/DonationForms/V2/Endpoints/ListDonationForms.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DonationForms/V2/Endpoints/ListDonationForms.php b/src/DonationForms/V2/Endpoints/ListDonationForms.php index f52aa73d4c..fac1a80f98 100644 --- a/src/DonationForms/V2/Endpoints/ListDonationForms.php +++ b/src/DonationForms/V2/Endpoints/ListDonationForms.php @@ -130,8 +130,8 @@ public function handleRequest(WP_REST_Request $request): WP_REST_Response foreach ($items as &$item) { $v2form = defined('GIVE_NEXT_GEN_VERSION') && ! get_post_meta($item['id'], 'formBuilderFields'); - $canMigrate = $v2form && ! give_is_form_migrated($item['id']); // @phpstan-ignore - $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($item['id']); // @phpstan-ignore + $canMigrate = $v2form && ! give_is_form_migrated($item['id']); // @phpstan-ignore-line + $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($item['id']); // @phpstan-ignore-line $item['name'] = get_the_title($item['id']); $item['edit'] = get_edit_post_link($item['id'], 'edit');