Нема описа

buttons.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Premium Content Buttons Child Block.
  4. *
  5. * @package automattic/jetpack
  6. */
  7. namespace Automattic\Jetpack\Extensions\Premium_Content;
  8. use Automattic\Jetpack\Blocks;
  9. use Jetpack_Gutenberg;
  10. const BUTTONS_NAME = 'premium-content/buttons';
  11. /**
  12. * Registers the block for use in Gutenberg
  13. * This is done via an action so that we can disable
  14. * registration if we need to.
  15. */
  16. function register_buttons_block() {
  17. // Only load this block on WordPress.com.
  18. if ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || jetpack_is_atomic_site() ) {
  19. Blocks::jetpack_register_block(
  20. BUTTONS_NAME,
  21. array(
  22. 'render_callback' => __NAMESPACE__ . '\render_buttons_block',
  23. )
  24. );
  25. }
  26. }
  27. add_action( 'init', __NAMESPACE__ . '\register_buttons_block' );
  28. /**
  29. * Render callback.
  30. *
  31. * @param array $attributes Array containing the block attributes.
  32. * @param string $content String containing the block content.
  33. *
  34. * @return string
  35. */
  36. function render_buttons_block( $attributes, $content ) {
  37. Jetpack_Gutenberg::load_styles_as_required( BUTTONS_NAME );
  38. return $content;
  39. }