format_to_edit
Acts on text which is about to be edited.
Description
The $content
is run through esc_textarea(…)
, which uses htmlspecialchars(…) to convert special characters to HTML entities. If $richedit
is set to true, it is simply a holder for the filter.
Returns (string)
The text after the filter (and possibly htmlspecialchars()) has been run.
Parameters (2)
- 0. $content (string)
- The text about to be edited.
- 1. $rich_text — Optional. (bool) =>
false
- Whether
$content
should be considered rich text, in which case it would not be passed throughesc_textarea(…)
. Default false.
Usage
if ( !function_exists( 'format_to_edit' ) ) { require_once ABSPATH . WPINC . '/formatting.php'; } // The text about to be edited. $content = ''; $rich_text = false; // NOTICE! Understand what this does before running. $result = format_to_edit($content, $rich_text);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/formatting.php
- function format_to_edit( $content, $rich_text = false ) {
- /**
- * Filters the text to be formatted for editing.
- *
- * @since 1.2.0
- *
- * @param string $content The text, prior to formatting for editing.
- */
- $content = apply_filters( 'format_to_edit', $content );
- if ( ! $rich_text )
- $content = esc_textarea( $content );
- return $content;
- }