WordPress.org

Make WordPress Core

Changeset 48478


Ignore:
Timestamp:
07/14/2020 12:39:16 PM (14 months ago)
Author:
SergeyBiryukov
Message:

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

Follow-up to [43016].

Props Christian1012, jdgrimes, markparnell.
Fixes #39542. See #33801.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/kses.php

    r48199 r48478  
    737737 *
    738738 * @param string         $string            Text content to filter.
    739  * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes, or a
    740  *                                          context name such as 'post'.
     739 * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     740 *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     741 *                                          for the list of accepted context names.
    741742 * @param string[]       $allowed_protocols Array of allowed URL protocols.
    742743 * @return string Filtered content containing only the allowed HTML.
     
    746747        $allowed_protocols = wp_allowed_protocols();
    747748    }
     749
    748750    $string = wp_kses_no_null( $string, array( 'slash_zero' => 'keep' ) );
    749751    $string = wp_kses_normalize_entities( $string );
    750752    $string = wp_kses_hook( $string, $allowed_html, $allowed_protocols );
     753
    751754    return wp_kses_split( $string, $allowed_html, $allowed_protocols );
    752755}
     
    910913 * @since 1.0.0
    911914 *
    912  * @param string          $string            Content to filter through KSES.
    913  * @param array[]|string  $allowed_html      List of allowed HTML elements.
    914  * @param string[]        $allowed_protocols Array of allowed URL protocols.
     915 * @param string         $string            Content to filter through KSES.
     916 * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     917 *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     918 *                                          for the list of accepted context names.
     919 * @param string[]       $allowed_protocols Array of allowed URL protocols.
    915920 * @return string Filtered content through {@see 'pre_kses'} hook.
    916921 */
    917922function wp_kses_hook( $string, $allowed_html, $allowed_protocols ) {
    918923    /**
    919      * Filters content to be run through kses.
     924     * Filters content to be run through KSES.
    920925     *
    921926     * @since 2.3.0
    922927     *
    923      * @param string          $string            Content to run through KSES.
    924      * @param array[]|string  $allowed_html      Allowed HTML elements.
    925      * @param string[]        $allowed_protocols Array of allowed URL protocols.
     928     * @param string         $string            Content to filter through KSES.
     929     * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     930     *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     931     *                                          for the list of accepted context names.
     932     * @param string[]       $allowed_protocols Array of allowed URL protocols.
    926933     */
    927934    return apply_filters( 'pre_kses', $string, $allowed_html, $allowed_protocols );
     
    946953 * @since 1.0.0
    947954 *
    948  * @global array $pass_allowed_html
    949  * @global array $pass_allowed_protocols
    950  *
    951  * @param string   $string            Content to filter.
    952  * @param array    $allowed_html      Allowed HTML elements.
    953  * @param string[] $allowed_protocols Array of allowed URL protocols.
     955 * @global array[]|string $pass_allowed_html      An array of allowed HTML elements and attributes,
     956 *                                                or a context name such as 'post'.
     957 * @global string[]       $pass_allowed_protocols Array of allowed URL protocols.
     958 *
     959 * @param string         $string            Content to filter.
     960 * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     961 *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     962 *                                          for the list of accepted context names.
     963 * @param string[]       $allowed_protocols Array of allowed URL protocols.
    954964 * @return string Content with fixed HTML tags
    955965 */
    956966function wp_kses_split( $string, $allowed_html, $allowed_protocols ) {
    957967    global $pass_allowed_html, $pass_allowed_protocols;
     968
    958969    $pass_allowed_html      = $allowed_html;
    959970    $pass_allowed_protocols = $allowed_protocols;
     971
    960972    return preg_replace_callback( '%(<!--.*?(-->|$))|(<[^>]*(>|$)|>)%', '_wp_kses_split_callback', $string );
    961973}
     
    10181030 * @ignore
    10191031 *
    1020  * @global array $pass_allowed_html
    1021  * @global array $pass_allowed_protocols
     1032 * @global array[]|string $pass_allowed_html      An array of allowed HTML elements and attributes,
     1033 *                                                or a context name such as 'post'.
     1034 * @global string[]       $pass_allowed_protocols Array of allowed URL protocols.
    10221035 *
    10231036 * @return string
     
    10251038function _wp_kses_split_callback( $match ) {
    10261039    global $pass_allowed_html, $pass_allowed_protocols;
     1040
    10271041    return wp_kses_split2( $match[0], $pass_allowed_html, $pass_allowed_protocols );
    10281042}
     
    10441058 * @since 1.0.0
    10451059 *
    1046  * @param string   $string            Content to filter.
    1047  * @param array    $allowed_html      Allowed HTML elements.
    1048  * @param string[] $allowed_protocols Array of allowed URL protocols.
     1060 * @param string         $string            Content to filter.
     1061 * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     1062 *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     1063 *                                          for the list of accepted context names.
     1064 * @param string[]       $allowed_protocols Array of allowed URL protocols.
    10491065 * @return string Fixed HTML element
    10501066 */
     
    11101126 * @since 1.0.0
    11111127 *
    1112  * @param string   $element           HTML element/tag.
    1113  * @param string   $attr              HTML attributes from HTML element to closing HTML element tag.
    1114  * @param array    $allowed_html      Allowed HTML elements.
    1115  * @param string[] $allowed_protocols Array of allowed URL protocols.
     1128 * @param string         $element           HTML element/tag.
     1129 * @param string         $attr              HTML attributes from HTML element to closing HTML element tag.
     1130 * @param array[]|string $allowed_html      An array of allowed HTML elements and attributes,
     1131 *                                          or a context name such as 'post'. See wp_kses_allowed_html()
     1132 *                                          for the list of accepted context names.
     1133 * @param string[]       $allowed_protocols Array of allowed URL protocols.
    11161134 * @return string Sanitized HTML element.
    11171135 */
Note: See TracChangeset for help on using the changeset viewer.