The Word Press code X is a great place to see a comprehensive(综合的) list of
all the Word Press actions and filters.
So let's jump into the browser and
see what we're working with in terms(术语) of native Word Press hooks.
One of the simplest ways to get a full list of all of
the Word Press filters is simply to search Google for Word Press, filters.
You may even see a customized result box come up, but the link that you're
looking for should have plug in API, and then filter reference(参考).
This page starts off with some general(一般) information about the plug in API and
writing a plug in,
as well as a link to a full database output of all the hooks available.
If we come down the page a little bit, we could see that the filters are broken up
into different sections that relate to post filters, comment-related filters,
categories, links, date and time and author, as well as a number of other ones.
What you'll notice as you begin to look through this list,
is that a lot of filters are applied to template tags that you
would recognize from theme development.
We can see that some filters apply when we're reading from the database and
then some filters are going to apply when we're writing to the database, again,
filters work with data that's either being pulled from the database and
before it's displayed to the browser or possibly the other way around.
It's important that after this video you take the time to really scroll through
this page and look at some of these filters that are available.
Some of them, you may not understand or know what they do,
however, some of them, like excerpt and things related to getting pages,
should sort of make sense from other work that you've done in WordPress.
[BLANK_AUDIO]
As we scroll through the page, we'll see the different sections where we
can see filters that apply to different things.
For example, in this case, the comment filters.
We have filters that relate to the categories, link filters,
date and time filters, author filters,
as well as ones that relate to general information about the site-
[BLANK_AUDIO]
general text filters and then some helpful ones for the admin side as well.
Like I said, it's important that you take the time to at
least read through this list and try to get an idea of what makes sense to you and
what you see that is familiar.
Filters again can let you take this data that you
would commonly be exporting out or using in your template for
example, and let you apply your own code in customization quickly from
something like the functions.php file which we'll look at later.
If we wanted to look at all of the actions that are available,
we could simple search for WordPress actions, see a similar result, and
look for the Plugin API Action Reference URL.
Now actions are a little bit different in that instead of allowing us to
manipulate data before or after it comes from the database or the browser.
In this case, we're getting access to run our code at a certain point while
WordPress is building out the actual page or the admin area.
So if we take a look at how these are organized, we could see that it
gives us actions that are run during a typical request of building out a page,
as well as actions that are run when building out an admin page.
It then has similar sections to filters, except instead of manipulating the data,
we'd be running our own actions or code at those different points.
As we scroll down here, we can see from a very beginning all of the actions that
take place as WordPress is firing up, figuring out what's going on,
running its initialization, building out things like what side bar's being used,
the admin bar that's displaying, and then we can see that we reach a point at
WP loaded where word press is fully loaded and then it's going to begin echoing out
the actual page sending headers, pulling together the WP object, getting
the header in queuing scripts which you should recognize from loading your CSS,
the wp_head output, then getting into the actual post and the loop,
outputting sidebars, the footer, and then finally, the very end of the process.
It then runs through the actions that would happen when building out an admin
page, which can be slightly different, although you'll see some of the same
things, however, in this case we'll see more hooks that have admin in them, and
pertain more to setting up what's needed for authentication and access and
building out admin pages and viewing content that way.
However, at a certain point it will begin to pull in poster other data that it
needs to display.
The rest of the page goes through all of the different actions that you
would find in relation to these different categories or sections.
For example, we could see when a post is being edited, when it's being deleted,
when it's being published or saved, and we could run our own code at those points.
Also getting access to whatever data WordPress has at that point.
Going through comments, the feed, templates, admin
actions, and then finally some advanced ones at the end.
As I said before with filters, it's important that you take a few minutes, or
longer if it interests you, and go through and look at each one of these.
If you see one that you're interested in but it's in red, that means that
there's currently no page in the Codex that gives information about it.
However, at the time of writing, WordPress is working on a new code reference and
you can take whatever it is that you're looking for
here, come over to the new code reference,
[BLANK_AUDIO]
and search for it there.
Find that it's the hook that you're looking for, and
then click through to find out more information.
We can see that here, it's telling us that this hook has been deprecated and
we shouldn't be using it, and we could look for this one instead.
At the point of writing this, the developer resources at developer.org
does have a few more hooks documented, in fact quite a few more hooks documented.
However, it doesn't currently have the same generic pages that let us easily see
the different categories and groupings of different actions and filters.
For that reason, the codex action reference and filter reference
is still a good general resource, however, if you come to things
like widgets init for example we can come over to the new code reference,
[BLANK_AUDIO]
search for widgets in it and find out more information about it here.
So for the time being you may need to bounce between these two in order to
find out more information on all of the different actions and
filters, however, this is a great start in resource for finding more about these.
In then next view videos, we're going to look at some other ways in
which you could also access this same information in some different formats.