This document discusses extending WordPress through plugins. It advises not to hack the WordPress core files and instead use plugins to add new functionality. Plugins can use hooks called actions and filters to modify WordPress behavior at certain points. Actions allow plugins to execute functions at specific times, while filters allow modifying text before it is saved or output. The document provides examples of actions and filters and best practices for plugin development like using unique names and coding standards. It also briefly introduces the Transient API and WP Events.
11. Extending WP
Plugins
“Plugins are tools to extend the
functionality of WordPress. The core of
WordPress is designed to be lean, to
maximize flexibility and minimize code
bloat. Plugins offer custom functions
and features so that each user can tailor
their site to their specific needs.”
21. Extending WP
Actions
“Actions are the hooks that the WordPress
core launches at specific points during
execution, or when specific events occur.
Your plugin can specify that one or more of
its PHP functions are executed at these
points, using the Action API.”
22. Extending WP
Actions
hook_name = name of action hook
your_function_name = name of function you have defined
to be executed following the specified action hook
priority (optional) = an integer that can be used to specify
the order of action hooks. (default: 10)
accepted_args (optional) = how many arguments your
function takes
26. Filters
Extending WP
“Filters are the hooks that WordPress
launches to modify text of various types
before adding it to the database or sending
it to the browser screen. Your plugin can
specify that one or more of its PHP
functions is executed to modify specific
types of text at these times, using the Filter
API.”
27. Extending WP
Filters
tag = name of filter hook
your_function_name = name of function you have defined
to be apply filter
priority (optional) = an integer that can be used to specify
the order of filter hooks. (default: 10)
accepted_args (optional) = how many arguments your
function takes
30. Extending WP
From WP.org...
Follow Coding Standards.
Use Unique Names.
Don’t hardcode DB prefixes but use $wpdb->prefix
instead. (ie. wp_)
SELECT only what you need.
Add define('WP_DEBUG', true); to your wp-config.php
file.