shortcode.php 794 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Server-side rendering of the `core/shortcode` block.
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Performs wpautop() on the shortcode block content.
  9. *
  10. * @param array $attributes The block attributes.
  11. * @param string $content The block content.
  12. *
  13. * @return string Returns the block content.
  14. */
  15. function render_block_core_shortcode( $attributes, $content ) {
  16. return wpautop( $content );
  17. }
  18. /**
  19. * Registers the `core/shortcode` block on server.
  20. */
  21. function register_block_core_shortcode() {
  22. register_block_type(
  23. 'core/shortcode',
  24. array(
  25. 'attributes' => array(
  26. 'text' => array(
  27. 'type' => 'string',
  28. 'source' => 'html',
  29. ),
  30. ),
  31. 'render_callback' => 'render_block_core_shortcode',
  32. )
  33. );
  34. }
  35. add_action( 'init', 'register_block_core_shortcode' );