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'] ); diff --git a/src/DonationForms/V2/Endpoints/ListDonationForms.php b/src/DonationForms/V2/Endpoints/ListDonationForms.php index f17be954d5..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']); - $canTransfer = $v2form && ! $canMigrate && ! give_is_form_donations_transferred($item['id']); + $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'); 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');