Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_kses_allowed_html

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 7 times in this file.

Line Code
1071            * HTML tags and attribute names are case-insensitive in HTML but must be
1072            * added to the KSES allow list in lowercase. An item added to the allow list
1073            * in upper or mixed case will not recognized as permitted by KSES.
1074            *
1075            * @since 3.5.0
1076            *
1077            * @param array[] $html    Allowed HTML tags.
1078            * @param string  $context Context name.
1079            */
1080           return apply_filters( 'wp_kses_allowed_html', $html, $context );
1081      }
1082
1083      switch ( $context ) {
1084           case 'post':
1085                /** This filter is documented in wp-includes/kses.php */
1086                $tags = apply_filters( 'wp_kses_allowed_html', $allowedposttags, $context );
1087
1088                // 5.0.1 removed the `<form>` tag, allow it if a filter is allowing it's sub-elements `<input>` or `<select>`.
1089                if ( ! CUSTOM_TAGS && ! isset( $tags['form'] ) && ( isset( $tags['input'] ) || isset( $tags['select'] ) ) ) {
1090                     $tags = $allowedposttags;
1091
1092                     $tags['form'] = array(
1093                          'action'         => true,
1094                          'accept'         => true,
1095                          'accept-charset' => true,
1096                          'enctype'        => true,
1097                          'method'         => true,
1098                          'name'           => true,
1099                          'target'         => true,
1100                     );
1101
1102                     /** This filter is documented in wp-includes/kses.php */
1103                     $tags = apply_filters( 'wp_kses_allowed_html', $tags, $context );
1104                }
1105
1106                return $tags;
1107
1108           case 'user_description':
1109           case 'pre_term_description':
1110           case 'pre_user_description':
1111                $tags                = $allowedtags;
1112                $tags['a']['rel']    = true;
1113                $tags['a']['target'] = true;
1114                /** This filter is documented in wp-includes/kses.php */
1115                return apply_filters( 'wp_kses_allowed_html', $tags, $context );
1116
1117           case 'strip':
1118                /** This filter is documented in wp-includes/kses.php */
1119                return apply_filters( 'wp_kses_allowed_html', array(), $context );
1120
1121           case 'entities':
1122                /** This filter is documented in wp-includes/kses.php */
1123                return apply_filters( 'wp_kses_allowed_html', $allowedentitynames, $context );
1124
1125           case 'data':
1126           default:
1127                /** This filter is documented in wp-includes/kses.php */
1128                return apply_filters( 'wp_kses_allowed_html', $allowedtags, $context );
1129      }
1130 }
1131
1132 /**
1133  * You add any KSES hooks here.
1134  *
1135  * There is currently only one KSES WordPress hook, {@see 'pre_kses'}, and it is called here.
1136  * All parameters are passed to the hooks and expected to receive a string.
1137  *