Plugin Directory

Changeset 616900


Ignore:
Timestamp:
10/24/2012 03:54:26 PM (13 years ago)
Author:
alexandreb3
Message:

update to 1.6

Location:
aweber-subscribers-count/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • aweber-subscribers-count/trunk/aweber-count-optin.php

    r577192 r616900  
    66Author: Alex from WP Themes Pro
    77Author URI: http://wp-themes-pro.com
    8 Version: 1.5.0
     8Version: 1.6.0
    99License: GNU General Public License v3.0
    1010License URI: http://www.opensource.org/licenses/gpl-license.php
     
    126126                'show'                  => 1,
    127127                'inc_unsubscribed'      => '',
     128                'cache_validity'        => '',
    128129                'check_text'            => 'Subscribe me to your mailing list',
    129130                'subscribed_text'       => 'You are currently subscribed to our mailing list',
     
    221222                    $tgm_aw_options['lists'][$i]['id'] = $list['id'];
    222223                    $tgm_aw_options['lists'][$i]['name'] = $list['name'];
     224                    $tgm_aw_options['lists'][$i]['real_subscribers']=(int)$list['total_subscribers'];
     225                    $tgm_aw_options['lists'][$i]['total_subscribers']=(int)$list['total_subscribed_subscribers'];
     226                    $tgm_aw_options['lists'][$i]['last_updated']=time();
    223227                    $i++;
    224228                }
     
    293297                        <form id="tgm-aw-options" action="options.php" method="post">
    294298                            <?php
    295                            
     299                                /*echo "<pre>";
     300                                print_r($tgm_aw_options);
     301                                echo "</pre>";*/
    296302                             settings_fields( $this->option ); ?>
    297303                            <?php $this->get_form_options(); ?>
     
    400406                                </th>
    401407                                <td>
    402                                     <input id="tgm-aw-inc_unsubscribed" type="checkbox" name="<?php echo $this->option; ?>[inc_unsubscribed]" value="<?php echo $tgm_aw_options['inc_unsubscribed']; ?>" <?php checked( $tgm_aw_options['inc_unsubscribed'], 1 ); ?> /> <?php _e( 'Tick in order to display the Grand Total count.<br/>Untick to display your real subscriber count.', 'tgm-aw-optin' ); ?>
     408                                    <input id="tgm-aw-inc_unsubscribed" type="checkbox" name="<?php echo $this->option; ?>[inc_unsubscribed]" value="<?php echo $tgm_aw_options['inc_unsubscribed']; ?>" <?php checked( $tgm_aw_options['inc_unsubscribed'], 1 ); ?> /> <?php _e( 'Tick in order to display your real subscriber count.<br/>Untick to display the Grand Total count.', 'tgm-aw-optin' ); ?>
    403409                                </td>
    404410                            </tr>
    405                            
     411                            <tr valign="middle" >
     412                                <th scope="row">
     413                                    <label for="<?php echo $this->option; ?>[cache_validity]"><?php _e( 'Refresh cached count data validity period ', 'tgm-aw-optin' ); ?></label>
     414                                </th>
     415                                <td>
     416                                    <input id="tgm-aw-cache_validity" type="text" name="<?php echo $this->option; ?>[cache_validity]" value="<?php echo $tgm_aw_options['cache_validity']; ?>"  /> <?php _e( 'Enter number of seconds for which the cache is valid for particular list count.', 'tgm-aw-optin' ); ?>
     417                                </td>
     418                            </tr>
    406419                            <tr valign="middle" style="display:none;">
    407420                                <th scope="row">
     
    484497            $tgm_aw_options['show'] = isset( $input['show'] ) ? (int) 1 : (int) 0;
    485498            $tgm_aw_options['inc_unsubscribed'] = isset( $input['inc_unsubscribed'] ) ? (int) 1 : (int) 0;
     499            $tgm_aw_options['cache_validity'] = isset( $input['cache_validity'] ) ? (int) esc_attr( strip_tags( $input['cache_validity'] ) ) : (int) 7200;
    486500            $tgm_aw_options['check_text'] = esc_attr( strip_tags( $input['check_text'] ) );
    487501            $tgm_aw_options['subscribed_text'] = esc_attr( strip_tags( $input['subscribed_text'] ) );
  • aweber-subscribers-count/trunk/aweber-count-shortcode.php

    r577192 r616900  
    2727       global $wp, $wpdb;
    2828       global $tgm_aw_options, $tgm_aw_Count_data;
    29       // echo '<pre>';
    30        //print_r($tgm_aw_options);
     29      /* echo '<pre>';
     30      print_r($tgm_aw_options); exit;*/
    3131       
    32        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'] ) ) ) {
    33            
    34                     /** Everything is set in our options, so let's move forward */
    35                     require_once('lib/aweber_api/aweber_api.php');
    36                     $aweber = new AWeberAPI( $tgm_aw_options['auth_key'], $tgm_aw_options['auth_token'] );
    37                     $aweber->user->requestToken = $tgm_aw_options['req_key'];
    38                     $aweber->user->tokenSecret = $tgm_aw_options['req_token'];
    39                     $aweber->user->verifier = $tgm_aw_options['oauth'];
    40                
    41                     /** Attempt to get account information, return false if there is an error */
    42                     try {           
    43                         $user_account = $aweber->getAccount( $tgm_aw_options['user_token'], $tgm_aw_options['user_token_secret'] );                     
    44                         $acc = $user_account->lists->data;
    45                         $list=explode(",",$list);
    46                         //echo '<pre>'; print_r($acc);
    47                         //print_r($tgm_aw_options); die;
    48                         if(count($list)<=0){
    49                             for ($i = 0; $i< count($acc['entries']); $i++)
    50                             {
    51                                 if ( $acc['entries'][$i]['name'] == $tgm_aw_options['current_list_name'] )
    52                                 {
    53                                     if($tgm_aw_options['inc_unsubscribed']=='1')
    54                                         return $acc['entries'][$i]['total_subscribers'];
    55                                     else
    56                                         return $acc['entries'][$i]['total_subscribed_subscribers'];
    57                                    
    58                                 }
    59                                 //echo $value;
    60                             }
    61                         } else {
    62                             //print_r($list);
    63                             $subscriber_count=0; //initially set the subscriber count to 0;
    64                             for ($i = 0; $i< count($acc['entries']); $i++)
    65                             {
    66                                
    67                                 if (in_array( $acc['entries'][$i]['name'], $list) )
     32       $list=explode(",",$list);
     33        //echo '<pre>'; print_r($acc);
     34        //print_r($tgm_aw_options); die;
     35        if(count($list)<=0){
     36            $subscriber_count=getListCount($tgm_aw_options['current_list_name']);
     37        } else {
     38            //print_r($list);
     39            $subscriber_count=0; //initially set the subscriber count to 0;
     40            foreach ($list as $l )
     41            {
     42                $subscriber_count += (int)getListCount($l);
     43            }
     44           
     45        }
     46        return $subscriber_count;
     47}
     48
     49function getListCount($list_name='')
     50{
     51        global $option;
     52        global $wp, $wpdb;
     53        global $tgm_aw_options, $tgm_aw_Count_data;
     54       
     55        if($list_name!='')
     56        {
     57            for($i=0; $i<count($tgm_aw_options['lists']); $i++)
     58            {
     59                if($tgm_aw_options['lists'][$i]['name']==$list_name)
     60                {
     61                    $diff=time() - $tgm_aw_options['lists'][$i]['last_updated'];
     62                   
     63                    if($tgm_aw_options['lists'][$i]['real_subscribers']=='' or $tgm_aw_options['lists'][$i]['total_subscribers']=='' or $diff>=$tgm_aw_options['cache_validity'] ) // if listcount is not present in the cache then fetch from aweber
     64                    {
     65                       
     66                        if ( ! ( empty( $tgm_aw_options['auth_key'] ) && empty( $tgm_aw_options['auth_token'] ) && empty( $tgm_aw_options['req_key'] )
     67                                && empty( $tgm_aw_options['req_token'] ) && empty( $tgm_aw_options['oauth'] ) && empty( $tgm_aw_options['user_token'] )
     68                                && empty( $tgm_aw_options['user_token_secret'] ) ) )
     69                        {
     70                            /** Everything is set in our options, so let's move forward */
     71                            require_once('lib/aweber_api/aweber_api.php');
     72                            $aweber = new AWeberAPI( $tgm_aw_options['auth_key'], $tgm_aw_options['auth_token'] );
     73                            $aweber->user->requestToken = $tgm_aw_options['req_key'];
     74                            $aweber->user->tokenSecret = $tgm_aw_options['req_token'];
     75                            $aweber->user->verifier = $tgm_aw_options['oauth'];
     76                            try
     77                            {           
     78                                $user_account = $aweber->getAccount( $tgm_aw_options['user_token'], $tgm_aw_options['user_token_secret'] );                     
     79                                $acc = $user_account->lists->data;
     80                                for ($j = 0; $j< count($acc['entries']); $j++)
    6881                                {
    6982                                   
    70                                     if($tgm_aw_options['inc_unsubscribed']=='1') //check if options for include unsubscribers in count is ON
    71                                          $subscriber_count += (int)$acc['entries'][$i]['total_subscribers']; //This is the total no of Subsribers including unsubscribers as well
    72                                     else
    73                                         $subscriber_count+= (int)$acc['entries'][$i]['total_subscribed_subscribers'];   // This is the total subscribers exluding unsubscribed.
     83                                    if ($acc['entries'][$j]['name']==$list_name ) //if listname matches the current list
     84                                    {
     85                                        $tgm_aw_options['lists'][$i]['real_subscribers']=(int)$acc['entries'][$j]['total_subscribers'];
     86                                        $tgm_aw_options['lists'][$i]['total_subscribers']=(int)$acc['entries'][$j]['total_subscribed_subscribers'];
     87                                        $tgm_aw_options['lists'][$i]['last_updated']=time();
     88                                       
     89                                        update_option( 'tgm_aweber_Count_settings', $tgm_aw_options );
     90                                       
     91                                       
     92                                    }
     93                                   
     94                                    //echo $value;
    7495                                }
    75                                
    76                                 //echo $value;
    7796                            }
    78                             return $subscriber_count;
     97                            catch ( AWeberException $e ) {
     98                                return false;
     99                            }
     100                           
    79101                        }
    80                        
    81                     } catch ( AWeberException $e ) {
    82                         return false;
    83102                    }
    84103                   
    85                    
    86                    
     104                    if( $tgm_aw_options['inc_unsubscribed']=='1' ) //check if options for include unsubscribers in count is ON
     105                        return $tgm_aw_options['lists'][$i]['total_subscribers'];
     106                    else
     107                        return $tgm_aw_options['lists'][$i]['real_subscribers'];
    87108                }
     109            }
     110           
     111        }
     112        else
     113        {
     114            return "EMPTY LIST";
     115        }
     116       
    88117}
    89 
    90118add_shortcode('displaycount','show_AW_count',1);
    91119add_filter('widget_text', 'do_shortcode');
  • aweber-subscribers-count/trunk/readme.txt

    r577345 r616900  
    55Requires at least: 3.0
    66Tested up to: 3.4.1
    7 Stable tag: 1.5.3
     7Stable tag: 1.6.0
    88License: GNU General Public License v3.0
    99License URI: http://www.opensource.org/licenses/gpl-license.php
     
    3939== Changelog ==
    4040
     41= 1.6.0 =
     42- The plugin now stores the count in the database in order to increase the page loading
     43- You can set the count refresh frequency
     44- Fixed grand total tick in admin
     45
    4146= 1.5.3 =
    42 CSS Fix
     47-CSS Fix
    4348
    4449= 1.5.2 =
    45 Readme update
     50-Readme update
    4651
    4752= 1.5.1 =
    48 Minor CSS fix
     53-Minor CSS fix
    4954
    5055= 1.5 =
Note: See TracChangeset for help on using the changeset viewer.