-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use the plugin's icon picker modal elsewhere #173
Comments
Hi, there's no official API for doing this through the WP plugin, per se. So there might be some vulnerability to breaking changes with the following approach... However, the implementation of that icon chooser modal is just the There's some example code here that shows it being used. I can't recall off the top of my head whether there's a specific ID for the DOM element that is the chooser, but you could probably just query for the first--and hopefully only--one with Then add the event listener on the
The event handler callback function will receive an That Like:
You'd just need to put code in that event handler to do whatever needs doing with that result. |
Also, using that |
Hi @mlwilkerson Thanks for your feedback above, and I've finally gotten around to trying to implement the icon picker again within my custom WordPress theme options. I took your advice and installed/compiled the fa-icon-chooser web component via NPM as per instructions on page. I can see the JS has compiled into my main JS bundle and have it loaded on my admin theme options page (outside of the Gutenberg editor). Questions:
If I have missed the point on this web component and I can't use it within other WP Admin pages, please let me know :) Thanks again for your help here. |
Hi @STV11C. I'd recommend that you analyze the code for this plugin to see an example. This plugin uses the React wrapper, though that's only for convenience. The event that causes the icon chooser to be opened is specific to how it's wired into the block editor. Again, once you have figured out how to open and close it, you ought to be able to just add an event handler for that |
Hi, I have a Pro License of FA, and was hoping to utilise the Icon Picker Modal on a custom admin editor metabox text field.
I've worked out how to call the icon picker on a custom button by using the same onclick event:
onclick="__FontAwesomeOfficialPlugin__openIconChooserModal()"
but I can't workout how to add the selected icon's value (shortcode or class) into my custom metabox text field.
Any ideas if this is possible with the WP Plugin?
Cheers!
The text was updated successfully, but these errors were encountered: