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 :
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!
More Problems
Bei mir gab es in der composer-teaser.js ( * composer-teaser.js v1.1) noch ein Problem. Quelle: https://gist.github.com/stiucsib86/add88d94ec5dcfee1a116c5b82c80f48
Fehler in der Konsole:
unrecognized expression: .vc-teaser-btn-Vorlage:Name
Diese Funktion austauschen...
Visual Composer fixes ".vc_teaser-btn-Vorlage:Name" error fixes
composer-teaser.js
parse: function() {
var value = this.$data_field.val(),
data = !_.isEmpty(value) ? $.parseJSON(value) : [];
if(_.isEmpty(value)) {
data = [{link: "post", name: "title"}, {name: 'image'}, {name: 'text'}];
this.$data_field.val(JSON.stringify(data));
}
_.each(data, function(block_data){
if(_.isString(block_data.name) && block_data.name.indexOf('{{') < 0) {
var $control = $('.vc_teaser-btn-' + block_data.name, this.$toolbar).prop('checked', true);
if(block_data.name == 'image' && !_.isUndefined(block_data.image)) {
if(block_data.image !== 'featured') {
this.custom_image_attributes = {id: block_data.image};
block_data.mode = 'custom';
} else {
block_data.mode = 'featured';
}
} else if(block_data.name == 'text') {
if(block_data.mode === 'custom') {
this.custom_text = block_data.text;
}
}
this.createControl(block_data);
this.$spinner.hide();
}
}, this);
this.$spinner.hide();
}