Can ChatGPT Construct a Helpful WordPress Plugin That In reality Works?

by | May 21, 2023 | Etcetera | 0 comments

Can AI turn non-coders into skilled WordPress plugin developers? To resolve, we asked ChatGPT to build a custom designed WordPress plugin from scratch and then had our crack group of workers of developers learn in regards to the code…

AI is the world’s freshest two-letter word nowadays. With all the contemporary data headlines about whether or not or no longer AI will take our jobs away, we’d have favored to grasp… can ChatGPT if truth be told expand a sensible and useful WordPress plugin and not using a wish to write down code from scratch? And does the plugin meet best coding practices?

Fortunately, WPMU DEV builds one of the crucial most difficult WordPress plugins on the planet, so we have now now relatively a couple of skilled WordPress plugin developers who can put ChatGPT to the take a look at.

In reality, if you’re taking a stroll spherical our company’s virtual corridors, you’ll’t help alternatively bump into WordPress coders and developers. It seems everyone spherical proper right here can check out a WordPress plugin and see PHP the best way by which Neo sees the Matrix’s virtual rain code.

Matrix code
What PHP code looks like to professional WordPress plugin developers. Provide:

Everyone, that is …with the exception of me!

I’m just a blog writer with out a coding skills and a burning want to be able to upload “speedy engineer” to my CV.

So, in this put up, we’ll uncover learn how to leverage the ability of ChatGPT to build a simple custom designed WordPress plugin quickly and securely, even supposing you lack extensive coding skills.

We’ll do this by way of:

1) Asking ChatGPT to generate the code for a useful plugin that we will take a look at, and

2) Running the code generated by way of ChatGPT earlier our group of workers {{of professional}} plugin developers so they are able to evaluate it and provide their honest feedback.

We’ll cover the following:

Step 1 – Define the Plugin’s Capacity

Faster than the use of ChatGPT to generate code, we wish to have a clear figuring out of the potential we would like our plugin to supply.

This starts by way of outlining the specific choices, actions, or adjustments we’ll wish to succeed in with our plugin. This may occasionally increasingly more then help us generate right kind turns on for ChatGPT and make sure that our AI-generated code aligns with our desired effects.

Step 2 – Generate Code Snippets with ChatGPT

To generate our code snippets the use of ChatGPT, we’ll keep problems simple (and free) and use the freely available interface provided by way of OpenAI.

Take #1…

Phrase: My first attempt at the use of ChatGPT to create a WordPress plugin from scratch was approach too bold. I asked ChatGPT to build me a simple WordPress time-travel dummy text generating plugin, the use of the speedy underneath…

ChatGPT - WordPress plugin creation prompt.
This speedy will for sure kick ChatGPT’s WordPress plugin construction tyres.

As somebody who spends a large number of time writing WordPress tutorials, I incessantly need dummy content material subject material to test plugins, create screenshots, and so on.

So, I thought it is going to be great to model my AI-generated dummy content material subject material plugin on a plugin I incessantly use known as FakerPress.

ChatGPT pushed once more on my request and let me know that creating a completely sensible WordPress plugin with all the choices I requested was previous the scope of a single response.

Alternatively, it did offer to supply me with a basic template, data me on learn how to implement one of the crucial choices I mentioned, and even gave me instructions on learn how to create a plugin checklist and document…

ChatGPT response to WordPress plugin development prompt.
Mmm…in all probability my first attempt at creating a WordPress plugin was too bold!

At first, ChatGPT output code that gave the impression slightly impressive…

ChatGPT code
To somebody who’s conscious about ‘zip’ about coding, the above code snippet sure turns out impressive!

ChatGPT moreover output all the additional code required to complete the next steps.

ChatGPT - WordPress plugin development prompt.
Lacking coding skills, I trusted ChatGPT to steer me through each step of the plugin construction process.

With the plugin code output, your next step was so as to add the plugin to my take a look at site and take a look at it to ensure it actually works.

Step 3 – Check out The Custom designed Plugin

After uploading the folder containing the plugin code to the wp-content > plugins checklist of my take a look at site and activating it all the way through the Plugins show…

Plugins screen - Dummy Content Generator activation menu link.
And now for the immediate we’ve all been taking a look forward to [drumroll]…

I got a dangerous error!

Plugins screen - Fatal error message.
What an anticlimax…the ground degree of my WordPress plugin construction career!

Assuming that in all probability I didn’t add the additional snippets that ChatGPT provided appropriately, I went once more and asked for all the code to be provided as a single document that I would possibly simply simply copy and paste to overwrite and exchange the uploaded plugin document…

