Last active
November 29, 2020 12:11
-
-
Save levantoan/519bb0d42c9f7bd6c4d78ef1686bb848 to your computer and use it in GitHub Desktop.
Fix $template.get is not a function in VC when updated WordPress to 4.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Find html2element in | |
Version < 4.8: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js | |
Version > 4.9: wp-content/plugins/js_composer/assets/js/dist/backend-actions.min.js | |
*/ | |
html2element: function(html) { | |
var attributes = {}, | |
$template; | |
if (_.isString(html)) { | |
this.template = _.template(html); | |
$template = $(this.template(this.model.toJSON()).trim()); | |
} else { | |
this.template = html; | |
$template = html; | |
} | |
_.each($template.get(0).attributes, function(attr) { // **errors on this line** | |
attributes[attr.name] = attr.value; | |
}); | |
this.$el.attr(attributes).html($template.html()); | |
this.setContent(); | |
this.renderContent(); | |
}, | |
/* | |
Then replace to 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() | |
}, | |
/*by http://levantoan.com/cach-sua-loi-uncaught-typeerror-template-get-not-function-cua-plugin-visual-composer-khi-update-wordpress-len-4-5/*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was really helpful...replacing htmlelement worked for me