Sourabh Agrawal

How to launch WordPress Plugin in Repository?

Posted By Sourabh Agrawal

Hello Guys. So if you are planning to create a new WordPress plugin than defiantly this blog is for you, if you already have a WordPress Plugin and you want to know few commands to update the code of your plugin, then I would suggest you to jump to the command section.

Well, WordPress library already have plenty of plugins that you can use for free. and you can find some of the paid/premium plugins in different plugin stores as well.

To create the plugin, one thing is for sure you must know, which is “What”.

Yes, if don’t know “What” you want to create, it is baseless. So, now the questions arises, how do you know What you want to create. So, the answer is simple, if you are working on something and found issue and you belive that you know “How to fix this WordPress problem?”, then bingo, you have succeed the first step. At least you know what you want.

launch wordpress plugin

Without goal, nothing is possible. So, its always better to write down your plugin goal.

See Also:

Why WordPress?

Now, the the next step is to find the solution. To get the solution, you have to brainstorm on the goal of the plugin and you will find the solution, you can refer to different blogs, plugins, and books to read and learn how to code the WordPress plugin.

The plugin can be anything, either it could be only single function or the full featured code. The concept of plugin is simple, if you are able to plug-in or plug-out any functionality, it can take a shape of the plugin.

Now, if you have prepare the plugin, its time to make sure it is secure and complaint with the WordPress repository guidelines.

The most important thing is, the data you are saving or retrieving is safe. For that you have to read the Secure Input and Secure Out section carefully.

Secure Input

It is required to make sure the data user can submit via any form is secure enough. This can be achieved by sanitizing that data.

Any time the plugin is accepting any potentially unsafe data, it is very important to validate or sanitize it.

You can use following functions to sanitize the input data:

sanitize_title()
sanitize_option()
esc_url_raw()
sanitize_key()
sanitize_meta()
sanitize_email()
sanitize_file_name()
sanitize_hex_color_no_hash()
sanitize_hex_color()
sanitize_title_with_dashes()
sanitize_html_class()
sanitize_sql_orderby()
sanitize_text_field()
wp_kses_post()
sanitize_mime_type()
sanitize_title_for_query()
sanitize_user()
sanitize_textarea_field()
wp_kses()

The one thing you must remember that if you are saving any data in option table, you don’t need to serialize or JSON encode the data, as wordpress’s function will automatically serialize the array to the serialize JSON object for you. So, don’t worry.

Secure Output

Similar to secure input, you also have to make sure whatever data you are getting from the database is secure to perform the actions and is safe enough.

Here when we say, secure output means, we have to make sure the data is escaped properly to prevent XSS (cross site scripting) as well as rendering the HTML code and any script inside the content is safe to output for the user as well as the WordPress application.

In simple words, Escaping is a process to eliminate all unwanted HTML and script tags.

Here are some common functions that you can use to escape the secure the output:

esc_html()
esc_attr()
esc_textarea()
esc_js()
esc_url_raw()
esc_url()
wp_kses()
wp_kses_post()
wp_kses_data()

Peoples also like to read following article: How to install WordPress?

What is Readme.txt file in WordPress Plugin?

The plugin code is ready and pass all the security measures, then it is a time to create a description of your plugin, and for that you have to create a readme.txt file.

readme.txt is a file that you have to create on the root of your plugin.

Let’s assume your plugin folder is: “my-test-plugin”

Then this should be the minimum structure of your plugin:

| -- plugins
| -- my-test-plugin
|-- my-test-plugin.php
|-- readme.txt

(Structure of basic WordPress Plugin)

Their is a specific format of creating the readme.txt file.

Click here to download the format of the readme.txt file of WordPress Plugin.

Submit WordPress Plugin to WordPress Repository

If you are ready with your WordPress plugin with the readme.txt file, now it is a time to submit your plugin to the WordPress plugin repository.

Just create a Zip of the plugin and make sure the zip name is also same as the plugin name and login to the WordPress.org website.

If you don’t have any account in WordPress.org, you have to create new account. Because it is mandatory to create account on wordpress.org.

Remember your username and password and keep it safe as they are require for you to commit your changes in once it is approved.

Here is a quick steps to submit your wordpress plugin on wordpress.org:

  1. Login to the WordPress.org
  2. Click here to submit the plugin for review.
  3. Now your plugin will be manually reviewed.
  4. You will receive an email communication if plugin approved or it needs some changes.
  5. If your plugin needs some changes, then fix them and this time do not re-upload, follow the instruction in the received email.
  6. Once approved, you will receive the access to the Subversion Repository.
  7. Once you commit your plugin with assets and readme file to the repository, it will be publicly available.

Push/Pull WordPress plugin on Mac

Here, I am showing you the steps to upload the WordPress plugin on the subversion repository using on the Mac OS:

For that you can create a specific folder to manage this plugin. Here for this example, i have created a folder named “plugin” on my desktop. and i have used “myuser” in place of the username of the system. So, the default path will be:

/Users/myuser/Desktop/plugins

Now, Open the Terminal and type the following commands:

$ cd /Users/myuser/Desktop/plugins

Now you are on the plugin folder that you have created.

Check the email that you received from the WordPress plugin directory and find your plugin’s subversion repository link. it will be something like this:

http://plugins.svn.wordpress.org/my-sample-plugin

Checkout The Plugin:

Checkout is a process of getting the plugin in your local machine. anybody who have this SVN link can checkout the plugin. Even if he/she does not have the owner. This is useful, when you are about to contribute on any code. Anyway, now checkout the plugin to download the fresh copy of the plugin structure:

$ svn co http://plugins.svn.wordpress.org/my-sample-plugin my-sample-plugin

Once you run this command, you will find that a new folder “my-sample-plugin” is created inside the “plugin” folder.

