Plugin Directory

Changeset 1754726


Ignore:
Timestamp:
10/29/2017 01:25:09 PM (8 years ago)
Author:
madaritech
Message:

Release 1.5

Location:
synchro-mailchimp
Files:
45 added
8 edited

Legend:

Unmodified
Added
Removed
  • synchro-mailchimp/trunk/admin/class-synchro-mailchimp-admin.php

    r1746848 r1754726  
    128128    public function read_mailchimp_schema( &$mailchimp_lists, &$mailchimp_interest_categories, &$mailchimp_interests ) {
    129129
     130        // Extract lists from MailChimp.
    130131        $lists_obj = $this->api->get_lists( array() );
    131132        $list_arr = array();
     
    135136        }
    136137
     138        // For each list extracted...
    137139        foreach ( $list_arr as $list ) {
    138140
     141            // ...save list name..
    139142            $mailchimp_lists[ $list['id'] ] = [
    140143                'name' => $list['name'],
    141144                'checked' => false,
    142145            ];
     146
     147            // ...extract the list interest categories from MailChimp...
    143148            $interest_categories_obj = $this->api->get_list_interest_categories( $list['id'] );
    144149            $interest_categories_arr = json_decode( json_encode( $interest_categories_obj ), true );
    145150
     151            // ... and foreach interest category extracted...
    146152            foreach ( $interest_categories_arr as $interest_category ) {
    147153
    148                                 $mailchimp_interest_categories[ $list['id'] ][ $interest_category['id'] ] = $interest_category['title'];
     154                // ...save the interest category and...
     155                $mailchimp_interest_categories[ $list['id'] ][ $interest_category['id'] ] = $interest_category['title'];
     156
     157                // ...extract from MailChimp the category interests...
    149158                $interests_obj = $this->api->get_list_interest_category_interests( $list['id'], $interest_category['id'] );
    150159                $interests_arr = json_decode( json_encode( $interests_obj ), true );
    151160
     161                // ...finally for each interest...
    152162                foreach ( $interests_arr as $interest ) {
     163
     164                    // ...save the interest informations.
    153165                    $mailchimp_interests[ $interest_category['id'] ][ $interest['id'] ] = [
    154166                        'name' => $interest['name'],
     
    225237
    226238        // Update 'checked' property using configuration, and assignment to the proper wp role.
     239        // Scan every role.
    227240        foreach ( $all_roles as $role => $role_name ) {
    228241
     242            // The $configuration was extracted by MailChimp site, and it contains only the selected lists and interests.
    229243            foreach ( $configuration[ $role ] as $configuration_list_id => $configuration_interest_array ) {
    230244
     245                // The $setting_* contains all the values, without know if checked or not: in this function we find out and set properly thei values. Here we cycle on all the lists for the $role.
    231246                foreach ( $settings_lists[ $role ] as $mailchimp_list_id => $mailchimp_list_array ) {
    232247
     248                    // If the list exists in $configuration, it means is checked on MailChimp, so we have to check it too on the form.
    233249                    if ( $mailchimp_list_id == $configuration_list_id ) {
    234250
    235                         // Checked sulla lista.
     251                        // Check the list!
    236252                        $settings_lists[ $role ][ $mailchimp_list_id ]['checked'] = true;
    237253
    238                     }
    239 
    240                     if ( $settings_lists[ $role ][ $mailchimp_list_id ]['checked'] ) {
    241 
     254                        // Now examine the related interests.
     255                        // If there are interest categories for the list...
    242256                        if ( isset( $settings_interest_categories[ $role ][ $mailchimp_list_id ] ) ) {
     257
     258                            // ...let's cycle over these categories...
    243259                            foreach ( $settings_interest_categories[ $role ][ $mailchimp_list_id ] as $mailchimp_category_id => $mailchimp_category_name ) {
    244260
     261                                // ...and so from the category let's cycle over all the relative interests.
    245262                                foreach ( $settings_interests[ $role ][ $mailchimp_category_id ] as $mailchimp_interest_id => $mailchimp_interest_bool ) {
    246263
     264                                    // If the particular interest exists in the configuration array, it means have to be checked. We get that value from the $configuration_interest_array that contain all the set checked interests.
    247265                                    if ( array_key_exists( $mailchimp_interest_id, $configuration_interest_array ) ) {
    248266
     
    403421        try {
    404422            $subscription_status = $this->subscription_service->check_subscription_status( $user_email, $user_role );
    405             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    406                 $this->log->debug( "Checking subscrition status [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]" );
    407             }
     423            $this->log->debug( "Checking subscrition status [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]" );
    408424        } catch ( Exception $e ) {
    409425            $error_message = __( 'Subscription check status failed. ', 'synchro_mailchimp' );
     
    419435        }
    420436
    421         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    422             $this->log->debug( "Checkbox status received [ check status :: $check_status ]" );
    423         }
     437        $this->log->debug( "Checkbox status received [ check status :: $check_status ]" );
    424438
    425439        if ( $check_status ) {
  • synchro-mailchimp/trunk/includes/class-synchro-mailchimp-log-service.php

    r1746824 r1754726  
    3737     */
    3838    public function __construct( $class_name ) {
    39 
    4039        $this->class_name = $class_name;
    41 
    4240    }
    4341
     
    5048     */
    5149    public static function is_enabled() {
    52 
    5350        return defined( 'WP_DEBUG' ) && WP_DEBUG;
    5451    }
     
    6461     */
    6562    public static function create( $class_name ) {
    66 
    6763        return new Synchro_MailChimp_Log_Service( $class_name );
    6864    }
     
    7672     */
    7773    public function debug( $message ) {
    78 
    7974        $this->log( 'DEBUG', $message );
    80 
    8175    }
    8276
     
    127121     * @param string $level   The debug level.
    128122     * @param string $message The message.
     123     * @param bool   $override True if the logger print the message without check if the debug is enabled on wp-config.
    129124     */
    130     private function log( $level, $message ) {
    131 
    132         error_log( sprintf( '%-6s [%-40s] %s', $level, $this->class_name, $message ) );
    133 
     125    private function log( $level, $message, $override = false ) {
     126        if ( $override ) {
     127            error_log( sprintf( '%-6s [%-40s] %s', $level, $this->class_name, $message ) );
     128        } elseif ( $this->is_enabled() ) {
     129            error_log( sprintf( '%-6s [%-40s] %s', $level, $this->class_name, $message ) );
     130        }
    134131    }
    135132
  • synchro-mailchimp/trunk/includes/class-synchro-mailchimp-requirements-service.php

    r1746824 r1754726  
    7575                    'strong' => array(),
    7676                );
    77                 $html_text = kses( '<strong>Synchro MailChimp</strong> needs <strong>MailChimp for WordPress</strong> installed, active and configured. Download it now! ', $allowed_html );
     77                $html_text = wp_kses( '<strong>Synchro MailChimp</strong> needs <strong>MailChimp for WordPress</strong> installed, active and configured. Download it now! ', $allowed_html );
    7878                echo __( $html_text, 'synchro_mailchimp' );
    7979            ?>
  • synchro-mailchimp/trunk/includes/class-synchro-mailchimp-subscription-service.php

    r1746824 r1754726  
    8080    public function subscribe_process( $subscription_status, $user_email, $user_role ) {
    8181
    82         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    83             $this->log->debug( "Subscribing [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]..." );
    84         }
     82        $this->log->debug( "Subscribing [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]..." );
    8583
    8684        $res = false;
     
    112110        }
    113111
    114         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    115             $this->log->info( "Subscribed [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]." );
    116         }
     112        $this->log->info( "Subscribed [ subscription status :: $subscription_status ][ user e-mail :: $user_email ][ user role :: $user_role ]." );
    117113
    118114        return ( $res );
     
    174170     */
    175171    public function check_subscription_status( $user_email, $user_role ) {
    176         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    177             $this->log->debug( "Checking subscription status [ user e-mail :: $user_email ][ user role :: $user_role ]..." );
    178         }
     172
     173        $this->log->debug( "Checking subscription status [ user e-mail :: $user_email ][ user role :: $user_role ]..." );
    179174
    180175        // Extract configuration parameters.
    181176        $smc = $this->configuration->get_by_role( $user_role );
    182177
    183         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    184                 $c = count( $smc );
    185                 $this->log->debug( "Checking configuration [ count smc :: $c ][ user role :: $user_role ]" );
    186         }
     178        $c = count( $smc );
     179        $this->log->debug( "Checking configuration [ count smc :: $c ][ user role :: $user_role ]" );
    187180
    188181        // User lists extraction and verifies alignment with configuration.
     
    200193            } // Unchecked.
    201194
    202             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    203                 $this->log->debug( "Check Subscription Status [ num_list_config :: $num_list_config ]" );
    204             }
     195            $this->log->debug( "Check Subscription Status [ num_list_config :: $num_list_config ]" );
    205196
    206197            if ( 0 == $num_list_config ) {
     
    246237        } catch ( MC4WP_API_Connection_Exception $e ) {
    247238
    248             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    249 
    250                 $message = $e->getMessage();
    251                 $code = $e->getCode();
    252                 $this->log->debug( "Check Subscription Status: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
    253 
    254             }
     239            $message = $e->getMessage();
     240            $code = $e->getCode();
     241            $this->log->debug( "Check Subscription Status: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
     242
    255243            $exep_message = __( 'Connection failure.','synchro_mailchimp' );
    256244            throw new Exception( $exep_message . ' ' . $message );
     
    258246        } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
    259247
    260             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    261 
    262                 $message = $e->getMessage();
    263                 $code = $e->getCode();
    264                 $this->log->debug( "Check Subscription Status: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
    265 
    266             }
     248            $message = $e->getMessage();
     249            $code = $e->getCode();
     250            $this->log->debug( "Check Subscription Status: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
     251
    267252            throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) );
    268253
    269254        } catch ( MC4WP_API_Exception $e ) {
    270255
    271             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    272 
    273                 $message = $e->getMessage();
    274                 $code = $e->getCode();
    275                 $this->log->debug( "Check Subscription Status: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
    276 
    277             }
     256            $message = $e->getMessage();
     257            $code = $e->getCode();
     258            $this->log->debug( "Check Subscription Status: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
     259
    278260            throw new Exception( __( 'Connection API error.','synchro_mailchimp' ) );
    279261
    280262        } catch ( Exception $e ) {
    281263
    282             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    283 
    284                 $message = $e->getMessage();
    285                 $code = $e->getCode();
    286                 $this->log->debug( "Check Subscription Status: Exception [ message :: $message ] [ code :: $code]" );
    287 
    288             }
     264            $message = $e->getMessage();
     265            $code = $e->getCode();
     266            $this->log->debug( "Check Subscription Status: Exception [ message :: $message ] [ code :: $code]" );
     267
    289268            throw new Exception( __( 'Generic error.','synchro_mailchimp' ) );
    290269        }
     
    301280     */
    302281    public function subscribe_user( $user_email ) {
    303         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    304             $this->log->debug( "Subscribing user [ user e-mail :: $user_email ]..." );
    305         }
     282
     283        $this->log->debug( "Subscribing user [ user e-mail :: $user_email ]..." );
    306284
    307285        $args['email_address'] = $user_email;
     
    339317
    340318            } catch ( MC4WP_API_Connection_Exception $e ) {
    341 
    342                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    343 
    344                     $message = $e->getMessage();
    345                     $code = $e->getCode();
    346                     $this->log->debug( "Subscribing user: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
    347 
    348                 }
     319                $message = $e->getMessage();
     320                $code = $e->getCode();
     321
     322                $this->log->debug( "Subscribing user: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
     323
    349324                $excep_message = __( 'Connection problem.','synchro_mailchimp' );
    350325                throw new Exception( $excep_message . ' ' . $message );
    351326
    352327            } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
    353 
    354                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    355 
    356                     $message = $e->getMessage();
    357                     $code = $e->getCode();
    358                     $this->log->debug( "Subscribing user: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
    359 
    360                 }
     328                $message = $e->getMessage();
     329                $code = $e->getCode();
     330                $this->log->debug( "Subscribing user: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
     331
    361332                throw new Exception( __( 'Resource not found in subscribing user.','synchro_mailchimp' ) );
    362333
    363334            } catch ( MC4WP_API_Exception $e ) {
    364 
    365                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    366 
    367                     $message = $e->getMessage();
    368                     $code = $e->getCode();
    369                     $this->log->debug( "Subscribing user: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
    370 
    371                 }
     335                $message = $e->getMessage();
     336                $code = $e->getCode();
     337                $this->log->debug( "Subscribing user: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
     338
    372339                $excep_message = __( 'Subscribing user: API error. MailChimp message:','synchro_mailchimp' );
    373340                throw new Exception( $excep_message . ' ' . $e->detail );
    374341
    375342            } catch ( Exception $e ) {
    376 
    377                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    378 
    379                     $message = $e->getMessage();
    380                     $code = $e->getCode();
    381                     $this->log->debug( "Subscribing user: Exception [ message :: $message ] [ code :: $code]" );
    382 
    383                 }
     343                $message = $e->getMessage();
     344                $code = $e->getCode();
     345                $this->log->debug( "Subscribing user: Exception [ message :: $message ] [ code :: $code]" );
     346
    384347                throw new Exception( __( 'Subscribing user: generic error.','synchro_mailchimp' ) );
    385348
    386349            }
    387350
    388             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    389                 $this->log->trace( 'Call to `add_list_member` returned [ ' . var_export( $add_status, true ) . ' ]' );
    390             }
     351            $this->log->trace( 'Call to `add_list_member` returned [ ' . var_export( $add_status, true ) . ' ]' );
    391352        }
    392353
     
    404365    public function unsubscribe_user_config( $user_email ) {
    405366
    406         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    407             $this->log->debug( "Unsubscribing user config [ user e-mail :: $user_email ]" );
    408         }
     367        $this->log->debug( "Unsubscribing user config [ user e-mail :: $user_email ]" );
    409368
    410369        // Get the user id.
     
    414373        $lists = apply_filters( 'sm_user_list', $lists, $user->ID );
    415374
    416         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    417             $c = count( $lists );
    418             $this->log->debug( "Unsubscribing user config [ lists after apply filter :: $c ]" );
    419         }
     375        $c = count( $lists );
     376        $this->log->debug( "Unsubscribing user config [ lists after apply filter :: $c ]" );
    420377
    421378        $reset_args['email'] = $user_email;
     
    429386            } catch ( MC4WP_API_Connection_Exception $e ) {
    430387
    431                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    432 
    433                                         $message = $e->getMessage();
    434                     $code = $e->getCode();
    435                     $this->log->debug( "Unsubscribe User Config: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
    436 
    437                 }
     388                $message = $e->getMessage();
     389                $code = $e->getCode();
     390                $this->log->debug( "Unsubscribe User Config: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
     391
    438392                $excep_message = __( 'Connection problem.','synchro_mailchimp' );
    439393                throw new Exception( $excep_message . ' ' . $message );
     
    441395            } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
    442396
    443                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    444 
    445                             $message = $e->getMessage();
    446                     $code = $e->getCode();
    447                     $this->log->debug( "Unsubscribe User Config: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
    448 
    449                 }
     397                $message = $e->getMessage();
     398                $code = $e->getCode();
     399                $this->log->debug( "Unsubscribe User Config: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
     400
    450401                throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) );
    451402
    452403            } catch ( MC4WP_API_Exception $e ) {
    453404
    454                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    455 
    456                     $message = $e->getMessage();
    457                     $code = $e->getCode();
    458                     $this->log->debug( "Unsubscribe User Config: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
    459 
    460                 }
     405                $message = $e->getMessage();
     406                $code = $e->getCode();
     407                $this->log->debug( "Unsubscribe User Config: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
     408
    461409                throw new Exception( __( 'API connection error.','synchro_mailchimp' ) );
    462410
    463411            } catch ( Exception $e ) {
    464412
    465                 if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    466 
    467                     $message = $e->getMessage();
    468                     $code = $e->getCode();
    469                     $this->log->debug( "Unsubscribe User Config: Exception [ message :: $message ] [ code :: $code]" );
    470 
    471                 }
     413                $message = $e->getMessage();
     414                $code = $e->getCode();
     415                $this->log->debug( "Unsubscribe User Config: Exception [ message :: $message ] [ code :: $code]" );
     416
    472417                throw new Exception( __( 'Generic error.','synchro_mailchimp' ) );
    473418
     
    499444        } catch ( MC4WP_API_Connection_Exception $e ) {
    500445
    501             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    502 
    503                                     $message = $e->getMessage();
    504                 $code = $e->getCode();
    505                 $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
    506 
    507             }
     446            $message = $e->getMessage();
     447            $code = $e->getCode();
     448            $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Connection_Exception [ message :: $message ] [ code :: $code]" );
     449
    508450            $excep_message = __( 'Connection problem.','synchro_mailchimp' );
    509451            throw new Exception( $excep_message . ' ' . $message );
     
    511453        } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) {
    512454
    513             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    514 
    515                         $message = $e->getMessage();
    516                 $code = $e->getCode();
    517                 $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
    518 
    519             }
     455            $message = $e->getMessage();
     456            $code = $e->getCode();
     457            $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Resource_Not_Found_Exception [ message :: $message ] [ code :: $code]" );
     458
    520459            throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) );
    521460
    522461        } catch ( MC4WP_API_Exception $e ) {
    523462
    524             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    525 
    526                 $message = $e->getMessage();
    527                 $code = $e->getCode();
    528                 $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
    529 
    530             }
     463            $message = $e->getMessage();
     464            $code = $e->getCode();
     465            $this->log->debug( "Unsubscribe User MailChimp: MC4WP_API_Exception [ message :: $message ] [ code :: $code]" );
     466
    531467            throw new Exception( __( 'API connection error.','synchro_mailchimp' ) );
    532468
    533469        } catch ( Exception $e ) {
    534470
    535             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    536 
    537                 $message = $e->getMessage();
    538                 $code = $e->getCode();
    539                 $this->log->debug( "Unsubscribe User MailChimp: Exception [ message :: $message ] [ code :: $code]" );
    540 
    541             }
     471            $message = $e->getMessage();
     472            $code = $e->getCode();
     473            $this->log->debug( "Unsubscribe User MailChimp: Exception [ message :: $message ] [ code :: $code]" );
     474
    542475            throw new Exception( __( 'Generic error.','synchro_mailchimp' ) );
    543476
  • synchro-mailchimp/trunk/includes/class-synchro-mailchimp-user-service-adapter.php

    r1746824 r1754726  
    7474    public function user_lists( $lists, $user_id ) {
    7575
    76         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    77             $this->log->debug( "Getting the lists and interests for user $user_id" );
    78         }
    79 
     76        $this->log->debug( "Getting the lists and interests for user $user_id" );
    8077        return $this->user_service->get_lists( $lists, $user_id );
    8178    }
     
    107104     */
    108105    public function user_list_interests( $interests, $user_id, $list_id ) {
    109 
    110         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    111             $this->log->debug( "Getting the interests for user $user_id and list $list_id..." );
    112         }
    113 
     106        $this->log->debug( "Getting the interests for user $user_id and list $list_id..." );
    114107        return $this->user_service->get_interests( $user_id, $list_id, $interests );
    115108    }
  • synchro-mailchimp/trunk/includes/class-synchro-mailchimp-user-service.php

    r1746824 r1754726  
    7474    public function get_lists( $lists, $user_id ) {
    7575
    76         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    77             $this->log->debug( "Getting the lists for user $user_id" );
    78         }
     76        $this->log->debug( "Getting the lists for user $user_id" );
    7977
    8078        // Get the user.
     
    8381        // Return an empty array if the user doesn't exist.
    8482        if ( false === $user ) {
    85 
    86             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    87                 $this->log->warn( "User $user_id not found." );
    88             }
    89 
     83            $this->log->warn( "User $user_id not found." );
    9084            return $lists;
    9185        }
     
    9791            $role_lists = $this->configuration_service->get_by_role( $role );
    9892
    99             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    100                 $this->log->trace( 'Got ' . count( $role_lists ) . " list(s) for user $user_id, role $role." );
    101             }
     93            $this->log->trace( 'Got ' . count( $role_lists ) . " list(s) for user $user_id, role $role." );
    10294
    10395            // Add the list to the return array and combine it with the existing value if any.
     
    10799        }
    108100
    109         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    110             $this->log->info( 'Found ' . count( $lists ) . " list(s) for user $user_id: " . var_export( $lists, true ) );
    111         }
     101        $this->log->info( 'Found ' . count( $lists ) . " list(s) for user $user_id: " . var_export( $lists, true ) );
    112102
    113103        return $lists;
     
    138128    public function get_interests( $user_id, $list_id, $seed = array() ) {
    139129
    140         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    141             $this->log->debug( "Getting the interests for user $user_id and list $list_id..." );
    142         }
     130        $this->log->debug( "Getting the interests for user $user_id and list $list_id..." );
    143131
    144132        // Get the user.
     
    147135        // Return an empty array if the user doesn't exist.
    148136        if ( false === $user ) {
    149 
    150             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    151                 $this->log->warn( "User $user_id not found." );
    152             }
    153 
     137            $this->log->warn( "User $user_id not found." );
    154138            return $seed;
    155139        }
     
    164148            $role_interests = $this->configuration_service->get_by_role_and_list( $role, $list_id );
    165149
    166             if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    167                 $this->log->trace( 'Got ' . count( $role_interests ) . " interest(s) for user $user_id, role $role, list $list_id." );
    168             }
     150            $this->log->trace( 'Got ' . count( $role_interests ) . " interest(s) for user $user_id, role $role, list $list_id." );
    169151
    170152            // Add the interest to the return array and combine it with the existing value if any: the seed is not changed, only new keys are added with their values.
     
    174156        }
    175157
    176         if ( Synchro_MailChimp_Log_Service::is_enabled() ) {
    177             $this->log->info( 'Found ' . count( $interests ) . " interest(s) for user $user_id and list $list_id: " . var_export( $interests, true ) );
    178         }
     158        $this->log->info( 'Found ' . count( $interests ) . " interest(s) for user $user_id and list $list_id: " . var_export( $interests, true ) );
    179159
    180160        return $interests;
  • synchro-mailchimp/trunk/readme.txt

    r1746848 r1754726  
    66Requires at least: 4.8
    77Tested up to: 4.8.2
    8 Stable tag: 1.4
     8Stable tag: 1.5
    99License: GPLv2
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5252== Changelog ==
    5353
     54= 1.5 =
     55* bug fixed
     56* Comments to code added
     57* Code refactoring
     58
    5459= 1.3 =
    5560* Refactoring based on WordPress Standard
     
    6671== Upgrade Notice ==
    6772
     73= 1.5 =
     74This version fixes a security issue.  Upgrade immediately.
     75
    6876= 1.3 =
    6977This version fixes a security issue.  Upgrade immediately.
  • synchro-mailchimp/trunk/synchro-mailchimp.php

    r1746848 r1754726  
    1010 * Plugin Name:       Synchro MailChimp
    1111 * Description:       The plugin permits administrators to subscribe/unsubscribe WordPress users to MailChimp by a checkbox on the WordPress user settings page. Every user, depending on their roles and the template defined in plugin settings page, can be associated to MailChimp lists and interests. The plugin requires MailChimp for WordPress plugin.
    12  * Version:           1.4
     12 * Version:           1.5
    1313 * Author:            Madaritech
    1414 * Author URI:        http://www.madaritech.com
Note: See TracChangeset for help on using the changeset viewer.