diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php
index 9c57c3a8e5..3000299f85 100644
--- a/src/wp-includes/kses.php
+++ b/src/wp-includes/kses.php
@@ -1152,6 +1152,13 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) {
  * @return bool Whether or not the attribute is allowed.
  */
 function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowed_html ) {
+	if ( ! isset( $allowed_html[ strtolower( $element ) ] ) ) {
+		$name  = '';
+		$value = '';
+		$whole = '';
+		return false;
+	}
+
 	$allowed_attr = $allowed_html[ strtolower( $element ) ];
 
 	$name_low = strtolower( $name );
