-
Notifications
You must be signed in to change notification settings - Fork 46
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
Extracted any logic that may need to be tested from the api class #522
Conversation
790b8f3
to
c18c22c
Compare
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.
This is a big PR! But I know it's because it's a combination of multiple branches. Here's my test results from following the test instructions. All these actions are from the options within the Site Editor.
Make changes to Global Styles and save the theme:
Changes reflected in the theme.json file ✅
Make changes to templates and save the theme:
- Image assets included in the theme, referenced from the pattern, which is referenced from the template ❓
I noticed some characters in the image alt text are not correctly encoded: (Sorry, I think this is correct as it's coming through as HTML character codes within the alt text, which is what I'd expect.)
![image](https://private-user-images.githubusercontent.com/1645628/316128950-f8f04e24-a561-4690-ad4d-f11de20c55b1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMjc0MjgsIm5iZiI6MTcyNDEyNzEyOCwicGF0aCI6Ii8xNjQ1NjI4LzMxNjEyODk1MC1mOGYwNGUyNC1hNTYxLTQ2OTAtYWQ0ZC1mMTFkZTIwYzU1YjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDQxMjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2JkZmIwNzRjNDBmZjM0OTU4MTY3NWM5YjQ0OTI1YzJkMjUzNzk5ZWRkYWZiOTgzZTA5YzRmNTM3NjY5NDY1NiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.druUntSy2wKrBRUBKl_vf-iO12eISouuQlZMBkqP0nE)
They're also not localized, but I think this could happen in a follow-up (I'm happy to open a separate issue).
When testing with a Cover block, I noticed that there are some encoding issues with the start and end of the PHP tag for referencing an image:
<!-- wp:cover {"url":"\u003c?php echo esc_url( get_stylesheet_directory_uri() ); ?\u003e/assets/images/flying-w.jpg","dimRatio":50,"customOverlayColor":"#88817d","isDark":false,"layout":{"type":"constrained"}} -->
- Paragraph blocks localized in a pattern and referenced from a template ❌
I noticed when the paragraph is localized, some characters are not encoded correctly:
<!-- wp:paragraph --><p><?php echo __('The page you’re looking doesn’t seem to exist. Maybe try a search?', 'pixl');?></p>
<!-- /wp:paragraph -->
![image](https://private-user-images.githubusercontent.com/1645628/316128282-4273d181-fcbd-462b-bf9d-015a271358db.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQxMjc0MjgsIm5iZiI6MTcyNDEyNzEyOCwicGF0aCI6Ii8xNjQ1NjI4LzMxNjEyODI4Mi00MjczZDE4MS1mY2JkLTQ2MmItYmY5ZC0wMTVhMjcxMzU4ZGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjBUMDQxMjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Yjc2MDBmOTUzMjM2ZjZlZmIwODQ4NmNhYTJmZDdlYzUxYmU4NGJiN2E5MDhkNjM0ZGJkMWQ2MzJhYTcxMmNmYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.LoxjCr6pR-V7ORt9isDUkwTUOAknrc8ddsTh12t4tI0)
Otherwise, this looks like it's working well.
- Templates with NO images or paragraphs not converted to a pattern ✅
Export a saved theme ✅
Clone a theme ✅
Create a Blank Theme ✅
I also tested based on the proposed changes from #162:
- Remove
ref
attributes from the Navigation block ✅ - Remove
id
attributes from Image and Cover blocks ✅ - Remove
wp-image-[id]
classes from Image and Cover blocks ✅ - Remove
category
IDs from query blocks ✅ - Remove
taxQuery
attribute from query blocks ❌taxQuery
is not removed from the block
In summary, looks like there are some small issues with encoding and the taxQuery
attribute but overall this is testing really well. Thank you for working on this, the code is looking much cleaner and better organised. Looking forward to this landing, especially the changes related to removing the site-specific attributes ✨
This avoids passing php code to `serialize_blocks`.
While testing, observed that patronizer copies content into new patterns instead of re-using existing patterns. |
…from templates with media
…essing the content as HTML
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.
Verified the changes for all the exported options and changes to templates. It works as expected. 🚢
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.
This is working well for me too, I think this is good to bring in now 🎉
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.
+1 to previous comments; this is testing well for me.
Fixes: #162
This change moves any logic that may need to be tested outside of the api implementation. This logic is now in a 'Theme_Create
class. Logic is re-used in the other
Theme-*` classes whenever possible.Additionally this change incorporates the removal of site-specific attributes from template markup fixing #162. That work began in #524 and was copied to this branch.
This also fixes #336 since the asset processing from the API was cleaned up and now the assets are being copied as expected. The logic to process this is now quite a bit simpler: the block parsing is mostly gone, with only the gathering of URLs happening as it used to. Once that happens the URLs that were gathered are transformed to a local path, wrapped in a PHP tag and replaced in the template.
This fixes #489 as it escapes (most) strings during template parsing.
Many comments were added to clarify the code and functions renamed where appropriate.
Lastly templates that have strings (currently only in paragraphs, additional blocks are needed) have those strings wrapped in PHP tags and localized. (Any templates with PHP tags are converted to patterns).
To Test
Complete the following actions to ensure that the resulting theme matches expected results: