WordPress.org

Ready to get started?Download WordPress

Forums

Return multiple select posts instead one - JSON & Wysija (1 post)

  1. puikaaa
    Member
    Posted 8 months ago #

    This code is snipet from Wysija admin-campaign-articles.php JSON. It is returning only one item instead of the selected/checked (more than 1 item) items after submiting.
    Where is the error? How can I change from single item return to multiple?

    function selectArticle(s) {
        window.parent.WysijaPopup.success(allposts[s].html)
    }
    var allposts = new Array, query_offset = 0, wysappend = 0, totalReached = !1;
    jQuery(function(s) {
        function t() {
            var t = "<ul class='loading-ul'>";
            t += "<li><img title='Loading' alt='loading' src='../wp-content/plugins/wysija-newsletters/img/wpspin_light.gif' /></li>", t += "</ul>", wysappend ? s("#search-results").append(t) : s("#search-results").html(t), wysijaAJAX.task = "get_articles", wysijaAJAX.search = s("#search-box").val(), wysijaAJAX.cpt = s("select#cpt").val(), wysijaAJAX.status = s("select#status").val(), wysijaAJAX.query_offset = query_offset, s("#get-full-post").is(":checked") ? wysijaAJAX.fullarticle = 1 : delete wysijaAJAX.fullarticle, wysijaAJAX._wpnonce = s("#wysijax").val(), jQuery.ajax({type: "POST", url: wysijaAJAX.ajaxurl, data: wysijaAJAX, success: e, error: l, dataType: "json"})
        }
    
        function return_select(){
            return selectArticle(' + e + ');
        }
    
        function e(t) {
            if (t.result.result) {
                for (var e in t.result.posts)
                    allposts.push(t.result.posts[e]);
                var l, a = '<ul class="posts">';
                s.each(t.result.posts, function(s, t) {
                    l = {src: null, alt: "", title: ""}, null !== t.post_image && (l.src = t.post_image.src, l.alt = t.post_image.alt, l.title = t.post_title);
                    var e = query_offset + s;
                    a += '<li class="clearfix">', a += '<div class="article-cpt">', a+= '<div class="checkbox" style="float:left;padding:8px 15px 8px 0px;"><input type="checkbox" name="checkbox" /></div>', null !== l.src && (a += '<div class="thumbnail"><img width="60" title="' + l.title + '" src="' + l.src + '" alt="' + l.alt + '" />' + "</div>"), a += "<h3>" + t.post_title + '</h3></div><div class="cpt-type">' + t.post_type + " - <small>" + t.post_status + "</small></div></li>"
                }), a += "</ul>", a+= '<input type="submit" onClick="selectArticle(' + e + ')" />';
            } else if (t.result.append)
                var a = "";
            else {
                var a = "<ul>";
                a += "<li><strong>" + t.result.msg + "</strong></li>", a += "</ul>"
            }
            s("#search-results").find(".loading-ul").remove(), t.result.append ? "" !== a && s("#search-results").append("<hr/>" + a) : s("#search-results").html(a), wysappend = 0, totalReached = parseInt(t.result.total) === s("ul.posts li").length ? !0 : !1
        }
    
        function l(s) {
            wysappend = 0, alert("Request error not JSON:" + s.responseText)
        }
    
        function a() {
            query_offset += 10, wysappend = 1, t()
        }
    
        s("#gallery-form").submit(function() {
            return query_offset = 0, allposts = new Array, t(), !1
        }), s("#get-full-post").change(function() {
            return query_offset = 0, allposts = new Array, t(), !1
        }), s("select#cpt").change(function() {
            return query_offset = 0, allposts = new Array, t(), !1
        }), s("select#status").change(function() {
            return query_offset = 0, allposts = new Array, t(), !1
        }), s("#show-advanced-controls").click(function() {
            s("#search-advanced").toggle()
        }), s(function() {
            t()
        }), s(window).scroll(function() {
            totalReached === !1 && allposts.length >= 10 && !wysappend && s(window).scrollTop() === s(document).height() - s(window).height() && a()
        })
    });

Reply

You must log in to post.

About this Topic