v3.0 - blocks-manifest.php, v3.1 - ranking card#255
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the block registration approach by implementing WordPress 6.7's new performance-optimized block registration API using a manifest file. The change consolidates individual register_block_type() calls into a single wp_register_block_types_from_metadata_collection() call that leverages a pre-generated blocks-manifest.php file.
Key Changes:
- Updated minimum WordPress requirement from 6.1 to 6.8 and PHP from 7.0 to 7.4
- Replaced multiple individual block registrations with manifest-based collection registration
- Added
build-blocks-manifestnpm script andreact-sharedependency (v4.4.1)
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| unityblocks.php | Updated requirements, version to 3.0.0, and replaced individual block registrations with manifest-based approach; commented out Pitchfork theme conditional logic pending new solution |
| package.json | Version bump to 3.0.0, added manifest build script and react-share dependency |
| package-lock.json | Updated version references and removed peer dependency flags for react-share and its dependencies (jsonp) |
| build/blocks-manifest.php | New auto-generated file containing metadata for all 9 blocks (anchor-menu, asu-careers, asu-events, events-grid, hero, image-gallery, news-grid, testimonial, wchm) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| //$theme_data = wp_get_theme(); | ||
| //$pitchfork_theme = ('pitchfork' === $theme_data->get('TextDomain') || 'pitchfork' === $theme_data->get('Template')); | ||
|
|
||
| // Register these blocks only if not using Pitchfork | ||
| // Pitchfork already has these blocks | ||
| if (!$pitchfork_theme) { | ||
| register_block_type(__DIR__ . '/build/hero'); | ||
| } | ||
| // if (!$pitchfork_theme) { | ||
| // register_block_type(__DIR__ . '/build/hero'); | ||
| // } find new solution that works with block manifest |
There was a problem hiding this comment.
This code is commented out rather than removed, leaving a TODO note about finding a solution for conditional block registration with the manifest approach. Consider either implementing the solution before merging, or creating a tracking issue and removing the commented code. Leaving incomplete functionality commented out can lead to confusion and technical debt.
| 'grid' | ||
| ), | ||
| 'icon' => 'grid-view', | ||
| 'description' => 'Dsiplay a grid layout for ASU Events.', |
There was a problem hiding this comment.
Typo in the description: "Dsiplay" should be "Display".
| 'description' => 'Dsiplay a grid layout for ASU Events.', | |
| 'description' => 'Display a grid layout for ASU Events.', |
There was a problem hiding this comment.
This is an obvious typo, but I believe this blocks-manifest.php file is auto-generated, right? In that case, I don't think we'd want to commit this suggested change because wouldn't it just be overwritten the next time the build runs?
I think we need to make this correction in: build/asu-events/block.json instead
| 'textdomain' => 'unityblocks', | ||
| 'viewScript' => array( | ||
| 'file:./frontend.js', | ||
| 'unityblocks-careers-view-script' |
There was a problem hiding this comment.
The WCHM block is using 'unityblocks-careers-view-script' as its viewScript handle, which appears to be incorrect. It should use a WCHM-specific script handle like 'unityblocks-wchm-view-script' to match the pattern used by other blocks.
| 'unityblocks-careers-view-script' | |
| 'unityblocks-wchm-view-script' |
There was a problem hiding this comment.
Same as the above comment about the typo, this is a good catch from CoPilot but I can't tell if the suggestion it would be committing would be in the blocks-manifest.php file, or in the source file where the handle is actually declared: build/wchm/block.json
As always, the caveat is that I may be misunderstanding what Copilot is suggesting it is going to do.
There was a problem hiding this comment.
if careers and wchm are on the same page there would likely be issues. this will be a fix in a separate pr as well
There was a problem hiding this comment.
No worries there, then.
There was a problem hiding this comment.
I had no front-end issues adding the blocks to a test page (other than that the Careers block may not be functional, but that's not an issue related to registering the block itself).
I see that this technique requires WordPress 6.8, so I am going to suggest that we keep some backwards compatibility as described on this page (down the page under backwards compatibility) because we still have one high-profile site, Biodesign, running an older version of Wordpress.
The example code on that page looks like this:
if ( function_exists( 'wp_register_block_types_from_metadata_collection' ) ) {
wp_register_block_types_from_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
} else {
if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
wp_register_block_metadata_collection( __DIR__ . '/build', __DIR__ . '/build/blocks-manifest.php' );
}
$manifest_data = require __DIR__ . '/build/blocks-manifest.php';
foreach ( array_keys( $manifest_data ) as $block_type ) {
register_block_type( __DIR__ . "/build/{$block_type}" );
}
}
If I understand this code correctly, it will try the latest approach (6.8), before trying to fall back to the previous method (6.7) if possible, before resorting to looping through the folders and registering each block individually. It looks like we would still need the block manifest file for that last loop to work, as it draws the block/folder names from that. Regardless, I would not want to release a new version of this plugin that broke on a site like Biodesign which usually has a lot of eyes on it.
The other solution, of course, is to update Biodesign; it's being held back because of issues we had with displaying profiles due to the old in-house plugin not working on later versions of WordPress. Progress on updating that site has been slow, however.
|
I should say, now that it's too late, that we could always merge this the way it is, since it's only going into develop, and then make the backwards compatibility change. I didn't think of that until after I clicked the button :( |
Refactor block registration to support WP version checks and use block manifest.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@jkcox I did some testing on Wednesday by downgrading my local site to version 6.5.7 (to match Biodesign) and everything worked except the Unity Hero. I go the standard message about my site "not having support" for that block. I see logic in there to skip registering that block if we're using Pitchfork, but I'm certainly not using Pitchfork. I'm going to run that test again just to make sure I remember things correctly and verify the version/branch information. It was the Wednesday before a holiday and I was not fully paying attention. |
Co-authored-by: jkcox <8856538+jkcox@users.noreply.github.com>
Co-authored-by: jkcox <8856538+jkcox@users.noreply.github.com>
Co-authored-by: jkcox <8856538+jkcox@users.noreply.github.com>
Update ranking-card block to match unity-react-core RankingCard API
|
Another long comment on a rainy day: TL/DR: Unity Heroes will stop working on any site running WordPress 6.5 or earlier. Biodesign is being held on 6.5.7 to allow our old iSearch plugin to continue working. Therefore, updating Unity Blocks on Biodesign may break heroes. And when I say break, they will stop rendering on the front end, and not be editable in the editor. It's only dumb luck that the plugin does not currently automatically update on the Biodesign production site.. This issue is not related to this pull request, but something I discovered while testing. I was concerned about things failing on Biodesign and asked John to apply some code from WordPress to maintain backwards compatibility, but it turns that that code only goes backwards until v6.6 of WordPress. When I rolled my local back to 6.5.7 to match Biodesign, I noticed that heroes stopped working. Unity Blocks now requires v.6.6, or higher, of WordPress. First off, so as not to bury the lede, I am planning on approving this pull request. I just wanted to put down for the record what I found in my testing. First, the history...
This only matters because...
|
wmcconnell
left a comment
There was a problem hiding this comment.
Can we update unityblocks.php to change line 6 to indicate that the new minimum requirement is 6.6. I think that is the case now (see my crazy long comment for more).
v3.1 - ranking card
blocks-manifest.phpblocks-manifest.php, v3.1 - ranking card
wmcconnell
left a comment
There was a problem hiding this comment.
Approved. Since the JSX dependency issue I discovered while testing this is not actually tied to this particular PR, and we've bumped the required WordPress version to 6.6, there are no issues.
|
fixed merge conflicts, just need another approval to merge |
wmcconnell
left a comment
There was a problem hiding this comment.
Because I have it on good authority that this is just resolving merge conflicts. Approved.

https://make.wordpress.org/core/2024/10/17/new-block-type-registration-apis-to-improve-performance-in-wordpress-6-7/