service->has_active_extras( 'checkout_block' ) || $this->goals->may_have_goals(); /** * Filters whether frontend assets are loaded. * * @since 1.0.0 * * @param bool $load Load. * @param string $location `checkout_block` or `checkout_classic`. */ return (bool) apply_filters( 'extrova_load_frontend_assets', $load, 'checkout_block' ); } /** * {@inheritDoc} * * Called by WooCommerce when the Checkout block enqueues its assets; the style is enqueued * here too so nothing loads on pages without the Checkout block. */ public function get_script_handles(): array { if ( ! wp_script_is( self::FRONTEND_HANDLE, 'registered' ) || ! $this->should_load() ) { return array(); } if ( wp_style_is( self::FRONTEND_HANDLE, 'registered' ) ) { wp_enqueue_style( self::FRONTEND_HANDLE ); } return array( self::FRONTEND_HANDLE ); } /** * {@inheritDoc} * * The editor scripts are declared in each block.json (registered by BlockRegistrar). */ public function get_editor_script_handles(): array { $handles = array(); foreach ( BlockRegistrar::CHECKOUT_INNER_BLOCKS as $name ) { $handle = generate_block_asset_handle( $name, 'editorScript' ); if ( wp_script_is( $handle, 'registered' ) ) { $handles[] = $handle; } } return $handles; } /** * {@inheritDoc} * * Available in JS as getSetting( 'extrova_data' ). */ public function get_script_data(): array { return array( 'adminUrl' => Capability::check() ? admin_url( 'admin.php?page=extrova' ) : '', ); } }