WordPress.org

Plugin Directory

Changeset 609682


Ignore:
Timestamp:
10/08/12 17:28:57 (19 months ago)
Author:
MattyRob
Message:

Extend AJAX form to support the shortcode hide parameter - proposed by bwsl

Location:
subscribe2/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • subscribe2/trunk/ReadMe.txt

    r608628 r609682  
    327327* Order CSS files better by applying CSSComb 
    328328* Reuse $value variable in the 'frontend' class to reduce translation strings 
     329* Improve AJAX form to obey the shortcode hide parameter - proposed by bwsl 
    329330 
    330331= Version 8.5 by Matthew Robinson = 
  • subscribe2/trunk/classes/class-s2-core.php

    r607157 r609682  
    18031803            if ( '1' == $this->subscribe2_options['ajax'] ) { 
    18041804                add_action('wp_enqueue_scripts', array(&$this, 'add_ajax')); 
    1805                 add_action('wp_head', array(&$this, 'add_s2_ajax')); 
     1805                add_action('wp_footer', array(&$this, 'add_s2_ajax')); 
    18061806            } 
    18071807        } 
  • subscribe2/trunk/classes/class-s2-frontend.php

    r608628 r609682  
    77    function shortcode($atts) { 
    88        extract(shortcode_atts(array( 
    9             'hide'  => '', 
     9            'hide'  => strtolower(''), 
    1010            'id'    => '', 
    1111            'url' => '', 
     
    1717        // if link is true return a link to the page with the ajax class 
    1818        if ( $link !== '' && !is_user_logged_in() ) { 
    19             $this->s2form = "<a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\" class=\"s2popup\">" . $link . "</a>\r\n"; 
     19            $hide_id = ($hide === '') ? "": " id=\"" . $hide . "\""; 
     20            $this->s2form = "<a href=\"" . get_permalink($this->subscribe2_options['s2page']) . "\" class=\"s2popup\"" . $hide_id . ">" . $link . "</a>\r\n"; 
    2021            return $this->s2form; 
    2122        } 
     
    279280        echo "//<![CDATA[\r\n"; 
    280281        echo "jQuery(document).ready(function() {\r\n"; 
    281         echo "  var dialog = jQuery('<div></div>')\r\n"; 
    282         echo "  .html('" . do_shortcode('[subscribe2 nojs="true"]') . "')\r\n"; 
     282        echo "  var dialog = jQuery('<div></div>');\r\n"; 
     283        echo "  if (jQuery('a.s2popup').attr('id') === 'unsubscribe') {\r\n"; 
     284        echo "      dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="unsubscribe"]') . "');\r\n"; 
     285        echo "  } else if (jQuery('a.s2popup').attr('id') === 'subscribe') {\r\n"; 
     286        echo "      dialog.html('" . do_shortcode('[subscribe2 nojs="true" hide="subscribe"]') . "');\r\n"; 
     287        echo "  } else {\r\n"; 
     288        echo "      dialog.html('" . do_shortcode('[subscribe2 nojs="true"]') . "');\r\n"; 
     289        echo "  }\r\n"; 
    283290        if ( $this->s2form != $this->form && !is_user_logged_in() ) { 
    284             echo "  .dialog({modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n"; 
    285         } else { 
    286             echo "  .dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n"; 
     291            echo "  dialog.dialog({modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n"; 
     292        } else { 
     293            echo "  dialog.dialog({autoOpen: false, modal: true, zIndex: 10000, title: '" . __('Subscribe to this blog', 'subscribe2') . "'});\r\n"; 
    287294        } 
    288295        echo "  jQuery('a.s2popup').click(function(){\r\n"; 
Note: See TracChangeset for help on using the changeset viewer.