Visual Composer Backend editor problem – rjesenje
Odnedavno se pojavio Visual Composer backend editor problem gdje nisam bio u mogucnosti da uradim bilo sta sa njim. Problem je bio taj sto je backend editor jednostavno nestao i updatiranje plugina nije donijelo nikakvog rezultata. Nakon mnogo raznih pokusaja pronasao sam rjesenje za svoj, a vjerujem i za vas, problem.
Potrebno je jednostavno promjeniti neke dijelove koda u pluginu i on ce ponovo da radi kao nekada.
Rjesenje
Kod se mijenja na dva mjesta u jednom file-u, composer-view.js. File mozete pronaci na sljedecoj lokaciji u vasoj wordpress instalaciji: wp-content/plugins/js_composer/assets/js/backend
Stari kod:
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(); }
Novi kod:
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(); }
I na drugom mjestu u istom file-u
Stari kod:
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; }
Novi kod:
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; }
I to je to. Updatirajte stranicu i Visual Coposer ce opet da radi.