Admin
3 years ago
Assets
3 years ago
Pages
3 years ago
PostTypes
3 years ago
Shortcodes
3 years ago
Sitemap
3 years ago
Templates
3 years ago
Users
3 years ago
ActionsService.php
4 years ago
CompatibilityService.php
3 years ago
PluginService.php
3 years ago
PluginServiceProvider.php
3 years ago
RecaptchaValidationService.php
3 years ago
ThemeService.php
3 years ago
ThemeServiceProvider.php
3 years ago
TranslationsServiceProvider.php
3 years ago
CompatibilityService.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package SureCartAppCore |
| 4 | * @author SureCart <support@surecart.com> |
| 5 | * @copyright SureCart |
| 6 | * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0 |
| 7 | * @link https://surecart.com |
| 8 | */ |
| 9 | |
| 10 | namespace SureCart\WordPress; |
| 11 | |
| 12 | /** |
| 13 | * Provides compatibility with other plugins. |
| 14 | */ |
| 15 | class CompatibilityService { |
| 16 | /** |
| 17 | * Bootstrap the service. |
| 18 | * |
| 19 | * @return void |
| 20 | */ |
| 21 | public function bootstrap() { |
| 22 | // UAG fix. |
| 23 | add_action( 'render_block_data', [ $this, 'maybeEnqueueUAGBAssets' ] ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Render block data. |
| 28 | * |
| 29 | * @param array $block_data Block data. |
| 30 | * |
| 31 | * @return array |
| 32 | */ |
| 33 | public function maybeEnqueueUAGBAssets( $parsed_block ) { |
| 34 | // UAGB must be activated. |
| 35 | if ( ! class_exists( '\UAGB_Post_Assets' ) ) { |
| 36 | return $parsed_block; |
| 37 | } |
| 38 | |
| 39 | // must be our checkout form block. |
| 40 | if ( 'surecart/checkout-form' !== $parsed_block['blockName'] ) { |
| 41 | return $parsed_block; |
| 42 | } |
| 43 | |
| 44 | // must have an ID. |
| 45 | if ( empty( $parsed_block['attrs']['id'] ) ) { |
| 46 | return $parsed_block; |
| 47 | } |
| 48 | |
| 49 | // If Spectra Blocks are present in the form, enqueue the assets. |
| 50 | $post_assets_instance = new \UAGB_Post_Assets( $parsed_block['attrs']['id'] ); |
| 51 | $post_assets_instance->enqueue_scripts(); |
| 52 | |
| 53 | return $parsed_block; |
| 54 | } |
| 55 | } |
| 56 |