Where to create a plugin (folder structure)?
A PHP file with a WordPress plugin header comment is the most basic form of a WordPress plugin. To ensure that all of your plugin’s files are arranged neatly in one location, it is strongly advised that you create a directory for it.
- Go to the wp-content directory in the WordPress installation.
- Navigate to the plugins directory.
- Make a new directory give name as you wish . ex weather
- Open the directory ie weather
- In this create new php file. ex weather.php
wordpress $ cd wp-content
wp-content $ cd plugins
plugins $ mkdir plugin-name
plugins $ cd plugin-name
plugin-name $ vi plugin-name.php
Note : vi is a text editor.
You must now add a plugin header comment to the PHP file containing your new plugin. The plugin’s name, creator, version, license, and other metadata are contained in this specifically formed PHP block comment. The plugin name must be included in the plugin header comment, and it must also adhere to the header specifications.
The header comment should only appear in one file within the plugin’s folder; if the plugin contains several PHP files, it should only appear in one of those files.
Once the file has been saved, your WordPress website should list your plugin. After logging in, select Plugins from the WordPress Admin’s left navigation pane. All of the plugins that are installed on your WordPress website are listed on this page. Your new plugin should now be in that list!
Header Requirements
Header comments, which inform WordPress that a file is a plugin and offer details about the plugin, should be included in the main PHP code.
The Plugin Name must appear in a header comment at the very least.
Valid PHP Header comments:
/*
* Plugin Name: My Basics Plugin
* Plugin URI: https://example.com/plugins/the-basics/
* Description: Handle the basics with this plugin.
* Version: 1.10.3
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: John Smith
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: https://example.com/my-plugin/
* Text Domain: my-basics-plugin
* Domain Path: /languages
* Requires Plugins: my-plugin, yet-another-plugin
*/