kollapsminoriteten/wp-content/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php

48 lines
1.1 KiB
PHP
Raw Normal View History

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' )
);
}
}
add_action( 'init', __NAMESPACE__ . '\register_block' );
/**
* 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;
}