-
Notifications
You must be signed in to change notification settings - Fork 31
Enhancement: Add new acf/fields/icon_picker/{tab_name}/icons
filter
#177
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
Enhancement: Add new acf/fields/icon_picker/{tab_name}/icons
filter
#177
Conversation
$custom_icons = apply_filters( 'acf/fields/icon_picker/' . $name . '/icons', array(), $field ); | ||
|
||
if ( is_array( $custom_icons ) && ! empty( $custom_icons ) ) { | ||
$this->render_icon_list_tab( $name, $custom_icons ); |
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.
PHPStan is right about this: The function only supports one argument.
Since I carried the code over from upstream, it looks like it's a bug there.
This means that the newly introduced acf/fields/icon_picker/{tab_name}/icons
filter won't actually work there. This leaves us with two options:
- We punt this PR for now (until it's fixed upstream), or
- we fix it here.
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.
Let's fix it here.
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 means that the newly introduced
acf/fields/icon_picker/{tab_name}/icons
filter won't actually work there.
I misspoke, it's actually working -- jQuery is doing all of the heavy lifting.
Simply removing the extra arg should be enough.
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.
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.
Tested and work as expected. Cannot comment on code as is a backport.
Work in progress. Testing instructions to follow.
PHP changes correspond to this changeset: https://plugins.trac.wordpress.org/changeset/3289772/advanced-custom-fields/tags/6.4.1/includes/fields/class-acf-field-icon_picker.php
Testing Instructions
Add the following code as a plugin, and enable it:
Code
In the SCF Field Groups panel, add an Icon Picker field to a fieldset that's used for a given post type. Make sure to enabled the checkbox for the "My custom icons" tab.
Create or edit an instance of that post type. Verify that searching and selecting an icon from the icon selector works as before, and that the selected icon is persisted when saving.
Finally, select the new "My custom icons" tab and verify that you can also select an icon there.