Nessuna descrizione

whatsapp-button.php 1007B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * WhatsApp Button Block.
  4. *
  5. * @package automattic/jetpack
  6. */
  7. namespace Automattic\Jetpack\Extensions\WhatsApp_Button;
  8. use Automattic\Jetpack\Blocks;
  9. use Jetpack_Gutenberg;
  10. const PARENT_NAME = 'send-a-message';
  11. const FEATURE_NAME = 'whatsapp-button';
  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. Blocks::jetpack_register_block(
  20. BLOCK_NAME,
  21. array(
  22. 'render_callback' => __NAMESPACE__ . '\render_block',
  23. 'plan_check' => true,
  24. )
  25. );
  26. }
  27. add_action( 'init', __NAMESPACE__ . '\register_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_block( $attributes, $content ) {
  37. Jetpack_Gutenberg::load_styles_as_required( PARENT_NAME );
  38. return $content;
  39. }