Constant Contact Forms - Version 1.4.5

Version Description

  • Fixed: Conflicts with custom textareas and notes inside of Constant Contact account when updating an existing contact.
  • Fixed: Potential issues around reading Constant Contact Forms error logs when log file is potentially not readable.
Download this release

Release Info

Developer constantcontact
Plugin Icon 128x128 Constant Contact Forms
Version 1.4.5
Comparing to
See all releases

Code changes from version 1.4.4 to 1.4.5

constant-contact-forms.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Constant Contact Forms for WordPress
13
  * Plugin URI: https://www.constantcontact.com
14
  * Description: Be a better marketer. All it takes is Constant Contact email marketing.
15
- * Version: 1.4.4
16
  * Author: Constant Contact
17
  * Author URI: https://www.constantcontact.com/index?pn=miwordpress
18
  * License: GPLv3
@@ -78,7 +78,7 @@ class Constant_Contact {
78
  * @since 1.0.0
79
  * @var string
80
  */
81
- const VERSION = '1.4.4';
82
 
83
  /**
84
  * URL of plugin directory.
12
  * Plugin Name: Constant Contact Forms for WordPress
13
  * Plugin URI: https://www.constantcontact.com
14
  * Description: Be a better marketer. All it takes is Constant Contact email marketing.
15
+ * Version: 1.4.5
16
  * Author: Constant Contact
17
  * Author URI: https://www.constantcontact.com/index?pn=miwordpress
18
  * License: GPLv3
78
  * @since 1.0.0
79
  * @var string
80
  */
81
+ const VERSION = '1.4.5';
82
 
83
  /**
84
  * URL of plugin directory.
includes/class-api.php CHANGED
@@ -105,7 +105,7 @@ class ConstantContact_API {
105
 
106
  // If we're not connectd, bail out.
107
  if ( ! $this->is_connected() ) {
108
- return array();
109
  }
110
 
111
  // Get our saved account info.
@@ -152,7 +152,7 @@ class ConstantContact_API {
152
 
153
  // Verify we're connected.
154
  if ( ! $this->is_connected() ) {
155
- return array();
156
  }
157
 
158
  // First, check our saved transient for a value.
@@ -185,7 +185,7 @@ class ConstantContact_API {
185
 
186
  // Verify we're connected.
187
  if ( ! $this->is_connected() ) {
188
- return array();
189
  }
190
 
191
  // First, check our saved transient for a value.
@@ -231,12 +231,12 @@ class ConstantContact_API {
231
 
232
  // Sanity check that.
233
  if ( ! $id ) {
234
- return array();
235
  }
236
 
237
  // Verify we're connected.
238
  if ( ! $this->is_connected() ) {
239
- return array();
240
  }
241
 
242
  // First, check our saved transient for a value.
@@ -269,11 +269,11 @@ class ConstantContact_API {
269
 
270
  // Bail out early if we don't have the data we need.
271
  if ( empty( $new_list ) || ! isset( $new_list['id'] ) ) {
272
- return array();
273
  }
274
 
275
  // Set our return list to empty array.
276
- $return_list = array();
277
 
278
  try {
279
  // Try to get the list from the API.
@@ -366,7 +366,7 @@ class ConstantContact_API {
366
  public function delete_list( $updated_list = array() ) {
367
 
368
  if ( ! isset( $updated_list['id'] ) ) {
369
- return array();
370
  }
371
 
372
  $list = false;
@@ -395,12 +395,12 @@ class ConstantContact_API {
395
 
396
  // Make sure we're passed a full set of data.
397
  if ( empty( $new_contact ) ) {
398
- return array();
399
  }
400
 
401
  // If we don't get an email, it does us no good.
402
  if ( ! isset( $new_contact['email'] ) ) {
403
- return array();
404
  }
405
 
406
  $api_token = $this->get_api_token();
@@ -413,15 +413,15 @@ class ConstantContact_API {
413
 
414
  try {
415
  // Check to see if a contact with the email address already exists in the account.
416
- $response = $this->cc()->contactService->getContacts( $api_token, array( 'email' => $email ) );
417
 
418
  if ( isset( $response->results ) && ! empty( $response->results ) ) {
419
- constant_contact_maybe_log_it( 'API', 'Contact set to be updated', array( 'form' => get_the_title( $form_id ) ) );
420
  // Update the existing contact if address already existed.
421
  $return_contact = $this->_update_contact( $response, $api_token, $list, $new_contact, $form_id );
422
 
423
  } else {
424
- constant_contact_maybe_log_it( 'API', 'Contact set to be created', array( 'form' => get_the_title( $form_id ) ) );
425
  // Create a new contact if one does not exist.
426
  $return_contact = $this->_create_contact( $api_token, $list, $email, $new_contact, $form_id );
427
  }
@@ -459,7 +459,7 @@ class ConstantContact_API {
459
 
460
  // Map the rest of our properties to.
461
  try {
462
- $contact = $this->set_contact_properties( $contact, $user_data, $form_id );
463
  } catch ( CtctException $ex ) {
464
  $this->log_errors( $ex->getErrors() );
465
  }
@@ -470,7 +470,7 @@ class ConstantContact_API {
470
  return $this->cc()->contactService->addContact(
471
  $api_token,
472
  $contact,
473
- array( 'action_by' => 'ACTION_BY_VISITOR' )
474
  );
475
 
476
  }
@@ -507,7 +507,7 @@ class ConstantContact_API {
507
 
508
  // Set the rest of our properties.
509
  try {
510
- $contact = $this->set_contact_properties( $contact, $user_data, $form_id );
511
  } catch ( CtctException $ex ) {
512
  $this->log_errors( $ex->getErrors() );
513
  }
@@ -515,15 +515,15 @@ class ConstantContact_API {
515
  /*
516
  * See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in array( 'action_by' => 'ACTION_BY_VISITOR' )
517
  */
518
- return $this->cc()->contactService->updateContact(
519
- $api_token,
520
- $contact,
521
- array( 'action_by' => 'ACTION_BY_VISITOR' )
522
- );
523
  } else {
524
- $error = new CtctException();
525
- $error->setErrors( array( 'type', __( 'Contact type not returned', 'constant-contact-forms' ) ) );
526
- throw $error;
527
  }
