novelist/book/render/$key

⌘K
  1. Home
  2. Developers
  3. Filters
  4. novelist/book/render/$key

novelist/book/render/$key

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:

  1. $final_value – The final value of the field, with the value inserted into the template.
  2. $key – Current key being modified (ie “title”, “publisher”, etc.).
  3. $all_fields – Array of all available book fields.
  4. $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 );
Was this article helpful to you? No Yes

How can we help?