query-pagination.php 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Server-side rendering of the `core/query-pagination` block.
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Renders the `core/query-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 Query pagination.
  14. */
  15. function render_block_core_query_pagination( $attributes, $content ) {
  16. if ( empty( trim( $content ) ) ) {
  17. return '';
  18. }
  19. $wrapper_attributes = get_block_wrapper_attributes(
  20. array(
  21. 'aria-label' => __( 'Pagination' ),
  22. )
  23. );
  24. return sprintf(
  25. '<nav %1$s>%2$s</nav>',
  26. $wrapper_attributes,
  27. $content
  28. );
  29. }
  30. /**
  31. * Registers the `core/query-pagination` block on the server.
  32. */
  33. function register_block_core_query_pagination() {
  34. register_block_type_from_metadata(
  35. __DIR__ . '/query-pagination',
  36. array(
  37. 'render_callback' => 'render_block_core_query_pagination',
  38. )
  39. );
  40. }
  41. add_action( 'init', 'register_block_core_query_pagination' );