with one click
add-hook
Add a WordPress action or filter hook to a plugin or theme.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Add a WordPress action or filter hook to a plugin or theme.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Add a WordPress AJAX handler to a plugin, with nonce verification, input sanitisation, and JSON response.
Register a block pattern in a theme or plugin, using the WordPress 6.0+ file-based pattern system.
Add a new Gutenberg block to an existing plugin or theme.
Register a WP-CLI command in a plugin using a command class, following Dekode conventions.
Scaffold a new must-use plugin in packages/mu-plugins/ - either a simple utility or a service-class integration.
Register a custom post type (and optionally a taxonomy) in a theme or plugin, following Dekode conventions.
| name | add-hook |
| description | Add a WordPress action or filter hook to a plugin or theme. |
| allowedDomains | ["wordpress.org","developer.wordpress.org"] |
Add a properly structured WordPress action or filter to the correct class in an existing package.
Ask the user:
add_action or add_filter?save_post, the_content) or a custom hook (e.g. dekodeinteraktiv/plugin/after_save).packages/?Search the target package for:
hooks() method — this is the right place.src/.src/Frontend/ContentModifier.php).hooks()public function hooks(): void {
// ... existing hooks ...
add_filter( 'the_content', [ $this, 'modify_content' ], 20 );
}
Priority guidelines:
10 — default, use when order doesn't matter.< 10 — must run before core/other plugins.> 10 — must run after core/other plugins.PHP_INT_MAX — must run absolutely last (e.g. final output sanitisation).Filter example:
/**
* Modifies the post content.
*
* @param string $content The original post content.
* @return string The modified content.
*/
public function modify_content( string $content ): string {
if ( ! is_singular( 'post' ) ) {
return $content;
}
// ... apply transformation ...
return $content;
}
Action example:
/**
* Fires after a post is saved.
*
* @param int $post_id Post ID.
* @param \WP_Post $post Post object.
* @param bool $update Whether this is an update.
*/
public function after_post_save( int $post_id, \WP_Post $post, bool $update ): void {
if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) ) {
return;
}
// ... do the work ...
}
When dispatching your own hook (so other code can extend it):
// Action
do_action( 'dekodeinteraktiv/plugin/after_item_created', $item_id, $item_data );
// Filter
$value = apply_filters( 'dekodeinteraktiv/plugin/item_title', $title, $item_id );
Rules:
<org>/<plugin-slug>/ to guarantee uniqueness.do_action / apply_filters.composer lint
composer lint-fix # if needed
composer lint # re-run to confirm clean