This filter is run on each final book value after the placeholder has been swapped out for the actual value and after any line breaks have been added.
The filter accepts five parameters:
- $final_value – The final value of the field, with the value inserted into the template.
- $key – Current key being modified (ie “title”, “publisher”, etc.).
- $all_fields – Array of all available book fields.
- $enabled_fields – Array of only the fields that are enabled. $enabled_fields[ $key ] contains an array of keys including ‘label’ (template entered in Book Layout page), ‘placeholder’, and ‘linebreak’.
Here’s an example from the Novelist plugin, where some fields are given paragraph tags:
/** * Auto add paragraph tags * * @param string $value Final formatted value * @param string $key The key that is being filtered * @param array $all_fields All available book fields * @param array $enabled_fields Only the fields that are enabled * @param Novelist_Book $book Book object * * @since 1.0.0 * @return string */ function novelist_wpautop_field( $value, $key, $all_fields, $enabled_fields, $book ) { return wpautop( $value ); } add_filter( 'novelist/book/render/extra_text', 'novelist_wpautop_field', 10, 5 ); add_filter( 'novelist/book/render/synopsis', 'novelist_wpautop_field', 10, 5 );