format_to_edit

函式
format_to_edit ( $content, $rich_text = false )
引數
  • (string) $content The text about to be edited.
    Required:
  • (bool) $rich_text Optional. Whether `$content` should be considered rich text, in which case it would not be passed through esc_textarea(). Default false.
    Required:
    Default: false
返回值
  • (string) The text after the filter (and possibly htmlspecialchars()) has been run.
定義位置
相關方法
format_for_editorformat_to_postload_image_to_editget_term_to_editget_post_to_edit
引入
0.71
棄用
-

format_to_edit: 這個函式用來格式化文字以便在WordPress編輯器中顯示。它將某些HTML實體轉換為它們相應的字元。

對即將被編輯的文字採取行動。

$content通過esc_textarea()執行,它使用htmlspecialchars()將特殊字元轉換成HTML實體。如果`$richedit`被設定為true,它只是{@see ‘format_to_edit’}過濾器的持有者。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >