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 / includes / Campaign / CampaignStyles.php

CampaignStyles.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.4.1, at includes/Campaign/CampaignStyles.php

75 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Campaign;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Fires the hooks through which an add-on loads campaign theme CSS.
11 *
12 * The designs of the four Pro `-v2` themes (bp-v2-water, -fooddrive, -wildlife,
13 * -climate) and the theming of Pro's widgets used to be compiled into Lite's
14 * campaign-display stylesheet, because Pro had no way to add CSS to a campaign
15 * page. They ship with Pro now (src/css/campaign-themes.scss), which loads them
16 * through the `better_payment/campaign/enqueue_styles` action and the
17 * `better_payment/campaign/preview_stylesheets` filter fired here.
18 *
19 * Without Pro, no surface loads any Pro design — not a live page, not the
20 * Campaign Builder, not a preview document. A campaign built from a Pro template
21 * keeps its theme class, and the zero-specificity `:where()` fallback tokens in
22 * the campaign-display stylesheet render it as a plain v2 page. A free install's
23 * locked Pro template cards preview as their screenshot only. Lite's transitional
24 * copy of the Pro themes was deleted when ProCompatibility::MIN_PRO_VERSION
25 * reached 1.4.4.
26 *
27 * @since 2.4.0
28 */
29 final class CampaignStyles {
30
31 /**
32 * The campaign-display stylesheet every theme builds on.
33 */
34 const DISPLAY_HANDLE = 'better-payment-campaign-display-style';
35
36 /**
37 * Enqueue the theme stylesheets for one campaign surface.
38 *
39 * Call it right after the campaign-display stylesheet is enqueued or registered.
40 *
41 * @param string $context 'frontend' for a live campaign page, 'builder' for the
42 * Campaign Builder admin page.
43 * @return void
44 */
45 public static function enqueue_theme_styles( string $context = 'frontend' ): void {
46 /**
47 * Fires wherever a campaign's stylesheets are enqueued, so an add-on can load
48 * its own theme CSS after Lite's campaign-display stylesheet.
49 *
50 * @param string $context 'frontend' or 'builder'.
51 */
52 do_action( 'better_payment/campaign/enqueue_styles', $context );
53 }
54
55 /**
56 * Stylesheet URLs a standalone preview document links after campaign-display.
57 *
58 * Preview documents (the builder canvas, the template picker's lightbox) are
59 * built as HTML strings and never run wp_head, so they cannot use enqueues.
60 *
61 * @return string[]
62 */
63 public static function preview_stylesheets(): array {
64 /**
65 * Filter the extra stylesheets linked into a campaign preview document.
66 *
67 * @param string[] $urls Absolute stylesheet URLs.
68 */
69 $urls = apply_filters( 'better_payment/campaign/preview_stylesheets', array() );
70
71 // A misbehaving callback can return anything; keep only strings.
72 return array_values( array_filter( (array) $urls, 'is_string' ) );
73 }
74 }
75