On this page
format_to_edit( string $content, bool $rich_text = false ): string
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 ‘format_to_edit’ filter.
Parameters
$contentstring Required-
The text about to be edited.
$rich_textbool Optional-
Whether
$contentshould be considered rich text, in which case it would not be passed through esc_textarea() .
Default:
false
Return
string The text after the filter (and possibly htmlspecialchars()) has been run.
Source
File: wp-includes/formatting.php. View all references
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;
}
Hooks
- apply_filters( 'format_to_edit',
string $content ) -
Filters the text to be formatted for editing.
Related
Uses
| Uses | Description |
|---|---|
| esc_textarea() wp-includes/formatting.php | Escaping for textarea values. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| edit_form_image_editor() wp-admin/includes/media.php | Displays the image and editor in the post editor |
| get_comment_to_edit() wp-admin/includes/comment.php | Returns a WP_Comment object based on comment ID. |
| sanitize_post_field() wp-includes/post.php | Sanitizes a post field based on context. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/format_to_edit