Constant Contact Forms - Version 1.8.2

Version Description

  • Updated: Amended logging location for more hopefully more consistent write-ability and smoother support requests.
Download this release

Release Info

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

Code changes from version 1.8.1 to 1.8.2

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.8.1
16
  * Author: Constant Contact
17
  * Author URI: https://www.constantcontact.com/index?pn=miwordpress
18
  * License: GPLv3
@@ -72,7 +72,7 @@ class Constant_Contact {
72
  * @since 1.0.0
73
  * @var string
74
  */
75
- const VERSION = '1.8.1';
76
 
77
  /**
78
  * URL of plugin directory.
@@ -376,7 +376,6 @@ class Constant_Contact {
376
  $this->basename = plugin_basename( __FILE__ );
377
  $this->url = plugin_dir_url( __FILE__ );
378
  $this->path = plugin_dir_path( __FILE__ );
379
- $this->logger_location = WP_CONTENT_DIR . '/ctct-logs/constant-contact-errors.log';
380
 
381
  if ( ! $this->meets_php_requirements() ) {
382
  add_action( 'admin_notices', array( $this, 'minimum_version' ) );
@@ -387,6 +386,9 @@ class Constant_Contact {
387
  $this->plugin_classes();
388
  $this->admin_plugin_classes();
389
 
 
 
 
390
  // Include our helper functions function for end-users.
391
  self::include_file( 'helper-functions', false );
392
 
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.8.2
16
  * Author: Constant Contact
17
  * Author URI: https://www.constantcontact.com/index?pn=miwordpress
18
  * License: GPLv3
72
  * @since 1.0.0
73
  * @var string
74
  */
75
+ const VERSION = '1.8.2';
76
 
77
  /**
78
  * URL of plugin directory.
376
  $this->basename = plugin_basename( __FILE__ );
377
  $this->url = plugin_dir_url( __FILE__ );
378
  $this->path = plugin_dir_path( __FILE__ );
 
379
 
380
  if ( ! $this->meets_php_requirements() ) {
381
  add_action( 'admin_notices', array( $this, 'minimum_version' ) );
386
  $this->plugin_classes();
387
  $this->admin_plugin_classes();
388
 
389
+ // Set logging location.
390
+ $this->logger_location = $this->logging->get_logging_location();
391
+
392
  // Include our helper functions function for end-users.
393
  self::include_file( 'helper-functions', false );
394
 
includes/class-logging.php CHANGED
@@ -83,6 +83,14 @@ class ConstantContact_Logging {
83
  */
84
  protected $log_index_file = '';
85
 
 
 
 
 
 
 
 
 
86
  /**
87
  * WP_Filesystem
88
  *
@@ -101,9 +109,11 @@ class ConstantContact_Logging {
101
  public function __construct( $plugin ) {
102
  $this->plugin = $plugin;
103
  $this->options_url = admin_url( 'edit.php?post_type=ctct_forms&page=ctct_options_logging' );
104
- $this->log_location_url = content_url() . '/ctct-logs/constant-contact-errors.log';
105
- $this->log_location_dir = WP_CONTENT_DIR . '/ctct-logs';
106
- $this->log_location_file = "{$this->log_location_dir}/constant-contact-errors.log";
 
 
107
  $this->log_index_file = "{$this->log_location_dir}/index.php";
108
 
109
  $this->hooks();
@@ -117,6 +127,7 @@ class ConstantContact_Logging {
117
  public function hooks() {
118
  add_action( 'admin_menu', [ $this, 'add_options_page' ] );
119
  add_action( 'admin_init', [ $this, 'delete_log_file' ] );
 
120
  add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
121
  add_action( 'admin_footer', [ $this, 'dialog' ] );
122
  add_action( 'admin_init', [ $this, 'set_file_system' ] );
@@ -289,7 +300,9 @@ class ConstantContact_Logging {
289
  unlink( $log_file );
290
  }
291
 
292
- $this->create_log_file();
 
 
293
 
294
  wp_redirect( $this->options_url );
295
  exit();
@@ -345,13 +358,8 @@ class ConstantContact_Logging {
345
  * Create the log folder.
346
  *
347
  * @since 1.5.0
348
- * @return void
349
  */
350
  public function create_log_folder() {
351
- if ( ! constant_contact_debugging_enabled() ) {
352
- return;
353
- }
354
-
355
  mkdir( $this->log_location_dir );
356
  chmod( $this->log_location_dir, 0755 );
357
  }
@@ -363,10 +371,6 @@ class ConstantContact_Logging {
363
  * @return void
364
  */
365
  public function create_log_index_file() {
366
- if ( ! constant_contact_debugging_enabled() ) {
367
- return;
368
- }
369
-
370
  if ( ! is_writable( $this->log_location_dir ) ) {
371
  return;
372
  }
@@ -385,10 +389,6 @@ class ConstantContact_Logging {
385
  * @return void
386
  */
387
  public function create_log_file() {
388
- if ( ! constant_contact_debugging_enabled() ) {
389
- return;
390
- }
391
-
392
  if ( ! is_writable( $this->log_location_dir ) ) {
393
  return;
394
  }
@@ -399,4 +399,64 @@ class ConstantContact_Logging {
399
 
400
  touch( $this->log_location_file );
401
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
402
  }
83
  */
84
  protected $log_index_file = '';
85
 
86
+ /**
87
+ * The logging directory name.
88
+ *
89
+ * @since NEXT
90
+ * @var string
91
+ */
92
+ protected $log_file_dir = 'ctct-logs';
93
+
94
  /**
95
  * WP_Filesystem
96
  *
109
  public function __construct( $plugin ) {
110
  $this->plugin = $plugin;
111
  $this->options_url = admin_url( 'edit.php?post_type=ctct_forms&page=ctct_options_logging' );
112
+ $uploads_dir = wp_upload_dir();
113
+ $log_file_name = 'constant-contact-errors.log';
114
+ $this->log_location_url = "{$uploads_dir['baseurl']}/{$this->log_file_dir}/{$log_file_name}";
115
+ $this->log_location_dir = "{$uploads_dir['basedir']}/{$this->log_file_dir}";
116
+ $this->log_location_file = "{$this->log_location_dir}/{$log_file_name}";
117
  $this->log_index_file = "{$this->log_location_dir}/index.php";
118
 
119
  $this->hooks();
127
  public function hooks() {
128
  add_action( 'admin_menu', [ $this, 'add_options_page' ] );
129
  add_action( 'admin_init', [ $this, 'delete_log_file' ] );
130
+ add_action( 'admin_init', [ $this, 'maybe_delete_old_log_dir' ] );
131
  add_action( 'admin_enqueue_scripts', [ $this, 'scripts' ] );
132
  add_action( 'admin_footer', [ $this, 'dialog' ] );
133
  add_action( 'admin_init', [ $this, 'set_file_system' ] );
300
  unlink( $log_file );
301
  }
302
 
303
+ if ( constant_contact_debugging_enabled() ) {
304
+ $this->create_log_file();
305
+ }
306
 
307
  wp_redirect( $this->options_url );
308
  exit();
358
  * Create the log folder.
359
  *
360
  * @since 1.5.0
 
361
  */
362
  public function create_log_folder() {
 
 
 
 
363
  mkdir( $this->log_location_dir );
364
  chmod( $this->log_location_dir, 0755 );
365
  }
371
  * @return void
372
  */
373
  public function create_log_index_file() {
 
 
 
 
374
  if ( ! is_writable( $this->log_location_dir ) ) {
375
  return;
376
  }
389
  * @return void
390
  */
391
  public function create_log_file() {
 
 
 
 
392
  if ( ! is_writable( $this->log_location_dir ) ) {
393
  return;
394
  }
399
 
400
  touch( $this->log_location_file );
401
  }
402
+
403
+ /**
404
+ * Retrieve logging file location.
405
+ *
406
+ * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
407
+ * @since NEXT
408
+ *
409
+ * @return string Logging file location.
410
+ */
411
+ public function get_logging_location() {
412
+ return $this->log_location_file;
413
+ }
414
+
415
+ /**
416
+ * Remove old logging directory and files for older plugin versions (<= 1.8.1).
417
+ *
418
+ * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
419
+ * @since NEXT
420
+ *
421
+ * @return void
422
+ */
423
+ public function maybe_delete_old_log_dir() {
424
+ if ( Constant_Contact::VERSION <= '1.8.1' ) {
425
+ return;
426
+ }
427
+
428
+ $this->delete_log_dir( WP_CONTENT_DIR . '/ctct-logs' );
429
+ }
430
+
431
+ /**
432
+ * Remove current logging directory and files.
433
+ *
434
+ * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
435
+ * @since NEXT
436
+ */
437
+ public function delete_current_log_dir() {
438
+ $this->delete_log_dir( $this->log_location_dir );
439
+ }
440
+
441
+ /**
442
+ * Helper function to remove logging directory.
443
+ *
444
+ * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
445
+ * @since NEXT
446
+ *
447
+ * @return void
448
+ */
449
+ protected function delete_log_dir( $dir = '' ) {
450
+ if ( empty( $dir ) || ! is_dir( $dir ) ) {
451
+ return;
452
+ }
453
+
454
+ // Don't allow removing non-logging directories.
455
+ if ( empty( stristr( $dir, $this->log_file_dir ) ) ) {
456
+ return;
457
+ }
458
+
459
+ array_map( 'unlink', glob( "{$dir}/*" ) );
460
+ rmdir( $dir );
461
+ }
462
  }
includes/class-settings.php CHANGED
@@ -85,7 +85,7 @@ class ConstantContact_Settings {
85
 
86
  add_filter( 'preprocess_comment', [ $this, 'process_optin_comment_form' ] );
87
  add_filter( 'authenticate', [ $this, 'process_optin_login_form' ], 10, 3 );
88
- add_action( 'cmb2_save_field__ctct_logging', [ $this, 'maybe_init_logs' ], 10, 2 );
89
  add_filter( 'ctct_custom_spam_message', [ $this, 'get_spam_error_message' ], 10, 2 );
90
  }
91
 
@@ -932,15 +932,20 @@ class ConstantContact_Settings {
932
  *
933
  * @since 1.5.0
934
  *
935
- * @param string $updated Whether or not we're updating.
936
- * @param string $action Current action being performed.
 
937
  * @return void
938
  */
939
- public function maybe_init_logs( $updated, $action ) {
940
  if ( 'updated' !== $action ) {
941
  return;
942
  }
943
 
 
 
 
 
944
  $this->plugin->logging->create_log_folder();
945
  $this->plugin->logging->create_log_index_file();
946
  $this->plugin->logging->create_log_file();
85
 
86
  add_filter( 'preprocess_comment', [ $this, 'process_optin_comment_form' ] );
87
  add_filter( 'authenticate', [ $this, 'process_optin_login_form' ], 10, 3 );
88
+ add_action( 'cmb2_save_field__ctct_logging', [ $this, 'maybe_init_logs' ], 10, 3 );
89
  add_filter( 'ctct_custom_spam_message', [ $this, 'get_spam_error_message' ], 10, 2 );
90
  }
91
 
932
  *
933
  * @since 1.5.0
934
  *
935
+ * @param string $updated Whether or not we're updating.
936
+ * @param string $action Current action being performed.
937
+ * @param CMB2_Field $field Current field object.
938
  * @return void
939
  */
940
+ public function maybe_init_logs( $updated, $action, $field ) {
941
  if ( 'updated' !== $action ) {
942
  return;
943
  }
944
 
945
+ if ( 'on' !== $field->value ) {
946
+ return;
947
+ }
948
+
949
  $this->plugin->logging->create_log_folder();
950
  $this->plugin->logging->create_log_index_file();
951
  $this->plugin->logging->create_log_file();
includes/class-uninstall.php CHANGED
@@ -53,6 +53,7 @@ class ConstantContact_Uninstall {
53
  $this->delete_options();
54
  $this->delete_transients();
55
  $this->delete_cron_hooks();
 
56
  }
57
 
58
  /**
@@ -172,4 +173,14 @@ class ConstantContact_Uninstall {
172
  wp_clear_scheduled_hook( $cron_hook_name );
173
  }
174
  }
 
 
 
 
 
 
 
 
 
 
175
  }
53
  $this->delete_options();
54
  $this->delete_transients();
55
  $this->delete_cron_hooks();
56
+ $this->delete_log_dir();
57
  }
58
 
59
  /**
173
  wp_clear_scheduled_hook( $cron_hook_name );
174
  }
175
  }
176
+
177
+ /**
178
+ * Delete logging directory.
179
+ *
180
+ * @author Rebekah Van Epps <rebekah.vanepps@webdevstudios.com>
181
+ * @since NEXT
182
+ */
183
+ private function delete_log_dir() {
184
+ constant_contact()->logging->delete_current_log_dir();
185
+ }
186
  }
includes/helper-functions.php CHANGED
@@ -412,12 +412,21 @@ function constant_contact_maybe_log_it( $log_name, $error, $extra_data = '' ) {
412
  return;
413
  }
414
 
415
- if ( ! is_writable( constant_contact()->logger_location ) ) {
 
 
 
 
 
 
 
 
 
416
  return;
417
  }
418
 
419
  $logger = new Logger( $log_name );
420
- $logger->pushHandler( new StreamHandler( constant_contact()->logger_location ) );
421
  $extra = [];
422
 
423
  if ( $extra_data ) {
412
  return;
413
  }
414
 
415
+ $logging_file = constant_contact()->logger_location;
416
+
417
+ // Create logging file and directory if they don't exist.
418
+ if ( ! file_exists( $logging_file ) ) {
419
+ constant_contact()->logging->create_log_folder();
420
+ constant_contact()->logging->create_log_index_file();
421
+ constant_contact()->logging->create_log_file();
422
+ }
423
+
424
+ if ( ! is_writable( $logging_file ) ) {
425
  return;
426
  }
427
 
428
  $logger = new Logger( $log_name );
429
+ $logger->pushHandler( new StreamHandler( $logging_file ) );
430
  $extra = [];
431
 
432
  if ( $extra_data ) {
readme.txt CHANGED
@@ -3,7 +3,8 @@ Contributors: constantcontact, webdevstudios, tw2113, znowebdev, ggwicz, ra
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: 5.2.0
5
  Tested up to: 5.3.2
6
- Stable tag: 1.8.1
 
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
  Requires PHP: 5.6
@@ -35,6 +36,9 @@ BONUS: If you have a Constant Contact account, all new email addresses that you
35
 
36
  == Changelog ==
37
 
 
 
 
38
  = 1.8.1 =
39
  * Fixed: Google reCAPTCHA issues with jQuery dependencies.
40
  * Fixed: Google reCAPTCHA undefined class errors when `allow_url_fopen` is disabled.
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: 5.2.0
5
  Tested up to: 5.3.2
6
+
7
+ Stable tag: 1.8.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
  Requires PHP: 5.6
36
 
37
  == Changelog ==
38
 
39
+ = 1.8.2 =
40
+ * Updated: Amended logging location for more hopefully more consistent write-ability and smoother support requests.
41
+
42
  = 1.8.1 =
43
  * Fixed: Google reCAPTCHA issues with jQuery dependencies.
44
  * Fixed: Google reCAPTCHA undefined class errors when `allow_url_fopen` is disabled.