<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

add_action(
	'wp_enqueue_scripts',
	function () {
		wp_enqueue_style(
			'reeid-theme-twentytwentyfive-switcher',
			plugins_url( 'switcher.css', __FILE__ ),
			array( 'reeid-switcher-style' ),
			filemtime( __DIR__ . '/switcher.css' )
		);
	},
	20
);

add_filter(
	'render_block',
	function ( $block_content, $block ) {
		$name = isset( $block['blockName'] ) ? (string) $block['blockName'] : '';
		if ( 'core/shortcode' !== $name ) {
	return $block_content;
}

if ( false === strpos( $block_content, 'reeid-dropdown' ) ) {
	return $block_content;
}

$block_content = preg_replace( '#</p>\s*#i', '', $block_content );
$block_content = preg_replace( '#\s*<p>#i', '', $block_content );
$block_content = preg_replace( '#<br\s*/?>#i', '', $block_content );

return trim( $block_content );
	},
	10,
	2
);