Skip to content

Commit

Permalink
Use tag index as the data-wp-key value
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz committed Feb 12, 2024
1 parent 3255e10 commit f61a275
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/block-library/src/query-pagination-numbers/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,16 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
}

if ( $enhanced_pagination ) {
$p = new WP_HTML_Tag_Processor( $content );
$dots_i = 0;
$p = new WP_HTML_Tag_Processor( $content );
$tag_index = 0;
while ( $p->next_tag(
array( 'class_name' => 'page-numbers' )
) ) {
if ( null === $p->get_attribute( 'data-wp-key' ) ) {
$p->set_attribute( 'data-wp-key', 'index-' . $tag_index++ );
}
if ( 'A' === $p->get_tag() ) {
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
$p->set_attribute( 'data-wp-key', $p->get_attribute( 'href' ) );
} elseif ( $p->has_class( 'current' ) ) {
$p->set_attribute( 'data-wp-key', 'current' );
} elseif ( $p->has_class( 'dots' ) ) {
$p->set_attribute( 'data-wp-key', 'dots-' . $dots_i++ );
}
}
$content = $p->get_updated_html();
Expand Down

0 comments on commit f61a275

Please sign in to comment.