render.php
43 lines
| 1 | <?php |
| 2 | |
| 3 | use Give\Campaigns\Models\Campaign; |
| 4 | use Give\Campaigns\Repositories\CampaignRepository; |
| 5 | |
| 6 | /** |
| 7 | * @var array $attributes |
| 8 | * @var Campaign $campaign |
| 9 | * |
| 10 | * @unrelesed |
| 11 | */ |
| 12 | |
| 13 | if (! isset($attributes['campaignId']) || |
| 14 | ! ($campaign = give(CampaignRepository::class)->getById($attributes['campaignId'])) |
| 15 | ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | ob_start(); |
| 20 | $atts = [ |
| 21 | 'campaign_id' => $attributes['campaignId'], |
| 22 | 'block_id' => $attributes['blockId'] ?? '', |
| 23 | 'prev_id' => $attributes['prevId'] ?? 0, |
| 24 | 'id' => $attributes['id'], |
| 25 | 'display_style' => $attributes['displayStyle'] ?? 'onpage', |
| 26 | 'continue_button_title' => $attributes['continueButtonTitle'] ?? __('Donate Now', 'give'), |
| 27 | 'show_title' => $attributes['showTitle'] ?? true, |
| 28 | 'content_display' => $attributes['contentDisplay'] ?? 'above', |
| 29 | 'show_goal' => $attributes['showGoal'] ?? true, |
| 30 | 'show_content' => $attributes['showContent'] ?? true, |
| 31 | 'use_default_form' => $attributes['useDefaultForm'] ?? true, |
| 32 | ]; |
| 33 | |
| 34 | if ($atts['use_default_form'] === true) { |
| 35 | $atts['id'] = $campaign->defaultFormId; |
| 36 | } |
| 37 | |
| 38 | echo give_form_shortcode($atts); |
| 39 | |
| 40 | $final_output = ob_get_clean(); |
| 41 | |
| 42 | echo $final_output; |
| 43 |