Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



format_for_editor ›

Od4.3.0
Przestarzałyn/a
format_for_editor ( $text, $default_editor = null )
Parametry: (2)
  • (string) $text The text to be formatted.
    Wymagane: Tak
  • (string) $default_editor The default editor for the current user. It is usually either 'html' or 'tinymce'.
    Wymagane: Nie
    Domyślny: null
Zobacz:
  • _WP_Editors::editor()
Powrót:
  • (string) The formatted text after filter is applied.
Zdefiniowane na:
Codex:

Formats text for the editor.

Generally the browsers treat everything inside a textarea as text, but it is still a good idea to HTML entity encode </code>, > and & in the content.

The filter {@see 'format_for_editor'} is applied here. If $text is empty the filter will be applied to an empty string.



Źródło

function format_for_editor( $text, $default_editor = null ) {
	if ( $text ) {
		$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
	}

	/**
	 * Filters the text after it is formatted for the editor.
	 *
	 * @since 4.3.0
	 *
	 * @param string $text           The formatted text.
	 * @param string $default_editor The default editor for the current user.
	 *                               It is usually either 'html' or 'tinymce'.
	 */
	return apply_filters( 'format_for_editor', $text, $default_editor );
}