WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/content save pre

Description

The "content_save_pre" filter is part of a group of dynamic filters that allow you to sanitize content prior to saving it in the database. This filter runs in wp-admin.

Usage

The 'content_save_pre' filter will get on

function my_filter_function_name( $content ) {
  // Process content here
  return $content;
}

add_filter( 'content_save_pre', 'my_filter_function_name', 10, 1 );

Note that the filter function must return a string after it is finished processing or the content will be empty.

Examples

Removes undesirable carriage return character

function my_sanitize_content( $content ) {
    return str_replace( "\r<figcaption>", "<figcaption>", $content );
}
add_filter( 'content_save_pre' , 'my_sanitize_content' , 10, 1);

Source File

sanitize_post_field() is located in wp-includes/post.php.

See Also