No Description

query-pagination.php 1023B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. 'role' => 'navigation',
  22. 'aria-label' => __( 'Pagination' ),
  23. )
  24. );
  25. return sprintf(
  26. '<nav %1$s>%2$s</nav>',
  27. $wrapper_attributes,
  28. $content
  29. );
  30. }
  31. /**
  32. * Registers the `core/query-pagination` block on the server.
  33. */
  34. function register_block_core_query_pagination() {
  35. register_block_type_from_metadata(
  36. __DIR__ . '/query-pagination',
  37. array(
  38. 'render_callback' => 'render_block_core_query_pagination',
  39. )
  40. );
  41. }
  42. add_action( 'init', 'register_block_core_query_pagination' );