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