diff options
Diffstat (limited to 'plugins/jetpack/extensions/blocks/amazon/amazon.php')
-rw-r--r-- | plugins/jetpack/extensions/blocks/amazon/amazon.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/plugins/jetpack/extensions/blocks/amazon/amazon.php b/plugins/jetpack/extensions/blocks/amazon/amazon.php index a368ab79..53af15d6 100644 --- a/plugins/jetpack/extensions/blocks/amazon/amazon.php +++ b/plugins/jetpack/extensions/blocks/amazon/amazon.php @@ -4,13 +4,29 @@ * * @since 8.x * - * @package Jetpack + * @package automattic/jetpack */ -jetpack_register_block( - 'jetpack/amazon', - array( 'render_callback' => 'jetpack_amazon_block_load_assets' ) -); +namespace Automattic\Jetpack\Extensions\Amazon; + +use Automattic\Jetpack\Blocks; +use Jetpack_Gutenberg; + +const FEATURE_NAME = 'amazon'; +const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; + +/** + * Registers the block for use in Gutenberg + * This is done via an action so that we can disable + * registration if we need to. + */ +function register_block() { + Blocks::jetpack_register_block( + BLOCK_NAME, + array( 'render_callback' => __NAMESPACE__ . '\load_assets' ) + ); +} +add_action( 'init', __NAMESPACE__ . '\register_block' ); /** * Amazon block registration/dependency declaration. @@ -20,7 +36,7 @@ jetpack_register_block( * * @return string */ -function jetpack_amazon_block_load_assets( $attr, $content ) { - Jetpack_Gutenberg::load_assets_as_required( 'amazon' ); +function load_assets( $attr, $content ) { + Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); return $content; } |