Datasheet

10
CHAPTER 1 AN INTRODUCTION TO PLUGINS
The last four drop - in plugins are speci c to the WordPress Multisite feature. A standard WordPress
installation will have no use for these plugins.
When developing a new plugin, determine what type of plugin you want to create before you start
the development process. Most plugins will be standard WordPress plugins, but occasionally you
might need to create a Must - Use or Drop - in specifi c plugin.
Testing Plugin Functionality
On occasion you may want to test some plugin functionality without actually creating a plugin to
do so. Many developers will place code directly in the
wp - config.php le to do so. This is a bad
technique and should not be used because when the con g fi le is parsed and loaded, WordPress is
not wholly instantiated yet.
Instead of hacking
wp - config.php , make a test.php le with the following code snippet and place
it in your WordPress root directory:
< ?php
// Load the WordPress Environment
// define( ‘WP_DEBUG’, true ); /* uncomment for debug mode */
require(‘./wp-load.php’);
// require_once (‘./wp-admin/admin.php’); /* uncomment for is_admin() */
? >
< pre >
< ?php
/* test stuff here */
var_dump( is_admin() );
? >
< /pre >
Code snippet test.php
This is a quick way to load all of the required WordPress functions to test plugin functionality
without actually creating a plugin. As you can see
wp - load.php is included at the beginning of
the fi le. You can also include
wp - admin/admin.php if you want to test admin side functionality.
Once you have included the required WordPress core fi les, you want test any code that would
otherwise exist reside in your plugin. Don t forget to remove your
test.php le when you are
done testing.
SUMMARY
In this chapter you learned what about plugins and how they can interact with WordPress using
the available APIs. The major advantages to using plugins and why plugin functionality shouldn t
always be included in a theme was discussed. Installing and managing plugins in the WordPress
admin dashboard was covered.
Now that you understand how plugins work in WordPress, it s time to create the plugin foundation!
CH001.indd 10CH001.indd 10 2/4/11 4:34:05 PM2/4/11 4:34:05 PM