Visual Composer Backend editor problem – lösning
Nyligen visade Visual Composer backend editor problemet var jag inte kunde göra något med det. Problemet var att backendredigeraren helt enkelt försvann och uppdateringen av plugin gav inga resultat. Efter många olika försök hittade jag en lösning för mitt, och jag tror också på ditt, problem.
Det är nödvändigt att helt enkelt ändra vissa delar av koden i en fil i tillägget och det kommer att fungera igen som det tidigare var.
Lösning
Koden ändras på två platser i en enda fil, composer-view.js. Du kan hitta filen på nästa plats i din wordpress-installation: wp-content / plugins / js_composer / assets / js / backend
Gammla koden:
html2element: function ( html ) { var attributes = {}, $template; if ( _.isString( html ) ) { this.template = _.template( html ); $template = $( this.template( this.model.toJSON(), vc.templateOptions.default ).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(); }
Nya koden:
html2element:function (html) { var attributes = {}, $template; if (_.isString(html)) { this.template = _.template(html); } else { try { this.template = _.template(html()); } catch (err) { this.template = html; } } $template = $(this.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(); }
Och på andra ställe i samma fil
Gammla koden:
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, _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; }
Nya koden:
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(), this.model.toJSON(), vc.templateOptions.default ); 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; }
Och det var allt. Uppdatera sidan och Visual Composer kommer att fungera igen