528
  }
529
 
@@ -533,18 +533,20 @@ class ConstantContact_API {
533
  *
534
  * @since 1.0.0
535
  * @since 1.3.0 Added $form_id parameter.
 
536
  *
537
  * @param object $contact Contact object.
538
  * @param array $user_data Bunch of user data.
539
  * @param string $form_id Form ID being processed.
 
540
  * @throws CtctException $error An exception error.
541
  * @return object Contact object, with new properties.
542
  */
543
- public function set_contact_properties( $contact, $user_data, $form_id ) {
544
  // First, verify we have what we need.
545
  if ( ! is_object( $contact ) || ! is_array( $user_data ) ) {
546
  $error = new CtctException();
547
- $error->setErrors( array( 'type', esc_html__( 'Not a valid contact to set properties to.', 'constant-contact-forms' ) ) );
548
  throw $error;
549
  }
550
 
@@ -554,7 +556,10 @@ class ConstantContact_API {
554
  $address = null;
555
  $count = 1;
556
  $textareas = 0;
557
- $contact->notes = array();
 
 
 
558
 
559
  // Loop through each of our values and set it as a property.
560
  foreach ( $user_data as $original => $value ) {
@@ -585,7 +590,6 @@ class ConstantContact_API {
585
  case 'city_address':
586
  case 'state_address':
587
  case 'zip_address':
588
-
589
  // Set our global address so we can append more data.
590
  if ( is_null( $address ) ) {
591
  $address = new Ctct\Components\Contacts\Address();
@@ -637,10 +641,10 @@ class ConstantContact_API {
637
  $custom = new Ctct\Components\Contacts\CustomField();
638
 
639
  // Create, name it the way the API needs.
640
- $custom = $custom->create( array(
641
  'name' => 'CustomField' . $count,
642
  'value' => $custom_field_name . $value,
643
- ) );
644
 
645
  // Attach it.
646
  $contact->addCustomField( $custom );
@@ -653,13 +657,17 @@ class ConstantContact_API {
653
  if ( $textareas > 1 ) {
654
  break;
655
  }
656
- $unique_id = explode( '___', $original );
657
- $contact->notes[] = array(
658
- 'created_date' => date( 'Y-m-d\TH:i:s' ),
659
- 'id' => $unique_id[1],
660
- 'modified_date' => date( 'Y-m-d\TH:i:s' ),
661
- 'note' => $value,
662
- );
 
 
 
 
663
  break;
664
  default:
665
  // If we got here, try to map our field to the key.
@@ -767,6 +775,7 @@ class ConstantContact_API {
767
  * Helper method to output a link for our connect modal.
768
  *
769
  * @since 1.0.0
 
770
  */
771
  public function get_connect_link() {
772
 
@@ -786,6 +795,8 @@ class ConstantContact_API {
786
  * Helper method to output a link for our connect modal.
787
  *
788
  * @since 1.0.0
 
 
789
  */
790
  public function get_signup_link() {
791
 
@@ -807,33 +818,35 @@ class ConstantContact_API {
807
  * @since 1.0.0
808
  *
809
  * @param bool $as_parts If true return an array.
810
- * array (
811
- * [name] => Business Name
812
- * [address] => 555 Business Place Ln., Beverly Hills, CA, 90210
813
- * )
814
  * @return mixed
815
  */
816
  public function get_disclosure_info( $as_parts = false ) {
 
 
 
 
 
 
817
 
818
  // These fields are used to try and buld the full address.
819
- static $address_fields = array( 'line1', 'city', 'state_code', 'postal_code' );
820
 
821
  // Grab disclosure info from the API.
822
  $account_info = $this->get_account_info();
823
 
824
  // Bail on empty.
825
  if ( empty( $account_info ) ) {
826
- return $as_parts ? array() : '';
827
  }
828
 
829
- $disclosure = array(
830
  'name' => empty( $account_info->organization_name ) ? ctct_get_settings_option( '_ctct_disclose_name', '' ) : $account_info->organization_name,
831
  'address' => ctct_get_settings_option( '_ctct_disclose_address', '' ),
832
- );
833
 
834
  // Bail if we don't have a name.
835
  if ( empty( $disclosure['name'] ) ) {
836
- return $as_parts ? array() : '';
837
  }
838
 
839
  // Determine the address to use for disclosure from the API.
@@ -843,7 +856,7 @@ class ConstantContact_API {
843
  ) {
844
  // Assume the first address.
845
  $organization_address = array_shift( $account_info->organization_addresses );
846
- $disclosure_address = array();
847
 
848
  // Add in our disclouse address.
849
  if ( is_array( $address_fields ) ) {
105
 
106
  // If we're not connectd, bail out.
107
  if ( ! $this->is_connected() ) {
108
+ return [];
109
  }
110
 
111
  // Get our saved account info.
152
 
153
  // Verify we're connected.
154
  if ( ! $this->is_connected() ) {
155
+ return [];
156
  }
157
 
158
  // First, check our saved transient for a value.
185
 
186
  // Verify we're connected.
187
  if ( ! $this->is_connected() ) {
188
+ return [];
189
  }
190
 
191
  // First, check our saved transient for a value.
231
 
232
  // Sanity check that.
233
  if ( ! $id ) {
234
+ return [];
235
  }
236
 
237
  // Verify we're connected.
238
  if ( ! $this->is_connected() ) {
239
+ return [];
240
  }
241
 
242
  // First, check our saved transient for a value.
269
 
270
  // Bail out early if we don't have the data we need.
271
  if ( empty( $new_list ) || ! isset( $new_list['id'] ) ) {
272
+ return [];
273
  }
274
 
275
  // Set our return list to empty array.
276
+ $return_list = [];
277
 
278
  try {
279
  // Try to get the list from the API.
366
  public function delete_list( $updated_list = array() ) {
367
 
368
  if ( ! isset( $updated_list['id'] ) ) {
369
+ return [];
370
  }
371
 
372
  $list = false;
395
 
396
  // Make sure we're passed a full set of data.
397
  if ( empty( $new_contact ) ) {
398
+ return [];
399
  }
400
 
401
  // If we don't get an email, it does us no good.
402
  if ( ! isset( $new_contact['email'] ) ) {
403
+ return [];
404
  }
405
 
406
  $api_token = $this->get_api_token();
413
 
414
  try {
415
  // Check to see if a contact with the email address already exists in the account.
416
+ $response = $this->cc()->contactService->getContacts( $api_token, [ 'email' => $email ] );
417
 
418
  if ( isset( $response->results ) && ! empty( $response->results ) ) {
419
+ constant_contact_maybe_log_it( 'API', 'Contact set to be updated', [ 'form' => get_the_title( $form_id ) ] );
420
  // Update the existing contact if address already existed.
421
  $return_contact = $this->_update_contact( $response, $api_token, $list, $new_contact, $form_id );
422
 
423
  } else {
424
+ constant_contact_maybe_log_it( 'API', 'Contact set to be created', [ 'form' => get_the_title( $form_id ) ] );
425
  // Create a new contact if one does not exist.
426
  $return_contact = $this->_create_contact( $api_token, $list, $email, $new_contact, $form_id );
427
  }
459
 
460
  // Map the rest of our properties to.
461
  try {
462
+ $contact = $this->set_contact_properties( $contact, $user_data, $form_id, false );
463
  } catch ( CtctException $ex ) {
464
  $this->log_errors( $ex->getErrors() );
465
  }
470
  return $this->cc()->contactService->addContact(
471
  $api_token,
472
  $contact,
473
+ [ 'action_by' => 'ACTION_BY_VISITOR' ]
474
  );
475
 
476
  }
507
 
508
  // Set the rest of our properties.
509
  try {
510
+ $contact = $this->set_contact_properties( $contact, $user_data, $form_id, true );
511
  } catch ( CtctException $ex ) {
512
  $this->log_errors( $ex->getErrors() );
513
  }
515
  /*
516
  * See: http://developer.constantcontact.com/docs/contacts-api/contacts-index.html#opt_in array( 'action_by' => 'ACTION_BY_VISITOR' )
517
  */
518
+ return $this->cc()->contactService->updateContact(
519
+ $api_token,
520
+ $contact,
521
+ [ 'action_by' => 'ACTION_BY_VISITOR' ]
522
+ );
523
  } else {
524
+ $error = new CtctException();
525
+ $error->setErrors( [ 'type', __( 'Contact type not returned', 'constant-contact-forms' ) ] );
526
+ throw $error;
527
  }
528
  }
529
 
533
  *
534
  * @since 1.0.0
535
  * @since 1.3.0 Added $form_id parameter.
536
+ * @since 1.4.5 Added $updated paramater.
537
  *
538
  * @param object $contact Contact object.
539
  * @param array $user_data Bunch of user data.
540
  * @param string $form_id Form ID being processed.
541
+ * @param bool $updated Whether or not we are updating a contact. Default false.
542
  * @throws CtctException $error An exception error.
543
  * @return object Contact object, with new properties.
544
  */
545
+ public function set_contact_properties( $contact, $user_data, $form_id, $updated = false ) {
546
  // First, verify we have what we need.
547
  if ( ! is_object( $contact ) || ! is_array( $user_data ) ) {
548
  $error = new CtctException();
549
+ $error->setErrors( [ 'type', esc_html__( 'Not a valid contact to set properties to.', 'constant-contact-forms' ) ] );
550
  throw $error;
551
  }
552
 
556
  $address = null;
557
  $count = 1;
558
  $textareas = 0;
559
+ if ( ! $updated ) {
560
+ // Only initiate an empty array if we are not updating.
561
+ $contact->notes = [];
562
+ }
563
 
564
  // Loop through each of our values and set it as a property.
565
  foreach ( $user_data as $original => $value ) {
590
  case 'city_address':
591
  case 'state_address':
592
  case 'zip_address':
 
593
  // Set our global address so we can append more data.
594
  if ( is_null( $address ) ) {
595
  $address = new Ctct\Components\Contacts\Address();
641
  $custom = new Ctct\Components\Contacts\CustomField();
642
 
643
  // Create, name it the way the API needs.
644
+ $custom = $custom->create( [
645
  'name' => 'CustomField' . $count,
646
  'value' => $custom_field_name . $value,
647
+ ] );
648
 
649
  // Attach it.
650
  $contact->addCustomField( $custom );
657
  if ( $textareas > 1 ) {
658
  break;
659
  }
660
+ if ( ! $updated ) {
661
+ $unique_id = explode( '___', $original );
662
+ $contact->notes[] = [
663
+ 'created_date' => date( 'Y-m-d\TH:i:s' ),
664
+ 'id' => $unique_id[1],
665
+ 'modified_date' => date( 'Y-m-d\TH:i:s' ),
666
+ 'note' => $value,
667
+ ];
668
+ } else {
669
+ $contact->notes[0]->note = $value;
670
+ }
671
  break;
672
  default:
673
  // If we got here, try to map our field to the key.
775
  * Helper method to output a link for our connect modal.
776
  *
777
  * @since 1.0.0
778
+ * @return string Connect URL.
779
  */
780
  public function get_connect_link() {
781
 
795
  * Helper method to output a link for our connect modal.
796
  *
797
  * @since 1.0.0
798
+ *
799
+ * @return string Signup URL.
800
  */
801
  public function get_signup_link() {
802
 
818
  * @since 1.0.0
819
  *
820
  * @param bool $as_parts If true return an array.
 
 
 
 
821
  * @return mixed
822
  */
823
  public function get_disclosure_info( $as_parts = false ) {
824
+ /*
825
+ * array (
826
+ * [name] => Business Name
827
+ * [address] => 555 Business Place Ln., Beverly Hills, CA, 90210
828
+ * )
829
+ */
830
 
831
  // These fields are used to try and buld the full address.
832
+ static $address_fields = [ 'line1', 'city', 'state_code', 'postal_code' ];
833
 
834
  // Grab disclosure info from the API.
835
  $account_info = $this->get_account_info();
836
 
837
  // Bail on empty.
838
  if ( empty( $account_info ) ) {
839
+ return $as_parts ? [] : '';
840
  }
841
 
842
+ $disclosure = [
843
  'name' => empty( $account_info->organization_name ) ? ctct_get_settings_option( '_ctct_disclose_name', '' ) : $account_info->organization_name,
844
  'address' => ctct_get_settings_option( '_ctct_disclose_address', '' ),
845
+ ];
846
 
847
  // Bail if we don't have a name.
848
  if ( empty( $disclosure['name'] ) ) {
849
+ return $as_parts ? [] : '';
850
  }
851
 
852
  // Determine the address to use for disclosure from the API.
856
  ) {
857
  // Assume the first address.
858
  $organization_address = array_shift( $account_info->organization_addresses );
859
+ $disclosure_address = [];
860
 
861
  // Add in our disclouse address.
862
  if ( is_array( $address_fields ) ) {
includes/class-logging.php CHANGED
@@ -47,6 +47,30 @@ class ConstantContact_Logging {
47
  */
48
  public $options_page = '';
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  /**
51
  * Constructor.
52
  *
@@ -57,6 +81,9 @@ class ConstantContact_Logging {
57
  public function __construct( $plugin ) {
58
  $this->plugin = $plugin;
59
  $this->options_url = admin_url( 'edit.php?post_type=ctct_forms&page=ctct_options_logging' );
 
 
 
60
  $this->hooks();
61
  }
62
 
@@ -66,10 +93,11 @@ class ConstantContact_Logging {
66
  * @since 1.3.7
67
  */
68
  public function hooks() {
69
- add_action( 'admin_menu', array( $this, 'add_options_page' ) );
70
- add_action( 'admin_init', array( $this, 'delete_log_file' ) );
71
- add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
72
- add_action( 'admin_footer', array( $this, 'dialog' ) );
 
73
  }
74
 
75
  /**
@@ -121,10 +149,16 @@ class ConstantContact_Logging {
121
  $connect_title,
122
  'manage_options',
123
  $this->key,
124
- array( $this, 'admin_page_display' )
125
  );
126
  }
127
 
 
 
 
 
 
 
128
  /**
129
  * Admin page markup.
130
  *
@@ -142,7 +176,7 @@ class ConstantContact_Logging {
142
  <div class="ctct-body">
143
  <?php
144
  $contents = '';
145
- $log_location = '#';
146
 
147
  if ( ! file_exists( constant_contact()->logger_location ) ) {
148
 
@@ -162,21 +196,7 @@ class ConstantContact_Logging {
162
  constant_contact()->logger_location
163
  );
164
  } else {
165
- // logger location from primary class is server path and not URL path. Thus we go this route for moment.
166
- $log_location = content_url() . '/ctct-logs/constant-contact-errors.log';
167
- $log_content = wp_remote_get( $log_location );
168
- if ( is_wp_error( $log_content ) ) {
169
- $contents .= sprintf(
170
- // translators: placeholder wil have error message.
171
- esc_html__(
172
- 'Log display error: %s',
173
- 'constant-contact-forms'
174
- ),
175
- $log_content->get_error_message()
176
- );
177
- } else {
178
- $contents .= wp_remote_retrieve_body( $log_content );
179
- }
180
  }
181
  ?>
182
  <p><?php esc_html_e( 'Error log below can be used with support requests to help identify issues with Constant Contact Forms.', 'constant-contact-forms' ); ?></p>
@@ -240,7 +260,7 @@ class ConstantContact_Logging {
240
 
241
  check_admin_referer( 'ctct_delete_log', 'ctct_delete_log' );
242
 
243
- $log_file = constant_contact()->logger_location;
244
  if ( file_exists( $log_file ) ) {
245
  unlink( $log_file );
246
  }
@@ -248,4 +268,37 @@ class ConstantContact_Logging {
248
  wp_redirect( $this->options_url );
249
  exit();
250
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
47
  */
48
  public $options_page = '';
49
 
50
+ /**
51
+ * Log location, URL path.
52
+ *
53
+ * @since 1.4.5
54
+ * @var string
55
+ */
56
+ protected $log_location_url = '';
57
+
58
+ /**
59
+ * Log location, server path.
60
+ *
61
+ * @since 1.4.5
62
+ * @var string
63
+ */
64
+ protected $log_location_dir = '';
65
+
66
+ /**
67
+ * WP_Filesystem
68
+ *
69
+ * @since 1.4.5
70
+ * @var null
71
+ */
72
+ protected $file_system = null;
73
+
74
  /**
75
  * Constructor.
76
  *
81
  public function __construct( $plugin ) {
82
  $this->plugin = $plugin;
83
  $this->options_url = admin_url( 'edit.php?post_type=ctct_forms&page=ctct_options_logging' );
84
+ $this->log_location_url = content_url() . '/ctct-logs/constant-contact-errors.log';
85
+ $this->log_location_dir = WP_CONTENT_DIR . '/ctct-logs/constant-contact-errors.log';
86
+
87
  $this->hooks();
88
  }
89
 
93
  * @since 1.3.7
94
  */
95
  public function hooks() {
96
+ add_action( 'admin_menu', [ $this, 'add_options_page' ] );
97
+ add_action( 'admin_init', [ $this, 'delete_log_file' ] );
98
+ add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
99
+ add_action( 'admin_footer', [ $this, 'dialog' ] );
100
+ add_action( 'admin_init', [ $this, 'set_file_system' ] );
101
  }
102
 
103
  /**
149
  $connect_title,
150
  'manage_options',
151
  $this->key,
152
+ [ $this, 'admin_page_display' ]
153
  );
154
  }
155
 
156
+ public function set_file_system() {
157
+ global $wp_filesystem;
158
+ WP_Filesystem();
159
+ $this->file_system = $wp_filesystem;
160
+ }
161
+
162
  /**
163
  * Admin page markup.
164
  *
176
  <div class="ctct-body">
177
  <?php
178
  $contents = '';
179
+ $log_location = $this->log_location_url;
180
 
181
  if ( ! file_exists( constant_contact()->logger_location ) ) {
182
 
196
  constant_contact()->logger_location
197
  );
198
  } else {
199
+ $contents .= $this->get_log_contents();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  }
201
  ?>
202
  <p><?php esc_html_e( 'Error log below can be used with support requests to help identify issues with Constant Contact Forms.', 'constant-contact-forms' ); ?></p>
260
 
261
  check_admin_referer( 'ctct_delete_log', 'ctct_delete_log' );
262
 
263
+ $log_file = $this->log_location_dir;
264
  if ( file_exists( $log_file ) ) {
265
  unlink( $log_file );
266
  }
268
  wp_redirect( $this->options_url );
269
  exit();
270
  }
271
+
272
+ /**
273
+ * Get our log content.
274
+ *
275
+ * @since 1.4.5
276
+ *
277
+ * @return string
278
+ */
279
+ protected function get_log_contents() {
280
+ // Attempt URL version first.
281
+ $log_content_url = wp_remote_get( $this->log_location_url );
282
+ if ( is_wp_error( $log_content_url ) ) {
283
+ return sprintf(
284
+ // translators: placeholder wil have error message.
285
+ esc_html__(
286
+ 'Log display error: %s',
287
+ 'constant-contact-forms'
288
+ ),
289
+ $log_content_url->get_error_message()
290
+ );
291
+ }
292
+
293
+ // If we have data from a successful request.
294
+ if ( 200 === wp_remote_retrieve_response_code( $log_content_url ) ) {
295
+ return wp_remote_retrieve_body( $log_content_url );
296
+ }
297
+
298
+ // If we have anything BUT 200 status from the url, let's attempt a file system read.
299
+ $log_content_dir = $this->file_system->get_contents( $this->log_location_dir );
300
+ if ( ! empty( $log_content_dir ) && is_string( $log_content_dir ) ) {
301
+ return $log_content_dir;
302
+ }
303
+ }
304
  }
languages/constant-contact-forms.pot CHANGED
@@ -3,14 +3,14 @@ msgid ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Constant Contact Forms for WordPress\n"
6
- "POT-Creation-Date: 2018-11-20 09:30-0600\n"
7
  "PO-Revision-Date: 2017-01-12 14:46-0600\n"
8
  "Last-Translator: Michael Beckwith <michael.d.beckwith@gmail.com>\n"
9
  "Language-Team: Constant Contact\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 2.2\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: constant-contact-forms.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
@@ -318,11 +318,11 @@ msgstr ""
318
  msgid "Contact type not returned"
319
  msgstr ""
320
 
321
- #: includes/class-api.php:547
322
  msgid "Not a valid contact to set properties to."
323
  msgstr ""
324
 
325
- #: includes/class-api.php:727
326
  msgid ""
327
  "Your API access token is invalid. Reconnect to Constant Contact to receive a "
328
  "new token."
@@ -841,7 +841,7 @@ msgstr ""
841
  msgid "Are you sure you want to disconnect?"
842
  msgstr ""
843
 
844
- #: includes/class-connect.php:172 includes/class-logging.php:141
845
  #: includes/class-notification-content.php:109
846
  #: includes/class-notification-content.php:139 includes/class-optin.php:129
847
  #: includes/class-settings.php:815
@@ -1313,55 +1313,55 @@ msgstr ""
1313
  msgid "Sync Lists with Constant Contact"
1314
  msgstr ""
1315
 
1316
- #: includes/class-logging.php:94
1317
  msgid "Are you sure you want to delete current logs?"
1318
  msgstr ""
1319
 
1320
- #: includes/class-logging.php:114
1321
  msgid "Debug logs"
1322
  msgstr ""
1323
 
1324
- #: includes/class-logging.php:152 includes/class-logging.php:161
1325
  #, php-format
1326
  msgid "We are not able to write to the %s file."
1327
  msgstr ""
1328
 
1329
- #: includes/class-logging.php:156
1330
  msgid "No error log exists"
1331
  msgstr ""
1332
 
1333
- #: includes/class-logging.php:172
1334
- #, php-format
1335
- msgid "Log display error: %s"
1336
- msgstr ""
1337
-
1338
- #: includes/class-logging.php:182
1339
  msgid ""
1340
  "Error log below can be used with support requests to help identify issues "
1341
  "with Constant Contact Forms."
1342
  msgstr ""
1343
 
1344
- #: includes/class-logging.php:183
1345
  msgid ""
1346
  "When available, you can share information by copying and pasting the content "
1347
  "in the textarea, or by using the \"Download logs\" link at the end. Logs can "
1348
  "be cleared by using the \"Delete logs\" link."
1349
  msgstr ""
1350
 
1351
- #: includes/class-logging.php:190
1352
  msgid ""
1353
  "Error log may still have content, even if an error is shown above. Please "
1354
  "use the download link below."
1355
  msgstr ""
1356
 
1357
- #: includes/class-logging.php:199
1358
  msgid "Download logs"
1359
  msgstr ""
1360
 
1361
- #: includes/class-logging.php:207
1362
  msgid "Delete logs"
1363
  msgstr ""
1364
 
 
 
 
 
 
1365
  #: includes/class-mail.php:309
1366
  #, php-format
1367
  msgid "Duplicate send mail for: %1$s and: %2$s"
@@ -1481,16 +1481,16 @@ msgstr ""
1481
  msgid "Disagree"
1482
  msgstr ""
1483
 
1484
- #: includes/class-process-form.php:107 includes/class-process-form.php:663
1485
  msgid "There was an error sending your form."
1486
  msgstr ""
1487
 
1488
- #: includes/class-process-form.php:121 includes/class-process-form.php:686
1489
  msgid "Your information has been submitted."
1490
  msgstr ""
1491
 
1492
- #: includes/class-process-form.php:139 includes/class-process-form.php:259
1493
- #: includes/class-process-form.php:703
1494
  msgid ""
1495
  "We had trouble processing your submission. Please review your entries and "
1496
  "try again."
@@ -1504,7 +1504,8 @@ msgstr ""
1504
  msgid "No form verify value provided"
1505
  msgstr ""
1506
 
1507
- #: includes/class-process-form.php:206 includes/class-process-form.php:247
 
1508
  msgid "We do no think you are human"
1509
  msgstr ""
1510
 
@@ -1516,8 +1517,8 @@ msgstr ""
1516
  msgid "Failed reCAPTCHA check"
1517
  msgstr ""
1518
 
1519
- #: includes/class-process-form.php:268 includes/class-process-form.php:277
1520
- #: includes/class-process-form.php:286
1521
  msgid ""
1522
  "We had trouble processing your submission. Make sure you haven't changed the "
1523
  "required Form ID and try again."
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: Constant Contact Forms for WordPress\n"
6
+ "POT-Creation-Date: 2019-02-27 13:32-0600\n"
7
  "PO-Revision-Date: 2017-01-12 14:46-0600\n"
8
  "Last-Translator: Michael Beckwith <michael.d.beckwith@gmail.com>\n"
9
  "Language-Team: Constant Contact\n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.2.1\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: constant-contact-forms.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
318
  msgid "Contact type not returned"
319
  msgstr ""
320
 
321
+ #: includes/class-api.php:549
322
  msgid "Not a valid contact to set properties to."
323
  msgstr ""
324
 
325
+ #: includes/class-api.php:735
326
  msgid ""
327
  "Your API access token is invalid. Reconnect to Constant Contact to receive a "
328
  "new token."
841
  msgid "Are you sure you want to disconnect?"
842
  msgstr ""
843
 
844
+ #: includes/class-connect.php:172 includes/class-logging.php:175
845
  #: includes/class-notification-content.php:109
846
  #: includes/class-notification-content.php:139 includes/class-optin.php:129
847
  #: includes/class-settings.php:815
1313
  msgid "Sync Lists with Constant Contact"
1314
  msgstr ""
1315
 
1316
+ #: includes/class-logging.php:122
1317
  msgid "Are you sure you want to delete current logs?"
1318
  msgstr ""
1319
 
1320
+ #: includes/class-logging.php:142
1321
  msgid "Debug logs"
1322
  msgstr ""
1323
 
1324
+ #: includes/class-logging.php:186 includes/class-logging.php:195
1325
  #, php-format
1326
  msgid "We are not able to write to the %s file."
1327
  msgstr ""
1328
 
1329
+ #: includes/class-logging.php:190
1330
  msgid "No error log exists"
1331
  msgstr ""
1332
 
1333
+ #: includes/class-logging.php:202
 
 
 
 
 
1334
  msgid ""
1335
  "Error log below can be used with support requests to help identify issues "
1336
  "with Constant Contact Forms."
1337
  msgstr ""
1338
 
1339
+ #: includes/class-logging.php:203
1340
  msgid ""
1341
  "When available, you can share information by copying and pasting the content "
1342
  "in the textarea, or by using the \"Download logs\" link at the end. Logs can "
1343
  "be cleared by using the \"Delete logs\" link."
1344
  msgstr ""
1345
 
1346
+ #: includes/class-logging.php:210
1347
  msgid ""
1348
  "Error log may still have content, even if an error is shown above. Please "
1349
  "use the download link below."
1350
  msgstr ""
1351
 
1352
+ #: includes/class-logging.php:219
1353
  msgid "Download logs"
1354
  msgstr ""
1355
 
1356
+ #: includes/class-logging.php:227
1357
  msgid "Delete logs"
1358
  msgstr ""
1359
 
1360
+ #: includes/class-logging.php:286
1361
+ #, php-format
1362
+ msgid "Log display error: %s"
1363
+ msgstr ""
1364
+
1365
  #: includes/class-mail.php:309
1366
  #, php-format
1367
  msgid "Duplicate send mail for: %1$s and: %2$s"
1481
  msgid "Disagree"
1482
  msgstr ""
1483
 
1484
+ #: includes/class-process-form.php:107 includes/class-process-form.php:670
1485
  msgid "There was an error sending your form."
1486
  msgstr ""
1487
 
1488
+ #: includes/class-process-form.php:121 includes/class-process-form.php:693
1489
  msgid "Your information has been submitted."
1490
  msgstr ""
1491
 
1492
+ #: includes/class-process-form.php:139 includes/class-process-form.php:266
1493
+ #: includes/class-process-form.php:710
1494
  msgid ""
1495
  "We had trouble processing your submission. Please review your entries and "
1496
  "try again."
1504
  msgid "No form verify value provided"
1505
  msgstr ""
1506
 
1507
+ #: includes/class-process-form.php:206 includes/class-process-form.php:239
1508
+ #: includes/class-process-form.php:254
1509
  msgid "We do no think you are human"
1510
  msgstr ""
1511
 
1517
  msgid "Failed reCAPTCHA check"
1518
  msgstr ""
1519
 
1520
+ #: includes/class-process-form.php:275 includes/class-process-form.php:284
1521
+ #: includes/class-process-form.php:293
1522
  msgid ""
1523
  "We had trouble processing your submission. Make sure you haven't changed the "
1524
  "required Form ID and try again."
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: constantcontact
3
  Tags: capture, contacts, constant contact, constant contact form, constant contact newsletter, constant contact official, contact forms, email, form, forms, marketing, mobile, newsletter, opt-in, plugin, signup, subscribe, subscription, widget
4
  Requires at least: 4.0.0
5
- Tested up to: 5.0.2
6
- Stable tag: 1.4.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
  Requires PHP: 5.4
@@ -35,6 +35,10 @@ BONUS: If you have a Constant Contact account, all new email addresses that you
35
 
36
  == Changelog ==
37
 
 
 
 
 
38
  = 1.4.4 =
39
  * Fixed: Hardened reCAPTCHA and form processing from possible AJAX bypass.
40
 
@@ -152,63 +156,6 @@ BONUS: If you have a Constant Contact account, all new email addresses that you
152
  * Updated: Improved return messages for submission failures.
153
  * Updated: Upgraded to the latest version of CMB2.
154
 
155
- = 1.2.5 =
156
- * Fixed: Customized labels no longer reset to default when adding new fields.
157
- * Added: Ability to bypass using WP_CRON when trying to have form entries sent to ConstantContact.com lists. If you're having trouble getting them sent, use this setting.
158
- * Updated: Revised content for "Disconnect" page when connected, and have not created a form yet.
159
-
160
- = 1.2.4 =
161
- * Added: Google reCAPTCHA "I am human" checkbox support for forms. See https://www.google.com/recaptcha/intro/. Will fall back to honeypot prevention if not set up.
162
- * Fixed: Stray quote mark in honeypot markup.
163
- * Fixed: missing space after placeholder attribute for inputs.
164
- * Fixed: Removed unintentional "Leave page" confirmation popup when saving settings.
165
-
166
- = 1.2.3 =
167
- * Fixed: Attempt to process forms that have provided a custom url via filter.
168
- * Fixed: Clean up class attributes regarding validation errors in text inputs.
169
-
170
- = 1.2.2 =
171
- * Fixed: Conflicts with other plugins using the Constant Contact PHP SDK.
172
- * Fixed: Added honeypot-style spam prevention on forms.
173
- * Fixed: Removed anonymous function usage in widget to prevent potential errors.
174
- * Fixed: Hardened up helper function in cases where internal function does not exist.
175
- * Fixed: Issues with multiple custom textareas and the Constant Contact API. See the "Learn more" link/modal for some more information.
176
- * Added: Potential admin notice requesting users to review plugin if they have not already.
177
-
178
- = 1.2.1 =
179
- * Fixed: Re-show sections of "Publish" metabox incorrectly hidden for post types outside Constant Contact Forms.
180
- * Fixed: Issues with transparent background on frontend forms when input is valid.
181
- * Fixed: Fatal errors on deactivation if user is on PHP 5.3 or lower.
182
- * Fixed: PHP Warnings regarding missing parameters for maybe_log_mail_status().
183
- * Updated: Bumped Guzzle to 5.3.1 for PHP7.1 compatibility.
184
-
185
- = 1.2.0 =
186
- * Added: Reveal shortcode for newly published form in admin notice and popup for non-connected accounts.
187
- * Added: Classes for individual form inputs and textareas on rendered form.
188
- * Added: Request to opt into some anonymous data tracking for Constant Contact's information usage.
189
- * Added: Note about no forms being available in modal popup, if none available.
190
- * Added: Ability to disable emails if Constant Contact account is connected and "disable email" option checked.
191
- * Added: Necessary disclosure text to output on comment form and login/registration form when able to do advanced opt-in for list enrollment.
192
- * Fixed: Possible issues with PHP 5.2 compatibility from the widget.
193
- * Fixed: Prevent status message from displaying multiple times if multiple forms present on the page.
194
- * Fixed: Ability to remove description values from various available form inputs.
195
- * Updated: Changed field order in admin UI for creating Constant Contact form.
196
- * Updated: Better compatibility with TwentyFourteen.
197
-
198
- = 1.1.1 =
199
- * Fixed: Made frontend form default to an empty action attribute to take care of occasional 404 errors after submission.
200
- * Added: New filter on the default empty string from above, so others can provide their own redirect location if desired.
201
-
202
- = 1.1.0 =
203
- * Added: Widget that allows you to select a form to display.
204
- * Added: Small metabox in form editor showing shortcode to use for current form.
205
- * Added: Field and filter for text shown on the rendered submit button.
206
- * Added: Developers: Inline documentation of actions and filters.
207
- * Fixed: Loading position of Constant Contact stylesheet. Should now load in `<head>`.
208
- * Fixed: Removed redundant "Add form" button on Constant Contact form editor TinyMCE.
209
- * Fixed: Removed required attribute for Address line 2 when line 1 is required.
210
- * Updated: Labels in Constant Contact Form list around none available and none in trash.
211
-
212
  == Frequently Asked Questions ==
213
 
214
  #### Constant Contact Forms Options
2
  Contributors: constantcontact
3
  Tags: capture, contacts, constant contact, constant contact form, constant contact newsletter, constant contact official, contact forms, email, form, forms, marketing, mobile, newsletter, opt-in, plugin, signup, subscribe, subscription, widget
4
  Requires at least: 4.0.0
5
+ Tested up to: 5.1.0
6
+ Stable tag: 1.4.5
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
  Requires PHP: 5.4
35
 
36
  == Changelog ==
37
 
38
+ = 1.4.5 =
39
+ * Fixed: Conflicts with custom textareas and notes inside of Constant Contact account when updating an existing contact.
40
+ * Fixed: Potential issues around reading Constant Contact Forms error logs when log file is potentially not readable.
41
+
42
  = 1.4.4 =
43
  * Fixed: Hardened reCAPTCHA and form processing from possible AJAX bypass.
44
 
156
  * Updated: Improved return messages for submission failures.
157
  * Updated: Upgraded to the latest version of CMB2.
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  == Frequently Asked Questions ==
160
 
161
  #### Constant Contact Forms Options