Changeset 32899 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 06/21/2015 10:00:42 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/formatting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r32897 r32899 3063 3063 3064 3064 /** 3065 * Formats text for the rich text editor. 3066 * 3067 * The filter 'richedit_pre' is applied here. If $text is empty the filter will 3068 * be applied to an empty string. 3069 * 3070 * @since 2.0.0 3065 * Formats text for the editor. 3066 * 3067 * Generally the browsers treat everything inside a textarea as text, but 3068 * it is still a good idea to HTML entity encode `<`, `>` and `&` in the content. 3069 * 3070 * The filter 'format_for_editor' is applied here. If $text is empty the filter will 3071 * be applied to an empty string. 3072 * 3073 * @since 4.3.0 3071 3074 * 3072 3075 * @param string $text The text to be formatted. 3073 * @return string The formatted text after filter is applied. 3074 */ 3075 function wp_richedit_pre( $text ) { 3076 if ( empty( $text ) ) { 3077 /** 3078 * Filter text returned for the rich text editor. 3079 * 3080 * This filter is first evaluated, and the value returned, if an empty string 3081 * is passed to wp_richedit_pre(). If an empty string is passed, it results 3082 * in a break tag and line feed. 3083 * 3084 * If a non-empty string is passed, the filter is evaluated on the wp_richedit_pre() 3085 * return after being formatted. 3086 * 3087 * @since 2.0.0 3088 * 3089 * @param string $output Text for the rich text editor. 3090 */ 3091 return apply_filters( 'richedit_pre', '' ); 3092 } 3093 3094 $output = convert_chars($text); 3095 $output = wpautop($output); 3096 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); 3097 3098 /** This filter is documented in wp-includes/formatting.php */ 3099 return apply_filters( 'richedit_pre', $output ); 3100 } 3101 3102 /** 3103 * Formats text for the HTML editor. 3104 * 3105 * Unless $output is empty it will pass through htmlspecialchars before the 3106 * 'htmledit_pre' filter is applied. 3107 * 3108 * @since 2.5.0 3109 * 3110 * @param string $output The text to be formatted. 3111 * @return string Formatted text after filter applied. 3112 */ 3113 function wp_htmledit_pre( $output ) { 3114 if ( !empty($output) ) 3115 $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & 3076 * @return string The formatted text after filter is applied. <? 3077 */ 3078 function format_for_editor( $text, $default_editor = null ) { 3079 // Back-compat: check if any characters need encoding. 3080 if ( ! empty( $text ) && ( false !== strpos( $text, '<' ) || false !== strpos( $text, '>' ) || 3081 preg_match( '/&(?!#(?:\d+|x[a-f0-9]+);|[a-z1-4]{1,8};)/i', $text ) ) ) { 3082 3083 $text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) ); 3084 } 3116 3085 3117 3086 /** 3118 * Filter the text before it is formatted for the HTMLeditor.3119 * 3120 * @since 2.5.03121 * 3122 * @param string $ output The HTML-formatted text.3087 * Filter the text after it is formatted for the editor. 3088 * 3089 * @since 4.3.0 3090 * 3091 * @param string $text The formatted text. 3123 3092 */ 3124 return apply_filters( ' htmledit_pre', $output);3093 return apply_filters( 'format_for_editor', $text, $default_editor ); 3125 3094 } 3126 3095
Note: See TracChangeset
for help on using the changeset viewer.