2020-06-23 13:49:54 +02:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Subscriptions Block.
|
|
|
|
|
*
|
2021-04-27 08:32:47 +02:00
|
|
|
* @package automattic/jetpack
|
2020-06-23 13:49:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Automattic\Jetpack\Extensions\Subscriptions;
|
|
|
|
|
|
2020-11-18 09:10:44 +01:00
|
|
|
use Automattic\Jetpack\Blocks;
|
2020-06-23 13:49:54 +02:00
|
|
|
use Jetpack;
|
|
|
|
|
use Jetpack_Gutenberg;
|
|
|
|
|
|
|
|
|
|
const FEATURE_NAME = 'subscriptions';
|
|
|
|
|
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() {
|
|
|
|
|
if (
|
2020-09-15 14:30:05 +02:00
|
|
|
( defined( 'IS_WPCOM' ) && IS_WPCOM )
|
2021-04-27 08:32:47 +02:00
|
|
|
|| ( Jetpack::is_connection_ready() && Jetpack::is_module_active( 'subscriptions' ) )
|
2020-06-23 13:49:54 +02:00
|
|
|
) {
|
2020-11-18 09:10:44 +01:00
|
|
|
Blocks::jetpack_register_block(
|
2020-06-23 13:49:54 +02:00
|
|
|
BLOCK_NAME,
|
|
|
|
|
array( 'render_callback' => __NAMESPACE__ . '\render_block' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-07-23 11:58:50 +02:00
|
|
|
add_action( 'init', __NAMESPACE__ . '\register_block', 9 );
|
2020-06-23 13:49:54 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Subscriptions block render callback.
|
|
|
|
|
*
|
|
|
|
|
* @param array $attributes Array containing the block attributes.
|
|
|
|
|
* @param string $content String containing the block content.
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function render_block( $attributes, $content ) {
|
|
|
|
|
Jetpack_Gutenberg::load_styles_as_required( FEATURE_NAME );
|
|
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
|
}
|