Skip to content

Commit

Permalink
Button Block: Add back compat for WP6.4 regarding HTML Tag Processor (#…
Browse files Browse the repository at this point in the history
…63082)

* Button Block: Add back compat for WP6.4 regarding HTML tag processor

* Don't use conditional statement

* Update packages/block-library/src/button/index.php

Re-add conditional statement

Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>

* Fix lint and update comment

* Remove space

---------

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Co-authored-by: ndiego <ndiego@git.wordpress.org>
Co-authored-by: beckej13820 <beckej@git.wordpress.org>
  • Loading branch information
7 people committed Jul 4, 2024
1 parent 4d0cfa0 commit b6310be
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/block-library/src/button/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@
* @return string The block content.
*/
function render_block_core_button( $attributes, $content ) {
$p = new WP_HTML_Tag_Processor( $content );
/*
* The current Gutenberg plugin supports WordPress 6.4, but the next_token()
* method does not exist in WordPress 6.4. Therefore, if Gutenberg is used
* as a plugin, use the Gutenberg class that has the `next_token()` method.
*
* TODO: After the Gutenberg plugin drops support for WordPress 6.4, this
* conditional statement will be removed and the core class `WP_HTML_Tag_Processor`
* should be used.
*/
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && class_exists( 'Gutenberg_HTML_Tag_Processor_6_5' ) ) {
$p = new Gutenberg_HTML_Tag_Processor_6_5( $content );
} else {
$p = new WP_HTML_Tag_Processor( $content );
}

/*
* The button block can render an `<a>` or `<button>` and also has a
Expand Down

1 comment on commit b6310be

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in b6310be.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9789845446
📝 Reported issues:

Please sign in to comment.