Things to consider before publishing your WordPress plugin
Tags: wordpress, wordpressplugins
Published: 2021-02-16 02:19:44

---
title: Things to consider before publishing your WordPress plugin
published: true
description: Creating plugins benefits the extendability of the functionality of WordPress Core and existing plugins. When creating plugins, there are few facts that you need to keep in mind. Let's talk about them in this article.
tags: Wordpress, wordpressplugins
cover_image: https://i.imgur.com/RFW0r0p.png
---

This post was originally published on [my blog](https://harshanas.medium.com/things-to-consider-before-publishing-your-wordpress-plugin-e48397b11362)

One of the best features of WordPress is the extendability of its functionality via plugins. It reduces the risk of directly modifying the source code in the WordPress core system or any plugin that you need to extend the functionality. There are a few facts that you need to keep in mind when developing a plugin. In this article, Let’s talk about what are those facts and how you can apply them.


## Catchy Display Name
![Plugin Search Results in WordPress Dashboard](https://i.imgur.com/KeDe8Ft.png)

The display name is the main trademark of your plugin. It should be **unique, readable, and defines what you’re going to provide**. When choosing a display name, it is better to avoid names that are [already trademarked](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#17-plugins-must-respect-trademarks-copyrights-and-project-names).

There are certain cases that you need to create and publish plugins that extend the functionality of an existing plugin. One such case is creating a payment gateway plugin for Woocommerce. In this case, developers most of the time use the trademark “Woocommerce” in their plugin name (**Example**: *My Payment Gateway - Woocommerce OR My Payment Gateway for Woocommerce*) and that doesn’t restrict you from publishing the plugin because you don’t use the trademark for any illegal reasons.


## Test up to the latest version of WordPress
![Tested up to version displayed in WordPress Plugin Page](https://i.imgur.com/amy8ygf.jpg)

Before publishing or requesting to get published, you should test your WordPress plugin with the latest WordPress version available because if the tested version is older than the latest version, then the plugin will not appear in the search results.

## Data must be Sanitized, Escaped, and Validated

In order to avoid Cross-Site Scripting attacks and Man In the Middle attacks, the user input data such as POST/GET/REQUEST/FILE [calls should be sanitized](https://developer.wordpress.org/plugins/security/securing-input/).

{% gist https://gist.github.com/harshanas/2241964bd6bfb03189383225fcfb6921 %}

The data [should be validated](https://developer.wordpress.org/plugins/security/data-validation/) in order to check whether the relevant data get entered into your plugin.

{% gist https://gist.github.com/harshanas/9d422c60c90f77de947b589cea60b3e9 %}

In order to display correct data to your users, the data [should be escaped](https://developer.wordpress.org/plugins/security/securing-output/) properly. Escaping will strip out unwanted data, like malformed HTML or script tags.

{% gist https://gist.github.com/harshanas/6c883b6540911016d65fdba1fd9d6a2e %}



## Unique function names, namespaces, and class names

When developing a WordPress plugin, It is best to use unique function names, namespaces, and class names to avoid conflicts with current plugins. The WordPress Plugin Developer Documentation recommends [using a prefix](https://developer.wordpress.org/plugins/plugin-basics/best-practices/#prefix-everything) to every function name, variable, and class name.

_**Example:** Let’s say you create a plugin named “The Best Plugin In the World”. You can use the prefix: “TBPW”._

{% gist https://gist.github.com/harshanas/6bd5dc5f579ff531c40a5a701f3fe303 %}

**Note: Don’t use two or three letter prefixes as there are nearly 100,000 Plugins in the WordPress plugin repository.**


## Make your plugin Translation friendly

If you have any idea to translate your plugin to one language or multiple languages, then it is better to use methods such as `_()` for basic strings and `_n()` for strings with pluralization.

{% gist https://gist.github.com/harshanas/dbcff72cf64ebff93f0f6cd3ee0a4753 %}

More info on translating and internationalizing your plugin: [Click Here](https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/)


## Disclose Third Party Services if you use any
WordPress recommends disclosing any Third-party services such as APIs you use and data that you collect inside your plugin to maintain full transparency with the end-users. You can use the readme.txt file that you use to maintain plugin details to explain the services you use.


## Other things to take note of

Use `if ( !function_exists() ){}` condition around your functions and `if (!class_exists() ){}` condition around your classes to avoid any conflicts with other plugins.

Avoid using `__` (double underscores), `wp_` or `_` (single underscore) for naming variables, stand-alone functions, and classes because they’re reserved for WordPress itself.

Use a banner and screenshots of your plugin to explain the features of the plugin to the user. More info on plugin assets such as banners can be found [here](https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/)

Those are a few of the facts that you need to consider before publishing plugins. You can refer to [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/) to learn more about not only the guidelines but also the techniques that can be used to create plugins.

Happy Coding!


## Further Readings:

- [WordPress Plugin Handbook](https://developer.wordpress.org/plugins/)
- [Data Validation] (https://developer.wordpress.org/plugins/security/data-validation/)
- [Securing Inputs with Sanitizing](https://developer.wordpress.org/plugins/security/securing-input/)
- [Securing Outputs with Escaping](https://developer.wordpress.org/plugins/security/securing-output/)
- [Plugin Internalization](https://developer.wordpress.org/plugins/internationalization/)
- [Plugin Guidelines](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/)
- [Plugin Assets](https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/)