Reply To: Search Results showing my Editor code

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search Results showing my Editor code Reply To: Search Results showing my Editor code

#6206

Ernest Marcinko
Keymaster

Hi!

After a few hours (!) of debugging I found that for some yet unknown reason some of the Enfold layout builder shortcodes are not registered in Ajax requests. I'm nor sure if this is a global theme issues, or just your case, or some misconfiguration.

The best solution would be to ask the theme author how to enable the “av_section”, “av_heading” and all the other shortcodes in ajax requests as well. It's probably either a minor bug or a configuration issue. I'm 100% sure that those shortcodes must exist in ajax requests, otherwise every ajax powered plugin that queries posts contents will fail.

Otherwise I can only suggest 2 “hack” solutions.

1. I've put the following code at the end of the theme functions.php file:

// Force to return the shortcode content only        
function x12_return_just_content($atts, $content) {
	return do_shortcode($content);
}

// Force to return an empty string
function x12_return_empty_content($atts, $content) {
	return "";
}

add_action( 'asp_before_search', 'x12_empty_unregistered_shortcodes');

function x12_empty_unregistered_shortcodes() {
  // The list is incomplete!
    
  add_shortcode( 'av_hr', 'x12_return_empty_content' );
  add_shortcode( 'av_image', 'x12_return_empty_content' );
  add_shortcode( 'av_button', 'x12_return_empty_content' );
  add_shortcode( 'av_two_third', 'x12_return_just_content' );
  add_shortcode( 'av_heading', 'x12_return_empty_content' );
  add_shortcode( 'av_one_half', 'x12_return_just_content' ); 
  add_shortcode( 'av_one_full', 'x12_return_just_content' ); 
  add_shortcode( 'av_one_third', 'x12_return_just_content' );
  add_shortcode( 'av_three_fourth', 'x12_return_just_content' );
  add_shortcode( 'av_one_fourth', 'x12_return_just_content' );
  add_shortcode( 'av_section', 'x12_return_just_content' );
  add_shortcode( 'av_textblock', 'x12_return_just_content' );  
}

2. Another solution is shorter, but it removes the undefined content. In case, you can replace that code with this:

// Force to return an empty string
function x12_return_empty_content($atts, $content) {
	return "";
}

add_action( 'asp_before_search', 'x12_empty_unregistered_shortcodes');

function x12_empty_unregistered_shortcodes() {
  add_shortcode( 'av_section', 'x12_return_empty_content' );
}

I don't fancy either of these solutions, but unless there is a way to turn on the registration of the layout editor shorcodes in ajax requests, I don't think there is any better way.

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)