Would like to see filters and actions documented
-
The plugin works well and seems to be well structured. It would be great if the filters and actions were documented in-line using the WP code standards for documentation. That would make it more likely for developers looking to integrate to be able to use the plugin easily.
For example, in wp-document-revisions.php around line 950 (in the current version I’m looking at) where you apply
serve_document_auth
://note: authentication is happeneing via a hook here to allow shortcircuiting if ( ! apply_filters( 'serve_document_auth', true, $post, $version ) ) { //...code continues here.
Using WP standards for inline documentation, that would look (somewhat) like this:
/** * Filter the authentication (or whatever). * * @since Unknown * * @param boolean $auth Short desc of $auth. * @param object $post Short desc of $post. * @param string $version Short desc of $version. */ $auth = apply_filters( 'serve_document_auth', true, $post, $version ); if ( ! $auth ) { //...code continues here.
Inline documentation helps users who are looking to integrate your plugin into their applications. Anywhere there’s an
apply_filters()
ordo_action()
should be documented, unless it’s already documented somewhere else in the plugin, in which case it should be noted:/** This filter is documented in path/to/filename.php */
Ideally, you’d use a unique stem (like ‘wpdr_’) at the beginning the hook name so it’s clear it’s not a WP hook and what it belongs to. That also avoids namespace collisions. That’s just nitpicking and this plugin is probably too far along in the lifecycle to change; but it’s something to consider in the future.
Since I’m nitpicking now, the last suggestion would be that ideally you wouldn’t bury the hook. Instead, separate it out so it’s easy to understand for others. For example:
if ( !class_exists( 'EF_Custom_Status' ) || !apply_filters( 'document_revisions_use_edit_flow', true ) )
This hides the hook. Instead, apply it separately to a variable, then use the variable in the logic. That makes it easier for others to (1) see the hook and (2) understand what’s going on.
The plugin works well. These are just suggestions to make things better – specifically in terms of wider adaptation by other developers. There’s no rule that says you have to do this, but following WP standards makes it easier for others to use your hooks.
- The topic ‘Would like to see filters and actions documented’ is closed to new replies.