Can AI flip non-coders into professional WordPress plugin builders? To determine, we requested ChatGPT to construct a customized WordPress plugin from scratch after which had our crack workforce of builders read about the code…

AI is the arena’s hottest two-letter phrase at the moment. With all of the fresh information headlines about whether or not AI will take our jobs away, we would have liked to understand… can ChatGPT in truth broaden a practical and helpful WordPress plugin with no need to write down code from scratch? And does the plugin meet perfect coding practices?

Thankfully, WPMU DEV builds one of the maximum tough WordPress plugins on this planet, so we have now quite a few professional WordPress plugin builders who can put ChatGPT to the check.

Actually, if you are taking a walk round our corporate’s digital corridors, you’ll’t assist however stumble upon WordPress coders and builders. It sort of feels everybody round right here can take a look at a WordPress plugin and spot PHP the way in which Neo sees the Matrix’s virtual rain code.

Matrix code
What PHP code looks as if to skilled WordPress plugin builders. Supply:

Everybody, this is …excluding me!

I’m only a weblog creator without a coding talents and a burning need so as to add “immediate engineer” to my CV.

So, on this publish, we’ll discover find out how to leverage the facility of ChatGPT to construct a easy customized WordPress plugin temporarily and securely, even though you lack in depth coding talents.

We’ll do that via:

1) Asking ChatGPT to generate the code for an invaluable plugin that we will be able to check, and

2) Operating the code generated via ChatGPT previous our workforce {of professional} plugin builders so they may be able to assessment it and supply their truthful comments.

We’ll duvet the next:

Step 1 – Outline the Plugin’s Capability

Sooner than the usage of ChatGPT to generate code, we want to have a transparent working out of the capability we wish our plugin to offer.

This begins via outlining the particular options, movements, or changes we’ll need to reach with our plugin. This may increasingly then assist us generate correct activates for ChatGPT and make certain that our AI-generated code aligns with our desired results.

Step 2 – Generate Code Snippets with ChatGPT

To generate our code snippets the usage of ChatGPT, we’ll stay issues easy (and unfastened) and use the freely to be had interface equipped via OpenAI.

Take #1…

Word: My first strive at the usage of ChatGPT to create a WordPress plugin from scratch used to be manner too formidable. I requested ChatGPT to construct me a easy WordPress time-travel dummy textual content producing plugin, the usage of the immediate under…

ChatGPT - WordPress plugin creation prompt.
This immediate will indisputably kick ChatGPT’s WordPress plugin building tyres.

As any person who spends numerous time writing WordPress tutorials, I steadily want dummy content material to check plugins, create screenshots, and so forth.

So, I assumed it will be nice to fashion my AI-generated dummy content material plugin on a plugin I steadily use referred to as FakerPress.

ChatGPT driven again on my request and let me know that developing an absolutely practical WordPress plugin with all of the options I asked used to be past the scope of a unmarried reaction.

Then again, it did be offering to offer me with a fundamental template, information me on find out how to put in force one of the options I discussed, or even gave me directions on find out how to create a plugin listing and record…

ChatGPT response to WordPress plugin development prompt.
Mmm…perhaps my first strive at making a WordPress plugin used to be too formidable!

In the beginning, ChatGPT output code that seemed rather spectacular…

ChatGPT code
To any person who is aware of ‘zip’ about coding, the above code snippet certain seems spectacular!

ChatGPT additionally output all of the further code required to finish the following steps.

ChatGPT - WordPress plugin development prompt.
Missing coding talents, I depended on ChatGPT to lead me thru each and every step of the plugin building procedure.

With the plugin code output, the next move used to be to add the plugin to my check website and check it to verify it really works.

Step 3 – Take a look at The Customized Plugin

After importing the folder containing the plugin code to the wp-content > plugins listing of my check website and activating it throughout the Plugins display…

Plugins screen - Dummy Content Generator activation menu link.
And now for the instant we’ve all been looking ahead to [drumroll]…

I were given a deadly error!

Plugins screen - Fatal error message.
What an anticlimax…the bottom level of my WordPress plugin building occupation!

