Нет описания

subscriptions.php 1.1KB

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