Sin descripción

conversation.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Conversation Block.
  4. *
  5. * @since 9.3.0
  6. *
  7. * @package automattic/jetpack
  8. */
  9. namespace Automattic\Jetpack\Extensions\Conversation;
  10. use Automattic\Jetpack\Blocks;
  11. use Jetpack_Gutenberg;
  12. const FEATURE_NAME = 'conversation';
  13. const BLOCK_NAME = 'jetpack/' . FEATURE_NAME;
  14. /**
  15. * Registers the block for use in Gutenberg
  16. * This is done via an action so that we can disable
  17. * registration if we need to.
  18. */
  19. function register_block() {
  20. $deprecated = function_exists( 'gutenberg_get_post_from_context' );
  21. $provides = $deprecated ? 'providesContext' : 'provides_context';
  22. Blocks::jetpack_register_block(
  23. BLOCK_NAME,
  24. array(
  25. 'render_callback' => __NAMESPACE__ . '\render_block',
  26. $provides => array(
  27. 'jetpack/conversation-participants' => 'participants',
  28. 'jetpack/conversation-showTimestamps' => 'showTimestamps',
  29. ),
  30. )
  31. );
  32. }
  33. add_action( 'init', __NAMESPACE__ . '\register_block' );
  34. /**
  35. * Conversation block registration/dependency declaration.
  36. *
  37. * @param array $attr Array containing the Conversation block attributes.
  38. * @param string $content String containing the Conversation block content.
  39. *
  40. * @return string
  41. */
  42. function render_block( $attr, $content ) {
  43. Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME );
  44. return $content;
  45. }