-
Book Overview & Buying
-
Table Of Contents
WordPress Plugin Development: Beginner's Guide
By :
Our plugin now works fine, but there is a problem. In order to use it, we also have to edit the theme. This can be a real pain for all sorts of reasons:
If you want to change to a different theme, the plugin will stop working until you edit the new theme.
If you want to distribute your plugin to other people, they can't just install it and activate it; they have to change their theme files too.
If you change the function name, you need to alter the theme files again
We need some way to make the plugin work on its own, without the users having to change their themes or anything else.
Hooks come to the rescue, making it possible to display our Digg This button in our posts—without ever modifying our theme.
We will use the the_content filter hook to automatically add our Digg This link to the end of the post content. This will avoid the need for the users to edit their theme files if they want to use our plugin.
Create a function that...
Change the font size
Change margin width
Change background colour