| 1 |
<?php |
| 2 |
|
| 3 |
namespace Better_Payment\Lite\Classes; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
/** |
| 10 |
* Styles for the Fundraising Campaign widget's Pro "Updates" tab. |
| 11 |
* |
| 12 |
* Only Pro renders that tab, so the rules live in their own stylesheet |
| 13 |
* (`src/css/fundraising-campaign-updates.scss`) instead of |
| 14 |
* `fundraising-campaign.scss`. Lite adds its copy to the widget's style depends |
| 15 |
* while Pro is active but does not declare `fundraising_campaign_update_styles`; |
| 16 |
* a Pro that declares it adds its own byte-identical copy through |
| 17 |
* `better_payment/elementor/editor/get_style_depends`. A later Lite release |
| 18 |
* deletes this class and the stylesheet. |
| 19 |
* |
| 20 |
* @since 2.4.0 |
| 21 |
*/ |
| 22 |
class ProFundraisingUpdateStyles { |
| 23 |
|
| 24 |
/** |
| 25 |
* Feature slug Pro declares once it loads the styles itself. |
| 26 |
*/ |
| 27 |
const FEATURE = 'fundraising_campaign_update_styles'; |
| 28 |
|
| 29 |
/** |
| 30 |
* Lite's style handle (registered in Assets). |
| 31 |
*/ |
| 32 |
const HANDLE = 'fundraising-campaign-updates-style'; |
| 33 |
|
| 34 |
/** |
| 35 |
* Whether Lite's copy of the styles should load. |
| 36 |
* |
| 37 |
* A free install renders only the upgrade banner in that tab, so nothing needs |
| 38 |
* the styles there. |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public static function lite_copy_applies(): bool { |
| 43 |
if ( ProCompatibility::provides( self::FEATURE ) ) { |
| 44 |
return false; |
| 45 |
} |
| 46 |
|
| 47 |
return (bool) apply_filters( 'better_payment/pro_enabled', false ); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* The widget's style depends, with Lite's copy appended when it applies. |
| 52 |
* |
| 53 |
* @param array $depends Style handles. |
| 54 |
* @return array |
| 55 |
*/ |
| 56 |
public static function style_depends( array $depends ): array { |
| 57 |
if ( self::lite_copy_applies() ) { |
| 58 |
$depends[] = self::HANDLE; |
| 59 |
} |
| 60 |
|
| 61 |
return $depends; |
| 62 |
} |
| 63 |
} |
| 64 |
|