_restore_wpautop_hook

函式
_restore_wpautop_hook ( $content )
Access
Private
引數
  • (string) $content The post content running through this filter.
    Required:
返回值
  • (string) The unmodified content.
定義位置
相關方法
_future_post_hookregister_activation_hook_save_post_hookregister_deactivation_hookrestore_current_blog
引入
5.0.0
棄用
-

_restore_wpautop_hook: 這個函式在原wpautop函式被外掛或主題修改後將其恢復到預設狀態。

如果do_blocks()需要從`the_content`過濾器中移除wpautop(),這將在之後重新新增它。以供後續的`the_content’使用。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _restore_wpautop_hook( $content ) {
$current_priority = has_filter( 'the_content', '_restore_wpautop_hook' );
add_filter( 'the_content', 'wpautop', $current_priority - 1 );
remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority );
return $content;
}
function _restore_wpautop_hook( $content ) { $current_priority = has_filter( 'the_content', '_restore_wpautop_hook' ); add_filter( 'the_content', 'wpautop', $current_priority - 1 ); remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority ); return $content; }
function _restore_wpautop_hook( $content ) {
	$current_priority = has_filter( 'the_content', '_restore_wpautop_hook' );

	add_filter( 'the_content', 'wpautop', $current_priority - 1 );
	remove_filter( 'the_content', '_restore_wpautop_hook', $current_priority );

	return $content;
}

常見問題

FAQs
檢視更多 >