Assuming that perhaps I didn’t upload the extra snippets that ChatGPT equipped as it should be, I went again and requested for all of the code to be equipped as a unmarried record that I may just merely replica and paste to overwrite and replace the uploaded plugin record…

Screenshot of ChatGPT prompt and response.
Why couldn’t it simply have given me all the replica and paste code the primary time?

There used to be numerous code to output, so on every occasion the method got here to a standstill, I steered ChatGPT to proceed…

Screenshot of ChatGPT prompt and response.
ChatGPT every so often simply wishes a little bit delicate encouragement to stay going.

After repeating this procedure a number of instances, ChatGPT output all the code or even equipped some useful data.

Screenshot of ChatGPT response.
After ready an entire 2 mins…ChatGPT in spite of everything output all the plugin code!

I uploaded the plugin record with the brand new code to my check website, then jumped into the website’s admin space and activated the plugin.

It labored! Or, so it appeared.

ChatGPT gave the plugin its personal menu merchandise…

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

And a settings display with quite a lot of fancy packing containers and fields…

Dummy Content Generator WordPress plugin settings screen.
Appears to be like spectacular…however will it paintings?

However I couldn’t see a box to specify what number of posts or pages to create, so I merely ticked some packing containers, entered some values, and clicked at the “Save Adjustments” button to look what occurs.

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

And…completely not anything came about!

WordPress Posts Table showing a sinlge
The most recent lowest level of my WordPress plugin building occupation…a plugin that does not anything!

My fancy-ass plugin used to be all make-believe, similar to a type of kids’s playground spaceships that’s stuffed with needless knobs you’ll flip and buttons you’ll press whilst pretending to be flying in outer house.

So, I reached out to certainly one of our builders by means of Slack and requested them to take a look at the plugin record.

Probably the most feedback that got here again integrated the next:

  • “The plugin tries to generate random content material on every admin web page load”
  • “It calls a serve as dummy_content_generator_generate_content_paragraphs which, in flip, makes an attempt to name dummy_content_generator_get_random_paragraph for each and every paragraph it tries to generate. The issue is that there is not any dummy_content_generator_get_random_paragraph serve as.
  • “The web page lots to some degree, then it mistakes out as a result of there’s extra lacking stuff”
  • “Rather then all of the discussed problems, there’s no validation in any way, and no escaping of the output, which is horrible”
  • “When it comes to having one thing as start line, it is a very, very deficient one. When it comes to having a running plugin, that is nowhere close to that”

After some from side to side discussions , it used to be deemed that there used to be rather so much improper with the plugin, that it will take numerous paintings to mend it, they usually steered I scrap the mission.

At this level, then again, I used to be too invested in my challenge to easily abandon the entirety and surrender. Recalling Sir Winston Churchill’s well-known phrases (“Fetch me every other brandy” “By no means give in, by no means give in, by no means, by no means, by no means…”), I determined it used to be time for…

Take #2…

Good enough, so my first try to get ChatGPT to construct a WordPress plugin from scratch used to be a dark failure. This in itself equipped some treasured insights into ChatGPT’s talent to accomplish complicated coding duties (or, as any person within the workforce put it, “you’ll’t code the usage of ChatGPT with no need in depth coding wisdom.”)

So, for “Take #2,” I determined to take a look at once more with a more practical plugin request.

Going again to the planning stage, a genius lightbulb second lit up in my thoughts…why now not ask ChatGPT to signify concepts for easy WordPress plugins it would then generate the code for?

So, that’s what I did. Right here’s the immediate I promptly engineered…

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

And right here’s the checklist of steered plugins ChatGPT responded with…

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

I appreciated the closing recommendation, so I requested ChatGPT to generate the code for a practical content material duplicator plugin, and it in an instant went to paintings.

ChatGPT prompt to generate code for a WordPress plugin that duplicates content.
That is what a license to print cash looks as if!

ChatGPT generated the next code for the plugin within the blink of a watch:

ID ), 'content_duplicator_duplicate_post' ) . '" identify="Replica this merchandise" rel="permalink">Replica';
    go back $movements;
