-
Notifications
You must be signed in to change notification settings - Fork 4
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
How this plugin handles paths #25
Conversation
Hi @mike-sheppard , PR is ready for review. I still have to document the changes. I also set up PHPunit tests that I do need to document as well in a contribution guide. If you want to lend a hand in this as well, feel free to do so. New default theme location There are two new filters For setting a custom folder inside your (parent)theme: // will look into themes/my-theme/custom/icons/ for icons and also in the parent theme in the case of parent/child themes.
add_filter('acf_svg_icon_picker_folder', function () {
return 'custom-icons/';
}); and for setting a complete custom location: // takes a path and url location
add_filter('acf_svg_icon_picker_custom_location', function () {
return [
'path' => WP_CONTENT_DIR . '/random-location-icons/',
'url' => content_url() . '/random-location-icons/',
];
}); There are three new helper functions:
|
ah nice one @Levdbas all sounds great to me, will pull this down and give it a test later this week. Thanks again for the hard work on all of this 🙏 |
We have automatic tests now @mike-sheppard 👯 |
@mike-sheppard , can you do one last check on my readme changes and contribution guide? I documented there how to run the tests locally. |
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.
Nice one! Left a few minor comments + still need to get my tests running locally
Co-authored-by: Mike Sheppard <[email protected]>
@mike-sheppard , shall I invite you to a quick Teams call to get the tests running? Or else we can schedule something for next week. |
* Add support for hashed assets 1. This hopefully simplifies our checks a bit as we're already gathering most of this info within `svg_collector()`, so we shouldn't need to check again. 2. By saving the full path in `svg_collector()` we can provide support for hashed assets eg. `arrow-left.524a72.svg` ```php "arrow left" => [ "name" => "arrow left" "filename" => "arrow-left.524a72" "icon" => "arrow-left.524a72.svg" "url" => "/dist/editor/images/icons/admin-picker/arrow-left.524a72.svg" ] ``` 3. Also, might be better to save an ID (`sanitize_key($name)`) of the icon to the ACF field instead of the name? * Fix filters * Use sanitized key for ACF field val instead 'name' * Bring back normalized title in filter * Fix icon array check * Support legacy field values * README tweaks - add filters + release links * Fix phpcs config, igmore `*/wp-content/*` * Add missing void return type * Move js, css & extract views into resources * Add composer aliases/nicknames * Fix silly typos * Add Test: check sanitised and legacy (unsanitised) acf values
* Add missing return types + simplify acf field view phpstan issues * Fix logic typo + encode plus symbol * Update versions
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.
Reckon this is good to go whenever you're happy to merge! 🙌
Merged! @mike-sheppard , can you do a changelog update as well before deploying the update? Probably emphasize a bit on the deprecated filters and the new way of saving the file names. Enjoy the weekend and amazing work! |
Related:
There are still some todos before we can review this:
__construct()
method is setup more flexible.acf_icon_path_suffix
or the new filter that we will use instead.Issue
The way you set paths, url's and directories via filters is not very handy.
Solution
Rewrite the way you can serve SVGs to this plugin.
Impact
High, users will have to use the new filters to keep using this new version. There will be a fallback for the most simple setups that will throw a deprecation notice.
Usage Changes
Some, but I will document that later.
Considerations
Might be a step too far, although I think this is way more flexible.
Testing
Not yet, something to consider later