Theme extension is broken due to BB's AJAX way

Hi,

After a new update, I noticed a change the broke my sites.
I added a few custom elements to support one of the themes I use. The way I did it was using do_shortcode() inside frontend.php, so basically, the input of the module form is passed to a function that parses it, builds a shortcode string, then sends it to do_shortcode() in order to convert it to HTML.

I realized when I enter the page, the shortcode is converted without any problem. However, when I edit the module form and the “refresh” event happens, the shortcode will not be converted. The reason being is that when the AJAX request is sent, the shortcode tag is not defined.

  1. What was the change and how do you suggest that I deal with it? Would be great to mention the best practices to extend a theme using their shortcode.

  2. Is there any way to include files that are not gone when the AJAX request happens? (it seems to me impossible, the AJAX is not a full request and therefore does not initialize all plugin files, correct?).

  3. Do you have any event that is guaranteed to run before all AJAX request when “refresh” happens?

Thanks!

Hi Elemento,

I don’t believe we made any changes to the AJAX logic in a recent update, but be sure to check out the beta later this week, because we have there :slight_smile:

1) What was the change and how do you suggest that I deal with it? Would be great to mention the best practices to extend a theme using their shortcode.

The existing AJAX logic (and the beta) runs on the wp action, so as long as your shortcode is defined before then, it should work.

2) Is there any way to include files that are not gone when the AJAX request happens? (it seems to me impossible, the AJAX is not a full request and therefore does not initialize all plugin files, correct?).

Since it fires on the wp action, all theme and plugin functions should be loaded. Maybe your shortcode is defined after the wp action?

3) Do you have any event that is guaranteed to run before all AJAX request when “refresh” happens?

The init action should work just fine :slight_smile:

Let me know if that helps!

Justin