This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Search box swapping

#37075
Ernest MarcinkoErnest Marcinko
Keymaster

Thanks!

Looks like it was some sort of an issue with the theme registering the shortcode too early, and no other shortcodes could be registered at that time. Interestingly it only happened in some cases.

It seems like this variation to the code has resolved the issue:

// Replaces Flatsome searhbar with ASP
function search_shortcode2($atts) {
	extract(shortcode_atts(array(
		'size' => 'normal',
		'style' => '',
		'class' => '',
		'visibility' => ''
	), $atts));

		$classes	= array( 'searchform-wrapper' , 'ux-search-box', 'relative' );
		
		if( $class ) $classes[] = $class;
		if( $visibility ) $classes[] = $visibility;
		if( $style ) $classes[] = 'form-'.$style;
		if( $size ) $classes[] = 'is-'.$size;
		$classes = implode(' ', $classes);

    ob_start();

    echo '<div class="'. $classes. '">';
	 	echo do_shortcode('[wd_asp id=1]');
 	echo '</div>';
 	
 	$content = ob_get_contents();
    ob_end_clean();
    return $content;
}

remove_shortcode("search");
add_action( 'plugins_loaded', 'my_plugin_override1' );
function my_plugin_override1() {
    // your code here
	remove_shortcode("search");
	add_shortcode("search", "search_shortcode2");
}

Although I still recommend investigating if you have any type of object cache active, to make sure the issue is not replicated.