How to Disable Inputs for Opposite Direction When Wall Sliding

Godot Version 4.2.1

I’m currently programming a 2D platformer and I gave the character the ability to wall jump and wall slide. I’m trying to figure out how to make it so that inputs are disabled for the opposite direction when wall sliding until the character jumps off the wall.

For example, when the character jumps onto the wall while holding right, I want to make it so pressing left does not take the character out of the wall slide. When the character wall jumps, then make left inputs start registering again and vice versa.

Here’s my code that handles the wall sliding and jumping:

if is_on_wall_only() && (Input.is_action_pressed("left") || Input.is_action_pressed("right")):
		velocity.y = WALL_SLIDE_SPEED * delta
func jump():
	var direction = Input.get_axis("left", "right")
	if is_on_wall_only():
		velocity.y = WALL_JUMP_VELOCITY
		velocity.x = -direction * WALL_JUMP_SPEED
		jump_sfx.play()
		DO_WALL_JUMP = true
		wall_jump_timer.start()
	elif is_on_floor() || JUMPS_MADE < 2 or coyote_jump_timer.time_left > 0.0:
		animated_sprite.scale = Vector2(0.7, 1.3)
		velocity.y = JUMP_VELOCITY
		JUMPS_MADE += 1
		jump_sfx.play()
	else:
		if !jump_buffered:
			jump_buffered = true
			jump_buffer_timer.start()

Please let me know what I can do to solve this. Thanks!