WordPress.org

Plugin Directory

Changeset 491260


Ignore:
Timestamp:
01/17/12 17:02:29 (2 years ago)
Author:
griffinjt
Message:

updated to v1.2.0 - legit works

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

Legend:

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

    r490770 r491260  
    66Author: Thomas Griffin 
    77Author URI: http://thomasgriffinmedia.com/ 
    8 Version: 1.1.0 
     8Version: 1.2.0 
    99License: GNU General Public License v3.0 
    1010License URI: http://www.opensource.org/licenses/gpl-license.php 
     
    124124                'count'                 => '', 
    125125                'show'                  => 1, 
    126                 'get_name'              => 0, 
    127126                'check_text'            => 'Subscribe me to your mailing list', 
    128127                'subscribed_text'       => 'You are currently subscribed to our mailing list', 
     
    402401                                <td> 
    403402                                    <input id="tgm-aw-show" type="checkbox" name="<?php echo $this->option; ?>[show]" value="<?php echo $tgm_aw_options['show']; ?>" <?php checked( $tgm_aw_options['show'], 1 ); ?> /> 
    404                                 </td> 
    405                             </tr> 
    406                             <tr valign="middle"> 
    407                                 <th scope="row"> 
    408                                     <label for="<?php echo $this->option; ?>[get_name]"><?php _e( 'Grab the commenter\'s name too?', 'tgm-aw-optin' ); ?></label> 
    409                                 </th> 
    410                                 <td> 
    411                                     <input id="tgm-aw-get-name" type="checkbox" name="<?php echo $this->option; ?>[get_name]" value="<?php echo $tgm_aw_options['get_name']; ?>" <?php checked( $tgm_aw_options['get_name'], 1 ); ?> /> 
    412                                     <span class="description"><?php _e( 'By default, only the email is sent to the list', 'tgm-aw-optin' ); ?></span> 
    413403                                </td> 
    414404                            </tr> 
     
    517507             
    518508            $tgm_aw_options['show'] = isset( $input['show'] ) ? (int) 1 : (int) 0; 
    519             $tgm_aw_options['get_name'] = isset( $input['get_name'] ) ? (int) 1 : (int) 0; 
    520509             
    521510            $tgm_aw_options['check_text'] = esc_attr( strip_tags( $input['check_text'] ) ); 
     
    588577        public function get_viewer_name() { 
    589578             
     579            global $tgm_aw_comment_data; 
     580             
    590581            /** Grab the current user's info if available */ 
    591582            get_currentuserinfo(); 
    592583             
    593584            /** Get the commenter email from cookies if available */ 
    594             $commenter_name = isset( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) ? trim( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) : ''; 
    595              
    596             if ( ! empty( $commenter_name ) ) 
    597                 return $commenter_name; 
    598              
    599             return false; 
     585            if ( ! empty( $tgm_aw_comment_data['comment_author_name'] ) ) 
     586                $commenter_name = $tgm_aw_comment_data['comment_author_name']; 
     587            elseif ( ! empty( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ) ) 
     588                $commenter_name = trim( $_COOKIE[sanitize_key( 'comment_author_' . COOKIEHASH )] ); 
     589             
     590            if ( empty( $commenter_name ) ) 
     591                return false; 
     592             
     593            return $commenter_name; 
    600594         
    601595        } 
     
    615609        public function get_viewer_email() { 
    616610         
    617             global $post, $user_email, $tgm_aw_options; 
     611            global $post, $user_email, $tgm_aw_options, $tgm_aw_comment_data; 
    618612             
    619613            /** Grab the current user's info if available */ 
     
    621615             
    622616            /** Get the commenter email from cookies if available */ 
    623             $commenter_email = isset( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) ? trim( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) : ''; 
     617            if ( ! empty( $tgm_aw_comment_data['comment_author_email'] ) ) 
     618                $commenter_email = $tgm_aw_comment_data['comment_author_email']; 
     619            elseif ( ! empty( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ) ) 
     620                $commenter_email = trim( $_COOKIE[sanitize_key( 'comment_author_email_' . COOKIEHASH )] ); 
    624621             
    625622            if ( is_email( $user_email ) ) 
     
    732729        public function populate_list() { 
    733730         
    734             global $tgm_aw_options; 
    735              
    736             /** Return early if we are in the admin */ 
    737             if ( is_admin() ) 
    738                 return; 
     731            global $tgm_aw_options, $tgm_aw_comment_data; 
    739732                 
    740733            /** Only go forward if the checkbox has been selected and the user isn't subscribed */ 
    741             if ( ! empty( $tgm_aw_comment_data['tgm_aw_subscribe'] ) && 'yes' == $tgm_aw_comment_data['tgm_aw_subscribe'] && ! $this->get_viewer_status() || ! empty( $_COOKIE['tgm_aw_checkbox_' . COOKIEHASH] ) && 'checked' == $_COOKIE['tgm_aw_checkbox_' . COOKIEHASH] && ! $this->get_viewer_status() ) { 
     734            if ( ! empty( $tgm_aw_comment_data['tgm_aw_subscribe'] ) && 'yes' == $tgm_aw_comment_data['tgm_aw_subscribe'] || ! empty( $_COOKIE['tgm_aw_checkbox_' . COOKIEHASH] ) && 'checked' == $_COOKIE['tgm_aw_checkbox_' . COOKIEHASH] ) { 
    742735                /** Before we can connect to the API, we need to make sure all of our data is set */ 
    743736                if ( ! ( empty( $tgm_aw_options['auth_key'] ) && empty( $tgm_aw_options['auth_token'] ) && empty( $tgm_aw_options['req_key'] ) && empty( $tgm_aw_options['req_token'] ) && empty( $tgm_aw_options['oauth'] ) && empty( $tgm_aw_options['user_token'] ) && empty( $tgm_aw_options['user_token_secret'] ) ) ) { 
     
    765758                    $name = $this->get_viewer_name(); 
    766759                    $email = $this->get_viewer_email(); 
    767                     $use_name = isset( $tgm_aw_options['get_name'] ) ? true : false; 
    768                  
    769                     /** Create a new subscriber (optionally with their name) */ 
    770                     if ( $use_name ) { 
    771                         try { 
    772                             $create = $subscribers->create( array( 'email' => $email, 'name' => $name ) ); 
    773                         } catch ( AWeberException $e ) { 
    774                             return false; 
    775                         } 
    776                     } 
    777                     else { 
    778                         try { 
    779                             $create = $subscribers->create( array( 'email' => $email ) ); 
    780                         } catch ( AWeberException $e ) { 
    781                             return false; 
    782                         } 
     760                 
     761                    /** Create a new subscriber */ 
     762                    try { 
     763                        $create = $subscribers->create( array( 'email' => $email, 'name' => $name ) ); 
     764                    } catch ( AWeberException $e ) { 
     765                        return false; 
    783766                    } 
    784767                } 
  • aweber-comment-optin/trunk/readme.txt

    r490801 r491260  
    3131== Changelog == 
    3232 
     33= 1.2.0 = 
     34* Fixed bug with email not being added on first comment 
     35* Removed option to optionally grab name (Aweber needs it) 
     36 
    3337= 1.1.0 = 
    3438* Fixed issue with `lib` folder not being including 
Note: See TracChangeset for help on using the changeset viewer.