Plugin development for WordPress from theory to practice – lesson 33

For those who do not know what a plugin is, I will explain in three words. A plugin is your code that somehow changes how the WordPress CMS works or adds new features to it.. Plugins were invented so that developers do not have to change the WordPress CMS core and all updates pass without errors, The site was kept safe and sound., and the functionality of the system could be supplemented. You can read more about what plugins are in Codex WordPress. For the lazy I give a link where to find wordpress plugins.

Many when learning how to develop plugins look at the code of already created WordPress plugins., but it's easier anyway, if someone at the beginning will explain elementary things. If you have already created a plugin, then you can always advertise it by placing a free version in the WordPress repository, and when the plugin gains popularity, you can make a PRO version, which will be more complete and useful. Usually PRO versions are sold for a small amount to many users.

Stage one “Planning”. What your plugin will do and how to name it?

Here you need to think carefully and maybe take a sheet of paper and draw a diagram of the plugin.

Think about what settings will be in the admin panel and what the output will be. Another important thing to understand is that the plugin should be useful, to download it. It is important for the popularity of the plugin on the Internet to name it like this, so that the keyword occurs in the title or that the title reflects part of the plugin's functionality. Here are some examples of good names for All in one plugins SEO pack, Yoast SEO, Rus is Lat.

If you later want to mark up your plugin in the repository https://wordpress.org/extend/plugins/, then you need to create a readme.txt file in the root.

Plugin home page

It is useful to create an information page or even a full-fledged website to get acquainted with the plugin you have created, which will explain the operation of the plugin., how to install it and where to buy the full version. On this page, they usually post all versions of the plugin and describe which version is tested for which version of WordPress..

Getting Started with Your First WordPress Plugin

In this tutorial and the following tutorials we will be looking at how to develop a plugin for WordPress., Let's start from the very beginning. Developing a plugin in WordPress is not tricky if you know the PHP programming language and the WordPress API.

To start creating your own planig, you need in the folder wp-content/plugins create plugin folder. We will create a simple plugin for changing the styles of the WordPress admin panel..

Create a folder styling-admin-panel (wp-content/plugins/styling-admin-panel) and create a file in it index.php. So it is accepted that the main file of the plugin should be the index.php file or the file with the name of the plugin, but since the name appears in the name of the directory where our plugin is located, then the file is simply called index.php.

Разработка плагинов для WordPress

Inside the file, you need to create a valid PHP comment that WordPress will understand.. With this comment you will be able to activate the created plugin in the admin panel. Add the code to the index.php file in the form in which I give you.

The order of the lines in this comment doesn't really matter.. The entered data can be changed to your own, but for this you need to understand where and what is located.

Let's analyze the basic code of the plugin line by line.

You can add copyright and plugin license to the created comment. Usually use a license GPL or GPL compliant. Let's finalize our code and add a license description.

This is how the standard comment for the plugin looks like along with the license.

After the work done, we can activate our plugin.

Creating WordPress Plugins

Let's work a little and make our plugin work.

Add Styles to the WordPress Admin Panel Using a Plugin, To do this, paste the following code into the plugin file.

 

add styles to wordpress admin panel

Next, in the folder with the plugin, create a style.css file.

Style the WordPress Admin Dashboard

Add styles to the created style.css file:

If you did everything right, then on your test site the color of the admin panel will change.

Change the color of the admin panel menu using the created WordPress plugin

With this simple action, we were able to change the default view of the menu in the WordPress admin panel. If you have HTML and CSS experience, then you can change the standard view of the panel beyond recognition.

All we have done is create a hook to a standard WordPress function and change how it works a little.. About what are hooks (cleats) you will learn from the next editions of the course. I decided to break the lesson into several, so that there is not a long sheet of text and give a small example of working with the plugin.


Buy WordPress hosting
/* WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal