Local for Local Development
I highly recommend Local for developing WordPress sites on your development PC. Easy as 1, 2, 3 and you up and running with the latest WP setup.
Basic Plugin
A very simple ‘Hello World’ plugin
WordPress
Plugin Handbook
Setting up your plugin
Creating the folders
In your WordPress installation, go to wp-content > plugins, create a folder called simple-plugin.
The main PHP file
In this new folder simple-plugin, create a file called simple-plugin.php
The main PHP file
Copy and paste the below code into your new simple-plugin.php
wp-content
└── plugins
└── simple-plugin
└── simple-plugin.php
Hello World
Take note of the various sections above, make sure to update the information to correlate to your personal / company information.
There is an additional element to the plugin file that is different from the usual tutorials.
The constant battle with accessing assets in the WordPress plugin was an annoyance that one line of code could fix, especially with nested folders in a plugin as it grows, so a define for SIMPLE_PLUGIN_PATH was a solution.
The above plugin creates a shortcode that can be inserted in your WordPress template. The shortcode is:
[hello_world]
Add comment