Hello, my name is Chrissy and in these lessons, I'm going to show you how to create a basic plugin for WordPress. We're going to start off by looking at the anatomy of a plugin. So I'm on a local installation of WordPress, it's on my computer. And I usually do this for development, just because it makes it easier, I'm not having to upload my files, every time I make a change, I can just refresh the page or whatever I'm looking at. And it should give me the latest code after I've saved my file. So I'm going to go into my files on my computer. And we'll see here, let me scroll back here a little bit. This is the WordPress installation on my computer. So it's just installed on my computer on the localhost. And inside of the WP content folder, that's where my plugins and themes go. You can see there is a plugins folder. And inside of that plugins folder, there are a few files there, there's an index .php file, that's just sort of a way so if somebody tries to look at my plugins files, they can't see it because there's an empty index .php. And then I've got three folders, I've got cadence blocks, cadence starter templates, and you can't really see the whole title there, let me stretch that out, cadence starter templates and WooCommerce. And if you look at my plugins, you'll see that I've got those three files over there, or those three plugins are installed over there. So what I want to show you in these directories is if you look at, for example, cadence blocks, cadence -blocks, if you look over in the files that are inside of that, the one file that is required, the one the file that's absolutely required for every single plugin is going to be a PHP file that has the same name as the directory. So you can see for cadence -blocks, I've got a cadence -blocks .php. For cadence -starter -templates, you can see I've got a cadence -starter -templates .php. And then for WooCommerce, I've got a WooCommerce .php. That's how WordPress knows that's the file that has the basic code for your plugin. So I'm going to create a new folder. I'm going to make a really, really basic plugin. It's going to be called Chocolato, and it's just going to display a quote about chocolate on every post. So I'm going to create a new folder called Chocolato. And inside of that folder, I'm going to create a file called Chocolato .php because I'm going to follow the same conventions that we've got for the other plugins. So let me go into my text editor. Let me drag this over here. There we go. And I'm going to create a new PHP file. So I'm going to add the PHP tag, and I'm going to save this in my Chocolato directory. So let me go into my files. I've got to browse to it. So let me go into my local sites, Chocolate World, app, public. Your directory is probably different from mine. I need to go into the right directory, but there is my Chocolato plugin, and I'm going to save this file as Chocolato .php. Remember, the file name needs to match the name of the folder. So it's going to be Chocolato . php. Now, if I was to save this and refresh this directory, you might think something's going to come up. It doesn't because I have to give some basic information to that PHP file for WordPress to understand what it does and what is in it. So let me go back into my text editor, and let's add that basic information. So first thing I need to do is add a comment or a big comment, and that comment is going to be a PHP comment. So it's going to have a slash asterisk and then followed by an asterisk slash, and then I'm going to put several lines of text, several values that the WordPress code needs to see in order to understand that this is a plugin and what it represents, what it's about and all that information. So first thing I need to do is say, what is the plugin name? And the plugin name in this case is Chocolato. So if I save that and refresh again, it doesn't have enough information there. There we go. So you can see here, it's not enough information because I don't have the description version and all that good stuff. We'll add that in a minute, but now you can actually see the plugin. So the only thing that's absolutely required in that Chocolato .php file is the plugin name, but we're going to add way more than that. So let's go back into that text file, and I'm going to add a description that's going to show up. So this is going to say, display a quote about chocolate. And I'm also going to add a version. So every plugin should have a version. This is going to be 1 .0, and we're going to say which WordPress version is required. And so we're going to say requires at least, we're going to say 6 .0 for this plugin. And we're also going to say which PHP version is required. So we're going to say requires PHP. We're going to say 7 .4 for this one. And we're also going to say, who is the author of this plugin? That's me. So author is Chrissy Ray. And we're going to put in the author URI, which is, I'm going to just put in a placeholder here, mysite . com, which doesn't actually exist. And we're going to add a license for this. A lot of WordPress plugins are GPL version 2 or later. So I'm going to put that in for mine, GPL v2 or later. And then finally, I will add the license URI, which is going to be https://www .gnu .org slash license slash gpl -2 .0 .html. So let me save that. Go back into WordPress, and I'm going to refresh. Let's refresh it. Did I save it? Let me make sure. Oh, yep, I did save it. And so we can see here, I've got the name of the plugin is Chocolato. There is my description. There is the version. And you can see there's the author. And if it's a link, if I move my mouse over that, if you look down in the status bar, you'll see that it's going to mysite . com. So right now, there's nothing else going on in this plugin. It's just a super simple placeholder, but I can activate it. It's not going to actually do anything just yet. We haven't gotten that far, but we can see that this is the basics of the plugin. Now, there is another file that's required. If you are going to add the plugin to the WordPress plugin repository. So let's actually look at one of these other plugins. Let's look at WooCommerce, for example. And that file is going to be the readme .txt. So you can see for this file here, WooCommerce, readme .txt. For WooCommerce, if I go into the cadence starter templates, there's the readme .txt. If I go into cadence blocks, there's the readme .txt. We're not going to make one for the Chapelato plugin right now, but I will show you what's in the cadence blocks one. So I'm going to just open this up in my text editor. So let's open that up. And so this information is used by the WordPress plugin repository. It's the information that gets displayed in the plugin directory. So you can see here, it's going to have the information, the name of the plugin, who are the contributors. These are going to be the WordPress .org usernames, any tags. You can add a donate link. What version of PHP is required? What version it's been tested up to? What is the stable tag? What version of PHP is required? And then you can see some of these other things that you saw in the WordPress plugin file, the PHP file, include the license and the license URI. And then we've got down here a description. This is going to be what gets displayed on the plugin page. So if we actually look at the plugin page, so I'm in the cadence blocks. If I view the details, you can see here, there's the description. And if we look at the readme . txt file, there's the description there. So we've got more, you've got custom blocks include, this is a heading. So if you look in the directory, custom blocks include, there's the heading. And then you've got a bulleted list. The bulleted list in the readme .txt file, each bullet starts with an asterisk. So it's a little bit more involved if you wanted to create this file to go into the WordPress plugin repository. So that's it for the basics of the plugin. Thanks for watching and stay tuned for the next lesson where I will show you how to handle plugin security.