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

Reply To: Shortcode gets wrapped in and tags – looks messy

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Shortcode gets wrapped in and tags – looks messy Reply To: Shortcode gets wrapped in and tags – looks messy

#44590
Ernest MarcinkoErnest Marcinko
Keymaster

If this didn’t work, then there is a very high chance that it’s not possible. The paragraphs are added after this code, during the pageview. If they are added just randomly and not because of white space, then that has to be solved on the page builder side.

You can try a different variation, mabe something like this:

add_shortcode( 'wd_asp_wrap', 'asp_wrap_shortcode' );
function asp_wrap_shortcode() {
	$output = do_shortcode('[wd_asp id=1]');
	$search = array(
		'/(\n|^)(\x20+|\t)/',
		'/(\n|^)\/\/(.*?)(\n|$)/',
		'/\n/',
		'/\<\!--.*?-->/',
		'/(\x20+|\t)/', # Delete multispace (Without \n)
		'/\>\s+\</', # strip whitespaces between tags
		'/(\"|\')\s+\>/', # strip whitespaces between quotation ("') and end tags
		'/=\s+(\"|\')/'); # strip whitespaces between = "'

	$replace = array(
		"\n",
		"\n",
		" ",
		"",
		" ",
		"><",
		"$1>",
		"=$1");

    $output = preg_replace($search,$replace,$output);
	return $output;
}

This is a bit more aggressive with whitespace removal. If the paragraph around the button is added for some other reason by the page handler, then it is going to be still there.