Changeset 1754726
- Timestamp:
- 10/29/2017 01:25:09 PM (8 years ago)
- Location:
- synchro-mailchimp
- Files:
-
- 45 added
- 8 edited
-
tags/1.5 (added)
-
tags/1.5/admin (added)
-
tags/1.5/admin/class-synchro-mailchimp-admin.php (added)
-
tags/1.5/admin/css (added)
-
tags/1.5/admin/css/synchro-mailchimp-admin.css (added)
-
tags/1.5/admin/images (added)
-
tags/1.5/admin/images/logo_synchro_mailchimp.png (added)
-
tags/1.5/admin/images/madaritech_logo.png (added)
-
tags/1.5/admin/images/spinner-2x.gif (added)
-
tags/1.5/admin/index.php (added)
-
tags/1.5/admin/js (added)
-
tags/1.5/admin/js/synchro-mailchimp-admin-ajax.js (added)
-
tags/1.5/admin/js/synchro-mailchimp-admin.js (added)
-
tags/1.5/admin/partials (added)
-
tags/1.5/admin/partials/synchro-mailchimp-admin-display.php (added)
-
tags/1.5/admin/partials/synchro-mailchimp-users-admin-display.php (added)
-
tags/1.5/includes (added)
-
tags/1.5/includes/class-synchro-mailchimp-activator.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-api-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-configuration-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-deactivator.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-i18n.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-loader.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-log-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-requirements-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-subscription-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-user-service-adapter.php (added)
-
tags/1.5/includes/class-synchro-mailchimp-user-service.php (added)
-
tags/1.5/includes/class-synchro-mailchimp.php (added)
-
tags/1.5/includes/index.php (added)
-
tags/1.5/index.php (added)
-
tags/1.5/languages (added)
-
tags/1.5/languages/synchro-mailchimp.pot (added)
-
tags/1.5/public (added)
-
tags/1.5/public/class-synchro-mailchimp-public.php (added)
-
tags/1.5/public/css (added)
-
tags/1.5/public/css/synchro-mailchimp-public.css (added)
-
tags/1.5/public/index.php (added)
-
tags/1.5/public/js (added)
-
tags/1.5/public/js/synchro-mailchimp-public.js (added)
-
tags/1.5/public/partials (added)
-
tags/1.5/public/partials/synchro-mailchimp-public-display.php (added)
-
tags/1.5/readme.txt (added)
-
tags/1.5/synchro-mailchimp.php (added)
-
tags/1.5/uninstall.php (added)
-
trunk/admin/class-synchro-mailchimp-admin.php (modified) (5 diffs)
-
trunk/includes/class-synchro-mailchimp-log-service.php (modified) (5 diffs)
-
trunk/includes/class-synchro-mailchimp-requirements-service.php (modified) (1 diff)
-
trunk/includes/class-synchro-mailchimp-subscription-service.php (modified) (14 diffs)
-
trunk/includes/class-synchro-mailchimp-user-service-adapter.php (modified) (2 diffs)
-
trunk/includes/class-synchro-mailchimp-user-service.php (modified) (8 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/synchro-mailchimp.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
synchro-mailchimp/trunk/admin/class-synchro-mailchimp-admin.php
r1746848 r1754726 128 128 public function read_mailchimp_schema( &$mailchimp_lists, &$mailchimp_interest_categories, &$mailchimp_interests ) { 129 129 130 // Extract lists from MailChimp. 130 131 $lists_obj = $this->api->get_lists( array() ); 131 132 $list_arr = array(); … … 135 136 } 136 137 138 // For each list extracted... 137 139 foreach ( $list_arr as $list ) { 138 140 141 // ...save list name.. 139 142 $mailchimp_lists[ $list['id'] ] = [ 140 143 'name' => $list['name'], 141 144 'checked' => false, 142 145 ]; 146 147 // ...extract the list interest categories from MailChimp... 143 148 $interest_categories_obj = $this->api->get_list_interest_categories( $list['id'] ); 144 149 $interest_categories_arr = json_decode( json_encode( $interest_categories_obj ), true ); 145 150 151 // ... and foreach interest category extracted... 146 152 foreach ( $interest_categories_arr as $interest_category ) { 147 153 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... 149 158 $interests_obj = $this->api->get_list_interest_category_interests( $list['id'], $interest_category['id'] ); 150 159 $interests_arr = json_decode( json_encode( $interests_obj ), true ); 151 160 161 // ...finally for each interest... 152 162 foreach ( $interests_arr as $interest ) { 163 164 // ...save the interest informations. 153 165 $mailchimp_interests[ $interest_category['id'] ][ $interest['id'] ] = [ 154 166 'name' => $interest['name'], … … 225 237 226 238 // Update 'checked' property using configuration, and assignment to the proper wp role. 239 // Scan every role. 227 240 foreach ( $all_roles as $role => $role_name ) { 228 241 242 // The $configuration was extracted by MailChimp site, and it contains only the selected lists and interests. 229 243 foreach ( $configuration[ $role ] as $configuration_list_id => $configuration_interest_array ) { 230 244 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. 231 246 foreach ( $settings_lists[ $role ] as $mailchimp_list_id => $mailchimp_list_array ) { 232 247 248 // If the list exists in $configuration, it means is checked on MailChimp, so we have to check it too on the form. 233 249 if ( $mailchimp_list_id == $configuration_list_id ) { 234 250 235 // Check ed sulla lista.251 // Check the list! 236 252 $settings_lists[ $role ][ $mailchimp_list_id ]['checked'] = true; 237 253 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... 242 256 if ( isset( $settings_interest_categories[ $role ][ $mailchimp_list_id ] ) ) { 257 258 // ...let's cycle over these categories... 243 259 foreach ( $settings_interest_categories[ $role ][ $mailchimp_list_id ] as $mailchimp_category_id => $mailchimp_category_name ) { 244 260 261 // ...and so from the category let's cycle over all the relative interests. 245 262 foreach ( $settings_interests[ $role ][ $mailchimp_category_id ] as $mailchimp_interest_id => $mailchimp_interest_bool ) { 246 263 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. 247 265 if ( array_key_exists( $mailchimp_interest_id, $configuration_interest_array ) ) { 248 266 … … 403 421 try { 404 422 $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 ]" ); 408 424 } catch ( Exception $e ) { 409 425 $error_message = __( 'Subscription check status failed. ', 'synchro_mailchimp' ); … … 419 435 } 420 436 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 ]" ); 424 438 425 439 if ( $check_status ) { -
synchro-mailchimp/trunk/includes/class-synchro-mailchimp-log-service.php
r1746824 r1754726 37 37 */ 38 38 public function __construct( $class_name ) { 39 40 39 $this->class_name = $class_name; 41 42 40 } 43 41 … … 50 48 */ 51 49 public static function is_enabled() { 52 53 50 return defined( 'WP_DEBUG' ) && WP_DEBUG; 54 51 } … … 64 61 */ 65 62 public static function create( $class_name ) { 66 67 63 return new Synchro_MailChimp_Log_Service( $class_name ); 68 64 } … … 76 72 */ 77 73 public function debug( $message ) { 78 79 74 $this->log( 'DEBUG', $message ); 80 81 75 } 82 76 … … 127 121 * @param string $level The debug level. 128 122 * @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. 129 124 */ 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 } 134 131 } 135 132 -
synchro-mailchimp/trunk/includes/class-synchro-mailchimp-requirements-service.php
r1746824 r1754726 75 75 'strong' => array(), 76 76 ); 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 ); 78 78 echo __( $html_text, 'synchro_mailchimp' ); 79 79 ?> -
synchro-mailchimp/trunk/includes/class-synchro-mailchimp-subscription-service.php
r1746824 r1754726 80 80 public function subscribe_process( $subscription_status, $user_email, $user_role ) { 81 81 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 ]..." ); 85 83 86 84 $res = false; … … 112 110 } 113 111 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 ]." ); 117 113 118 114 return ( $res ); … … 174 170 */ 175 171 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 ]..." ); 179 174 180 175 // Extract configuration parameters. 181 176 $smc = $this->configuration->get_by_role( $user_role ); 182 177 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 ]" ); 187 180 188 181 // User lists extraction and verifies alignment with configuration. … … 200 193 } // Unchecked. 201 194 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 ]" ); 205 196 206 197 if ( 0 == $num_list_config ) { … … 246 237 } catch ( MC4WP_API_Connection_Exception $e ) { 247 238 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 255 243 $exep_message = __( 'Connection failure.','synchro_mailchimp' ); 256 244 throw new Exception( $exep_message . ' ' . $message ); … … 258 246 } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) { 259 247 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 267 252 throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) ); 268 253 269 254 } catch ( MC4WP_API_Exception $e ) { 270 255 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 278 260 throw new Exception( __( 'Connection API error.','synchro_mailchimp' ) ); 279 261 280 262 } catch ( Exception $e ) { 281 263 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 289 268 throw new Exception( __( 'Generic error.','synchro_mailchimp' ) ); 290 269 } … … 301 280 */ 302 281 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 ]..." ); 306 284 307 285 $args['email_address'] = $user_email; … … 339 317 340 318 } 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 349 324 $excep_message = __( 'Connection problem.','synchro_mailchimp' ); 350 325 throw new Exception( $excep_message . ' ' . $message ); 351 326 352 327 } 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 361 332 throw new Exception( __( 'Resource not found in subscribing user.','synchro_mailchimp' ) ); 362 333 363 334 } 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 372 339 $excep_message = __( 'Subscribing user: API error. MailChimp message:','synchro_mailchimp' ); 373 340 throw new Exception( $excep_message . ' ' . $e->detail ); 374 341 375 342 } 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 384 347 throw new Exception( __( 'Subscribing user: generic error.','synchro_mailchimp' ) ); 385 348 386 349 } 387 350 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 ) . ' ]' ); 391 352 } 392 353 … … 404 365 public function unsubscribe_user_config( $user_email ) { 405 366 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 ]" ); 409 368 410 369 // Get the user id. … … 414 373 $lists = apply_filters( 'sm_user_list', $lists, $user->ID ); 415 374 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 ]" ); 420 377 421 378 $reset_args['email'] = $user_email; … … 429 386 } catch ( MC4WP_API_Connection_Exception $e ) { 430 387 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 438 392 $excep_message = __( 'Connection problem.','synchro_mailchimp' ); 439 393 throw new Exception( $excep_message . ' ' . $message ); … … 441 395 } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) { 442 396 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 450 401 throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) ); 451 402 452 403 } catch ( MC4WP_API_Exception $e ) { 453 404 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 461 409 throw new Exception( __( 'API connection error.','synchro_mailchimp' ) ); 462 410 463 411 } catch ( Exception $e ) { 464 412 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 472 417 throw new Exception( __( 'Generic error.','synchro_mailchimp' ) ); 473 418 … … 499 444 } catch ( MC4WP_API_Connection_Exception $e ) { 500 445 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 508 450 $excep_message = __( 'Connection problem.','synchro_mailchimp' ); 509 451 throw new Exception( $excep_message . ' ' . $message ); … … 511 453 } catch ( MC4WP_API_Resource_Not_Found_Exception $e ) { 512 454 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 520 459 throw new Exception( __( 'Resource not found.','synchro_mailchimp' ) ); 521 460 522 461 } catch ( MC4WP_API_Exception $e ) { 523 462 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 531 467 throw new Exception( __( 'API connection error.','synchro_mailchimp' ) ); 532 468 533 469 } catch ( Exception $e ) { 534 470 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 542 475 throw new Exception( __( 'Generic error.','synchro_mailchimp' ) ); 543 476 -
synchro-mailchimp/trunk/includes/class-synchro-mailchimp-user-service-adapter.php
r1746824 r1754726 74 74 public function user_lists( $lists, $user_id ) { 75 75 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" ); 80 77 return $this->user_service->get_lists( $lists, $user_id ); 81 78 } … … 107 104 */ 108 105 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..." ); 114 107 return $this->user_service->get_interests( $user_id, $list_id, $interests ); 115 108 } -
synchro-mailchimp/trunk/includes/class-synchro-mailchimp-user-service.php
r1746824 r1754726 74 74 public function get_lists( $lists, $user_id ) { 75 75 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" ); 79 77 80 78 // Get the user. … … 83 81 // Return an empty array if the user doesn't exist. 84 82 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." ); 90 84 return $lists; 91 85 } … … 97 91 $role_lists = $this->configuration_service->get_by_role( $role ); 98 92 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." ); 102 94 103 95 // Add the list to the return array and combine it with the existing value if any. … … 107 99 } 108 100 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 ) ); 112 102 113 103 return $lists; … … 138 128 public function get_interests( $user_id, $list_id, $seed = array() ) { 139 129 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..." ); 143 131 144 132 // Get the user. … … 147 135 // Return an empty array if the user doesn't exist. 148 136 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." ); 154 138 return $seed; 155 139 } … … 164 148 $role_interests = $this->configuration_service->get_by_role_and_list( $role, $list_id ); 165 149 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." ); 169 151 170 152 // 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. … … 174 156 } 175 157 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 ) ); 179 159 180 160 return $interests; -
synchro-mailchimp/trunk/readme.txt
r1746848 r1754726 6 6 Requires at least: 4.8 7 7 Tested up to: 4.8.2 8 Stable tag: 1. 48 Stable tag: 1.5 9 9 License: GPLv2 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 52 52 == Changelog == 53 53 54 = 1.5 = 55 * bug fixed 56 * Comments to code added 57 * Code refactoring 58 54 59 = 1.3 = 55 60 * Refactoring based on WordPress Standard … … 66 71 == Upgrade Notice == 67 72 73 = 1.5 = 74 This version fixes a security issue. Upgrade immediately. 75 68 76 = 1.3 = 69 77 This version fixes a security issue. Upgrade immediately. -
synchro-mailchimp/trunk/synchro-mailchimp.php
r1746848 r1754726 10 10 * Plugin Name: Synchro MailChimp 11 11 * 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. 412 * Version: 1.5 13 13 * Author: Madaritech 14 14 * Author URI: http://www.madaritech.com
Note: See TracChangeset
for help on using the changeset viewer.