- Overview
- Transcript
2.1 Make Your Plugin Visible to WordPress
In the early days of WordPress, if you wanted to modify the course functionality of WordPress, you’d need to edit those core framework files. Now, of course, the problem with this was whenever the WordPress team would release an update to the framework, you’d lose all of your updates. At that point, you were left with two options: 1) Never updated. 2) Lose all of your modifications and start from scratch. Luckily now, with WordPress hooks – action hooks and filter hooks – we can modify the behavior of WordPress without having to touch any of those core files. I’m going to give you a crash course in working with these. First, we need to create a new plugin. Access your WordPress project site, browse to WP-Content -> Plugins, and create a new folder, called JWFilter. Next, drag that folder into your code editor of choice. Next, create a new file, and give it the same JWFilter.php name. Now, we must left WordPress know that this file is, in fact, a plugin. To do so, we need to add some comments to the very top.
First, we need to create a new plugin. Access your WordPress project site, browse to WP-Content -> Plugins, and create a new folder, called JWFilter. Next, drag that folder into your code editor of choice. Next, create a new file, and give it the same JWFilter.php name. Now, we must left WordPress know that this file is, in fact, a plugin. To do so, we need to add some comments to the very top.
/*
|
* Plugin Name: JW Filter
|
* Plugin URI: net.tutsplus.com
|
* Description: Just for demo purposes.
|
* Author: Jeffrey Way
|
* Author URI: http://tutsplus.com
|
* Version: 1.0
|
*/
|
In order for WordPress to recognize a plugin file, the code above must be placed at the top of your file, and within comments. The framework will then scan each file in the plugins directory, and, when it finds these comments, respond accordingly, and make the plugin available for activation from within the WordPress -> Plugins section of the dashboard. Go and check for yourself!
We can activate it, but, naturally, as we haven’t written any actual code just yet, nothing will happen.
In the next lesson, I’ll teach you how to create a filter hook.







