PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / templates / single-bp_campaign.php

single-bp_campaign.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.4.1, at templates/single-bp_campaign.php

68 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for single bp_campaign posts.
4 *
5 * Loaded via the template_include filter in better-payment.php.
6 * Renders the full campaign using RendererService so the CPT permalink
7 * (/bp-campaigns/slug/) shows the same output as [bp_campaign id="X"].
8 */
9
10 use Better_Payment\Lite\Campaign\Services\RendererService;
11 use Better_Payment\Lite\Classes\Helper;
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 // For block themes, pre-render header/footer template parts so they display
18 // correctly on this CPT page (which bypasses the theme's block templates).
19 $bp_header = '';
20 $bp_footer = '';
21 if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
22 $theme_slug = wp_get_theme()->get( 'TextDomain' );
23 $bp_header = do_blocks( '<!-- wp:template-part {"slug":"header","theme":"' . esc_attr( $theme_slug ) . '"} /-->' );
24 $bp_footer = do_blocks( '<!-- wp:template-part {"slug":"footer","theme":"' . esc_attr( $theme_slug ) . '"} /-->' );
25 }
26
27 Helper::render_header( $bp_header );
28
29 if ( have_posts() ) :
30 the_post();
31 $campaign_id = get_the_ID();
32
33 if ( get_post_status( $campaign_id ) !== 'publish' ) {
34 global $wp_query;
35 $wp_query->set_404();
36 status_header( 404 );
37 nocache_headers();
38 Helper::render_footer( $bp_footer );
39 exit;
40 }
41
42 // Enqueue frontend styles.
43 $css_file = BETTER_PAYMENT_PATH . '/assets/blocks/campaign-display/style.min.css';
44 if ( file_exists( $css_file ) ) {
45 wp_enqueue_style(
46 'better-payment-campaign-display-style',
47 BETTER_PAYMENT_ASSETS . '/blocks/campaign-display/style.min.css',
48 [],
49 filemtime( $css_file )
50 );
51 }
52
53 // Theme CSS that loads on top of campaign-display (Pro's template themes).
54 \Better_Payment\Lite\Campaign\CampaignStyles::enqueue_theme_styles( 'frontend' );
55
56 // Enqueue frontend JS (amount selector → donate button URL).
57 wp_enqueue_script( 'fundraising-campaign-script' );
58 wp_enqueue_style( 'fundraising-campaign-style' );
59
60 ?>
61 <main id="bp-campaign-main" class="bp-campaign-page-wrap" role="main">
62 <?php echo RendererService::render_campaign( $campaign_id, is_preview() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
63 </main>
64 <?php
65 endif;
66
67 Helper::render_footer( $bp_footer );
68