amazon.php
| 1 | <?php |
| 2 | /** |
| 3 | * Amazon Block. |
| 4 | * |
| 5 | * @since 8.x |
| 6 | * |
| 7 | * @package Jetpack |
| 8 | */ |
| 9 | |
| 10 | namespace Automattic\Jetpack\Extensions\Amazon; |
| 11 | |
| 12 | use Jetpack_Gutenberg; |
| 13 | |
| 14 | const FEATURE_NAME = 'amazon'; |
| 15 | const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; |
| 16 | |
| 17 | /** |
| 18 | * Registers the block for use in Gutenberg |
| 19 | * This is done via an action so that we can disable |
| 20 | * registration if we need to. |
| 21 | */ |
| 22 | function register_block() { |
| 23 | jetpack_register_block( |
| 24 | BLOCK_NAME, |
| 25 | array( 'render_callback' => __NAMESPACE__ . '\load_assets' ) |
| 26 | ); |
| 27 | } |
| 28 | add_action( 'init', __NAMESPACE__ . '\register_block' ); |
| 29 | |
| 30 | /** |
| 31 | * Amazon block registration/dependency declaration. |
| 32 | * |
| 33 | * @param array $attr Array containing the Amazon block attributes. |
| 34 | * @param string $content String containing the Amazon block content. |
| 35 | * |
| 36 | * @return string |
| 37 | */ |
| 38 | function load_assets( $attr, $content ) { |
| 39 | Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); |
| 40 | return $content; |
| 41 | } |
| 42 |