_wp_filter_post_meta_footnotes

函数
_wp_filter_post_meta_footnotes ( $footnotes )
Access
Private
参数
  • (string) $footnotes JSON encoded string of an array containing the content and ID of each footnote.
    Required:
返回值
  • (string) Filtered content without any HTML on the footnote content and with the sanitized id.
定义位置
相关方法
wp_filter_post_kses_wp_delete_post_menu_itemwp_filter_out_block_nodeswp_filter_comment_wp_filter_taxonomy_base
引入
6.3.2
弃用
-

删除脚注内容中的所有 HTML 代码,并对 ID 进行净化。

该函数希望脚注内容中出现斜线数据。

function _wp_filter_post_meta_footnotes( $footnotes ) {
	$footnotes_decoded = json_decode( $footnotes, true );
	if ( ! is_array( $footnotes_decoded ) ) {
		return '';
	}
	$footnotes_sanitized = array();
	foreach ( $footnotes_decoded as $footnote ) {
		if ( ! empty( $footnote['content'] ) && ! empty( $footnote['id'] ) ) {
			$footnotes_sanitized[] = array(
				'id'      => sanitize_key( $footnote['id'] ),
				'content' => wp_unslash( wp_filter_post_kses( wp_slash( $footnote['content'] ) ) ),
			);
		}
	}
	return wp_json_encode( $footnotes_sanitized );
}

常见问题

FAQs
查看更多 >