Creating A WordPress Plugin (A Beginners Guide)

Are you at that stage with WordPress where you’re ready to start using and creating plugins but you have absolutely no idea where to start? Well, you’re in the right place.

WordPress plugins are a great feature for your website because they allow you to add an array of custom features, which will give your website some added flair and functionality.

Creating A WordPress Plugin (A Beginners Guide) 2

You can download already existing plugins, but you also have the option of making your own. It might seem like a daunting task at first, but if you follow this guide, you’ll be a plugin-making pro in no time!

So read on to find out everything you need to know. 

Creating A WordPress Plugin

Creating your own plugin can seem quite overwhelming at first, but if you follow these steps exactly, you’ll soon be making them in no time. So let’s get started!

  1. First, you need to create a new folder on your desktop and give it a name. For this example, we’ll be using the file name “first-plugin”. 

  1. Now you need to create a new file in your text editor, save it inside your plugin folder and name it “first-plugin.php”. This .php file must be opened with your text editor.

  1. In your plugin file, you need to first add your plugin header. Once the header has been added, you can add the plugin code below it. 

  1. You can find lots of different types of plugins online and you can simply copy and paste the appropriate code below the plugin header. 

  1. Once you’ve added the code, create a .zip file for the plugin folder.

Now the plugin is created, you need to test it out to make sure it’s working. Follow these next set of steps to do so: 

  1. Go to the WordPress admin area and head to Plugins » Add New.

  1. Next, click “Upload Plugin” and then “Choose File”. Upload the .zip file you created here.

  1. Now you want to click the “Install Now” button which will upload and install your newly created plugin. 

  1. As soon as it’s installed, you can then activate your plugin. 

  1. To see if it’s working properly, you can now visit your webpage and have a look. If it’s not working properly, double-check your code and try again. 

WordPress Plugin Repository

Once your plugin is on your website, you will want it to be discoverable to other people. You can also make your plugin available to other users so they can have the plugin on their website too. 

In order for your plugin to become public like this, you will need to submit it to the WordPress Plugin Repository. 

Before you can upload your new plugin to the Repository though, you will need to create a “Read Me” file for it. All you need to do to make that file is to open a blank text file, add the appropriate information and syntax and save it under the name “readme.txt” in your plugin folder. 

Your “Read Me” file will have to meet WordPress’s readme file syntax, so you will need to look into that in order for your file to be approved on submission, but you can find plenty of easily accessible examples online. 

Once your “Read Me” file is ready, your plugin will be ready for review by WordPress. Once you’re logged in to WordPress, go to the “Add Your Plugin” page and click on the “Select File”, add your plugin’s .zip file and then upload. 

You will have to wait for the WordPress plugin team to review your plugin to make sure there are no errors and for security checks, but once it’s all good to go, you will be sent an email by the team that contains a link to the Subversion (SVN) repository on WordPress. 

Uploading Your Plugin With Subversion

Once you get the link to Subversion, you will be able to use it and manage your plugins. Subversion (SVN) lets you make changes to your files and directories and also lets you manage different versions of your plugins and keep a record of the changes made. You can also collaborate with other plugin creators. 

In order to use Subversion (SVN), you will need an SVN client installed onto your computer. This will allow you to upload your plugin to WordPress.

Once you have installed the SVN client, you will need to open the Versions App and click on the “New Repository Bookmark” to view a copy of your WordPress plugin. 

When you create the new bookmark, just name it after your plugin so you’ll always be able to access it with no issues. Once you’ve done this, add your WordPress plugin’s SVN repository URL.

After you’ve done this, click the “Create” plugin, which will connect you to your repository and the Versions app will download a copy of the plugin’s repository straight to your computer. Once it does this, right-click it and choose the “Checkout” option. 

You’ll be asked to provide a name and location for the folder, but you can just use the same folder name as your plugin directory.

Once this is done, you need to copy the plugin files to the inside of the folder of your local repository. A question mark will appear next to all the new files in the Version app. Select all these new files and add them to the local folder.

With the files added in subversion, you can now upload them. Click your local repository and then click “Commit Changes”. A popup will appear and it will show you all the new changes and a box will also appear where you can add a commit message. 

Now you will need to tag your uploaded files to a version. To do this, you will need to go to the local copy of those files and copy them into your trunks folder. Once that is done, open the tags folder inside and create a new folder. 

You will want to name the folder after the version. Make sure it matches the name of the plugin header. 

A question mark will appear next to the folder name because it’s a new folder. Just click the “Commit” button again and this will sync your changes.

When you’re done and satisfied with the changes you’ve made, click the “Commit” button once more and this will sync them with the WordPress.org repository.

If you’re making any major changes to the plugin, you will want to create a new version. To do this, simply add a new folder named after the number of the version. The version number always has to match the plugin header. 

With all of this complete, you can preview your plugin on the WordPress.org plugins directory and you will be all set. 

Conclusion

There is a lot to do when it comes to creating plugins and setting up your plugin for others to use. But it is important that you know that you don’t actually have to make your plugin available for others to use, so if you don’t want to, you can ignore further instructions. 

Just be patient and be prepared to review your plugin code a few times before it will be successful. If you’ve never coded before, it is a learning curve, but a valuable one!

https://www.youtube.com/watch?v=l6NL-rF9bE8

Ollie Wilson

Leave a Comment

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