Central list of Action/Filter hooks in PB


#1

In the PB Community call on 7 Jan, 2019, I asked if we yet had a running list of action and filter hooks that can be utilized by other plugins seeking to add to PB’s core functionality. @ned responded and said that it’s something we’ve wanted for a long time, but hasn’t gotten around to yet.

This is a follow up for that conversation. It sounds like there’s a WP plugin and/or tool that can be used to search the PB codebase for action/filter hooks that might make this job a touch less manual? Is that true Ned?

Also, where were you considering this list should live? I was thinking a good place for it might be at https://docs.pressbooks.org under the “Developer Guides” dropdown nav menu. Are there other places that might be better?

Cheers!

Bryan


#2

Hey @bryan! This was the tool I found: https://github.com/WordPress/phpdoc-parser

It kinda works— it scans PHP source files for properly formatted PHPDoc documentation blocks for functions/methods/filters/hooks and creates custom post types in a WordPress install. It’s highly customized for WordPress.org so pulling it apart a bit would probably yield some results. I’ve never had a chance to do much with it. A few issues I ran into right away were that it requires the WordPress theme/plugins for WordPress.org to support the custom post types, and it doesn’t link to the correct source code (obviously, because we are not running it against WordPress core).


#3

try Doxygen documentaton.

one example: https://www.dropbox.com/s/ox0vpfqska0vz9n/html.zip?dl=0


#4

That looks like another possible path forward. Thank you. :slight_smile:


#5

One caveat regarding @colomet’s suggestion is that it will only handle function and method documentation. The code I linked to handles documentation blocks for actions and filters, which are a WordPress-specific thing and I think the key info you were looking for, @bryan.


#6

Yep this is great. I will work toward tinkering with this and phpdoc-parser once I can get a local instance of PB stood up.

@ned, where do you want me to put the list if/when I’m able to get that generated?


#7

Use PhpStorm?

image

image

PhpStorm provides full coding assistance for developing WordPress including WordPress-aware code completion, search for hook registration functions and functions specified as hook registration parameters, navigation between hook registrations and the hook invocations, callbacks, the possibility to configure the coding style in accordance with the WordPress code style, viewing the official WordPress documentation from the PhpStorm editor, etc.

More info:
https://www.jetbrains.com/help/phpstorm/using-wordpress-content-management-system.html


#8

@bryan If you end up using the phpdoc-parser method I think it’ll generate custom post types in a WordPress install— if you succeed in doing that locally, maybe we can look into adding them to docs.pressbooks.org?


#9

That definitely works — I think there’s a benefit to having them publicly documented as well.


#10

@dac.chartrand, that’s rad! thank you. I’ve been meaning to move over to Jetbrains IDEs…it’s been a long time coming, but still most comfy with lighter editors. I think I have a license for phpstorm floating around though, so I’ll circle back on that and give it a whirl.


#11

I think I am going to move forward with the phpdoc-parser tinkering method just because I’m curious and wanna play around with it a bit. Regardless, happy to add it to docs.pressbooks.org. To clarify, would that be a PR to this repo?


#12

So— my thinking is if you can figure out a way to generate the content using that tool, I can figure out how to pull that data into the existing site. I would say probably not a PR to that docs repo as that only syncs pages right now and phpdoc-parser uses custom post types. We could probably automate it somehow so that it happens on new releases, but let’s cross that bridge when we get there!


#13

Alright, I’ve compiled a list of actions/filters available in PB. Because I couldn’t get a local pressbooks-dev env spun up, I went ahead and dug up my PhpStorm license (thanks again for the reminder @dac.chartrand), and just used that.

I’ve included deprecated hooks and hooks that don’t have doc blocks on them (listed under “Unknown Status Hooks”) and emailed the list to @ned since it wouldn’t let me upload the file here.

Let me know if anything else is needed. Cheers!