-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate WordPress block asset files from PHP to JSON format #1656
Conversation
Signed-off-by: Joe Fusco <[email protected]>
🦋 Changeset detectedLatest commit: 42e0f85 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Hey @josephfusco thanks . Will review it today. |
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]> # Conflicts: # examples/next/block-support/package.json # package-lock.json
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
df1b6f5
to
5cd554d
Compare
Hey @josephfusco . I was trying to test your changes and although I can see the uploaded files now both Local and WP Engine instance are throwing 500 errors. I believe its located when you read the block.json contents:
|
Signed-off-by: Joe Fusco <[email protected]>
Signed-off-by: Joe Fusco <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I would be nice to have one more review
After syncing a block to my WPE site, I get this notice on every page load:
Edit: also appears the blocks are not showing up in my WPE site, but do in a Local dev site. |
cc @josephfusco Hey @mindctrl can you see the uploaded files in your WPE site? Is there a specific config that you use? |
@theodesp having issues connecting to my site via SSH to see the folders, but will let you know soon. I just used the example code in this PR, nothing different or special locally. |
I can confirm I'm seeing this warning too, although blocks are visible within the editor in both WP Engine & local environments. |
I've observed that blocks are functioning correctly in both the block editor and the GraphQL response, both in Local and WP Engine environments. This observation brings into question the relevance of the _doing_it_wrong warning that we're currently encountering. The warning is triggered by the following line in the WordPress core: Asset File Requirement in blocks.php. This line enforces a .php file requirement for asset files. In our case, however, dependencies are managed through a JSON file, which makes the .php requirement seem unnecessary. A screenshot illustrating the current warning is provided for reference: I propose introducing a filter at this point in the code. This filter would allow developers to inform WordPress that a .php file is not required in specific instances, such as ours where JSON is used for dependency management. This enhancement would provide greater flexibility in handling block dependencies, particularly for those of us leveraging modern development workflows. |
Proposed filter WordPress/wordpress-develop#5799 |
Tasks
Description
These changes aim to fix the failing unzipping action reported in #1633.
Traditional WordPress blocks generate *.asset.php files. However, many hosting environments restrict PHP files in the uploads directory. This change proposes converting these files to index.asset.json, aligning with hosting constraints and improving compatibility.
Supporting tests have been added to both the cli package and WordPress plugin.
Related Issue(s):
#1522, #1633
Testing
Checkout this branch:
fix/blockset-issue-1633
Update the block support example project (
examples/next/block-support/)
to be a WordPress site hosted on WP Engine.Add the updated faustwp.zip to your WordPress site.
Run
npm run blockset -w @faustwp/block-support-example
from the root of this cloned repo.Observe "WordPress: Blockset sync complete" in your terminal.
Observe the blocks defined in your Next.js app have been compiled and are present in your connected WordPress site's uploads directory.