Wordpress - Visual Composer
Ein verbesserter Editor. In neuen Versionen auch für Frontend. Kostenpflichtig oft bei Themes mit dabei.
Troubleshooting
Visual Composer funktioniert nach Update von Wordpress nicht mehr
So ca. bei 4.5 bis 4.7 in der Konsole wird der Fehler:
$template.get is not a function
angezeigt
http://heycodetech.com/uncaught-typeerror-template-get-is-not-a-function/
Solution 1 :Change the function: html2element
For resolving this issues, we need to change the function : html2element : in files. > composer-view.js, File path: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js:
Your code
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) {
attributes[attr.name] = attr.value;
});
this.$el.attr(attributes).html($template.html());
this.setContent();
this.renderContent();
},
change this code to
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()
},
Solution 2 :Change the function: render
Sometime,we need to change this function also.Here is the path of this function file. Hinweis Stephan: bei mir kam der Fehler
Syntax error, unrecognized expression: .vc-teaser-btn-Vorlage:Name
> composer-view.js, File path:
/wp-content/plugins/js_composer/assets/js/backend/composer-view.js:
Original function :
render: function () {
var $shortcode_template_el = $( '#vc_shortcode-template-' + this.model.get( 'shortcode' ) );
if ( $shortcode_template_el.is( 'script' ) ) {
this.html2element( _.template( $shortcode_template_el.html(),
this.model.toJSON(),
vc.templateOptions.default ) );
} else {
var params = this.model.get( 'params' );
$.ajax( {
type: 'POST',
url: window.ajaxurl,
data: {
action: 'wpb_get_element_backend_html',
data_element: this.model.get( 'shortcode' ),
data_width: _.isUndefined( params.width ) ? '1/1' : params.width
},
dataType: 'html',
context: this
} ).done( function ( html ) {
this.html2element( html );
} );
}
this.model.view = this;
this.$controls_buttons = this.$el.find( '.vc_controls > :first' );
return this;
},
'Change this function :'Fetter Text
render: function () {
var $shortcode_template_el = $( '#vc_shortcode-template-' + this.model.get( 'shortcode' ) );
if ( $shortcode_template_el.is( 'script' ) ) {
var newHtmlCode = _.template( $shortcode_template_el.html(),
if(!_.isString(newHtmlCode)){
newHtmlCode = $shortcode_template_el.html();
}
this.html2element( newHtmlCode );
} else {
var params = this.model.get( 'params' );
$.ajax( {
type: 'POST',
url: window.ajaxurl,
data: {
action: 'wpb_get_element_backend_html',
data_element: this.model.get( 'shortcode' ),
data_width: _.isUndefined( params.width ) ? '1/1' : params.width,
_vcnonce: window.vcAdminNonce
},
dataType: 'html',
context: this
} ).done( function ( html ) {
this.html2element( html );
} );
}
this.model.view = this;
this.$controls_buttons = this.$el.find( '.vc_controls > :first' );
return this;
},
Note :
1: When changed then : Delete the cache and cookies : and then check.
2: If you are using the plugin : js_composer: or :WPBakery Visual Composer “: or :any paid plugin visual composer: then try to find the file : composer-view.js, File path: /wp-content/plugins/js_composer/assets/js/backend/composer-view.js: and changed the function which is discussed above.
Hope this works for you!