shortcode.php 697 B

12345678910111213141516171819202122232425262728293031
  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_from_metadata(
  23. __DIR__ . '/shortcode',
  24. array(
  25. 'render_callback' => 'render_block_core_shortcode',
  26. )
  27. );
  28. }
  29. add_action( 'init', 'register_block_core_shortcode' );