← All changes
|
src/DonationForms/ViewModels/DonationFormViewModel.php
+10
-3
4.16.1
→
4.16.9
View file →
| @@ -6,8 +6,9 @@ | ||
| 6 | 6 | use Give\Campaigns\ValueObjects\CampaignGoalType; |
| 7 | 7 | use Give\DonationForms\Actions\GenerateAuthUrl; |
| 8 | 8 | use Give\DonationForms\Actions\GenerateDonateRouteUrl; |
| 9 | 9 | use Give\DonationForms\Actions\GenerateDonationFormValidationRouteUrl; |
| 10 | +use Give\DonationForms\Actions\IsolateEnqueuedFormViewAssets; | |
| 10 | 11 | use Give\DonationForms\DataTransferObjects\DonationFormGoalData; |
| 11 | 12 | use Give\DonationForms\Properties\FormSettings; |
| 12 | 13 | use Give\DonationForms\Repositories\DonationFormRepository; |
| 13 | 14 | use Give\DonationForms\ValueObjects\GoalType; |
| @@ -279,14 +280,18 @@ | ||
| 279 | 280 | * 1. Enqueue global styles from WP. |
| 280 | 281 | * - This ensures template compatability with global WP css variables as needed. Loads before our templates, so they can use things like global font-family, etc. |
| 281 | 282 | * 2. Enqueue our donation form specific scripts & styles. |
| 282 | 283 | * - We will let WP handle the actual printing depending on how they were enqueued. |
| 283 | - * 3. Call the specific WP functions wp_print_styles() and wp_print_head_scripts() | |
| 284 | + * 3. Pin the script and style queues to what we enqueued. | |
| 285 | + * - The print functions below fire actions that other plugins enqueue from, so the queues | |
| 286 | + * have to be constrained before printing rather than trusted. | |
| 287 | + * 4. Call the specific WP functions wp_print_styles() and wp_print_head_scripts() | |
| 284 | 288 | * - This will only print the styles and scripts that are enqueued within our route - so we don't have to dequeue a bunch of stuff. |
| 285 | - * 4. Manually echo our window data and root div for our React app to consume | |
| 286 | - * 5. Finally, call the specific WP function wp_print_footer_scripts() | |
| 289 | + * 5. Manually echo our window data and root div for our React app to consume | |
| 290 | + * 6. Finally, call the specific WP function wp_print_footer_scripts() | |
| 287 | 291 | * - This will only print the footer scripts that are enqueued within our route. |
| 288 | 292 | * |
| 293 | + * @since 4.16.7 Isolate the printed assets from anything enqueued after the form has been prepared | |
| 289 | 294 | * @since 4.14.3 Escape HTML attributes for classNames property |
| 290 | 295 | * @since 3.20.0 Adds class for form design |
| 291 | 296 | * @since 3.11.0 Sanitize customCSS property |
| 292 | 297 | * @since 3.0.0 |
| @@ -298,8 +303,10 @@ | ||
| 298 | 303 | $this->enqueueFormScripts( |
| 299 | 304 | $this->donationFormId, |
| 300 | 305 | $this->designId() |
| 301 | 306 | ); |
| 307 | + | |
| 308 | + (new IsolateEnqueuedFormViewAssets())(); | |
| 302 | 309 | |
| 303 | 310 | ob_start(); |
| 304 | 311 | wp_print_styles(); |
| 305 | 312 | wp_print_head_scripts(); |