How to Edit Your WordPress Plugin’s Code

Now that you’ve set up your WordPress site locally on your laptop so that you can easily code your plugin on the go, it’s time to add the features you want and start coding.

The code used by WordPress is English (mostly), sprinkled with a bit of math. While it might seem hard to understand right now, don’t worry about it too much. I was confused myself when I started coding. What really helped me though was just diving into the code and changing it, testing what worked and reversing the changes and trying again if it didn’t.

Edit Your Plugin Using WordPress’ Code Editor

The smart folks over at WordPress knew that site owner will want to mess around with their own site’s code. Rather than make it hard for them by forcing people to download, edit, then upload files, they just made editing possible right from the site’s admin area.

Here’s how to access that editor:

  1. Go to the admin area of your site and click Plugins, then click Editor. 
  2. Next to “Select plugin to edit:” at the top, choose the plugin you uploaded earlier then click the Select button.
  3. At the right, you will see the folders and files included in the plugin, arranged in a file browser like the one on your laptop.
  4. Inside the admin folder is a file starting with class-. If you followed along with my previous post, you’ll see that this is the same file you edited as before.
  5. Once you’re done editing, just click on Update File to save your changes.

NOTE: If you’re using InstantWP and getting an error saving your code, add the WP Editor plugin by Benjamin Rojas to fix that issue.

edit code using Coditor

Edit Code Using Coditor

There’s also a great plugin called Coditor which adds a real code editor into the admin area of your WordPress site. If you’ve seen cyberpunk-like dark coding screens in the movies, this makes your code look just like that.

To try it out:

  1. Search for Coditor it in the WordPress directory by going to Plugins > Add New.
  2. After installing and activating the plugin, you’ll see a new Coditor option at the left admin menu. Click on it.
  3. At the left panel, choose Theme to edit your theme or Plugin to edit your plugins.
  4. It works just like Windows Explorer or macOS Finder, with the files and folders at the left and the actual file at the right. Simply navigate to the file you want to edit and click it.
  5. At the upper right are buttons for saving your file, undoing and redoing, and searching the text.
  6. You’ll also notice that it highlights the syntax of the code, very useful to figure out what part of the code you’re editing.

———

While there are other ways of editing your plugin, including the roundabout way of downloading, editing and uploading the files, I’ll leave with these two simple tools so that you can start writing code right away. I’m sure you’ll be able to make simple changes from here on.

If you need something more complex or want to customize a plugin to suit your website, let me know. I’d be more than glad to help.

Need a Simple Custom Plugin for WordPress? I Can Build It for You

I’ve been writing about how to make WordPress plugins a lot lately. While I encourage everyone to try creating a simple custom plugin on their own, I also realize that not everyone is inclined to do so.

You might not have the time to spend learning and building a plugin. Or you might have tried building one but discovered that coding really isn’t for you.

If you don’t have the time to build a plugin but still want to add a simple feature or function to your WordPress site, let’s talk and I might be able to build the plugin for you.

If it’s a really useful plugin that we definitely need to share to the world, I can build it for free and then upload it here for everyone to download. We’ll work together to iron out the kinks and you have first dibs in installing it.

For plugins that need a bit of extra elbow grease to make or if you don’t want it to be publicly available, you can also hire me to build it for you. I can both create something from the ground up or modify an existing plugin for your company’s private use.

Interested in getting your plugin idea made?
Post a comment below with your idea, email me or send me a message.

Coding Your WordPress Plugin on the Go Using InstantWP

Since a website is online, then you need to go online to update it, correct?

But isn’t that too cumbersome? You need to connect to your server, download the file, edit it then upload the edited file. After that, you need to check if your changes worked, otherwise you do that whole dance again.

It’s better to just have a copy of your website on your computer and edit it without needing to go online. Not only does it save you a lot of the trouble, you can test all the new plugins and themes you want without breaking your website. And as a bonus, it’s also a backup copy of your live site, in case you need it.

I know what you’re thinking, “Setting up my WordPress site on my computer? Madness! Isn’t that asking for too much for someone who’s not a developer?”

Fortunately, I did find something super simple for installing a WordPress on your local computer. I present: InstantWP!

It’s the simplest way I’ve found to setup a local WordPress on your laptop. Just download the free installer and run it on your computer. Then, you get a website server without all the crazy setup and trial and error. Trust me, it can get complicated setting up locally (and I might write about that in the future).

Here’s how I installed my copy:

  1. Go here and download the installer for your computer. It works with Windows and macOS. The latest release should be at the top. Download the one with “Win” in the name if you’re using Windows, or the one with “macOS” if you’re using a Mac.
  2. The file is around 300MB so it might take up to an hour to download. Might be good to grab something to eat or do some chores while it works (and stay off the computer so it can download faster).
  3. Once you download it, unzip the file and open the ReadMe file included, the one that starts with “ReadMe” and ends in “.html”. It talks about a few things you might need to do to make InstantWP on your computer.
  4. After that, just open “Start-InstantWP” inside the folder, wait for it to load, and you get a nice friendly screen that lets you do everything you need to do with your site. This is what it looks like:
for Windows
for macOS

Now that you have InstantWP installed, we need to do a few housekeeping activities before starting.

  • InstantWP starts with very little RAM, which might affect the performance of your offline site.
    1. On the InstantWP screen, click Advanced, then click Edit Config File.
    2. Edit the line RAM=268 to be RAM=512 or RAM=1024.
    3. Save the file, then Quit and Restart InstantWP.
  • Click on WordPress Admin to go to your site’s admin area. By the way, the webpage might load a bit slowly at first but that’s normal. I suggest you wait a bit and let the site load up before clicking the button.
  • You can also add the plugin you made via my previous post. Just go to Plugins > Add New > Upload Plugin, then activate it. Try and see if it work.
  • Let’s go ahead and update WordPress as well, since InstantWP’s version is a bit old.
    1. Click on WordPress Admin in the InstantWP screen.
    2. Go to Dashboard, then click the Update Now.
    3. Wait for the update to finish. You should see a screen similar to the one below (the latest version as I wrote this was 4.9.1)

That’s it! Some minor changes and a bit of waiting is all you need to get your WordPress site running on your computer.

If you need more info on how to use InstantWP, you can read the user guide, browse the FAQ or check the troubleshooting guide.

Right now, I’m assuming you’re building something from scratch so you don’t have a website yet. If in case you want to copy your live site into your local one, here’s a guide I found that will help you export your site. Note that it’s a bit comprehensive but I’m sure you can tackle it no problem.

Why Build a WordPress Plugin?

I’ve always been impressed with all the things you can do with plugins.

Remove the annoying bar at the top of the site? There’s a plugin for that. Want to collect emails on your home page? There’s a plugin for that as well. And yep, there’s even a plugin if you want to turn your site into a full-blown marketplace.

Ah, so much good stuff, so little time (and server space).

But if there’s already a plugin for everything WordPress, why should you build one yourself? After all, it’s not like plugins are hard to add to your WP site.

First, let me answer that from my own perspective.

Why I Built a WordPress Plugin

I’ve been working on WordPress sites for over 5 years now, mainly via our microjobs marketplace and some tinkering for side project. But I really haven’t made a plugin from scratch before and I wondered why.

Then it hit me that I’ve always been making plugins, just not in the usual way.

  • I modify free plugins all the time, making them my own. I add extra features, format the display and even sometimes remove code that doesn’t fit my needs.
  • I actually built a few one-file plugins (yes, you can do this!) but have since absorbed the code into the theme I use.

All those are nice for personal projects but I think it’s high time that I make something I can share to the world. After all, it’s bad manners to edit someone else’s work and push it as your own.

build a WordPress custom plugin from scratch

Why YOU Should Build a Plugin

So I made this plugin mainly because I wanted to learn WordPress plugin development. But I think even non-developers like digital marketers, creative freelancers, and consultants would benefit from building their own plugins.

Since you already own a WordPress site, why not discover how you can modify it to suit your needs?

  1. Building a plugin helps you understand how WordPress works. This way, you know what goes on when a developer tinkers with your site. It also gives you an insight how the non-coding side of WordPress works, like publishing to the plugin directory.
  2. Building a plugin teaches you how to modify other plugins to suit your needs. Often, you just need to change a single line of code to change a plugin to how you want it to work, much better than hiring a dev.
  3. Building a plugin means you make something new. There’s no better feeling than getting that first person to install your plugin and tell you that it works on their site without a hitch.
  4. Building a plugin also builds up your career (or business, as the case may be). You add one more skill to your toolbox and the plugin can be used to improve your site’s SEO, gather future customers, and expand the range of services you offer.
  5. Building a plugin means you solve other people’s problems. Sure, you can install an existing plugin to make your own site better. But what if you can make something, publish it, and help dozens of other site owners without any extra effort? Everyone wins!

To my last point, I think making plugins is all about being helpful. Software is the most scalable way I know to help others, and plugins are an easy entry point for anyone who’s familiar with WordPress.

If you’re a WordPress site owner but don’t have programming skills, don’t fret! Making a plugin is a great starting point if you want to learn how to code and get something useful out of it.

But I think the next question is: what plugin should I build?