I\'m debugging a visual composer plugin that broke after I updated WordPress to 4.5 and I can\'t figure out why it is throwing a TypeError.
The error message in the
Well, i found the solution in this site: https://wordpress.org/support/topic/visual-composer-is-not-working
first: edit html2element:.... in in /wp-content/plugins/js_composer/assets/js/backend/composer-view.js
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()},
second: However if you open up the frontend editor you'll have this "trim" issue on custom_views.js:101 , and line 467 of another file. I forgot the name, but I think it may be frontend_editor.js.
edit in: \wp-content\plugins\js_composer\assets\js\frontend_editor\
Bad code:
this.$controls = $( _.template( template, data, _.extend( {},
vc.template_options,
{ evaluate: /\{#([\s\S]+?)#}/g } ) ).trim() ).addClass( 'vc_controls' );
Fixed code:
this.$controls = $( _.template( template, data, _.extend( {},
vc.template_options,
{ evaluate: /\{#([\s\S]+?)#}/g } ) )().trim() ).addClass( 'vc_controls' );
third: See the black magic.
Cheers.