impress-org / givewp-next-gen

GiveWP 3.0.0 Feature Plugin
https://givewp.com/
GNU General Public License v3.0
10 stars 1 forks source link

Feature: "Redirect" migrated form IDs in shortcodes and blocks #227

Closed kjohnson closed 1 year ago

kjohnson commented 1 year ago

Description

This PR hooks into shortcodes and block to "redirect" old (v2) form IDs to the new (v3) migrated form IDs.

With a single line the $formId can be updated to the migrated form ID:

givewp_migrated_form_id($formId);

While this falls under the category of "clever", the trade-off is for ease of use with a single line additive update.

The implementation uses an auto-loaded function with an "output argument". The single argument is passed by reference so that the value is updated in the called location without needing to update the value manually.

Affects

The GiveWP (core) plugin will need to be updated in each location that a Form ID is specified as a shortcode or block argument.

Visuals

add_shortcode('give_example', function($atts) {
    $formId = absint( $atts['id'] );
+   givewp_migrated_form_id($formId);
    echo $formId;
});

// [give_example id="297"] => 988

Testing Instructions