-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add logic for block style entry points #229
Merged
fabiankaegy
merged 10 commits into
trunk
from
feature/339-filename-based-entrypoint-for-block-specific-CSS
Sep 26, 2024
Merged
Add logic for block style entry points #229
fabiankaegy
merged 10 commits into
trunk
from
feature/339-filename-based-entrypoint-for-block-specific-CSS
Sep 26, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 tasks
Marking this as a draft till the toolkit PR has been merged & released :) |
fabiankaegy
reviewed
May 23, 2024
…lock-specific-CSS
…lock-specific-CSS # Conflicts: # themes/10up-theme/includes/blocks.php
This PR has been updated and tested 👍 Once toolkit 6.3 gets officially released we can merge this in 👍 |
fabiankaegy
approved these changes
Sep 24, 2024
fabiankaegy
deleted the
feature/339-filename-based-entrypoint-for-block-specific-CSS
branch
September 26, 2024 09:15
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces the
enqueue_block_specific_styles()
function in theblocks.php
file. This function is designed to enqueue styles that are specific to a block.The function operates by first retrieving all the CSS files in the 'blocks/autoenqueue' directory. For each stylesheet, it determines the block type by removing the directory path and '.css' from the stylesheet path.
The function then attempts to get the asset file for the block type. If the asset file doesn't exist, it creates a new one with the version set to the file modification time of the stylesheet and no dependencies.
Finally, the function enqueues the block style using the block type, the URL to the stylesheet, the path to the stylesheet, the version from the asset file, and the dependencies from the asset file.
This is required for 10up/10up-toolkit#339
How To Test
Once 10up/10up-toolkit#390 is merged and released, the /dist/blocks/ directory will contain a new folder: /autoenqueue/. I was able to test this by generating block styles via the 10up-toolkit repository and then copying the /autoenqueue/ folder into the scaffold.
Credits
Props @fabiankaegy, @dmtrmrv, @Antonio-Laguna
Checklist: