AvadaService.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\Integrations\Avada; |
| 4 | |
| 5 | /** |
| 6 | * Controls the Avada integration. |
| 7 | */ |
| 8 | class AvadaService { |
| 9 | /** |
| 10 | * Bootstrap the Avada integration. |
| 11 | * |
| 12 | * @return void |
| 13 | */ |
| 14 | public function bootstrap(): void { |
| 15 | add_action( 'after_setup_theme', [ $this, 'init' ] ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Check if Avada theme is active. |
| 20 | * |
| 21 | * @return bool |
| 22 | */ |
| 23 | private function isAvadaThemeActive(): bool { |
| 24 | $active_theme = wp_get_theme(); |
| 25 | return 'Avada' === $active_theme->get( 'Name' ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Initialize the Avada integration. |
| 30 | * |
| 31 | * @return void |
| 32 | */ |
| 33 | public function init(): void { |
| 34 | if ( ! $this->isAvadaThemeActive() ) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueueAvadaBlockStyles' ], 999999 ); // must be greater than 999. |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Enqueue the Avada block styles. |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | public function enqueueAvadaBlockStyles(): void { |
| 47 | wp_enqueue_style( 'global-styles' ); |
| 48 | wp_enqueue_style( 'wp-block-library' ); |
| 49 | wp_enqueue_style( 'wp-block-library-theme' ); |
| 50 | wp_enqueue_style( 'classic-theme-styles' ); |
| 51 | } |
| 52 | } |
| 53 |