Skip to content

Allow span tag in pagination labels#66029

Open
huubl wants to merge 2 commits intoWordPress:trunkfrom
huubl:allow-span-tag-in-pagination-labels
Open

Allow span tag in pagination labels#66029
huubl wants to merge 2 commits intoWordPress:trunkfrom
huubl:allow-span-tag-in-pagination-labels

Conversation

@huubl
Copy link
Copy Markdown
Contributor

@huubl huubl commented Oct 10, 2024

What?

Allows <span> tags in pagination labels by filter for better flexibility. Addresses #60878.

Why?

The current implementation of the core/query-pagination-previous and core/query-pagination-next blocks in Gutenberg use esc_html to escape the label text, which doesn't allow any HTML tags. This limits the freedom to set a label as Previous <span class="hide-on-mobile">Page</span>.

How?

Modifies the core/query-pagination-previous and core/query-pagination-next blocks to allow <span> tags in the pagination labels when filtered.

Testing Instructions

  1. Open a post or page.
  2. Insert a Query Loop with Pagination block.
  3. Add this to functions.php:
function render_block_data_pagination($parsed_block)
{
	if ('core/query-pagination-next' === $parsed_block['blockName']) {
		$parsed_block['attrs']['label'] = 'Next <span class="hide-on-mobile">Page</span>';
	}

	return $parsed_block;
}
add_filter('render_block_data', 'render_block_data_pagination', 10, 3);
  1. Confirm that pagination navigation next label has the inner span tag.

Testing Instructions for Keyboard

--

Screenshots or screencast

--

@huubl huubl requested a review from ajitbohra as a code owner October 10, 2024 16:47
@github-actions
Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Technical Prototype, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core, Gutenberg Plugin.
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 10, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: huubl <huubl@git.wordpress.org>
Co-authored-by: badasswp <badasswp@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@huubl huubl force-pushed the allow-span-tag-in-pagination-labels branch from 681bd69 to f23f758 Compare October 10, 2024 17:03
@huubl huubl requested a review from badasswp January 17, 2025 10:53
@huubl huubl requested a review from fabiankaegy as a code owner March 4, 2025 13:38
@huubl huubl force-pushed the allow-span-tag-in-pagination-labels branch from 306f8d0 to 054759d Compare March 4, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants