Plugin hooks can be used to alter the plugin functionality or output without directly editing the plugin files (you should not do that, as those changes will get overwritten on update). This is for advanced users who are comfortable with PHP only.
Block Shortcode Hooks
Block shortcodes are used in our Modern Templates to output different parts of the recipe. All of these have a plugin hook to filter the attributes and one to filter the output.
Filter Block Shortcodes Attributes
Filter what’s used as the shortcode attributes using the shortcode_atts_%wprm_shortcode_with_underscores% hook. For example:
function recipe_name_attributes( $attributes ) {
return $attributes;
}
add_filter( 'shortcode_atts_wprm_recipe_name', 'recipe_name_attributes' );
Filter Block Shortcodes Output
Filter what a block shortcode outputs using the %wprm_shortcode_with_underscores%_shortcode hook. For example:
function recipe_name_output( $output, $attributes, $recipe ) {
return $output;
}
add_filter( 'wprm_recipe_name_shortcode', 'recipe_name_output', 10, 3 );
Take note: for general blocks the $recipe variable will not be set.
Other Plugin Hooks
This table lists all other available plugin hooks:
Hook | Attributes | Description |
---|---|---|
wprm_recipe_submission_approve_add_post | $post, $recipe_id | Adjust what’s passed to wp_insert_post() for the parent post when using the “Approve and add recipe submission to post” option |
wprm_nutrition_ingredient_taxonomy | $args | Arguments used to create the wprm_nutrition_ingredient taxonomy |
wprm_custom_css | $output, $type, $selector | Hook into the custom CSS that gets output to the <head> |
wprm_template_comment_rating | $template | Template for the rating inside a comment |
wprm_template_comment_rating_form | $template | Template for the comment rating form |
wprm_recipe_metadata | $metadata, $recipe | JSON-LD metadata for a recipe |
wprm_recipe_post_type_arguments | $args | Arguments for the WPRM_POST_TYPE register_post_type() |
wprm_parse_ingredient_units | $units | Units recognized when parsing ingredients |
wprm_recipe_taxonomies | $taxonomies | Taxonomies to register with their labels |
wprm_get_template | $output, $recipe, $type, $slug | Output for a recipe |
wprm_recipe_shortcode_output | $output, $recipe, $type, $slug | The entire shortcode output |
wprm_recipe_rating_star_icon | $icon | What to use for the empty star rating icon |
wprm_comment_rating_star_full_icon | $icon | What to use for the full star rating icon |