Make WordPress Core

Opened 7 weeks ago

Closed 5 weeks ago

#64449 closed enhancement (fixed)

Block support: Add server-side processing for anchor

Reported by: wildworks's profile wildworks Owned by: wildworks's profile wildworks
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: Editor Keywords: gutenberg-merge has-patch has-unit-tests has-test-info
Focuses: Cc:

Description

Gutenberg PR: https://github.com/WordPress/gutenberg/pull/74183

We are adding anchor (id) support to dynamic blocks. Dynamic blocks are rendered server-side, so we need to process the ID attribute value to output it.

Change History (5)

This ticket was mentioned in PR #10655 on WordPress/wordpress-develop by @wildworks.


7 weeks ago
#1

  • Keywords has-patch has-unit-tests added

#2 @wildworks
7 weeks ago

  • Keywords has-patch has-unit-tests removed

Testing instructions

WordPress core does not yet have any dynamic blocks that support anchors, so run the following code to add anchor support to the Archive block:

add_filter( 'register_block_type_args', function( $args, $block_name ) {
        if ( 'core/archives' === $block_name ) {
                $args['supports']['anchor'] = true;
        }
        return $args;
}, 10, 2 );
  • Open a post.
  • Switch to Code Editor mode and enter the following HTML: <!-- wp:archives {"anchor":"my-anchor"} /-->
  • Save the post.
  • On the frontend, the Archive block should have an ID attribute.

#3 @wildworks
6 weeks ago

  • Keywords has-patch has-unit-tests has-test-info added

@wildworks commented on PR #10655:


5 weeks ago
#4

@westonruter Thanks for the review! I'll commit this change later.

#5 @wildworks
5 weeks ago

  • Owner set to wildworks
  • Resolution set to fixed
  • Status changed from new to closed

In 61437:

Block support: Add server-side processing for anchor.

Adds server-side registration for anchor block support and its required fields.

Props westonruter, wildworks.
Fixes #64449.

Note: See TracTickets for help on using tickets.