Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6939eb5
Add support in the JS hook
SantosGuillamot Jul 1, 2024
33ebfd8
Add support in the PHP array
SantosGuillamot Jul 1, 2024
1539bb5
Transform figure > a selector into a
SantosGuillamot Jul 1, 2024
47bac8c
Modify the image rendering if bindings are set
SantosGuillamot Jul 1, 2024
841165d
Add support for image caption
SantosGuillamot Jul 1, 2024
31a78b8
Adapt Gutenberg compatibility filters
SantosGuillamot Jul 1, 2024
2abb001
Use regex (temporary)
SantosGuillamot Jul 1, 2024
49f327c
Fix regex
SantosGuillamot Jul 1, 2024
c85de98
Another approach: Remove tags in render
SantosGuillamot Jul 1, 2024
f69662d
Update supported binding attribtues in another file
talldan Jul 1, 2024
d1734c5
Update client side pattern override supported attributes
talldan Jul 1, 2024
953eea5
Add `set_inner_text` private method instead of using regex
SantosGuillamot Jul 1, 2024
7f00489
Support only caption
SantosGuillamot Jul 1, 2024
cac2dd1
Only run `set_inner_text` when figcaption exists
SantosGuillamot Jul 1, 2024
fd58bcf
Go back to existing `save.js`
SantosGuillamot Jul 1, 2024
c5abad9
Fix typo
SantosGuillamot Jul 1, 2024
3a9c6e8
Remove comment
SantosGuillamot Jul 1, 2024
01ca7ee
Hide caption controls if the caption is binded
cbravobernal Jul 1, 2024
2967e88
Remove user permissions check
cbravobernal Jul 1, 2024
ec0e52c
Add caption e2e tests
SantosGuillamot Jul 1, 2024
fa01364
Copy latest changes from core
SantosGuillamot Jul 1, 2024
f39fa0b
Remove extra return
SantosGuillamot Jul 1, 2024
45cd9e4
Fix bookmarks
SantosGuillamot Jul 1, 2024
da0886d
Fix compatibility with older versions
SantosGuillamot Jul 1, 2024
75fc917
Move logic to 6.6 compat folder
SantosGuillamot Jul 1, 2024
0fe9b31
Only process image caption in 6.6 compat
SantosGuillamot Jul 1, 2024
435058e
Remove extra spaces
SantosGuillamot Jul 1, 2024
895110a
Don't grab bookmarks until the end
SantosGuillamot Jul 1, 2024
3e183b7
Remove release_bookmark
SantosGuillamot Jul 1, 2024
a2b825c
Add warning
SantosGuillamot Jul 1, 2024
77d7116
Make filter caption specific
SantosGuillamot Jul 1, 2024
dc568a9
Only process caption in WP 6.5
SantosGuillamot Jul 1, 2024
6eeb7c2
Change conditional
SantosGuillamot Jul 1, 2024
0e3b174
Add support for 6.4
SantosGuillamot Jul 1, 2024
7311680
Clarify methods only apply to figcaption
SantosGuillamot Jul 1, 2024
d38d635
Remove check to always run caption processing
SantosGuillamot Jul 1, 2024
586d7df
Add backport changelog
SantosGuillamot Jul 1, 2024
ac597ee
Move changelog to 6.7 folder
SantosGuillamot Jul 1, 2024
be4c4c2
Remove caption restriction in pattern overrides
SantosGuillamot Jul 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for 6.4
  • Loading branch information
SantosGuillamot committed Jul 1, 2024
commit 0e3b174cfe24400f75720162e63f1487f5f56b0d
39 changes: 25 additions & 14 deletions lib/compat/wordpress-6.6/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function gutenberg_replace_pattern_override_default_binding( $parsed_block ) {

add_filter( 'render_block_data', 'gutenberg_replace_pattern_override_default_binding', 10, 1 );

// Only process caption in WordPress 6.5.
if ( ! is_wp_version_compatible( '6.6' ) && is_wp_version_compatible( '6.5' ) ) {
// Only process caption for compat versions of WordPress.
if ( ! is_wp_version_compatible( '6.6' ) ) {
/**
* Replace the caption value in the HTML based on the binding value.
*
Expand All @@ -72,16 +72,8 @@ function gutenberg_block_bindings_replace_caption( $block_content, $block_name,
* @return bool Whether the inner text was properly replaced.
*/
public function gutenberg_set_inner_text( $new_content ) {
/*
* THIS IS A STOP-GAP MEASURE NOT TO BE EMULATED.
*
* Check that the processor is paused on an opener tag.
*
*/
if (
WP_HTML_Tag_Processor::STATE_MATCHED_TAG !== $this->parser_state ||
$this->is_tag_closer()
) {
// Check that the processor is paused on an opener tag.
if ( $this->is_tag_closer() ) {
return false;
}

Expand Down Expand Up @@ -110,13 +102,19 @@ public function gutenberg_set_inner_text( $new_content ) {
$closer_tag_bookmark = $this->bookmarks['closer_tag'];

// Appends the new content.
// Compat for 6.4, where bookmarks and WP_HTML_Text_Replacement are different.
if ( ! empty( $opener_tag_bookmark->end ) ) {
$this->lexical_updates[] = new WP_HTML_Text_Replacement( $opener_tag_bookmark->end + 1, $closer_tag_bookmark->start, $new_content );
return true;
}

$after_opener_tag = $opener_tag_bookmark->start + $opener_tag_bookmark->length;
/*
* There was a bug in the HTML Processor token length fixed after 6.5.
* This check is needed to add compatibility for that.
* Related issue: https://github.com/WordPress/wordpress-develop/pull/6625
*/
if ( '>' !== $this->html[ $after_opener_tag - 1 ] ) {
if ( '>' === $this->html[ $after_opener_tag ] ) {
++$after_opener_tag;
}
$inner_content_length = $closer_tag_bookmark->start - $after_opener_tag;
Expand All @@ -128,6 +126,7 @@ public function gutenberg_set_inner_text( $new_content ) {
* Add a new HTML element after the current tag.
*
* @param string $new_element New HTML element to append after the current tag.
* @return bool Whether the element was properly appended.
*/
public function gutenberg_append_element_after_tag( $new_element ) {
$tag_name = $this->get_tag();
Expand All @@ -146,7 +145,12 @@ public function gutenberg_append_element_after_tag( $new_element ) {
// Get position of the closer tag.
$this->set_bookmark( 'closer_tag' );
$closer_tag_bookmark = $this->bookmarks['closer_tag'];
$after_closer_tag = $closer_tag_bookmark->start + $closer_tag_bookmark->length;
// Compat for 6.4, where bookmarks and WP_HTML_Text_Replacement are different.
if ( ! empty( $closer_tag_bookmark->end ) ) {
$this->lexical_updates[] = new WP_HTML_Text_Replacement( $closer_tag_bookmark->end + 1, $closer_tag_bookmark->end + 1, $new_element );
return true;
}
$after_closer_tag = $closer_tag_bookmark->start + $closer_tag_bookmark->length;
/*
* There was a bug in the HTML Processor token length fixed after 6.5.
* This check is needed to add compatibility for that.
Expand All @@ -158,6 +162,7 @@ public function gutenberg_append_element_after_tag( $new_element ) {

// Append the new element.
$this->lexical_updates[] = new WP_HTML_Text_Replacement( $after_closer_tag, 0, $new_element );
return true;
}

/**
Expand Down Expand Up @@ -187,6 +192,12 @@ public function gutenberg_remove_current_tag_element() {
$opener_tag_bookmark = $this->bookmarks['opener_tag'];
$closer_tag_bookmark = $this->bookmarks['closer_tag'];

// Compat for 6.4, where bookmarks and WP_HTML_Text_Replacement are different.
if ( ! empty( $closer_tag_bookmark->end ) ) {
$this->lexical_updates[] = new WP_HTML_Text_Replacement( $opener_tag_bookmark->start, $closer_tag_bookmark->end + 1, '' );
return true;
}

$after_closer_tag = $closer_tag_bookmark->start + $closer_tag_bookmark->length;
/*
* There was a bug in the HTML Processor token length fixed after 6.5.
Expand Down