Docs: Synchronize description for the $allowed_html parameter of various KSES functions.

Follow-up to [43016].

Props Christian1012, jdgrimes, markparnell.
Fixes #39542. See #33801.
Built from https://develop.svn.wordpress.org/trunk@48478


git-svn-id: http://core.svn.wordpress.org/trunk@48247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-14 12:41:03 +00:00
parent fdd88e24ed
commit 0ce2ddce47
2 changed files with 42 additions and 24 deletions

View File

@ -736,8 +736,9 @@ if ( ! CUSTOM_TAGS ) {
* @since 1.0.0 * @since 1.0.0
* *
* @param string $string Text content to filter. * @param string $string Text content to filter.
* @param array[]|string $allowed_html An array of allowed HTML elements and attributes, or a * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* context name such as 'post'. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols. * @param string[] $allowed_protocols Array of allowed URL protocols.
* @return string Filtered content containing only the allowed HTML. * @return string Filtered content containing only the allowed HTML.
*/ */
@ -745,9 +746,11 @@ function wp_kses( $string, $allowed_html, $allowed_protocols = array() ) {
if ( empty( $allowed_protocols ) ) { if ( empty( $allowed_protocols ) ) {
$allowed_protocols = wp_allowed_protocols(); $allowed_protocols = wp_allowed_protocols();
} }
$string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) ); $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) );
$string = wp_kses_normalize_entities( $string ); $string = wp_kses_normalize_entities( $string );
$string = wp_kses_hook( $string, $allowed_html, $allowed_protocols ); $string = wp_kses_hook( $string, $allowed_html, $allowed_protocols );
return wp_kses_split( $string, $allowed_html, $allowed_protocols ); return wp_kses_split( $string, $allowed_html, $allowed_protocols );
} }
@ -909,20 +912,24 @@ function wp_kses_allowed_html( $context = '' ) {
* *
* @since 1.0.0 * @since 1.0.0
* *
* @param string $string Content to filter through KSES. * @param string $string Content to filter through KSES.
* @param array[]|string $allowed_html List of allowed HTML elements. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* @param string[] $allowed_protocols Array of allowed URL protocols. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols.
* @return string Filtered content through {@see 'pre_kses'} hook. * @return string Filtered content through {@see 'pre_kses'} hook.
*/ */
function wp_kses_hook( $string, $allowed_html, $allowed_protocols ) { function wp_kses_hook( $string, $allowed_html, $allowed_protocols ) {
/** /**
* Filters content to be run through kses. * Filters content to be run through KSES.
* *
* @since 2.3.0 * @since 2.3.0
* *
* @param string $string Content to run through KSES. * @param string $string Content to filter through KSES.
* @param array[]|string $allowed_html Allowed HTML elements. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* @param string[] $allowed_protocols Array of allowed URL protocols. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols.
*/ */
return apply_filters( 'pre_kses', $string, $allowed_html, $allowed_protocols ); return apply_filters( 'pre_kses', $string, $allowed_html, $allowed_protocols );
} }
@ -945,18 +952,23 @@ function wp_kses_version() {
* *
* @since 1.0.0 * @since 1.0.0
* *
* @global array $pass_allowed_html * @global array[]|string $pass_allowed_html An array of allowed HTML elements and attributes,
* @global array $pass_allowed_protocols * or a context name such as 'post'.
* @global string[] $pass_allowed_protocols Array of allowed URL protocols.
* *
* @param string $string Content to filter. * @param string $string Content to filter.
* @param array $allowed_html Allowed HTML elements. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* @param string[] $allowed_protocols Array of allowed URL protocols. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols.
* @return string Content with fixed HTML tags * @return string Content with fixed HTML tags
*/ */
function wp_kses_split( $string, $allowed_html, $allowed_protocols ) { function wp_kses_split( $string, $allowed_html, $allowed_protocols ) {
global $pass_allowed_html, $pass_allowed_protocols; global $pass_allowed_html, $pass_allowed_protocols;
$pass_allowed_html = $allowed_html; $pass_allowed_html = $allowed_html;
$pass_allowed_protocols = $allowed_protocols; $pass_allowed_protocols = $allowed_protocols;
return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string ); return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string );
} }
@ -1017,13 +1029,15 @@ function wp_kses_uri_attributes() {
* @access private * @access private
* @ignore * @ignore
* *
* @global array $pass_allowed_html * @global array[]|string $pass_allowed_html An array of allowed HTML elements and attributes,
* @global array $pass_allowed_protocols * or a context name such as 'post'.
* @global string[] $pass_allowed_protocols Array of allowed URL protocols.
* *
* @return string * @return string
*/ */
function _wp_kses_split_callback( $match ) { function _wp_kses_split_callback( $match ) {
global $pass_allowed_html, $pass_allowed_protocols; global $pass_allowed_html, $pass_allowed_protocols;
return wp_kses_split2( $match[0], $pass_allowed_html, $pass_allowed_protocols ); return wp_kses_split2( $match[0], $pass_allowed_html, $pass_allowed_protocols );
} }
@ -1043,9 +1057,11 @@ function _wp_kses_split_callback( $match ) {
* @ignore * @ignore
* @since 1.0.0 * @since 1.0.0
* *
* @param string $string Content to filter. * @param string $string Content to filter.
* @param array $allowed_html Allowed HTML elements. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* @param string[] $allowed_protocols Array of allowed URL protocols. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols.
* @return string Fixed HTML element * @return string Fixed HTML element
*/ */
function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) { function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) {
@ -1109,10 +1125,12 @@ function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) {
* *
* @since 1.0.0 * @since 1.0.0
* *
* @param string $element HTML element/tag. * @param string $element HTML element/tag.
* @param string $attr HTML attributes from HTML element to closing HTML element tag. * @param string $attr HTML attributes from HTML element to closing HTML element tag.
* @param array $allowed_html Allowed HTML elements. * @param array[]|string $allowed_html An array of allowed HTML elements and attributes,
* @param string[] $allowed_protocols Array of allowed URL protocols. * or a context name such as 'post'. See wp_kses_allowed_html()
* for the list of accepted context names.
* @param string[] $allowed_protocols Array of allowed URL protocols.
* @return string Sanitized HTML element. * @return string Sanitized HTML element.
*/ */
function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-beta1-48477'; $wp_version = '5.5-beta1-48478';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.