a cell phone sitting on top of a laptop computer

Using ChatGPT for my latest WordPress plugin

I’m, generally, pretty agnostic about the use of AI, particularly LLMs – I believe they should be used thoughtfully, rather than just for the sake of it.

For a few years now I’ve been looking to create a plugin that automagically tidies up the WP Admin menus (in fact, I mentioned it at last year’s WCEU talk), but assorted technical problems have slowed down progress. But I’m determined to crack it and, as part of a review of how it’s going to work, I’m looking to implement some ChatGPT functionality into it (but only as an option). In this post I’m going to explain what it does and it how it achieves it.

So, context – some plugins make use of their own menu icon, often a non-SVG, coloured icon, which is not great for accessibility. In this case, when working on this plugin in the past (and the default if you decide not to make use of ChatGPT in the plugin), the icon is overridden to a default Dashicon. I can’t be more precise because the WordPress.org directory doesn’t implement any kind of category system. But ChatGPT can read the context and do better. Much better.

To demonstrate this, try the following in ChatGPT (the URL at the end is a link to a plugin of your choice – here I’m using Yoast SEO)…

Which of the Dashicons at https://developer.wordpress.org/resource/dashicons/ would you recommend applies to the WordPress plugin at https://wordpress.org/plugins/wordpress-seo/

This will give you a potential list of Dashicons, including details as to why it thinks it’s a good option. This is a good way to help diagnose any issues that come up with this, as it gets ChatGPT to explain it’s reasoning.

When you want just a single answer and just the name of the icon (rather than any explanation), this will achieve this…

Choose a single Dashicon at https://developer.wordpress.org/resource/dashicons/ that you would recommend applies to the WordPress plugin at https://wordpress.org/plugins/wordpress-seo/. Tell me only the name of the Dashicon that you chose.

So, that’s how (via API) you’d request the Dashicon within your code.

By the way, that URL at the end doesn’t just for for the .org directory, but any plugin page (e.g. try https://codecanyon.net/item/filter-everything-wordpress-woocommerce-filter/31634508). Indeed, throw it a URL of something that isn’t a page for a plugin and it will still match a Dashicon to the content – even error pages. So far I haven’t yet been able to NOT get a Dashicon to be returned.


It’s actually likely that I’ll implement further ChatGPT functionality too, but the above is for the one that I’ve tried and tested already. So, what else can I use it for? Well, one of the menu changes I want to make is to move down those third-party main menus that insist on pushing themselves to the top. The current behaviour of my plugin is to just drag them down to the bottom somewhere, but ChatGPT will allow me to better group them (e.g. a YouTube plugin may be placed underneath the Media menu).

In fact, “current behaviour” is something I want to mention – using ChatGPT will be optional (and turned off by default). If you don’t use it, a default solution will be sought instead (albeit one that won’t be as nuanced as the AI version).


There are a couple of follow-up posts that you should expect in due course – details of that second use of ChatGPT, and how to access ChatGPT via a WordPress plugin.


Discover more from artiss.blog

Subscribe to get the latest posts sent to your email.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.