Bad practices and incompatibility

Hello, my first day using PB was not smooth, had to find that PB is incompatible with WP Minify, here’s the error msg after trying to change a title alignment and clicking save and finish:

SyntaxError: JSON.parse: bad control character in string literal at line 1 column 14 of the JSON data http://xxxxxxxxxxxxxxxxxxx.com/wp-content/plugins/fl-builder/js/fl-builder.js?ver=3.9.1
Line 892

There’s a problem with the XHR JSON response: it contains carriage returns or new line characters which are not allowed, that newlines are introduced by WP minify which strips most of white space characters but seems to also introduce some (may be to keep some human readability?)…

but wp-minify is not to be blamed for this problem:
Page Builder makes ajax POST request targeted to the same URL as the page it is working on!
Why PB is not using admin-ajax.php ?

Hi Alessandro,

Thanks for posting and sorry for the issues. I will look into the WP Minify issue today and see about releasing a quick fix. It hasn’t been updated in two years though, so I would recommend going with a different plugin for minification that isn’t already riddled with bugs.

Why PB is not using admin-ajax.php ?

Great question.

The page builder uses its own AJAX methods that work on the frontend rather than the admin like admin-ajax.php does. We had to go that route because we ran into a lot of problems when trying to render frontend content in the backend environment.

For example, shortcodes do not render in the admin. We also ran into issues with loops and secondary loops when submitting the request to a page other than the one you are currently editing.

I can assure you that these AJAX methods are safe and only accessible by a logged in user that has the appropriate capabilities for editing a page.

I’ll let you know what I find out about WP Minify.

Thanks,
Justin

Hi Justin,
I’m not really fond with WP Minify, despite I haven’t found any problem with it in years but I can change that easily.
That said, I’m not aware of shortcode malfunctions with admin-ajax, what’s the problem with do_shortcode ?
I was not suggesting to submit the request to other pages, but to admin-ajax.php, that should be shielded from any interference as it doesn’t even expose a filter, isn’t it?

Hi Alessandro,

I just released an update that fixes the WP Minify issues. Basically, I’m turning off WP Minify while the builder is in edit mode by using the variable wp-minify-off=1. The problem was that WP Minify is minifying core scripts such as Tiny MCE, which is throwing errors.

The JSON issue was caused by WP Minify as well. I removed the line breaks created by the builder and was still seeing the issue. It looks like WP Minify is adding carriage returns to the content which don’t get escaped by json_encode.

You wouldn’t want the layout to be minified while your working on it anyways. Say you write some HTML in an HTML module. The next time you try to edit it, it would be minified.

That said, I’m not aware of shortcode malfunctions with admin-ajax, what’s the problem with do_shortcode ?

Actually, I think the issue wasn’t that shortcodes don’t work via admin-ajax. It’s that some shortcodes, like Contact Form 7, weren’t rending via admin-ajax. As I said, shortcodes aren’t the only issue we were having. We are rending frontend content and admin-ajax just doesn’t play nice with that. When rendering the content for editing, we need access to the same conditions and environment that it is rendering in when viewing the page normally without the builder in edit mode.

Again, these AJAX calls will only work if you are logged in. Any updates to the database can only be made if you are authorized to edit the current post.

I hope that helps. Let me know if you run into anything else.

Thanks,
Justin

Another way to look at the AJAX issue is that any plugin can check for is_admin which returns true when using admin-ajax. Some plugins, like Contact Form 7, don’t register their shortcodes when is_admin is true, meaning we can’t render them via admin-ajax and have to render them through a frontend AJAX call.

Justin

I understand the context issue Justin, Thank you for the clarification.
Should I wait for an automatic update or a manual update is needed at this time ?

As we’re talking about compatibility here, do you have any advice about WPML?
Many web projects I work on are multi language, can you please give some hints about compatibility status between PB and WPML?

Hi Alessandro,

Thanks for understanding. It has definitely been tricky building something like this on the frontend!

You should be able to update the plugin just like you update wordpress.org plugins. If you don’t see it, try clicking the “Check Again” button on the WordPress updates page.

Regarding WPML, we haven’t tested that yet (we plan on doing so) but the builder is fully translatable. All strings are rendered using WordPress’ internationalization functions and the fl-builder text domain, so I’m guessing we just need to do a little more configuration to get WPML up and running. I’ve added that to my list and will try to get it out in the next major release.

Thanks,
Justin

Hi Justin,
sorry to bother again… I hope that I’m going to help a little with constructive critic.

I’ve found that images uploaded in PB are not attached to the post.
This may be possible with http://codex.wordpress.org/Function_Reference/media_sideload_image
please consider using it.

About WPML I’m going to test it soon as I really need translatable content.
Great thing you already internationalized PB, I’ve translated up to 100% of Page Builder strings to italian (my native language), how can I send you .po .mo files?

Thanks
Alessandro

This is a judgmental, inaccurate title for the forum post. Can the title be changed to add a fuller description of the issue?

sorry to bother again… I hope that I’m going to help a little with constructive critic.

No worries. Please, provide criticism! That really helps us make a better product!

I’ve found that images uploaded in PB are not attached to the post.

We’re using the JS implementation of the uploader, so media_sideload_image won’t work (I’ve used that before). Good catch though. I’ll look into making that happen.

About WPML I’m going to test it soon as I really need translatable content.

Let me know how that goes. We’re actively developing the builder and would love feedback regarding WPML.

I’ve translated up to 100% of Page Builder strings to italian (my native language), how can I send you .po .mo files?

Awesome! You can send them to justin [at] fastlinemedia [dot] com.

Thanks,
Justin

This is a judgmental, inaccurate title for the forum post. Can the title be changed to add a fuller description of the issue?

Jason, thanks for pointing that out. I agree but am also fine with it. I can see how front-end AJAX requests would be considered a bad practice. The nice thing about “best practices” is that once you know them well, you can safely bend them to your will, as we’ve done here :slight_smile: Hopefully, someone else that is curious about our front-end AJAX use will find this thread useful.

Thanks!
Justin

I’ve choosed Fastline Page Builder after extensive research and tests on page builders because my pesonal judgment is that for various reasons it is the most promising platform between the recent page builders galore, so please get me right, no offense was intended for the hard work of others!