Title: wp_richedit_pre
Published: April 25, 2014
Last modified: April 28, 2025

---

# wp_richedit_pre( string $text ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#wp--skip-link--target)

This function has been deprecated since 4.3.0. Use [format_for_editor()](https://developer.wordpress.org/reference/functions/format_for_editor/)
instead.

Formats text for the rich text editor.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#description)󠁿

The [‘richedit_pre’](https://developer.wordpress.org/reference/hooks/richedit_pre/)
filter is applied here. If `$text` is empty the filter will be applied to an empty
string.

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#see-also)󠁿

 * [format_for_editor()](https://developer.wordpress.org/reference/functions/format_for_editor/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#parameters)󠁿

 `$text`stringrequired

The text to be formatted.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#return)󠁿

 string The formatted text after filter is applied.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#source)󠁿

    ```php
    function wp_richedit_pre($text) {
    	_deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' );

    	if ( empty( $text ) ) {
    		/**
    		 * Filters text returned for the rich text editor.
    		 *
    		 * This filter is first evaluated, and the value returned, if an empty string
    		 * is passed to wp_richedit_pre(). If an empty string is passed, it results
    		 * in a break tag and line feed.
    		 *
    		 * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre()
    		 * return after being formatted.
    		 *
    		 * @since 2.0.0
    		 * @deprecated 4.3.0
    		 *
    		 * @param string $output Text for the rich text editor.
    		 */
    		return apply_filters( 'richedit_pre', '' );
    	}

    	$output = convert_chars($text);
    	$output = wpautop($output);
    	$output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) );

    	/** This filter is documented in wp-includes/deprecated.php */
    	return apply_filters( 'richedit_pre', $output );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/deprecated.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/deprecated.php#L3581)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/deprecated.php#L3581-L3609)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#hooks)󠁿

 [apply_filters( ‘richedit_pre’, string $output )](https://developer.wordpress.org/reference/hooks/richedit_pre/)

Filters text returned for the rich text editor.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#related)󠁿

| Uses | Description | 
| [convert_chars()](https://developer.wordpress.org/reference/functions/convert_chars/)`wp-includes/formatting.php` |

Converts lone & characters into `&#038;` (a.k.a. `&amp;`)

  | 
| [wpautop()](https://developer.wordpress.org/reference/functions/wpautop/)`wp-includes/formatting.php` |

Replaces double line breaks with paragraph elements.

  | 
| [_deprecated_function()](https://developer.wordpress.org/reference/functions/_deprecated_function/)`wp-includes/functions.php` |

Marks a function as deprecated and inform when it has been used.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_richedit_pre/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.3.0](https://developer.wordpress.org/reference/since/4.3.0/) | Deprecated. Use [format_for_editor()](https://developer.wordpress.org/reference/functions/format_for_editor/)  | 
| [2.0.0](https://developer.wordpress.org/reference/since/2.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_richedit_pre%2F)
before being able to contribute a note or feedback.