app.tsx
1 year ago
block.json
1 year ago
edit.tsx
1 year ago
index.tsx
1 year ago
render.php
1 year ago
styles.scss
1 year ago
render.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | use Give\Campaigns\Actions\RenderDonateButton; |
| 4 | use Give\Campaigns\Models\Campaign; |
| 5 | use Give\Campaigns\Repositories\CampaignRepository; |
| 6 | |
| 7 | /** |
| 8 | * @var array $attributes |
| 9 | * @var Campaign $campaign |
| 10 | */ |
| 11 | |
| 12 | if ( |
| 13 | ! isset($attributes['campaignId']) || |
| 14 | ! ($campaign = give(CampaignRepository::class)->getById($attributes['campaignId'])) |
| 15 | ) { |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | $blockInlineStyles = sprintf( |
| 20 | '--givewp-primary-color: %s;', |
| 21 | esc_attr($campaign->primaryColor ?? '#0b72d9') |
| 22 | ); |
| 23 | ?> |
| 24 | |
| 25 | <div |
| 26 | <?php |
| 27 | echo wp_kses_data(get_block_wrapper_attributes(['class' => 'givewp-campaign-donate-button-block'])); ?> |
| 28 | style="<?php |
| 29 | echo esc_attr($blockInlineStyles); ?>"> |
| 30 | <?php |
| 31 | echo give(RenderDonateButton::class)( |
| 32 | ($attributes['useDefaultForm'] || ! isset($attributes['selectedForm'])) |
| 33 | ? $campaign->defaultFormId |
| 34 | : $attributes['selectedForm'], |
| 35 | $attributes['buttonText'] ?? __('Donate', 'give'), |
| 36 | ); |
| 37 | ?> |
| 38 | </div> |
| 39 |