説明なし

send-a-message.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Send a Message Block.
  4. *
  5. * @package automattic/jetpack
  6. */
  7. namespace Automattic\Jetpack\Extensions\Send_A_Message;
  8. require_once __DIR__ . '/whatsapp-button/whatsapp-button.php';
  9. use Automattic\Jetpack\Blocks;
  10. use Jetpack_Gutenberg;
  11. const FEATURE_NAME = 'send-a-message';
  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( FEATURE_NAME );
  38. return $content;
  39. }