Introduction to WordPress Plugins

49 472 WordPress Plugins are available in the official repository. That’s a huge number! And they are just the Plugins available on wordpress.org. They are much more. For example, think about vendors that sell their own Plugins on their platforms or the thousands of Plugins loaded on GitHub, but never submitted to the official repository.

For many people Plugins are surrounded by mystery. It seems that WordPress provides us with a powerful magic wand to get anything we want. To turn WordPress into whatever we want.

What is a Plugin?

The shortest answer is a package of code. More specifically, a package of PHP code. That’s it.

The most straightforward Plugin is made up of a single unique PHP file. For example Hello Dolly, a Plugin that you’ve probably never used, but you have seen it at least once since it is delivered together with WordPress.

It’s important to understand how Plugins are related to WordPress itself. There are three major components: Core, Themes and Plugins. The Core is the application itself. Themes allow to display some data to users and to choose the look and presentation of your website. Finally, we have Plugins.

Plugins are used to extend WordPress functionalities or to add new ones. At this point, you can ask why not to modify the WordPress Core directly.

Why do we need Plugins?

Why can’t we change directly the Core program? Well, remember the first rule of WordPress development: Don’t touch the Core! Please, don’t do that. A lot of tutorials on the Internet suggest to modify some files inside the Core, but it’s wrong! Why? Because when you update WordPress, you’ll lose all your changes. If you lose all your changes, you won’t update WordPress. If you don’t update WordPress, say goodbye to Security! It’s enough not to touch it, don’t you think?

What about Themes? If we need some new functionalities, we can add them inside the functions.php file. Each Theme contains the functions.php file that is actually a Plugin: you can use it to do whatever you’d do with a Plugin.

The Plugin Territory

If we want to add new functionality to our WordPress website, should we use a Theme or a Plugin? We have to consider the so-called Plugin Territory. Theoretically, it doesn’t matter which one we use, both a Theme and a Plugin let us customise WordPress. But there are some guidelines to follow.

If we need to add a function unique to the Theme, it’s better to use the functions.php file. For example to add the menu support, post thumbnails, sidebars, customisation of the look and feel of our Theme.

If we need to add a new function to the WordPress application or to extend an existing one, then we should use a Plugin. For example to add Custom Post Types or Shortcodes. All those functions that we want to use even if we change the Theme.

What is strictly related to a Theme is put inside the functions.php file, what is related to the whole application, whatever Theme is used, is put inside a Plugin.

Conclusion

We have seen what Plugins are, why and when we use them. In a future article, I’ll talk about the fundamental concepts of WordPress Plugin Development. Do you want to develop your own Plugin?

Leave a Reply

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