Hello World Master

Tutorials, articles and quizzes on Software Development

PHP > Articles

Making our own plugin available to add WordPress

This article is associated with the following course
Building a basic WordPress plugin

If you’ve ever installed a WordPress plugin from the plugin store, you’d know that after you install the plugin, you need to activate the plugin.

Likewise, for your own plugins, you need to activate them.

The first thing we want to do is go into the plugins folder in our WordPress folder. The path you’d need to look for would be

${Your-Wordpress-Folder-Name}/wp-content/plugins

Now lets create a folder named my-first-plugin with the two PHP files inside it, index.php and my-first-plugin.php

Inside the index.php file, we just want to leave it blank

<?php
  // silence is golden

Adding Header Fields

Header fields tell WordPress that our file involves a plugin, and gives us information about the plugin.

Here are the following headers we’re going to add to our plugin

  • Plugin Name
  • Description
  • Version
  • Author
  • Author URI
  • License
There are more headers than the above, but for the purposes of getting started we’re going to limit ourselves to just these

Plugin Name

The name of our plugin. For this plugin, I’m just going to name it My First Plugin

<?php
  /**
   * @package My First Plugin
   */

   /*
    Plugin Name: My First Plugin
   */

Description

Describes our plugin, we can just state what our plugins purpose is for

<?php
  /**
   * @package My First Plugin
   */

   /*
    Plugin Name: My First Plugin
    Description: This is my first attempt on writing a custom Plugin for this amazing tutorial series.

   */

Version

What version of your plugin do you want to indicate we’re on. I’m going to just set mine as 1.0.0

Author

Name of the author of the plugin, I’m going to just use my own

Author URI

The link to the authors website, which I will also use my own site for this. If you don’t have your own website, or just don’t want to add your own site, feel free to omit this.

License

According to WordPress.org’s guidelines,

any GPL-compatible license is acceptable, using the same license as WordPress — “GPLv2 or later” — is strongly recommended.

https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/#the-guidelines

So I’m going to set the license to be GPLv2 or later

<?php
  /**
   * @package My First Plugin
   */

   /*
    Plugin Name: My First Plugin
    Description: This is my first attempt on writing a custom Plugin for this amazing tutorial series.
    Version: 1.0.0
    Author: Victoryflame
    Author URI: victoryflame.com
    License: GPLv2 or later
  */