This entry is part 2 of 14 in the Plugin Development 101 Series
- Introduction to WordPress Plugin Development 101
- Plugin Development 101 – What Makes a Plugin?
- Plugin Development 101 – General Best Practices
- Plugin Development 101 – An Intro to Filters
- Plugin Development 101 – Intro to Actions
- Plugin Development 101 – Registering a Custom Post Type
- Plugin Development 101 – Intro to Short Codes
- Plugin Development 101 – Intro to Loading Scripts and Styles
- Plugin Development 101 – Introduction to Adding Dashboard Menus
- Plugin Development 101 – Separating Your Plugin into Multiple Files
- Plugin Development 101 – Your First OOP Plugin
- Plugin Development 101 – Dissecting the Featured Comments Plugin
- Plugin Development 101 – Digging Into WordPress Core to Solve a Problem
- Plugin Development 101 – Introduction to extending classes
In this first real part of the Plugin Development 101 tutorial series we look into what makes a plugin. How is a plugin different than any other .php file? How do you make WordPress recognize your code as a plugin?
A plugin in WordPress is really nothing more than a PHP file (or multiple PHP files) with a very specific piece of information included at the top of the file that has been placed in the wp-content/plugins/ folder.
There is no minimum or maximum for what a plugin can or must do. Plugins can be a single line of code, or 50,000 lines of code. Regardless of the size of a plugin, it is defined as a plugin in exactly the same way: by a piece of meta data placed in the main file.
At the top of every WordPress plugin is a comment block that contains information about the plugin:
- The name of the plugin
- A brief description of the plugin
- The URL of the plugin’s homepage
- The author of the plugin
- The author’s website
- The plugin version number
The meta data is always placed in a comment block, so like:
1 2 3 4 5 6 7 8 9 | <?php /* Plugin Name: Featured Comments Plugin URI: https://pippinsplugins.com/featured-comments Description: Lets the admin add "featured" or "buried" css class to selected comments. Handy to highlight comments that add value to your post. Also includes a Featured Comments widget Version: 1.2.1 Author: Pippin Williamson Author URI: https://pippinsplugins.com */ |
All but the Plugin name lines are optional. A plugin can be defined with just this:
1 2 3 4 | <?php /* Plugin Name: Featured Comments */ |
This comment block should only ever be placed in the main plugin file, if your plugin has more than one.
The simple presence of this code block is all that is needed for WordPress to recognize your code as a plugin.
We will go into how to organize your plugin code in one of the upcoming parts of this series, for now just remember that a plugin is nothing more than a .php file placed inside of wp-content/plugins that contains the comment block shown above.
Is it me or does this video not work…?
Works just fine for me. What browser are you on?
This vid ain’t playing on my ipad at least Crome or safari . First in series was fine.
Does it just load forever or give some kind of error?
The video container itself is there but on all the vids past the first one the vid container itself is really small and when you hit play it “media source loading has failed”. Back on my Mac everyhting is cool but iPad in Chrome and Safari same thing. iPad and apps all fully up to date.
I got this message “Warning: explode() expects parameter 2 to be string, array given in /nas/wp/www/cluster-1583/pippinsplugins/wp-content/plugins/restrict-content-pro/includes/shortcodes.php on line 27” on those pages as well, Ive never checked out your restrict content plugin
Dont know if that or just getting my membership yesterday has anything to do with it.
I’m aware of the issue. The site is running a beta version of the plugin. It will be fixed as soon as the update is finished.
Copy the Wade’s PHP warning. I’ve got it displayed too.
And the video just loads forever, but never actually play. I’ve checked console and no error in there. Any help on this? (Using Chrome on Win7)
The same story with video on Opera. On FireFox 21.0 even the play button doesn’t disappear – actually pressing it seems to be doing nothing…
Just this video or all of them?
I’ve tried now this way: I’ve opened all the parts of this series in new tab and let it be for a couple of minutes. Some videos are being loaded. I am on fairly slow internet connection, but I don’t have such delays on YouTube or Vimeo (I understand I can’t compare 😉 ). Just to let you know that loading is very slow.
Ok thanks. I’m considering moving the videos to Vimeo (or similar service).
I want to learn how to make plugins in WordPress, so I am looking forward to reading the series.I’m logged in but can not see the video’s and at the end of the article I get the message to login to see the rest.
I tried other subscriber only articles and some of them I can see just fine. I’m using FF.
What is your username?
My username is filip.leemans.
I can see Pippin’s logo but have no videa controls.
Sorry for the trouble. I’ve found the issue and fixed it.
Thanks
It looks like I still have the same problem. I can’t play the video’s when I am logged in.
I don’t know if it has anything to do with it but the first times I changed pages on the site I got following message:
blockUI requires jQuery v1.2.3 or later! You are using v1.10.2
Hope you can find what the error is.
Do you still see the error about needing to have an active subscription?
The BlockUI error was caused by WP 3.6 and should be resolved now (cached if not).
No, I am not asked to login or register anymore. I can see the whole articles now.
But I still can not see the video’s, just your logo when i am logged in.
I will look into it. Sorry for the trouble.
Also for the video I am not asked to log in, so that is OK. The logo and the play icon is shown but when I click it nothing happens. Also right mouse button doesn’t do anything. I tried FF and IE.
IT doesn’t do anything when logged in or when logged out?
I am logged in and can see the article but when I click on the play icon nothing happens.
I took a screenshot with html code: http://screencloud.net/v/bhGG
Does Chrome work?
I can’t seem to replicate the problem . . .
I installed Chrome and everything works.
So with Chrome I have no problems and I can also watch the video’s.
Thanks.
That’s good to know! I’ll look into FireFox and the other browsers.
Hey Pippin, very good info. I’m starting to learn Plugin dev and I’m glad I found your tutorials because I know all your stuff are quality!
However I seem to be having real issues with the video, just like others have stated in their comments. My internet is pretty fast, so I know that’s not the issue. I’m guessing it’s the video player you’re using. The looooong delays are ruining the whole experience and as well as your brand 🙁
I’m trying to get the videos moved over to a better system really soon, sorry for the trouble.
I love your tutorial style. I’m an experienced WordPress user, but haven’t done an development. The biggest problem with most tutorials is that they forget that when starting anything new, you have no idea what is important and what is not.
The way you clearly break down everything from the beginning into simple steps and show how each thing you do changes inside WordPress, really makes things clear.
Thanks for these great tutorials. I look forward to the rest of them.
Glad to hear it!