wp_kses_post( string $data ): string
- Since
- 2.9.0
- Source
wp-includes/kses.php:2502
Description
Post content refers to the page contents of the 'post' type and not $_POST data from forms.
This function expects unslashed data.
Compatibility
- WordPress
- since 2.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$datastring- Post content to filter.
Return value
string- Filtered post content with allowed HTML tags and attributes intact.
Performance profile
How much work a call to wp_kses_post() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 6
- Plugin surface
- None
- Called by
- 31
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 6.
Nothing here hands control to plugin code.
31 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_kses_post() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 6 | wp_kses() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 6 instructions, 6 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- wp_kses()Filters text content and strips out disallowed HTML.
Used by · 31
- TwentyTwenty_Walker_Comment::html5_comment()Outputs a comment in the HTML5 format.
- Twenty_Twenty_One_Dark_Mode::add_privacy_policy_content()Adds information to the privacy policy.
- WP_Customize_Widgets::sanitize_widget_instance()Sanitizes a widget instance.
- WP_REST_Pattern_Directory_Controller::prepare_item_for_response()Prepare a raw block pattern before it gets output in a REST API response.
- WP_SimplePie_Sanitize_KSES::sanitize()WordPress SimplePie sanitization using KSES.
- WP_Site_Health::get_test_page_cache()Tests if a full page cache is available.
- WP_Widget_Block::update()Handles updating settings for the current Block widget instance.
- WP_Widget_Custom_HTML::update()Handles updating settings for the current Custom HTML widget instance.
- WP_Widget_Text::update()Handles updating settings for the current Text widget instance.
- _block_bindings_term_data_get_value()Gets value for Term Data source.
- block_core_gallery_render_dynamic_image()Renders a single `core/image` block for a Gallery block running in dynamic mode, applying the gallery-wide settings that affect how an image renders.
- block_core_page_list_render_nested_page_list()Outputs Page list markup from an array of pages with nested children.
Show all 31
- do_settings_sections()Prints out all settings sections added to a particular settings page.
- install_plugin_information()Displays plugin information in dialog box form.
- render_block_core_breadcrumbs()Renders the `core/breadcrumbs` block on the server.
- render_block_core_categories()Renders the `core/categories` block on server.
- render_block_core_footnotes()Renders the `core/footnotes` block on the server.
- render_block_core_home_link()Renders the `core/home-link` block.
- render_block_core_navigation_link()Renders the `core/navigation-link` block.
- render_block_core_navigation_overlay_close()Renders the `core/navigation-overlay-close` block on server.
- render_block_core_navigation_submenu()Renders the `core/navigation-submenu` block.
- render_block_core_post_author()Renders the `core/post-author` block on the server.
- render_block_core_post_excerpt()Renders the `core/post-excerpt` block on the server.
- render_block_core_post_navigation_link()Renders the `core/post-navigation-link` block on the server.
- render_block_core_post_terms()Renders the `core/post-terms` block on the server.
- render_block_core_read_more()Renders the `core/read-more` block on the server.
- render_block_core_search()Dynamically renders the `core/search` block.
- twenty_twenty_one_post_thumbnail()Displays an optional post thumbnail.
- twenty_twenty_one_register_block_pattern()Registers Block Patterns.
- wp_add_id3_tag_data()Parses ID3v2, ID3v1, and getID3 comments to extract usable data.
- wp_admin_notice()Outputs an admin notice.
Source code
function wp_kses_post( $data ) { return wp_kses( $data, 'post' );}Changelog
Introduced in 2.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/kses.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.