Support » Plugin: WP Post Notifier For All » [Plugin: WP Post Notifier For All] Would be nice to have an API

  • Thanks for producing this.

    I have a suggestion or request.

    It would be nice to have an API. The scenario is this: I have a front page and I’d like to provide people an quick and easy way to subscribe to posts, using AJAX and a dynamically displayed form. I don’t want to take them away from the blog page in order to subscribe, and I don’t want to do a full page refresh in order to allow them to subscribe. A prototypical scenario for DHTML and AJAX.

    What it looks like:

    before click:


    But there is no API that I could find within this plugin to allow me to do that. What I ended up doing was using javascript + jquery ajax to POST to the Subscribe form, which then retrieves 34k of HTML code. This works, but the 34k of UI that is sent back is completely unnecessary and useless, so the code I use just discards it. It would be nice to be able to get a real AJAX reply via a real WP AJAX call (via admin-ajax.php). I’m thinking 20-80 bytes of useful response, not 34k of html.

    Here’s the client-side javascript code I use for my hack approach.

    function popoutBox($anchor) {
            var $d = $anchor.closest("div#subscribe"),
                $pop, xpos,
                vanish = function() {
            // if the mini-form is already popped out, make it
            // go away.
            if ($anchor.hasClass("sub-form")) {$d.find("a.close-form").click();}
            else {
                // pop the mini form.
                xpos = $anchor.offset().left;
                $pop = $('<div class="share-post" ' +
                         'style="display:none;left:' + (xpos-176) + 'px;top:34px;">' +
                         'Get email notifications of posts' +
                         '<img class="loading" style="display:none;" ' +
                         'src="/wp-admin/images/loading-publish.gif">' +
                         '<input type="text" value="" ' +
                         'style="display:block; width:242px;">' +
                         '<input type="submit" value="subscribe" class="subscribe">' +
                         '<a class="close-form" style="top:10px;float:right">cancel</a></div>');
                    .find("input.subscribe").click(function(ev) {
                        var postdata = 'addr=' +
                            $pop.find("input[type=text]").val() +
                        $pop.css('background-color', '#777');
                        $pop.find('img.loading').css('display', 'block');
                        $.ajax({ type: "POST",
                          url: "/Subscribe", // subscription form
                          data: postdata,
                          error: vanish,  // discard response
                          success: vanish // discard response
                      return false;
        function setPopoutSubscribeLinks () {
            // There's an A tag in the page, that I use as the anchor
            // to trigger the popout of the subscription mini-form.
            $('div#subscribe a.postnotify').bind("click", function(ev) {
                return false;

  • The topic ‘[Plugin: WP Post Notifier For All] Would be nice to have an API’ is closed to new replies.