format_to_edit

Acts on text which is about to be edited.

Description

(string) format_to_edit( (string) $content, (bool) $rich_text = false ); 

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 through esc_textarea(). Default false.

Usage

  1. if ( !function_exists( 'format_to_edit' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The text about to be edited. 
  5. $content = ''; 
  6. $rich_text = false; 
  7.  
  8. // NOTICE! Understand what this does before running. 
  9. $result = format_to_edit($content, $rich_text); 
  10.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/formatting.php  
  1. function format_to_edit( $content, $rich_text = false ) { 
  2. /** 
  3. * Filters the text to be formatted for editing. 
  4. * @since 1.2.0 
  5. * @param string $content The text, prior to formatting for editing. 
  6. */ 
  7. $content = apply_filters( 'format_to_edit', $content ); 
  8. if ( ! $rich_text ) 
  9. $content = esc_textarea( $content ); 
  10. return $content;