See also  31 Easiest WordPress Topics for Blogs in 2022
Screenshot of ChatGPT prompt and response.
Why couldn’t it merely have given me all of the copy and paste code the principle time?

There was a large number of code to output, so on each instance the process were given right here to a standstill, I prompt ChatGPT to continue…

Screenshot of ChatGPT prompt and response.
ChatGPT each so continuously merely needs a bit of bit subtle encouragement to stick going.

After repeating this process various circumstances, ChatGPT output all of the code and even provided some helpful knowledge.

Screenshot of ChatGPT response.
After waiting a complete 2 minutes…ChatGPT in the end output all of the plugin code!

I uploaded the plugin document with the new code to my take a look at site, then jumped into the site’s admin area and activated the plugin.

It worked! Or, so it seemed.

ChatGPT gave the plugin its non-public menu products…

Dummy Content Generator WordPress plugin -created by ChatGPT
ChatGPT created all this!

And a settings show with relatively a large number of fancy boxes and fields…

Dummy Content Generator WordPress plugin settings screen.
Seems to be like impressive…alternatively will it artwork?

Alternatively I couldn’t see a field to specify what collection of posts or pages to create, so I simply ticked some boxes, entered some values, and clicked on the “Save Changes” button to seem what happens.

Dummy Content Generator WordPress plugin -created by ChatGPT
And now, for the immediate of reality…

And…utterly no longer the rest took place!

The newest lowest degree of my WordPress plugin construction career…a plugin that doesn’t the rest!

My fancy-ass plugin was all make-believe, very similar to one of those children’s playground spaceships that’s full of pointless knobs you’ll turn and buttons you’ll press while pretending to be flying in outer area.

So, I reached out to no doubt one in every of our developers by way of Slack and asked them to try the plugin document.

Some of the comments that were given right here once more built-in the following:

  • “The plugin tries to generate random content material subject material on each admin internet web page load”
  • “It calls a function dummy_content_generator_generate_content_paragraphs which, in turn, makes an try to identify dummy_content_generator_get_random_paragraph for each paragraph it tries to generate. The problem is that there’s no dummy_content_generator_get_random_paragraph function.
  • “The internet web page quite a bit to some extent, then it errors out because of there’s additional missing stuff”
  • “Quite then all the mentioned issues, there’s no validation whatsoever, and no escaping of the output, which is terrible”
  • “With regards to having something as place to begin, this can be a very, very poor one. With regards to having a working plugin, this is nowhere just about that”

After some backward and forward discussions , it was deemed that there was slightly such a lot flawed with the plugin, that it is going to take a large number of artwork to fix it, they most often prompt I scrap the venture.

At this degree, alternatively, I was too invested in my problem to simply abandon the whole thing and give up. Recalling Sir Winston Churchill’s well known words (“Fetch me each different brandy” “In no way give in, not at all give in, not at all, not at all, not at all…”), I decided it was time for…

Take #2…

Excellent sufficient, so my first attempt to get ChatGPT to build a WordPress plugin from scratch was a depressing failure. This in itself provided some precious insights into ChatGPT’s skill to perform difficult coding tasks (or, as somebody inside the group of workers put it, “you’ll’t code the use of ChatGPT without having extensive coding knowledge.”)

So, for “Take #2,” I decided to try yet again with a more effective plugin request.

Going once more to the strategy planning stage, a genius lightbulb 2nd lit up in my ideas…why no longer ask ChatGPT to suggest ideas for simple WordPress plugins it could then generate the code for?

So, that’s what I did. Proper right here’s the speedy I promptly engineered…

ChatGPT prompt for generating WordPress plugin ideas.
My genius speedy.

And proper right here’s the tick list of prompt plugins ChatGPT spoke back with…

ChatGPT - List of WordPress plugin ideas.
The blueprint of my WordPress plugin empire.

I preferred the last advice, so I asked ChatGPT to generate the code for a sensible content material subject material duplicator plugin, and it instantly went to artwork.

ChatGPT prompt to generate code for a WordPress plugin that duplicates content.
That’s what a license to print money looks like!

ChatGPT generated the following code for the plugin inside the blink of an eye fixed:

Plugin Establish: Content material subject material Duplicator
Description: Shall we in shoppers to replicate posts, pages, or custom designed put up varieties with one click on on.
Type: 1.0.0
Author: Your Establish
Author URI:

