| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! interface_exists( 'Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface' ) ) { |
| 4 |
return; |
| 5 |
} |
| 6 |
|
| 7 |
use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface; |
| 8 |
|
| 9 |
/** |
| 10 |
* Route Protection block integration with WooCommerce Blocks checkout. |
| 11 |
* |
| 12 |
* Enqueues the script that registers the additionalCartCheckoutInnerBlockTypes |
| 13 |
* filter so the Route block is allowed inside checkout inner-block areas. |
| 14 |
*/ |
| 15 |
class Routeapp_Blocks_Integration implements IntegrationInterface { |
| 16 |
|
| 17 |
/** |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
public function get_name() { |
| 21 |
return 'route-protection'; |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Register frontend script that whitelists the block in checkout areas. |
| 26 |
*/ |
| 27 |
public function initialize() { |
| 28 |
$deps = wp_script_is( 'wc-blocks-checkout', 'registered' ) |
| 29 |
? array( 'wc-blocks-checkout' ) |
| 30 |
: array(); |
| 31 |
|
| 32 |
wp_register_script( |
| 33 |
'route-protection-block-frontend', |
| 34 |
plugins_url( 'blocks/route-protection/frontend.js', dirname( __FILE__ ) ), |
| 35 |
$deps, |
| 36 |
defined( 'ROUTEAPP_VERSION' ) ? ROUTEAPP_VERSION : '1.0.0', |
| 37 |
true |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* @return string[] |
| 43 |
*/ |
| 44 |
public function get_script_handles() { |
| 45 |
return array( 'route-protection-block-frontend' ); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* @return string[] |
| 50 |
*/ |
| 51 |
public function get_editor_script_handles() { |
| 52 |
return array( 'route-protection-block-frontend' ); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* @return array |
| 57 |
*/ |
| 58 |
public function get_script_data() { |
| 59 |
return array(); |
| 60 |
} |
| 61 |
} |
| 62 |
|