WordPress.org

Plugin Directory

Changeset 491239


Ignore:
Timestamp:
01/17/12 16:30:37 (2 years ago)
Author:
griffinjt
Message:

updated to v1.2.0 - legit works

Location:
mailchimp-comment-optin/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mailchimp-comment-optin/trunk/mailchimp-comment-optin.php

    r490739 r491239  
    66Author: Thomas Griffin 
    77Author URI: http://thomasgriffinmedia.com/ 
    8 Version: 1.1.1 
     8Version: 1.2.0 
    99License: GNU General Public License v3.0 
    1010License URI: http://www.opensource.org/licenses/gpl-license.php 
     
    117117                'count'                 => '', 
    118118                'show'                  => 1, 
    119                 'get_name'              => 0, 
    120119                'check_text'            => 'Subscribe me to your mailing list', 
    121120                'subscribed_text'       => 'You are currently subscribed to our mailing list', 
     
    368367                            <tr valign="middle"> 
    369368                                <th scope="row"> 
    370                                     <label for="<?php echo $this->option; ?>[get_name]"><?php _e( 'Grab the commenter\'s name too?', 'tgm-mc-optin' ); ?></label> 
    371                                 </th> 
    372                                 <td> 
    373                                     <input id="tgm-mc-get-name" type="checkbox" name="<?php echo $this->option; ?>[get_name]" value="<?php echo $tgm_mc_options['get_name']; ?>" <?php checked( $tgm_mc_options['get_name'], 1 ); ?> /> 
    374                                     <span class="description"><?php _e( 'By default, only the email is sent to the list', 'tgm-mc-optin' ); ?></span> 
    375                                 </td> 
    376                             </tr> 
    377                             <tr valign="middle"> 
    378                                 <th scope="row"> 
    379369                                    <label for="<?php echo $this->option; ?>[check_text]"><?php _e( 'Customize the checkbox message', 'tgm-mc-optin' ); ?></label> 
    380370                                </th> 
     
    479469             
    480470            $tgm_mc_options['show'] = isset( $input['show'] ) ? (int) 1 : (int) 0; 
    481             $tgm_mc_options['get_name'] = isset( $input['get_name'] ) ? (int) 1 : (int) 0; 
    482471             
    483472            $tgm_mc_options['check_text'] = esc_attr( strip_tags( $input['check_text'] ) ); 
     
    550539        public function get_viewer_name() { 
    551540             
     541            global $tgm_mc_comment_data; 
     542             
    552543            /** Grab the current user's info if available */ 
    553544            get_currentuserinfo(); 
    554545             
    555546            /** Get the commenter email from cookies if available */ 
    556             $commenter_name = ! empty( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) ? trim( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) : ''; 
    557              
    558             if ( ! empty( $commenter_name ) ) 
    559                 return $commenter_name; 
    560              
    561             return false; 
     547            if ( ! empty( $tgm_mc_comment_data['comment_author_name'] ) ) 
     548                $commenter_name = $tgm_mc_comment_data['comment_author_name']; 
     549            elseif ( ! empty( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) ) 
     550                $commenter_name = trim( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ); 
     551             
     552            if ( empty( $commenter_name ) ) 
     553                return false; 
     554             
     555            return $commenter_name; 
    562556         
    563557        } 
     
    577571        public function get_viewer_email() { 
    578572         
    579             global $post, $user_email, $tgm_mc_options; 
     573            global $post, $user_email, $tgm_mc_options, $tgm_mc_comment_data; 
    580574             
    581575            /** Grab the current user's info if available */ 
     
    583577             
    584578            /** Get the commenter email from cookies if available */ 
    585             $commenter_email = ! empty( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) ? trim( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) : ''; 
     579            if ( ! empty( $tgm_mc_comment_data['comment_author_email'] ) ) 
     580                $commenter_email = $tgm_mc_comment_data['comment_author_email']; 
     581            elseif ( ! empty( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) ) 
     582                $commenter_email = trim( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ); 
    586583     
    587584            if ( is_email( $user_email ) ) 
     
    644641                 
    645642            $check_for_email = $api->listMemberInfo( $tgm_mc_options['current_list_id'], array( $email ) ); 
    646                      
     643                 
    647644            /** If there are any errors, we know they are not on the list */ 
    648645            if ( 0 !== $check_for_email['errors'] ) 
     
    665662         * @global array $tgm_mc_options Array of plugin options 
    666663         * @global array $tgm_mc_comment_data Array of submitted comment data 
    667          * @return null Return early if in admin 
    668664         */ 
    669665        public function populate_list() { 
     
    671667            global $tgm_mc_options, $tgm_mc_comment_data; 
    672668             
    673             /** Return early if we are in the admin */ 
    674             if ( is_admin() ) 
    675                 return; 
    676              
    677669            /** Only go forward if the checkbox has been selected and the user isn't subscribed */ 
    678             if ( ! empty( $tgm_mc_comment_data['tgm_mc_subscribe'] ) && 'yes' == $tgm_mc_comment_data['tgm_mc_subscribe'] && ! $this->get_viewer_status() || ! empty( $_COOKIE['tgm_mc_checkbox_' . COOKIEHASH] ) && 'checked' == $_COOKIE['tgm_mc_checkbox_' . COOKIEHASH] && ! $this->get_viewer_status() ) { 
     670            if ( ! empty( $tgm_mc_comment_data['tgm_mc_subscribe'] ) && 'yes' == $tgm_mc_comment_data['tgm_mc_subscribe'] || ! empty( $_COOKIE['tgm_mc_checkbox_' . COOKIEHASH] ) && 'checked' == $_COOKIE['tgm_mc_checkbox_' . COOKIEHASH] ) { 
    679671                $name = $this->get_viewer_name(); 
    680672                $email = $this->get_viewer_email(); 
    681                 $use_name = isset( $tgm_mc_options['get_name'] ) ? true : false; 
    682673             
    683674                $api = new MCAPI( $tgm_mc_options['apikey'] ); 
    684              
    685                 if ( $use_name ) { 
    686                     $merge_vars = array( 'FNAME' => $name ); 
    687                     $api->listSubscribe( $tgm_mc_options['current_list_id'], $email, $merge_vars ); 
    688                 } 
    689                 else { 
    690                     $api->listSubscribe( $tgm_mc_options['current_list_id'], $email, array() ); 
    691                 } 
     675                $merge_vars = array( 'FNAME' => $name ); 
     676                 
     677                $api->listSubscribe( $tgm_mc_options['current_list_id'], $email, $merge_vars ); 
    692678            } 
    693679         
  • mailchimp-comment-optin/trunk/readme.txt

    r490739 r491239  
    1212Never miss another potential lead again. With this plugin, you now have the ability to add a simple checkbox and message to the end of your comment forms to allow your users to subscribe to a MailChimp list when commenting.  
    1313 
    14 The plugin integrates seamlessly with the MailChimp API to register the email (and optionally name) of your commenters into an email list of your choosing. By using the double optin method for capturing these email addresses, you can rest assured you are getting the best qualified leads for your growing email list. 
     14The plugin integrates seamlessly with the MailChimp API to register the name and email of your commenters into an email list of your choosing. By using the double optin method for capturing these email addresses, you can rest assured you are getting the best qualified leads for your growing email list. 
    1515 
    1616This plugin was created by [Thomas Griffin](http://thomasgriffinmedia.com/ "Thomas Griffin Media"). 
     
    2323 
    2424== Changelog == 
     25 
     26= 1.2.0 = 
     27* Fixed bug that caused emails not to be sent on first comment 
     28* Removed option to optionally choose first name (MailChimp needs the first name regardless) 
    2529 
    2630= 1.1.1 = 
Note: See TracChangeset for help on using the changeset viewer.