If you open that folder here, you will find 4 empty folders:

Assets: This folder is used to store the plugin icons, plugin banners and screenshots.

Trunk: This folder contains the current build. Usually this is the main folder where you save the latest copy of the plugin. But since this is the main copy, you can use this for the continues development as well as a master branch. Here, In this folder the role of the readme.txt file is very important.

Tags: This is folder where you save all the versions of the plugins. It is an ideal process to tag all the versions of the plugin and add them here, so, always WordPress loads the stable copies from the tags folder instead of trunk.

Branches: This folder you can use for for testing and branching of the applications. Ideally, This is an extra folder that WordPress don’t use for any specific purpose. But just make sure whatever you store there can be accessible to anyone. so, do not try to use this folder to save any credentials or and confidential things.

Must have plugin for your WordPress website:

Clean your WordPress dashboard and improve security by Disable WP Notification

Manage The Plugin Stuffs

Now, as you know the structure of the plugin repository, so you can put the elements in the proper place.

Although, there is no such defined sequence of the process, but here I am sharing the ideal steps that you can follow to upload the plugin in SVN repository:

Assets

First, you need to upload the assets in the /assets/ folder. These assets includes the plugin banners, plugin icons and screenshots. Here i am sharing the size and name of these assets. The Size and Name of the plugin assets is very important and you can not compromise with the same.

As, there are some of the languages that writes in RTL (Right-To-Left) format. If you would like to create a banner that have RTL text, you can upload the banner in RTL format as well. Although the RTL banners are not required, but if they are available, the specific banners will show to the peoples whoes default language uses the RTL format. Rest all banner size are required.

Here, you see three format of the logo, but out of them it is advised to keep at lease normal and high-dpi logo. If you have the SVG logo that is the ideal case. If you don’t have that logo right now, it’s ok, you can upload it later as well.

Here as you can see, I have not mentioned the size of the screenshots because the size is not matter here, you can upload the screenshots of any size. But for ideal case, it is suggested to keep their size same so, when they convert to the slider, user can navigate them properly.

The important thing is, you just need add the numbers at the end of the their names and all the screenshots will automatically display in your plugin page. you can add their captions in the readme file.

Trunk

In this folder you have to upload all the plugin files that are inside the “my-sample-plugin” folder. such as readme.txt, and my-sample-plugin.php etc.

You just have to make sure that the versions are very well specify in readme.txt file and the header of the main file i.e., my-sample-plugin.php file

Upload The Plugin / Check-In Plugin

Once everything is ready, let’s check-in the stuffs:

Here I am writing a consolidated commands that you can use to check-in / deploy the assets on the WordPress plugin repository:

$ cd /Users/myuser/Desktop/plugins
$ cd my-plugin-slug
$ svn add assets/*
$ svn ci -m 'Deploy the assets of the plugin'

Once you put this lines one-by-one, you will prompt for the username and passwords. Here a thing you must notice that for checkout, the credentials are not required because anyone can download the code. But for check-in the credentials are required. So, only the authorized peoples can maintain the plugin.

. Enter Mac Password
. Enter username of wordpress.org
. Enter password of wordpress.org

Make sure all these are case sensitive.

Now, you can check that your assets are deployed on the WordPress repository by opening the SVN url on the browser.

Deploy the plugin files

Now, you can deploy the plugin files available in the trunk folder. For that use the following commands:

$ cd /Users/myuser/Desktop/plugins
$ cd my-plugin-slug
$ svn add trunk/*
$ svn ci -m 'First Version of My Plugin'

Note, if you are doing all the things in one shot, you can skip first two commands to navigate to the folder and directly use the svn command.

If any any time, it requires the credentials, you have to provide them.

Tag the version

After deploying the plugin in trunk folder, its time to deploy the same on the tag folder. so, after deploying to the trunk folder, if you did not change anything, you can directly create a tag. using following command:

$ svn cp trunk tags/1.0
$ svn ci -m "tagging version 1.0"

So, what actually this command does, It will copy the code from the trunk folder and move it to the tag folder. Here in tag folder, whatever you write after “tag/” will create a folder.

It is suggested to keep the sub-folder names of the tag folder same as per your plugin version. Since it is my first commit, and my plugin’s version is 1.0, I use the folder name “1.0”. If you would like to create any other version number you can use that.

Just make sure whatever version number is up-to-date in tags folder, you have to update that version number in the readme file available under the trunk folder.

Bingo

Your plugin is update and moved to the WordPress Plugin Repository.

Quick Summery

So, Here I am showing you a quick walk through of all the process:

  1. Check-out the plugin
  2. Update the assets to “/assets/” folder
  3. Update the plugin files in trunk folder
  4. Commit (Check-in) ‘/assets/’ folder to svn
  5. Commit ‘trunk’ folder to svn
  6. Create the tag of the stable release.

Commands To Launch WordPress Plugin:

$ cd /Users/myuser/Desktop/plugins
$ svn co http://plugins.svn.wordpress.org/my-sample-plugin my-sample-plugin
$ cd my-plugin-slug

$ svn add assets/*
$ svn ci -m 'Deploy the assets of the plugin'

$ svn add trunk/*
$ svn ci -m 'First Version of My Plugin'

$ svn cp trunk tags/1.0
$ svn ci -m "tagging version 1.0"

If you find this article useful, please leave your comment and share it on the social channel as well. Thanks.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Sourabh Agrawal - WordPress Developer

Sourabh Agrawal

An Interactive Web Engineer

I am a WordPress developer with the hands-on experience with front-end techniques as well as the backend coding. I love creating new websites, optimizing them for performance and front-end detailing. I am graduated from the University Institute of Technology, RGPV in 2011 with a Bachelor of Engineering in Information Technology.

0
Would love your thoughts, please comment.x
()
x