comments-pagination.php 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Server-side rendering of the `core/comments-pagination` block.
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Renders the `core/comments-pagination` block on the server.
  9. *
  10. * @param array $attributes Block attributes.
  11. * @param string $content Block default content.
  12. *
  13. * @return string Returns the wrapper for the Comments pagination.
  14. */
  15. function render_block_core_comments_pagination( $attributes, $content ) {
  16. if ( empty( trim( $content ) ) ) {
  17. return '';
  18. }
  19. if ( post_password_required() ) {
  20. return;
  21. }
  22. return sprintf(
  23. '<div %1$s>%2$s</div>',
  24. get_block_wrapper_attributes(),
  25. $content
  26. );
  27. }
  28. /**
  29. * Registers the `core/comments-pagination` block on the server.
  30. */
  31. function register_block_core_comments_pagination() {
  32. register_block_type_from_metadata(
  33. __DIR__ . '/comments-pagination',
  34. array(
  35. 'render_callback' => 'render_block_core_comments_pagination',
  36. )
  37. );
  38. }
  39. add_action( 'init', 'register_block_core_comments_pagination' );