Plugin throwing TypeError after WordPress 4.5 update

后端 未结 10 1418
甜味超标
甜味超标 2020-12-07 19:06

I\'m debugging a visual composer plugin that broke after I updated WordPress to 4.5 and I can\'t figure out why it is throwing a TypeError.

The error message in the

10条回答
  •  不思量自难忘°
    2020-12-07 19:25

    I am using the Astra theme. This fix is 99.9 % working. For some tho, this only stops the spinning wheel, but once the page loads visual composer does not.

    I made a slight change to this code (that is posted everywhere by now)

    Original Astra theme code here (composer-view.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) {
                attributes[attr.name] = attr.value;
            });
            this.$el.attr(attributes).html($template.html());
            this.setContent();
            this.renderContent();
        },
    

    The code that works :

    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()
    

    },

    The main difference is located here (versus original code)

    }); this.$el.attr
    

    There is a semicolon instead of the original comma :) :

    }), this.$el.attr
    

    Cheers folks :) So

提交回复
热议问题