In this session we discuss the difference between a Plugin and Custom Code. Basically, a Plugin is a block of code that can be installed using a plugin system while Custom Code is code added directly to the theme.
Member: So you said this, this right here, you call this a plugin. Is that correct? This code?
Rick: Well, this code is part of a plugin.
Member: Oh, it’s part of a plugin.
Rick: Yeah, it’s just one of the files inside of this plugin that I created.
Member: Okay because what I’m trying to figure out is how… I know a plugin you know, you go to WordPress. You go to Plugin. You download it. You install it, you activate it. That’s a plugin. But what technically… I don’t see myself ever creating plugins and certainly not to sell them. It just seems too complicated. But what exactly is a plugin? You know, I don’t quite… I mean I know it’s software that does something but sometimes, you download it from WordPress and install it. But sometimes people, I think, put code in to a site and they call that a plugin. I’m trying to figure out what is the technical definition of a plugin or…
Rick: Well, the technical definition of a plugin is a function that you’re adding to a WordPress site that is installed via the plugin installation.
Member: Gotcha. That, I get.
Rick: So you can write custom code, you can add custom code to a site by simply adding it to its functions php file or in Thesis’ case, the custom functions php file. You can do that and that’s not considered a plugin because that code is not being installed that way.
Rick: But a plugin is a block of code that can be installed using the plugin system. And then the plugin system has its own syntax. So, a regular plugin has to have this comment block at the very beginning. This plugin name, the plugin URI, the description, the version number, the author, author URI, license and date. This has to exist in anything that you call a plugin. And then when you use the plugin system for installing the plugin, it uses this information. It looks for this information. If it doesn’t find this information, it doesn’t install anything. It’s not a valid plugin.
Rick: And so in this case, the BYOB Genesis Agency Home Content plugin, includes a whole bunch of files similar to a child theme. It’s got a bunch of different files that do different things. But the key elements are, the name of the plugin or the slug of the plugin is its main plugin file. That main plugin file has this information in it at the very beginning and generally speaking, the name of the folder should follow the name of the plugin file. Now that’s not absolutely required but generally, that is the way in which it works. So the only thing you need absolutely for a plugin is really, a main plugin file with this information inserted into WP content plugins.