Table of Contents
‘cooked_format_author_name’
This filter lets you customize the display of the recipe author’s name throughout the Cooked plugin. Use it to modify, format, or add markup to the author name before it is shown.
Parameters #
$name
(string): The original author name.$format
(string): The requested format (‘full’, ‘first_last_initial’, ‘first_initial_last’, ‘first_only’).
Return (Required) #
You must return an array with two elements: [ $custom_name, $is_safe_html ]
$custom_name
(string): The new author name (can include HTML).$is_safe_html
(bool): Set to true if your output is already properly escaped and safe HTML, or false if it should be escaped by the plugin usingesc_html
.
Example:
- Apply to your plugins plugin.php or themes functions.php.
add_filter( 'cooked_format_author_name', function( $name, $format ) {
// Safe HTML output
$custom = '<span class=\"author-name\">' . esc_html( $name ) . ' <span class=\"emoji\">👨🍳</span></span>';
return [ $custom, true ];
}, 10, 2 );
Tip: Return an array with true as the second value if your output contains HTML and is already properly escaped.