binds * an attribute which KSES allows there with any value. KSES calls this to keep such a * directive out of content saved by an author who cannot post unfiltered HTML. * * @since 7.1.4 * @access private * @ignore * * @param string $directive_name The directive attribute name, in lowercase. * @param array|bool $allowed_attributes The attributes KSES allows on the element. * @return bool Whether the directive binds an attribute whose value KSES restricts. */ function _wp_kses_directive_binds_value_restricted_attribute( string $directive_name, $allowed_attributes ): bool { if ( ! str_starts_with( $directive_name, 'data-wp-bind--' ) ) { return false; } if ( ! _wp_kses_restricts_attribute_values( $allowed_attributes ) ) { return false; } /* * Both the whole remainder of the name and the part before a unique ID are checked, so * that the result does not depend on how the unique ID is parsed. A binding with a unique * ID is not applied at all, so removing one changes nothing. */ $bound_attribute = substr( $directive_name, strlen( 'data-wp-bind--' ) ); $bound_attributes = array( $bound_attribute ); $unique_id_index = strpos( $bound_attribute, '---' ); if ( false !== $unique_id_index ) { $bound_attributes[] = substr( $bound_attribute, 0, $unique_id_index ); } foreach ( $bound_attributes as $attribute_name ) { if ( isset( $allowed_attributes[ $attribute_name ] ) ) { $rules = $allowed_attributes[ $attribute_name ]; } elseif ( 1 === preg_match( '/^data-[a-z0-9_-]+$/', $attribute_name ) && isset( $allowed_attributes['data-*'] ) ) { $rules = $allowed_attributes['data-*']; } else { return true; } if ( ! $rules || is_array( $rules ) ) { return true; } } return false; }