add_filter( 'post_row_actions', 'content_duplicator_add_duplicate_link', 10, 2 );

// Replica the publish
serve as 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' ) ) {
            $publish = get_post( $post_id );

            $args = array(
                'post_title' => $post->post_title . ' (Replica)',
                '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 ) {
                // Replica meta fields
                $meta_fields = get_post_custom( $post_id );
                foreach ( $meta_fields as $key => $values ) {
                    foreach ( $values as $worth ) {
                        add_post_meta( $new_post_id, $key, $worth );

                // Redirect to the duplicated publish
                wp_redirect( admin_url( 'publish.php?motion=edit&publish=' . $new_post_id ) );
                go out;
add_action( 'admin_post_content_duplicator_duplicate_post', 'content_duplicator_duplicate_post' );

It even equipped a suite of directions after producing the code.

ChatGPT instructions.
The code now not handiest comes with directions, however ChatGPT even says “Please”!

I then uploaded the brand new plugin record to the wp-content > plugins listing of my check website the usage of The Hub’s record supervisor.

The Hub - File Manager
There’s numerous motion to unpack on this screenshot.

And created a dummy publish to check the plugin with…

WordPress test post.
Did the plugin replica this tacky publish? Let’s in finding out!

Listed here are the publish’s menu choices prior to activating the plugin…

WordPress Posts table with single post entry.
A default publish with default choices.

After activating the plugin…

WordPress Plugins screen - Activate Content Duplicator
“Turn on Content material Duplicator” – Appears like a line from a Superstar Trek film.


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

The plugin activated. However did it in truth paintings?

Right here’s my check publish once more (word that the plugin added a brand new “Replica” merchandise to the menu after activation). I then clicked on “Replica” to look what occurs…

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

And a reproduction publish used to be created!

An example of a duplicated WordPress post.
A replica of the unique publish.

Right here’s the desk of posts appearing entries for the unique and duplicated publish.

WordPress Posts table with original post and duplicated post.
The unique publish and its cloned model.

I’m certain that with higher immediate engineering and a few code tweaking, the plugin will have been considerably advanced. For instance, I would favor if the plugin set the publish standing of the newly-duplicated publish to ‘draft’ as a substitute of publishing it, however ChatGPT delivered a easy WordPress plugin that labored. It used to be fundamental, but it surely did the task.

The closing step used to be to invite any person who codes WordPress plugins for a residing to scrutinize the code and get their opinion about the usage of a device like ChatGPT to code plugins.

Comments from Our Professional Plugin Builders

In a while after importing the plugin to certainly one of our trying out channels, I were given a ping from certainly one of our builders. Listed here are one of the key issues equipped of their comments:

  • “ChatGPT et al are respectable at answering questions the solution to.”
  • “I extensively utilized it up to now to construct a easy plugin for me, however so long as I used to be giving extra complicated activates, it began to clutter issues round, so sooner or later I manually debug the given code to paintings, reason else it’d take ages for it to in truth debug it line via line.”
  • “Mainly, it does what it says. Then again, it does what it says very actually. As in, it will replica a publish and its corresponding postmeta (customized) fields. Then again, it doesn’t appear to be it is going to propagate any taxonomies to the duplicated publish (the plugin will have to replica and assign the similar taxonomy phrases, similar to classes or tags, from the unique publish to the duplicated publish).”
  • If I used to be to be super-nitpicky about this, I’d additionally point out that it’s now not L10n-ready – there received’t be an solution to translate this plugin. However, that’s simply being very nitpicky – I don’t actually assume, nor would I be expecting, a prompt-generated plugin to be generic sufficient to be desiring one thing like that in any respect. To me, it’s extra of a “very particular drawback area” roughly a factor, together with the language used. On the finish of the day, it does do what it says it is going to, which could be very great.”

Along with analyzing the WordPress plugin code generated via ChatGPT and offering comments as proven above, our builders additionally agreed with the next key issues after assessing ChatGPT’s present functions to generate code:

1 – It’s essential to workout warning and now not blindly settle for ChatGPT-generated code as proper.

  • ChatGPT can give solutions, but it surely’s as much as the consumer to evaluate whether or not the solution is proper or now not.
  • There’s a possibility of receiving unsuitable or nonsensical solutions from ChatGPT, each obtrusive and delicate.
  • It’s essential to workout warning and now not blindly settle for the generated code as proper.
  • ChatGPT’s output will have to be handled as autocomplete, making existence more straightforward however requiring warning and verification.

The facility to discern just right code from unhealthy or nonsensical code, then again, means that…

2 – Customers will have to have enough wisdom and working out of WordPress plugin building to guage and alter the generated code as wanted.

  • ChatGPT can assist simplify and expedite the method of creating easy customized WordPress plugins, generate code snippets, and supply explanations. Anything else extra complicated, then again, calls for plugin building revel in and coding talents.
  • The use of ChatGPT with out enough wisdom can result in unfavourable penalties or unreliable code.
  • Depending only on ChatGPT with out crucial considering is very similar to blindly copying the primary resolution from Stack Overflow (Stack Overflow threads supply extra context, more than one solutions, and comments from different customers, making it a extra dependable useful resource, however Stack Overflow threads have a tendency to be extra generic, while ChatGPT can give particular solutions to particular person queries).

3 – Using different sources, similar to WordPress documentation, tutorials, and group boards, along ChatGPT can give a extra complete working out of WordPress plugin building.

  • As you discover the chances of the usage of ChatGPT for WordPress plugin building, it’s treasured to have interaction with the WordPress group. Proportion your reports, ask for comments, and search steering from skilled builders. Taking part in boards, attending WordPress meetups, or becoming a member of on-line communities can give treasured insights and can help you refine your plugin building procedure.
  • Moreover, imagine following WordPress safety perfect practices to safeguard your site from possible vulnerabilities. ChatGPT can give tips about safety features you’ll put in force to offer protection to your plugin.
  • It’s additionally very important to take care of a transparent working out of your required capability and carefully assessment and check the generated code and protected your customized plugins prior to deploying them to a manufacturing surroundings.

Can ChatGPT Flip You Right into a WordPress Plugin Developer?

On this article, we’ve explored how you’ll make the most of ChatGPT to construct easy customized WordPress plugins, even though you might have restricted coding revel in.

In different articles, we’ve noticed that AI-powered equipment like ChatGP can streamline your workflow, spice up productiveness, and liberate new probabilities (take a look at our fresh article on ways in which ChatGPT help you as a WordPress developer).

Whilst there are over 60,000 unfastened WordPress plugins to be had protecting each and every form of capability you’ll consider, every so often you might want a customized option to meet a consumer’s particular necessities.

Past the core capability of your plugin, you’ll additionally leverage ChatGPT to generate code for customized consumer interfaces. With its talent to know activates and generate HTML, CSS, and JavaScript snippets, you’ll create intuitive admin interfaces, front-end parts, and interactive parts that can fortify the consumer revel in and help you ship a sophisticated ultimate product.

Through the use of the language fashion’s functions, you’ll generate code snippets, optimize capability, and create user-friendly interfaces. Then again, it’s a very powerful to know the generated code, assessment and refine it, and carefully check your customized plugins prior to deploying them in your reside site.

The generated code might also require changes to align with coding requirements, naming conventions, or particular mission necessities. This calls for a certain quantity of coding wisdom and talents, as does optimizing the code and making sure it follows WordPress coding pointers for higher maintainability.

The base line:

Listed here are my findings after seeking to get ChatGPT to code me a plugin from scratch:

  1. I couldn’t have got this finished with out the assistance of our skilled builders.
  2. The use of ChatGPT to generate code with out coding wisdom is actually difficult – it is helping to understand what you might be doing 🙂
  3. Whilst ChatGPT is an impressive and treasured software, it doesn’t appear to be AI will substitute professional coders any time quickly.

Taken with Growing WordPress plugins?

Take a look at a few of our tutorials and articles on WordPress plugin building:

WordPress Developers

[ continue ]