// Add copy movement links to put up row actions
function content_duplicator_add_duplicate_link( $actions, $put up ) {
    if ( current_user_can( 'edit_posts' ) ) {
        $actions['duplicate'] = 'ID ), 'content_duplicator_duplicate_post' ) . '" establish="Reproduction this products" rel="permalink">Reproduction';
    return $actions;
add_filter( 'post_row_actions', 'content_duplicator_add_duplicate_link', 10, 2 );

// Reproduction the put up
function content_duplicator_duplicate_post() {
    if ( isset( $_GET['post_id'] ) ) {
        $post_id = absint( $_GET['post_id'] );

        if ( current_user_can( 'edit_posts' ) && wp_verify_nonce( $_GET['_wpnonce'], 'content_duplicator_duplicate_post' ) ) {
            $put up = get_post( $post_id );

            $args = array(
                'post_title' => $post->post_title . ' (Reproduction)',
                'post_content' => $post->post_content,
                'post_type' => $post->post_type,
                'post_status' => $post->post_status,
                'post_parent' => $post->post_parent,
                'post_author' => get_current_user_id(),

            $new_post_id = wp_insert_post( $args );

            if ( $new_post_id ) {
                // Reproduction meta fields
                $meta_fields = get_post_custom( $post_id );
                foreach ( $meta_fields as $key => $values ) {
                    foreach ( $values as $value ) {
                        add_post_meta( $new_post_id, $key, $value );

                // Redirect to the duplicated put up
                wp_redirect( admin_url( 'put up.php?movement=edit&put up=' . $new_post_id ) );
                cross out;
add_action( 'admin_post_content_duplicator_duplicate_post', 'content_duplicator_duplicate_post' );

It even provided a set of instructions after generating the code.

See also  What Is Content material Intelligence?
ChatGPT instructions.
The code no longer only comes with instructions, alternatively ChatGPT even says “Please”!

I then uploaded the new plugin document to the wp-content > plugins checklist of my take a look at site the use of The Hub’s record supervisor.

The Hub - File Manager
There’s a large number of movement to unpack in this screenshot.

And created a dummy put up to test the plugin with…

WordPress test post.
Did the plugin copy this cheesy put up? Let’s to find out!

Listed below are the put up’s menu alternatives previous to activating the plugin…

WordPress Posts table with single post entry.
A default put up with default alternatives.

After activating the plugin…

WordPress Plugins screen - Activate Content Duplicator
“Activate Content material subject material Duplicator” – Seems like a line from a Celebrity Trek movie.

Good fortune!

WordPress Plugins screen - Plugin activated message.
A gratuitous screenshot proving that the plugin successfully activated.

The plugin activated. Alternatively did it if truth be told artwork?

Proper right here’s my take a look at put up yet again (phrase that the plugin added a brand spanking new “Reproduction” products to the menu after activation). I then clicked on “Reproduction” to seem what happens…

WordPress Posts Table - Post entry with a new Duplicate item.
ChatGPT even added a “Reproduction” menu products tooltip to the code!

And a replica put up was created!

An example of a duplicated WordPress post.
A reproduction of the original put up.

Proper right here’s the table of posts showing entries for the original and duplicated put up.

WordPress Posts table with original post and duplicated post.
The original put up and its cloned fashion.

I’m sure that with upper speedy engineering and a couple of code tweaking, the plugin can have been significantly complex. For example, I would like if the plugin set the put up status of the newly-duplicated put up to ‘draft’ instead of publishing it, alternatively ChatGPT delivered a simple WordPress plugin that worked. It was basic, but it surely for sure did the duty.

The last step was to ask somebody who codes WordPress plugins for a living to scrutinize the code and get their opinion about the use of a tool like ChatGPT to code plugins.

Feedback from Our Skilled Plugin Developers

Shortly after uploading the plugin to no doubt one in every of our testing channels, I got a ping from no doubt one in every of our developers. Listed below are one of the crucial key problems provided in their feedback:

  • “ChatGPT et al are decent at answering questions the approach to.”
  • “I also used it in the past to build a simple plugin for me, alternatively as long as I was giving additional difficult turns on, it all started to debris problems spherical, so someday I manually debug the given code to artwork, explanation why else it’d take ages for it to if truth be told debug it line by way of line.”
  • “Basically, it does what it says. Alternatively, it does what it says very if truth be told. As in, it will copy a put up and its corresponding postmeta (custom designed) fields. Alternatively, it doesn’t seem to be it’s going to propagate any taxonomies to the duplicated put up (the plugin must copy and assign the identical taxonomy words, very similar to categories or tags, from the original put up to the duplicated put up).”
  • If I was to be super-nitpicky about this, I’d moreover indicate that it’s no longer L10n-ready – there gained’t be an approach to translate this plugin. Alternatively, that’s merely being very nitpicky – I don’t if truth be told suppose, nor would I expect, a prompt-generated plugin to be generic enough to be needing something like that the least bit. To me, it’s additional of a “very specific problem space” more or less an element, at the side of the language used. At the end of the day, it does do what it says it’s going to, which might be very nice.”

In conjunction with examining the WordPress plugin code generated by way of ChatGPT and providing feedback as confirmed above, our developers moreover agreed with the following key problems after assessing ChatGPT’s provide purposes to generate code:

1 – It’s crucial to exercise caution and no longer blindly accept ChatGPT-generated code as correct.

  • ChatGPT may give answers, but it surely for sure’s up to the shopper to guage whether or not or no longer the answer is correct or no longer.
  • There’s a chance of receiving incorrect or nonsensical answers from ChatGPT, every obvious and mild.
  • It’s crucial to exercise caution and no longer blindly accept the generated code as correct.
  • ChatGPT’s output must be treated as autocomplete, making lifestyles easier alternatively requiring caution and verification.
See also  Startup Advertising Price range: Write an Unbelievable Price range for 2023

The ability to discern excellent code from bad or nonsensical code, alternatively, signifies that…

2 – Consumers must have sufficient knowledge and figuring out of WordPress plugin construction to judge and change the generated code as sought after.

  • ChatGPT can help simplify and expedite the process of making simple custom designed WordPress plugins, generate code snippets, and provide explanations. Anything additional difficult, alternatively, requires plugin construction enjoy and coding skills.
  • Using ChatGPT without sufficient knowledge can lead to unfavorable consequences or unreliable code.
  • Relying most effective on ChatGPT without the most important taking into account is similar to blindly copying the principle solution from Stack Overflow (Stack Overflow threads provide additional context, a couple of answers, and feedback from other shoppers, making it a additional unswerving helpful useful resource, alternatively Stack Overflow threads tend to be additional generic, whilst ChatGPT may give specific answers to specific individual queries).

3 – The use of other resources, very similar to WordPress documentation, tutorials, and workforce forums, alongside ChatGPT may give a additional whole figuring out of WordPress plugin construction.

  • As you find the possibilities of the use of ChatGPT for WordPress plugin construction, it’s precious to interact with the WordPress workforce. Share your stories, ask for feedback, and seek guidance from professional developers. Collaborating in forums, attending WordPress meetups, or turning into a member of online communities may give precious insights and will let you refine your plugin construction process.
  • Additionally, believe following WordPress protection best practices to safeguard your website online from imaginable vulnerabilities. ChatGPT may give tips on security features you’ll implement to give protection to your plugin.
  • It’s moreover essential to handle a clear running from your required capacity and in moderation evaluate and take a look at the generated code and secure your custom designed plugins previous to deploying them to a producing atmosphere.

Can ChatGPT Turn You Proper right into a WordPress Plugin Developer?

In this article, we’ve explored the way you’ll benefit from ChatGPT to build simple custom designed WordPress plugins, even supposing you will have limited coding enjoy.

In several articles, we’ve spotted that AI-powered apparatus like ChatGP can streamline your workflow, boost productivity, and unencumber new possibilities (check out our contemporary article on ways in which ChatGPT help you as a WordPress developer).

While there are over 60,000 free WordPress plugins available protective each type of capacity you’ll imagine, each so continuously you may want a custom designed approach to meet a shopper’s specific prerequisites.

Previous the core capacity of your plugin, you’ll moreover leverage ChatGPT to generate code for custom designed shopper interfaces. With its skill to grasp turns on and generate HTML, CSS, and JavaScript snippets, you’ll create intuitive admin interfaces, front-end portions, and interactive portions that may enhance the shopper enjoy and allow you to send an advanced final product.

Via using the language model’s purposes, you’ll generate code snippets, optimize capacity, and create user-friendly interfaces. Alternatively, it’s an important to grasp the generated code, evaluate and refine it, and in moderation take a look at your custom designed plugins previous to deploying them on your are living website online.

The generated code may also require adjustments to align with coding necessities, naming conventions, or specific venture prerequisites. This requires a certain amount of coding knowledge and abilities, as does optimizing the code and ensuring it follows WordPress coding guidelines for upper maintainability.

The bottom line:

Listed below are my findings after in quest of to get ChatGPT to code me a plugin from scratch:

  1. I couldn’t have were given this completed without the help of our professional developers.
  2. Using ChatGPT to generate code without coding knowledge is if truth be told tough – it’s serving to to grasp what you may well be doing 🙂
  3. While ChatGPT is an excellent and precious instrument, it doesn’t seem to be AI will replace skilled coders any time temporarily.

Involved in Rising WordPress plugins?

Check out a couple of of our tutorials and articles on WordPress plugin construction:

WordPress Developers

[ continue ]

WordPress Maintenance Plans | WordPress Hosting

read more


Submit a Comment

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