Plugin error after updating Wordpress

My hosting provider automatically upgraded to 4.5, and this led to an error with the Visual Composer plugin.

I READ THESE MAILS: The plugin throws a TypeError after updating Wordpress 4.5

The visual composer does not load and gives a TypeError: _.template (...). trim is not a function

Uncaught TypeError: $ template.get is not a function

And replaced the html2element function with the one provided. However, as many people commented on these posts, I get a new error:

composer-view.js?ver=4.6.1:139 Uncaught TypeError: Cannot read property 'attributes' of undefined 

Here is my function:

 html2element: function(html) { var $template, attributes = {}, template = html; $template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) { attributes[attr.name] = attr.value }), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent() }, 

The error seems to come from this line:

 $template.get(0).attributes 

Has anyone figured out how to fix this?

thanks for the help

+3
javascript jquery wordpress
May 7 '16 at 15:55
source share
2 answers

Had the same problem with update 4.5 and tried everything I found, but it still didn't work.

Finally, I replaced my visual composer plugin theme (something v4.7) with a recent one (4.11.2, google js_composer.zip).

I just replaced all the directory contents, it works great.

+17
May 10 '16 at 12:22
source share
— -

Hi graham

I think the problem is not in jquery, but in the underline, which is used in js_composer.

In the rendering method, pass the invalid html object to the html2element method as follows:

  this.html2element(_.template($shortcode_template_el.html(), this.model.toJSON(), vc.templateOptions.default)); 

But this code sends the html2element method to the html object as a function that has no properties or anything else. This is because the _.template function from the underscore library does not display the first arg (html template) before the second arg does not have a valid variable for the first arg.

In my opinion, to solve this problem, you need to do the following:

 this.html2element(_.template($shortcode_template_el.html())); 

These are the 2 render and html2element methods https://gist.github.com/maximspokoiny/34ad60ad90944f8a80c6fc093873a807/9fb041d2b12249fe4391f986f4e7e6a08f57c6b3#file-gistfile1-txt

i using js_composer 4.7.4 and wordpress 4.5.2 and this problem.

Thank!

UPDATED: Sorry, in html2element you also need one change, from:

  if ( _.isString( html ) ) { this.template = _.template( html ); $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() ); } else { this.template = html; $template = html; } 

at

  if ( _.isString( html ) ) { this.template = _.template( html ); $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() ); } else { this.template = html; $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).trim() ); } 
+4
May 08 '16 at 19:42
source share



All Articles