Email Log - Version 2.1.0

Version Description

GUI option to choose who can access email logs and performance improvements.

Download this release

Release Info

Developer sudar
Plugin Icon 128x128 Email Log
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.2 to 2.1.0

data/products.json ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "products": [
3
+ {
4
+ "info": {
5
+ "id": 18,
6
+ "slug": "more-fields",
7
+ "title": "More Fields",
8
+ "create_date": "2017-03-07 11:50:43",
9
+ "modified_date": "2017-09-21 10:02:24",
10
+ "status": "publish",
11
+ "link": "http:\/\/wpemaillog.com\/?post_type=download&p=18",
12
+ "content": "More Fields add-on shows additional fields about the email in the email log list page. The following are the additional fields that are added by this add-on.\r\n<ul>\r\n \t<li>From<\/li>\r\n \t<li>CC<\/li>\r\n \t<li>BCC<\/li>\r\n \t<li>Reply To<\/li>\r\n \t<li>Attachment<\/li>\r\n<\/ul>\r\nThese additional fields will allow you to see more information about the logged email.\r\n<h3>Screenshots<\/h3>\r\n[gallery columns=\"2\" ids=\"974,975\"]",
13
+ "excerpt": "More Fields add-on shows additional fields in the email log page like From, CC, BCC, Reply To, Attachment etc.",
14
+ "thumbnail": "https:\/\/wpemaillog.com\/wp-content\/uploads\/edd\/2016\/11\/more-fields-addon.png",
15
+ "category": [
16
+ {
17
+ "term_id": 4,
18
+ "name": "Addon",
19
+ "slug": "addon",
20
+ "term_group": 0,
21
+ "term_taxonomy_id": 4,
22
+ "taxonomy": "download_category",
23
+ "description": "",
24
+ "parent": 0,
25
+ "count": 5,
26
+ "filter": "raw"
27
+ }
28
+ ],
29
+ "tags": false,
30
+ "permalink": "https:\/\/wpemaillog.com\/addons\/more-fields\/",
31
+ "version": "2.0.1"
32
+ },
33
+ "pricing": {
34
+ "singlesite": "19.00",
35
+ "2-5sites": "37.00",
36
+ "unlimitedsites": "49.00"
37
+ },
38
+ "licensing": {
39
+ "enabled": true,
40
+ "version": "2.0.1",
41
+ "exp_unit": "years",
42
+ "exp_length": "1"
43
+ }
44
+ },
45
+ {
46
+ "info": {
47
+ "id": 16,
48
+ "slug": "resend-email",
49
+ "title": "Resend Email",
50
+ "create_date": "2017-03-07 11:40:25",
51
+ "modified_date": "2017-09-21 09:46:59",
52
+ "status": "publish",
53
+ "link": "http:\/\/wpemaillog.com\/?post_type=download&p=16",
54
+ "content": "Resend Email add-on allows you to resend the entire email directly from the email log. Before re-sending the email, this\u00a0add-on allows you to modify the different fields before re-sending the email.\r\n<h3>Screenshots<\/h3>\r\n[gallery ids=\"980,981,982,983,984\"]",
55
+ "excerpt": "Resend Email add-on allows you to resend the entire email directly from the email log. You can also modify the different fields before re-sending the email.",
56
+ "thumbnail": "https:\/\/wpemaillog.com\/wp-content\/uploads\/edd\/2016\/11\/resend-email-addon.png",
57
+ "category": [
58
+ {
59
+ "term_id": 4,
60
+ "name": "Addon",
61
+ "slug": "addon",
62
+ "term_group": 0,
63
+ "term_taxonomy_id": 4,
64
+ "taxonomy": "download_category",
65
+ "description": "",
66
+ "parent": 0,
67
+ "count": 5,
68
+ "filter": "raw"
69
+ }
70
+ ],
71
+ "tags": false,
72
+ "permalink": "https:\/\/wpemaillog.com\/addons\/resend-email\/",
73
+ "version": "2.0.2"
74
+ },
75
+ "pricing": {
76
+ "singlesite": "19.00",
77
+ "2-5sites": "37.00",
78
+ "unlimitedsites": "49.00"
79
+ },
80
+ "licensing": {
81
+ "enabled": true,
82
+ "version": "2.0.2",
83
+ "exp_unit": "years",
84
+ "exp_length": "1"
85
+ }
86
+ },
87
+ {
88
+ "info": {
89
+ "id": 20,
90
+ "slug": "forward-email",
91
+ "title": "Forward Email",
92
+ "create_date": "2017-03-07 11:30:56",
93
+ "modified_date": "2017-09-21 09:26:45",
94
+ "status": "publish",
95
+ "link": "http:\/\/wpemaillog.com\/?post_type=download&p=20",
96
+ "content": "Forward Email add-on allows you to send a copy of all the emails send from WordPress, to another email address. The add-on allows you to choose whether you want to forward through to, cc or bcc fields. This can be extremely useful when you want to debug by analyzing the emails that are sent from WordPress.\r\n<h3>Screenshots<\/h3>\r\n[gallery ids=\"987,988,989\"]",
97
+ "excerpt": "Forward Email add-on allows you to send a copy of all the emails send from WordPress, to another email address",
98
+ "thumbnail": "https:\/\/wpemaillog.com\/wp-content\/uploads\/edd\/2016\/11\/forward-email-addon.png",
99
+ "category": [
100
+ {
101
+ "term_id": 4,
102
+ "name": "Addon",
103
+ "slug": "addon",
104
+ "term_group": 0,
105
+ "term_taxonomy_id": 4,
106
+ "taxonomy": "download_category",
107
+ "description": "",
108
+ "parent": 0,
109
+ "count": 5,
110
+ "filter": "raw"
111
+ }
112
+ ],
113
+ "tags": false,
114
+ "permalink": "https:\/\/wpemaillog.com\/addons\/forward-email\/",
115
+ "version": "2.0.1"
116
+ },
117
+ "pricing": {
118
+ "singlesite": "19.00",
119
+ "2-5sites": "37.00",
120
+ "unlimitedsites": "49.00"
121
+ },
122
+ "licensing": {
123
+ "enabled": true,
124
+ "version": "2.0.1",
125
+ "exp_unit": "years",
126
+ "exp_length": "1"
127
+ }
128
+ },
129
+ {
130
+ "info": {
131
+ "id": 311,
132
+ "slug": "auto-delete-logs",
133
+ "title": "Auto Delete Logs",
134
+ "create_date": "2017-03-07 11:30:56",
135
+ "modified_date": "2017-07-15 09:13:31",
136
+ "status": "publish",
137
+ "link": "https:\/\/wpemaillog.com\/?post_type=download&p=311",
138
+ "content": "The Auto Delete Logs add-on allows you to automatically delete logs based on a schedule.\r\n<h3>Screenshots<\/h3>\r\n[gallery columns=\"2\" ids=\"991,992\"]",
139
+ "excerpt": "The Auto Delete Logs add-on allows you to automatically delete logs based on a schedule.",
140
+ "thumbnail": "https:\/\/wpemaillog.com\/wp-content\/uploads\/edd\/2017\/03\/delete-logs-addon.png",
141
+ "category": [
142
+ {
143
+ "term_id": 4,
144
+ "name": "Addon",
145
+ "slug": "addon",
146
+ "term_group": 0,
147
+ "term_taxonomy_id": 4,
148
+ "taxonomy": "download_category",
149
+ "description": "",
150
+ "parent": 0,
151
+ "count": 5,
152
+ "filter": "raw"
153
+ }
154
+ ],
155
+ "tags": false,
156
+ "permalink": "https:\/\/wpemaillog.com\/addons\/auto-delete-logs\/",
157
+ "version": "1.0.0"
158
+ },
159
+ "pricing": {
160
+ "singlesite": "19.00",
161
+ "2-5sites": "37.00",
162
+ "unlimitedsites": "49.00"
163
+ },
164
+ "licensing": {
165
+ "enabled": true,
166
+ "version": "1.0.0",
167
+ "exp_unit": "years",
168
+ "exp_length": "1"
169
+ }
170
+ },
171
+ {
172
+ "info": {
173
+ "id": 308,
174
+ "slug": "export-logs",
175
+ "title": "Export Logs",
176
+ "create_date": "2017-03-07 11:20:12",
177
+ "modified_date": "2017-07-15 09:13:51",
178
+ "status": "publish",
179
+ "link": "https:\/\/wpemaillog.com\/?post_type=download&p=308",
180
+ "content": "Export Logs add-on allows you to export the logged email logs as a csv file. The exported logs can be used for further processing or for record keeping.\r\n<h3>Screenshots<\/h3>\r\n[gallery ids=\"965,966,967,968\"]",
181
+ "excerpt": "Export Logs add-on allows you to export the logged email logs for further processing or record keeping.",
182
+ "thumbnail": "https:\/\/wpemaillog.com\/wp-content\/uploads\/edd\/2017\/03\/export-logs-addon.png",
183
+ "category": [
184
+ {
185
+ "term_id": 4,
186
+ "name": "Addon",
187
+ "slug": "addon",
188
+ "term_group": 0,
189
+ "term_taxonomy_id": 4,
190
+ "taxonomy": "download_category",
191
+ "description": "",
192
+ "parent": 0,
193
+ "count": 5,
194
+ "filter": "raw"
195
+ }
196
+ ],
197
+ "tags": false,
198
+ "permalink": "https:\/\/wpemaillog.com\/addons\/export-logs\/",
199
+ "version": "1.0.0"
200
+ },
201
+ "pricing": {
202
+ "singlesite": "19.00",
203
+ "2-5sites": "37.00",
204
+ "unlimitedsites": "49.00"
205
+ },
206
+ "licensing": {
207
+ "enabled": true,
208
+ "version": "1.0.0",
209
+ "exp_unit": "years",
210
+ "exp_length": "1"
211
+ }
212
+ }
213
+ ],
214
+ "request_speed": 0.0049359798431396484
215
+ }
email-log.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Logs every email sent through WordPress
6
  * Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me
7
  * Author: Sudar
8
- * Version: 2.0.2
9
  * Author URI: http://sudarmuthu.com/
10
  * Text Domain: email-log
11
  * Domain Path: languages/
@@ -46,7 +46,8 @@ if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) {
46
  ?>
47
  <div class="error">
48
  <p>
49
- <?php printf(
 
50
  __( 'Email Log requires at least PHP 5.3 to function properly. Please upgrade PHP or use <a href="%s">v1.9.1 of Email Log</a>.', 'email-log' ), // @codingStandardsIgnoreLine
51
  'https://downloads.wordpress.org/plugin/email-log.1.9.1.zip'
52
  );
5
  * Description: Logs every email sent through WordPress
6
  * Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me
7
  * Author: Sudar
8
+ * Version: 2.1.0
9
  * Author URI: http://sudarmuthu.com/
10
  * Text Domain: email-log
11
  * Domain Path: languages/
46
  ?>
47
  <div class="error">
48
  <p>
49
+ <?php
50
+ printf(
51
  __( 'Email Log requires at least PHP 5.3 to function properly. Please upgrade PHP or use <a href="%s">v1.9.1 of Email Log</a>.', 'email-log' ), // @codingStandardsIgnoreLine
52
  'https://downloads.wordpress.org/plugin/email-log.1.9.1.zip'
53
  );
include/Addon/Addon.php CHANGED
@@ -266,7 +266,13 @@ class Addon {
266
  * @return string Download url for add-on.
267
  */
268
  public function get_download_url() {
269
- return $this->email_log->get_licenser()->get_addon_download_url( $this->slug );
 
 
 
 
 
 
270
  }
271
 
272
  /**
@@ -275,7 +281,13 @@ class Addon {
275
  * @return bool True if valid, False otherwise.
276
  */
277
  protected function has_valid_bundle_license() {
278
- return $this->email_log->get_licenser()->is_bundle_license_valid();
 
 
 
 
 
 
279
  }
280
 
281
  /**
266
  * @return string Download url for add-on.
267
  */
268
  public function get_download_url() {
269
+ $licenser = $this->email_log->get_licenser();
270
+
271
+ if ( is_null( $licenser ) ) {
272
+ return '';
273
+ }
274
+
275
+ return $licenser->get_addon_download_url( $this->slug );
276
  }
277
 
278
  /**
281
  * @return bool True if valid, False otherwise.
282
  */
283
  protected function has_valid_bundle_license() {
284
+ $licenser = $this->email_log->get_licenser();
285
+
286
+ if ( is_null( $licenser ) ) {
287
+ return false;
288
+ }
289
+
290
+ return $licenser->is_bundle_license_valid();
291
  }
292
 
293
  /**
include/Addon/AddonList.php CHANGED
@@ -93,19 +93,22 @@ class AddonList {
93
 
94
  /**
95
  * Retrieve the list of add-ons by calling the store API.
 
96
  *
97
  * @return Addon[] List of add-ons, empty array if API call fails.
98
  */
99
  protected function get_addons() {
100
- if ( false === ( $json = get_transient( self::CACHE_KEY ) ) ) {
 
101
  $response = wp_remote_get( $this->get_api_url() );
102
 
103
  if ( is_wp_error( $response ) || ! is_array( $response ) ) {
104
- // TODO: Don't keep trying if the server is down.
105
- return array();
 
106
  }
107
 
108
- $json = json_decode( wp_remote_retrieve_body( $response ), true );
109
 
110
  if ( ! is_array( $json ) ) {
111
  return array();
@@ -187,4 +190,19 @@ class AddonList {
187
  protected function get_api_url() {
188
  return $this->store_url . '/edd-api/products/?category=addon';
189
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
93
 
94
  /**
95
  * Retrieve the list of add-ons by calling the store API.
96
+ * If the store API is down, then read the data from the local JSON file.
97
  *
98
  * @return Addon[] List of add-ons, empty array if API call fails.
99
  */
100
  protected function get_addons() {
101
+ $json = get_transient( self::CACHE_KEY );
102
+ if ( false === $json ) {
103
  $response = wp_remote_get( $this->get_api_url() );
104
 
105
  if ( is_wp_error( $response ) || ! is_array( $response ) ) {
106
+ $json_string = $this->get_addon_data_from_local_file();
107
+ } else {
108
+ $json_string = wp_remote_retrieve_body( $response );
109
  }
110
 
111
+ $json = json_decode( $json_string, true );
112
 
113
  if ( ! is_array( $json ) ) {
114
  return array();
190
  protected function get_api_url() {
191
  return $this->store_url . '/edd-api/products/?category=addon';
192
  }
193
+
194
+ /**
195
+ * Read the add-on data from the local data file.
196
+ *
197
+ * @since 2.1
198
+ *
199
+ * @return false|string JSON file content, False on failure.
200
+ */
201
+ private function get_addon_data_from_local_file() {
202
+ $email_log = email_log();
203
+
204
+ $local_json_file_path = $email_log->get_plugin_path() . 'data/products.json';
205
+
206
+ return file_get_contents( $local_json_file_path );
207
+ }
208
  }
include/Addon/AddonUpdater.php CHANGED
@@ -52,7 +52,13 @@ class AddonUpdater {
52
  */
53
  public function setup_updater() {
54
  $email_log = email_log();
55
- $license_key = $email_log->get_licenser()->get_addon_license_key( $this->addon_name );
 
 
 
 
 
 
56
 
57
  $updater = new EDDUpdater( $email_log->get_store_url(), $this->addon_file, array(
58
  'version' => $this->addon_version,
@@ -62,6 +68,6 @@ class AddonUpdater {
62
  )
63
  );
64
 
65
- $email_log->get_licenser()->add_updater( $updater );
66
  }
67
  }
52
  */
53
  public function setup_updater() {
54
  $email_log = email_log();
55
+ $licenser = $email_log->get_licenser();
56
+
57
+ if ( is_null( $licenser ) ) {
58
+ return;
59
+ }
60
+
61
+ $license_key = $licenser->get_addon_license_key( $this->addon_name );
62
 
63
  $updater = new EDDUpdater( $email_log->get_store_url(), $this->addon_file, array(
64
  'version' => $this->addon_version,
68
  )
69
  );
70
 
71
+ $licenser->add_updater( $updater );
72
  }
73
  }
include/Addon/EmailLogAddon.php CHANGED
@@ -32,10 +32,10 @@ abstract class EmailLogAddon {
32
  /**
33
  * Construct a new EmailLogAddon instance.
34
  *
35
- * @param string $addon_file Addon main file.
36
- * @param \EmailLog\Addon\AddonUpdater $updater Addon Updater.
37
  */
38
- public function __construct( $addon_file, $updater ) {
39
  $this->addon_file = $addon_file;
40
  $this->updater = $updater;
41
 
@@ -48,6 +48,10 @@ abstract class EmailLogAddon {
48
  * @inheritdoc
49
  */
50
  public function load() {
 
 
 
 
51
  $this->updater->set_addon_data( $this->addon_name, $this->addon_version, $this->addon_author );
52
  $this->updater->load();
53
  }
32
  /**
33
  * Construct a new EmailLogAddon instance.
34
  *
35
+ * @param string $addon_file Addon main file.
36
+ * @param \EmailLog\Addon\AddonUpdater|null $updater Addon Updater.
37
  */
38
+ public function __construct( $addon_file, $updater = null ) {
39
  $this->addon_file = $addon_file;
40
  $this->updater = $updater;
41
 
48
  * @inheritdoc
49
  */
50
  public function load() {
51
+ if ( is_null( $this->updater ) ) {
52
+ return;
53
+ }
54
+
55
  $this->updater->set_addon_data( $this->addon_name, $this->addon_version, $this->addon_author );
56
  $this->updater->load();
57
  }
include/Addon/License/Licenser.php CHANGED
@@ -266,7 +266,13 @@ final class Licenser implements Loadie {
266
  return $this->bundle_license->get_addon_license_key( $addon_name );
267
  }
268
 
269
- return $this->addon_list->get_addon_by_name( $addon_name )->get_addon_license_key();
 
 
 
 
 
 
270
  }
271
 
272
  /**
266
  return $this->bundle_license->get_addon_license_key( $addon_name );
267
  }
268
 
269
+ $addon = $this->addon_list->get_addon_by_name( $addon_name );
270
+
271
+ if ( ! $addon ) {
272
+ return false;
273
+ }
274
+
275
+ return $addon->get_addon_license_key();
276
  }
277
 
278
  /**
include/Addon/addon-helper.php CHANGED
@@ -22,7 +22,12 @@ function load_email_log_addon( $addon_class, $addon_file ) {
22
  $addon_dir = plugin_dir_path( $addon_file );
23
  $email_log->loader->add_namespace( 'EmailLog', $addon_dir . 'include' );
24
 
25
- $addon_updater = new \EmailLog\Addon\AddonUpdater( $addon_file );
 
 
 
 
 
26
  $addon = new $addon_class( $addon_file, $addon_updater );
27
 
28
  add_action( 'el_loaded', array( $addon, 'load' ) );
22
  $addon_dir = plugin_dir_path( $addon_file );
23
  $email_log->loader->add_namespace( 'EmailLog', $addon_dir . 'include' );
24
 
25
+ $addon_updater = null;
26
+
27
+ if ( ! \EmailLog\Util\is_admin_non_ajax_request() ) {
28
+ $addon_updater = new \EmailLog\Addon\AddonUpdater( $addon_file );
29
+ }
30
+
31
  $addon = new $addon_class( $addon_file, $addon_updater );
32
 
33
  add_action( 'el_loaded', array( $addon, 'load' ) );
include/Core/AdminCapabilityGiver.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php namespace EmailLog\Core;
2
+
3
+ use EmailLog\Core\UI\Page\LogListPage;
4
+
5
+ defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
6
+
7
+ /**
8
+ * Gives capability to admin.
9
+ * By default admins should be able to manage email logs.
10
+ *
11
+ * @since 2.1.0
12
+ */
13
+ class AdminCapabilityGiver implements Loadie {
14
+
15
+ public function load() {
16
+ add_filter( 'user_has_cap', array( $this, 'add_cap_to_admin_cap_list' ), 10, 4 );
17
+ }
18
+
19
+ /**
20
+ * Add `manage_email_logs` capability to admin's list of capabilities during `user_has_cap` check.
21
+ *
22
+ * In new installs this capability will be added to admins on plugin install.
23
+ * But in old installs the admins will not have this capability and that's why we need to add it using the filter.
24
+ *
25
+ * @param array $allcaps An array of all the user's capabilities.
26
+ * @param array $caps Actual capabilities for meta capability.
27
+ * @param array $args Optional parameters passed to has_cap(), typically object ID.
28
+ * @param \WP_User $user The user object.
29
+ *
30
+ * @return array Modified list of user's capabilities.
31
+ */
32
+ public function add_cap_to_admin_cap_list( $allcaps, $caps, $args, $user ) {
33
+ if ( ! in_array( 'administrator', $user->roles ) ) {
34
+ return $allcaps;
35
+ }
36
+
37
+ if ( array_key_exists( LogListPage::CAPABILITY, $allcaps ) ) {
38
+ return $allcaps;
39
+ }
40
+
41
+ $allcaps[ LogListPage::CAPABILITY ] = true;
42
+
43
+ return $allcaps;
44
+ }
45
+
46
+ /**
47
+ * Add Manage Email Logs capability to administrator role.
48
+ * This will be called on install.
49
+ */
50
+ public function add_cap_to_admin() {
51
+ $admin = get_role( 'administrator' );
52
+
53
+ if ( is_null( $admin ) ) {
54
+ return;
55
+ }
56
+
57
+ $admin->add_cap( LogListPage::CAPABILITY );
58
+ }
59
+ }
include/Core/EmailLog.php CHANGED
@@ -16,7 +16,7 @@ class EmailLog {
16
  * @since Genesis
17
  * @var string
18
  */
19
- const VERSION = '2.0.2';
20
 
21
  /**
22
  * Email Log Store URL.
@@ -66,11 +66,12 @@ class EmailLog {
66
 
67
  /**
68
  * Add-on Licenser.
 
69
  *
70
  * @since 2.0
71
  * @var \EmailLog\Addon\License\Licenser
72
  */
73
- private $licenser;
74
 
75
  /**
76
  * List of loadies.
@@ -110,7 +111,7 @@ class EmailLog {
110
  /**
111
  * Get Licenser.
112
  *
113
- * @return \EmailLog\Addon\License\Licenser
114
  */
115
  public function get_licenser() {
116
  return $this->licenser;
16
  * @since Genesis
17
  * @var string
18
  */
19
+ const VERSION = '2.1.0';
20
 
21
  /**
22
  * Email Log Store URL.
66
 
67
  /**
68
  * Add-on Licenser.
69
+ * For non-admin requests it will not be set.
70
  *
71
  * @since 2.0
72
  * @var \EmailLog\Addon\License\Licenser
73
  */
74
+ private $licenser = null;
75
 
76
  /**
77
  * List of loadies.
111
  /**
112
  * Get Licenser.
113
  *
114
+ * @return null|\EmailLog\Addon\License\Licenser
115
  */
116
  public function get_licenser() {
117
  return $this->licenser;
include/Core/EmailLogger.php CHANGED
@@ -39,16 +39,20 @@ class EmailLogger implements Loadie {
39
  */
40
  $mail_info = apply_filters( 'el_wp_mail_log', $mail_info );
41
 
42
- $headers = '';
43
- if ( isset( $mail_info['headers'] ) ) {
44
- $headers = is_array( $mail_info['headers'] ) ? implode( "\n", $mail_info['headers'] ) : $mail_info['headers'];
45
- }
 
 
 
 
46
 
47
  $data = array(
48
  'attachments' => ( count( $mail_info['attachments'] ) > 0 ) ? 'true' : 'false',
49
  'to_email' => is_array( $mail_info['to'] ) ? implode( ',', $mail_info['to'] ) : $mail_info['to'],
50
  'subject' => $mail_info['subject'],
51
- 'headers' => $headers,
52
  'sent_date' => current_time( 'mysql' ),
53
  );
54
 
39
  */
40
  $mail_info = apply_filters( 'el_wp_mail_log', $mail_info );
41
 
42
+ // Sometimes the array passed to the `wp_mail` filter may not contain all the required keys.
43
+ // See https://wordpress.org/support/topic/illegal-string-offset-attachments/
44
+ $mail_info = wp_parse_args( $mail_info, array(
45
+ 'attachments' => array(),
46
+ 'to' => '',
47
+ 'subject' => '',
48
+ 'headers' => '',
49
+ ) );
50
 
51
  $data = array(
52
  'attachments' => ( count( $mail_info['attachments'] ) > 0 ) ? 'true' : 'false',
53
  'to_email' => is_array( $mail_info['to'] ) ? implode( ',', $mail_info['to'] ) : $mail_info['to'],
54
  'subject' => $mail_info['subject'],
55
+ 'headers' => is_array( $mail_info['headers'] ) ? implode( "\n", $mail_info['headers'] ) : $mail_info['headers'],
56
  'sent_date' => current_time( 'mysql' ),
57
  );
58
 
include/Core/Request/LogListAction.php CHANGED
@@ -1,6 +1,7 @@
1
  <?php namespace EmailLog\Core\Request;
2
 
3
  use EmailLog\Core\Loadie;
 
4
 
5
  /**
6
  * Actions performed in Log List.
@@ -19,6 +20,7 @@ class LogListAction implements Loadie {
19
 
20
  add_action( 'el-log-list-delete', array( $this, 'delete_logs' ) );
21
  add_action( 'el-log-list-delete-all', array( $this, 'delete_all_logs' ) );
 
22
  }
23
 
24
  /**
@@ -27,81 +29,73 @@ class LogListAction implements Loadie {
27
  * @since 1.6
28
  */
29
  public function view_log_message() {
30
- /**
31
- * Filters the User capability to View Email Log content.
32
- *
33
- * Refer User Capabilities at
34
- * @link https://codex.wordpress.org/Roles_and_Capabilities#Capabilities
35
- *
36
- * @since 2.0.0
37
- *
38
- * @param string $user_capability User capability to view Log content.
39
- */
40
- $view_email_log_capability = apply_filters( 'el_view_email_log_capability', 'manage_options' );
41
-
42
- if ( current_user_can( $view_email_log_capability ) ) {
43
- $id = absint( $_GET['log_id'] );
44
-
45
- if ( $id > 0 ) {
46
- $log_items = $this->get_table_manager()->fetch_log_items_by_id( array( $id ) );
47
- if ( count( $log_items ) > 0 ) {
48
- $log_item = $log_items[0];
49
-
50
- ob_start();
51
- ?>
52
- <table style="width: 100%;">
53
- <tr style="background: #eee;">
54
- <td style="padding: 5px;"><?php _e( 'Sent at', 'email-log' ); ?>:</td>
55
- <td style="padding: 5px;"><?php echo $log_item['sent_date'] ?></td>
56
- </tr>
57
- <tr style="background: #eee;">
58
- <td style="padding: 5px;"><?php _e( 'To', 'email-log' ); ?>:</td>
59
- <td style="padding: 5px;"><?php echo $log_item['to_email'] ?></td>
60
- </tr>
61
- <tr style="background: #eee;">
62
- <td style="padding: 5px;"><?php _e( 'Subject', 'email-log' ); ?>:</td>
63
- <td style="padding: 5px;"><?php echo $log_item['subject'] ?></td>
64
- </tr>
65
-
66
- <?php
67
- /**
68
- * After the headers are displayed in the View Message thickbox.
69
- * This action can be used to add additional headers.
70
- *
71
- * @since 2.0.0
72
- *
73
- * @param array $log_item Log item that is getting rendered.
74
- */
75
- do_action( 'el_view_log_after_headers', $log_item );
76
- ?>
77
-
78
- </table>
79
-
80
- <div id="tabs">
81
- <ul>
82
- <li><a href="#tabs-1"><?php _e( 'HTML', 'email-log' ); ?></a></li>
83
- <li><a href="#tabs-2"><?php _e( 'Text', 'email-log' ); ?></a></li>
84
- </ul>
85
- <div id="tabs-1">
86
- <?php echo $log_item['message']; ?>
87
- </div>
88
- <div id="tabs-2">
89
- <textarea class="tabs-text-textarea"><?php echo esc_textarea( $log_item['message'] ); ?></textarea>
90
- </div>
91
- </div>
92
-
93
- <div id="view-message-footer">
94
- <a href="#" id="thickbox-footer-close"><?php _e( 'Close', 'email-log' ); ?></a>
95
- </div>
96
-
97
- <?php
98
- $output = ob_get_clean();
99
- echo $output;
100
- }
101
- }
102
  }
103
 
104
- die(); // this is required to return a proper result.
105
  }
106
 
107
  /**
@@ -131,6 +125,34 @@ class LogListAction implements Loadie {
131
  $this->render_log_deleted_notice( $logs_deleted );
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  /**
135
  * Render Logs deleted notice.
136
  *
1
  <?php namespace EmailLog\Core\Request;
2
 
3
  use EmailLog\Core\Loadie;
4
+ use EmailLog\Core\UI\Page\LogListPage;
5
 
6
  /**
7
  * Actions performed in Log List.
20
 
21
  add_action( 'el-log-list-delete', array( $this, 'delete_logs' ) );
22
  add_action( 'el-log-list-delete-all', array( $this, 'delete_all_logs' ) );
23
+ add_action( 'el-log-list-manage-user-roles-changed', array( $this, 'update_capabilities_for_user_roles' ), 10, 2 );
24
  }
25
 
26
  /**
29
  * @since 1.6
30
  */
31
  public function view_log_message() {
32
+ if ( ! current_user_can( LogListPage::CAPABILITY ) ) {
33
+ wp_die();
34
+ }
35
+
36
+ $id = absint( $_GET['log_id'] );
37
+
38
+ if ( $id <= 0 ) {
39
+ wp_die();
40
+ }
41
+
42
+ $log_items = $this->get_table_manager()->fetch_log_items_by_id( array( $id ) );
43
+ if ( count( $log_items ) > 0 ) {
44
+ $log_item = $log_items[0];
45
+
46
+ ob_start();
47
+ ?>
48
+ <table style="width: 100%;">
49
+ <tr style="background: #eee;">
50
+ <td style="padding: 5px;"><?php _e( 'Sent at', 'email-log' ); ?>:</td>
51
+ <td style="padding: 5px;"><?php echo $log_item['sent_date'] ?></td>
52
+ </tr>
53
+ <tr style="background: #eee;">
54
+ <td style="padding: 5px;"><?php _e( 'To', 'email-log' ); ?>:</td>
55
+ <td style="padding: 5px;"><?php echo $log_item['to_email'] ?></td>
56
+ </tr>
57
+ <tr style="background: #eee;">
58
+ <td style="padding: 5px;"><?php _e( 'Subject', 'email-log' ); ?>:</td>
59
+ <td style="padding: 5px;"><?php echo $log_item['subject'] ?></td>
60
+ </tr>
61
+
62
+ <?php
63
+ /**
64
+ * After the headers are displayed in the View Message thickbox.
65
+ * This action can be used to add additional headers.
66
+ *
67
+ * @since 2.0.0
68
+ *
69
+ * @param array $log_item Log item that is getting rendered.
70
+ */
71
+ do_action( 'el_view_log_after_headers', $log_item );
72
+ ?>
73
+
74
+ </table>
75
+
76
+ <div id="tabs">
77
+ <ul>
78
+ <li><a href="#tabs-1"><?php _e( 'HTML', 'email-log' ); ?></a></li>
79
+ <li><a href="#tabs-2"><?php _e( 'Text', 'email-log' ); ?></a></li>
80
+ </ul>
81
+ <div id="tabs-1">
82
+ <?php echo $log_item['message']; ?>
83
+ </div>
84
+ <div id="tabs-2">
85
+ <textarea class="tabs-text-textarea"><?php echo esc_textarea( $log_item['message'] ); ?></textarea>
86
+ </div>
87
+ </div>
88
+
89
+ <div id="view-message-footer">
90
+ <a href="#" id="thickbox-footer-close"><?php _e( 'Close', 'email-log' ); ?></a>
91
+ </div>
92
+
93
+ <?php
94
+ $output = ob_get_clean();
95
+ echo $output;
 
 
 
 
 
 
 
 
96
  }
97
 
98
+ wp_die(); // this is required to return a proper result.
99
  }
100
 
101
  /**
125
  $this->render_log_deleted_notice( $logs_deleted );
126
  }
127
 
128
+ /**
129
+ * Update user role capabilities when the allowed user role list is changed.
130
+ *
131
+ * The capability will be removed from old user roles and added to new user roles.
132
+ *
133
+ * @since 2.1.0
134
+ *
135
+ * @param array $old_roles Old user roles.
136
+ * @param array $new_roles New user roles.
137
+ */
138
+ public function update_capabilities_for_user_roles( $old_roles, $new_roles ) {
139
+ foreach ( $old_roles as $old_role ) {
140
+ $role = get_role( $old_role );
141
+
142
+ if ( ! is_null( $role ) ) {
143
+ $role->remove_cap( LogListPage::CAPABILITY );
144
+ }
145
+ }
146
+
147
+ foreach ( $new_roles as $new_role ) {
148
+ $role = get_role( $new_role );
149
+
150
+ if ( ! is_null( $role ) ) {
151
+ $role->add_cap( LogListPage::CAPABILITY );
152
+ }
153
+ }
154
+ }
155
+
156
  /**
157
  * Render Logs deleted notice.
158
  *
include/Core/Request/NonceChecker.php CHANGED
@@ -46,7 +46,7 @@ class NonceChecker implements Loadie {
46
  if ( isset( $_REQUEST['action'] ) ) {
47
  $action = sanitize_text_field( $_REQUEST['action'] );
48
 
49
- if ( 'el-log-list-' !== substr( $action, 0, 12 ) ) {
50
  return;
51
  }
52
 
46
  if ( isset( $_REQUEST['action'] ) ) {
47
  $action = sanitize_text_field( $_REQUEST['action'] );
48
 
49
+ if ( 'el-log-list-delete' !== substr( $action, 0, 18 ) ) {
50
  return;
51
  }
52
 
include/Core/Request/OverridePluginAPI.php CHANGED
@@ -1,6 +1,5 @@
1
  <?php namespace EmailLog\Core\Request;
2
 
3
- use EmailLog\Addon\AddonList;
4
  use EmailLog\Addon\API\EDDUpdater;
5
  use EmailLog\Core\Loadie;
6
 
@@ -22,6 +21,8 @@ class OverridePluginAPI implements Loadie {
22
  */
23
  public function load() {
24
  add_action( 'admin_init', array( $this, 'setup_updaters_for_inactive_addons' ) );
 
 
25
  }
26
 
27
  /**
@@ -29,12 +30,21 @@ class OverridePluginAPI implements Loadie {
29
  */
30
  public function setup_updaters_for_inactive_addons() {
31
  $email_log = email_log();
32
- $inactive_addons = $email_log->get_licenser()->get_addon_list()->get_inactive_addons();
 
 
 
 
 
 
33
 
34
  foreach ( $inactive_addons as $inactive_addon ) {
35
- $license_key = $email_log->get_licenser()->get_addon_license_key( $inactive_addon->name );
36
 
37
- $updater = new EDDUpdater( $email_log->get_store_url(), $inactive_addon->file, array(
 
 
 
38
  'version' => $inactive_addon->get_version(),
39
  'license' => $license_key,
40
  'item_name' => $inactive_addon->name,
@@ -42,7 +52,43 @@ class OverridePluginAPI implements Loadie {
42
  )
43
  );
44
 
45
- $email_log->get_licenser()->add_updater( $updater );
46
  }
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
1
  <?php namespace EmailLog\Core\Request;
2
 
 
3
  use EmailLog\Addon\API\EDDUpdater;
4
  use EmailLog\Core\Loadie;
5
 
21
  */
22
  public function load() {
23
  add_action( 'admin_init', array( $this, 'setup_updaters_for_inactive_addons' ) );
24
+
25
+ add_filter( 'plugins_api_result', array( $this, 'add_version_to_plugin_api_response' ), 100, 3 );
26
  }
27
 
28
  /**
30
  */
31
  public function setup_updaters_for_inactive_addons() {
32
  $email_log = email_log();
33
+ $licenser = $email_log->get_licenser();
34
+
35
+ if ( is_null( $licenser ) ) {
36
+ return;
37
+ }
38
+
39
+ $inactive_addons = $licenser->get_addon_list()->get_inactive_addons();
40
 
41
  foreach ( $inactive_addons as $inactive_addon ) {
42
+ $license_key = $licenser->get_addon_license_key( $inactive_addon->name );
43
 
44
+ $updater = new EDDUpdater(
45
+ $email_log->get_store_url(),
46
+ $inactive_addon->file,
47
+ array(
48
  'version' => $inactive_addon->get_version(),
49
  'license' => $license_key,
50
  'item_name' => $inactive_addon->name,
52
  )
53
  );
54
 
55
+ $licenser->add_updater( $updater );
56
  }
57
  }
58
+
59
+ /**
60
+ * Add version attribute to plugin API response.
61
+ *
62
+ * The API response generated by EDD doesn't have the version attribute and it results in some warnings.
63
+ * This method fixes it by manually adding the version attribute to the API response.
64
+ *
65
+ * @since 2.1.0
66
+ *
67
+ * @param object $response API Response.
68
+ * @param string $action Action name.
69
+ * @param array $args Arguments for the function.
70
+ *
71
+ * @return object Modified API response.
72
+ */
73
+ public function add_version_to_plugin_api_response( $response, $action, $args ) {
74
+ if ( 'plugin_information' !== $action ) {
75
+ return $response;
76
+ }
77
+
78
+ if ( ! isset( $args->slug ) || ( substr( $args->slug, 0, 10 ) != 'email-log-' ) ) {
79
+ return $response;
80
+ }
81
+
82
+ if ( isset( $response->version ) ) {
83
+ return $response;
84
+ }
85
+
86
+ if ( ! isset( $response->new_version ) ) {
87
+ return $response;
88
+ }
89
+
90
+ $response->version = $response->new_version;
91
+
92
+ return $response;
93
+ }
94
  }
include/Core/UI/Page/AddonListPage.php CHANGED
@@ -54,7 +54,10 @@ class AddonListPage extends BasePage {
54
  do_action( 'el_before_addon_list' );
55
 
56
  $email_log = email_log();
57
- $email_log->get_licenser()->get_addon_list()->render();
 
 
 
58
  ?>
59
  </div>
60
  <?php
54
  do_action( 'el_before_addon_list' );
55
 
56
  $email_log = email_log();
57
+ $licenser = $email_log->get_licenser();
58
+ if ( ! is_null( $licenser ) ) {
59
+ $licenser->get_addon_list()->render();
60
+ }
61
  ?>
62
  </div>
63
  <?php
include/Core/UI/Page/LogListPage.php CHANGED
@@ -29,6 +29,13 @@ class LogListPage extends BasePage {
29
  */
30
  const DELETE_LOG_ACTION = 'el-delete-email-log';
31
 
 
 
 
 
 
 
 
32
  /**
33
  * Setup hooks.
34
  */
@@ -49,7 +56,7 @@ class LogListPage extends BasePage {
49
  add_menu_page(
50
  __( 'Email Log', 'email-log' ),
51
  __( 'Email Log', 'email-log' ),
52
- 'manage_options',
53
  self::PAGE_SLUG,
54
  array( $this, 'render_page' ),
55
  'dashicons-email-alt',
@@ -60,7 +67,7 @@ class LogListPage extends BasePage {
60
  self::PAGE_SLUG,
61
  __( 'View Logs', 'email-log'),
62
  __( 'View Logs', 'email-log'),
63
- 'manage_options',
64
  self::PAGE_SLUG,
65
  array( $this, 'render_page' )
66
  );
@@ -81,6 +88,10 @@ class LogListPage extends BasePage {
81
  * Render page.
82
  */
83
  public function render_page() {
 
 
 
 
84
  add_thickbox();
85
 
86
  $this->log_list_table->prepare_items();
29
  */
30
  const DELETE_LOG_ACTION = 'el-delete-email-log';
31
 
32
+ /**
33
+ * Capability to manage email logs.
34
+ *
35
+ * @since 2.1.0
36
+ */
37
+ const CAPABILITY = 'manage_email_logs';
38
+
39
  /**
40
  * Setup hooks.
41
  */
56
  add_menu_page(
57
  __( 'Email Log', 'email-log' ),
58
  __( 'Email Log', 'email-log' ),
59
+ self::CAPABILITY,
60
  self::PAGE_SLUG,
61
  array( $this, 'render_page' ),
62
  'dashicons-email-alt',
67
  self::PAGE_SLUG,
68
  __( 'View Logs', 'email-log'),
69
  __( 'View Logs', 'email-log'),
70
+ self::CAPABILITY,
71
  self::PAGE_SLUG,
72
  array( $this, 'render_page' )
73
  );
88
  * Render page.
89
  */
90
  public function render_page() {
91
+ if ( ! current_user_can( self::CAPABILITY ) ) {
92
+ return;
93
+ }
94
+
95
  add_thickbox();
96
 
97
  $this->log_list_table->prepare_items();
include/Core/UI/Setting/CoreSetting.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php namespace EmailLog\Core\UI\Setting;
2
+
3
+ defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
+
5
+ /**
6
+ * All Email Log Core settings.
7
+ *
8
+ * @since 2.1.0
9
+ */
10
+ class CoreSetting extends Setting {
11
+
12
+ protected function initialize() {
13
+ $this->section->id = 'email-log-core';
14
+ $this->section->title = __( 'Core Email Log Settings', 'email-log' );
15
+ $this->section->option_name = 'email-log-core';
16
+
17
+ $this->section->field_labels = array(
18
+ 'allowed_user_roles' => __( 'Allowed User Roles', 'email-log' ),
19
+ 'remove_on_uninstall' => __( 'Remove Data on Uninstall?', 'email-log' ),
20
+ );
21
+
22
+ $this->section->default_value = array(
23
+ 'allowed_user_roles' => array(),
24
+ 'remove_on_uninstall' => '',
25
+ );
26
+
27
+ $this->load();
28
+ }
29
+
30
+ /**
31
+ * Override `load` method so that the core settings are displayed first.
32
+ *
33
+ * @inheritdoc
34
+ */
35
+ public function load() {
36
+ add_filter( 'el_setting_sections', array( $this, 'register' ), 9 );
37
+
38
+ add_action( 'add_option_' . $this->section->option_name, array( $this, 'allowed_user_roles_added' ), 10, 2 );
39
+ add_action( 'update_option_' . $this->section->option_name, array( $this, 'allowed_user_roles_changed' ), 10, 2 );
40
+ }
41
+
42
+ /**
43
+ * Renders the Email Log `Allowed User Roles` settings.
44
+ *
45
+ * @param array $args Arguments.
46
+ */
47
+ public function render_allowed_user_roles_settings( $args ) {
48
+ $option = $this->get_value();
49
+ $selected_roles = $option[ $args['id'] ];
50
+
51
+ $field_name = $this->section->option_name . '[' . $args['id'] . '][]';
52
+
53
+ $available_roles = get_editable_roles();
54
+ unset( $available_roles['administrator'] );
55
+ ?>
56
+
57
+ <p>
58
+ <input type="checkbox" checked disabled><?php _e( 'Administrator', 'email-log' ); ?>
59
+ </p>
60
+
61
+ <?php foreach ( $available_roles as $role_id => $role ) : ?>
62
+ <p>
63
+ <input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>" value="<?php echo esc_attr( $role_id ); ?>"
64
+ <?php \EmailLog\Util\checked_array( $selected_roles, $role_id ); ?>>
65
+
66
+ <?php echo $role['name']; ?>
67
+ </p>
68
+ <?php endforeach; ?>
69
+
70
+ <p>
71
+ <em>
72
+ <?php _e( '<strong>Note:</strong> Users with the above User Roles can view Email Logs.', 'email-log' ); ?>
73
+ <?php _e( 'Administrator role always has access and cannot be disabled.', 'email-log' ); ?>
74
+ </em>
75
+ </p>
76
+
77
+ <?php
78
+ }
79
+
80
+ /**
81
+ * Sanitize allowed user roles setting.
82
+ *
83
+ * @param array $roles User selected user roles.
84
+ *
85
+ * @return array Sanitized user roles.
86
+ */
87
+ public function sanitize_allowed_user_roles( $roles ) {
88
+ if ( ! is_array( $roles ) ) {
89
+ return array();
90
+ }
91
+
92
+ return array_map( 'sanitize_text_field', $roles );
93
+ }
94
+
95
+ /**
96
+ * Renders the Email Log `Remove Data on Uninstall?` settings.
97
+ *
98
+ * @param array $args
99
+ */
100
+ public function render_remove_on_uninstall_settings( $args ) {
101
+ $option = $this->get_value();
102
+ $remove_data = $option[ $args['id'] ];
103
+
104
+ $field_name = $this->section->option_name . '[' . $args['id'] . ']';
105
+ ?>
106
+
107
+ <input type="checkbox" name="<?php echo esc_attr( $field_name ); ?>" value="true" <?php checked( 'true', $remove_data ); ?>>
108
+ <?php _e( 'Check this box if you would like to completely remove all of its data when the plugin is deleted.', 'email-log' ) ?>
109
+
110
+ <p>
111
+ <em>
112
+ <?php printf(
113
+ __( '<strong>Note:</strong> You can also export the Email Logs using our <a href="%s" rel="noopener noreferrer" target="_blank">Export Logs</a> add-on.', 'email-log' ),
114
+ 'https://wpemaillog.com/addons/export-logs/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=settings&utm_content=el'
115
+ ); ?>
116
+ </em>
117
+ </p>
118
+
119
+ <?php
120
+ }
121
+
122
+ /**
123
+ * Sanitize Remove on uninstall value.
124
+ *
125
+ * @param string $value User entered value.
126
+ *
127
+ * @return string Sanitized value.
128
+ */
129
+ public function sanitize_remove_on_uninstall( $value ) {
130
+ return sanitize_text_field( $value );
131
+ }
132
+
133
+ /**
134
+ * Allowed user role list option is added.
135
+ *
136
+ * @param string $option Option name.
137
+ * @param array $value Option value.
138
+ */
139
+ public function allowed_user_roles_added( $option, $value ) {
140
+ $this->allowed_user_roles_changed( array(), $value );
141
+ }
142
+
143
+ /**
144
+ * Allowed user role list option was update.
145
+ *
146
+ * Change user role capabilities when the allowed user role list is changed.
147
+ *
148
+ * @param array $old_value Old Value.
149
+ * @param array $new_value New Value.
150
+ */
151
+ public function allowed_user_roles_changed( $old_value, $new_value ) {
152
+ $old_roles = $this->get_user_roles( $old_value );
153
+ $new_roles = $this->get_user_roles( $new_value );
154
+
155
+ /**
156
+ * The user roles who can manage email log list is changed.
157
+ *
158
+ * @since 2.1.0
159
+ *
160
+ * @param array $old_roles Old user roles.
161
+ * @param array $new_roles New user roles.
162
+ */
163
+ do_action( 'el-log-list-manage-user-roles-changed', $old_roles, $new_roles );
164
+ }
165
+
166
+ /**
167
+ * Get User roles from option value.
168
+ *
169
+ * @access protected
170
+ *
171
+ * @param array $option Option value
172
+ *
173
+ * @return array User roles.
174
+ */
175
+ protected function get_user_roles( $option ) {
176
+ if ( ! array_key_exists( 'allowed_user_roles', $option ) ) {
177
+ return array();
178
+ }
179
+
180
+ $user_roles = $option['allowed_user_roles'];
181
+ if ( ! is_array( $user_roles ) ) {
182
+ $user_roles = array( $user_roles );
183
+ }
184
+
185
+ return $user_roles;
186
+ }
187
+ }
include/Core/UI/Setting/Setting.php CHANGED
@@ -21,11 +21,12 @@ abstract class Setting {
21
  */
22
  public function __construct() {
23
  $this->section = new SettingSection();
 
 
 
24
  $this->section->fields = $this->get_fields();
25
  $this->section->callback = array( $this, 'render' );
26
  $this->section->sanitize_callback = array( $this, 'sanitize' );
27
-
28
- $this->initialize();
29
  }
30
 
31
  /**
@@ -50,11 +51,14 @@ abstract class Setting {
50
 
51
  /**
52
  * Get the value stored in the option.
 
53
  *
54
- * @return mixed Stored value.
55
  */
56
  public function get_value() {
57
- return get_option( $this->section->option_name );
 
 
58
  }
59
 
60
  /**
@@ -69,14 +73,18 @@ abstract class Setting {
69
  *
70
  * @return SettingField[] List of fields for the Setting.
71
  */
72
- abstract protected function get_fields();
 
 
73
 
74
  /**
75
- * Render the Settings.
76
  *
77
- * @return void
78
  */
79
- abstract public function render();
 
 
80
 
81
  /**
82
  * Sanitize the option values.
@@ -85,5 +93,47 @@ abstract class Setting {
85
  *
86
  * @return mixed Sanitized values.
87
  */
88
- abstract public function sanitize( $values );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
21
  */
22
  public function __construct() {
23
  $this->section = new SettingSection();
24
+
25
+ $this->initialize();
26
+
27
  $this->section->fields = $this->get_fields();
28
  $this->section->callback = array( $this, 'render' );
29
  $this->section->sanitize_callback = array( $this, 'sanitize' );
 
 
30
  }
31
 
32
  /**
51
 
52
  /**
53
  * Get the value stored in the option.
54
+ * If no values are found then the default values are returned.
55
  *
56
+ * @return array Stored value.
57
  */
58
  public function get_value() {
59
+ $value = get_option( $this->section->option_name );
60
+
61
+ return wp_parse_args( $value, $this->section->default_value );
62
  }
63
 
64
  /**
73
  *
74
  * @return SettingField[] List of fields for the Setting.
75
  */
76
+ protected function get_fields() {
77
+ return $this->build_fields();
78
+ }
79
 
80
  /**
81
+ * Render the Settings section.
82
  *
83
+ * By default it does nothing.
84
  */
85
+ public function render() {
86
+ return;
87
+ }
88
 
89
  /**
90
  * Sanitize the option values.
93
  *
94
  * @return mixed Sanitized values.
95
  */
96
+ public function sanitize( $values ) {
97
+ if ( ! is_array( $values ) ) {
98
+ return array();
99
+ }
100
+
101
+ $values = wp_parse_args( $values, $this->section->default_value );
102
+ $sanitized_values = array();
103
+
104
+ foreach ( $this->section->field_labels as $field_id => $label ) {
105
+ $callback = array( $this, 'sanitize_' . $field_id );
106
+
107
+ if ( is_callable( $callback ) ) {
108
+ $sanitized_values[ $field_id ] = call_user_func( $callback, $values[ $field_id ] );
109
+ } else {
110
+ $sanitized_values[ $field_id ] = $values[ $field_id ];
111
+ }
112
+ }
113
+
114
+ return $sanitized_values;
115
+ }
116
+
117
+ /**
118
+ * Build SettingField objects from field id and labels.
119
+ *
120
+ * @since 2.1.0
121
+ *
122
+ * @return \EmailLog\Core\UI\Setting\SettingField[] Built SettingFields.
123
+ */
124
+ protected function build_fields() {
125
+ $fields = array();
126
+
127
+ foreach ( $this->section->field_labels as $field_id => $label ) {
128
+ $field = new SettingField();
129
+ $field->id = $field_id;
130
+ $field->title = $label;
131
+ $field->args = array( 'id' => $field_id );
132
+ $field->callback = array( $this, 'render_' . $field_id . '_settings' );
133
+
134
+ $fields[] = $field;
135
+ }
136
+
137
+ return $fields;
138
+ }
139
  }
include/Core/UI/Setting/SettingSection.php CHANGED
@@ -7,6 +7,8 @@ defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
7
  * Ideally each add-on may have a different setting section.
8
  *
9
  * @see add_settings_section()
 
 
10
  */
11
  class SettingSection {
12
 
@@ -37,6 +39,24 @@ class SettingSection {
37
  */
38
  public $fields = array();
39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * Add a field to the section.
42
  *
7
  * Ideally each add-on may have a different setting section.
8
  *
9
  * @see add_settings_section()
10
+ *
11
+ * @since 2.0.0
12
  */
13
  class SettingSection {
14
 
39
  */
40
  public $fields = array();
41
 
42
+ /**
43
+ * Default value of the fields.
44
+ *
45
+ * @var array
46
+ *
47
+ * @since 2.1.0
48
+ */
49
+ public $default_value = array();
50
+
51
+ /**
52
+ * Field labels.
53
+ *
54
+ * @var array
55
+ *
56
+ * @since 2.1.0
57
+ */
58
+ public $field_labels = array();
59
+
60
  /**
61
  * Add a field to the section.
62
  *
include/Core/UI/UILoader.php CHANGED
@@ -53,6 +53,7 @@ class UILoader implements Loadie {
53
  */
54
  protected function initialize_components() {
55
  $this->components['admin_ui_enhancer'] = new Component\AdminUIEnhancer();
 
56
  }
57
 
58
  /**
@@ -64,7 +65,7 @@ class UILoader implements Loadie {
64
  */
65
  protected function initialize_pages() {
66
  $this->pages['log_list_page'] = new Page\LogListPage();
67
- $this->pages['addon_list_page'] = new Page\AddonListPage();
68
  $this->pages['settings_page'] = new Page\SettingsPage();
 
69
  }
70
  }
53
  */
54
  protected function initialize_components() {
55
  $this->components['admin_ui_enhancer'] = new Component\AdminUIEnhancer();
56
+ $this->components['core_settings'] = new Setting\CoreSetting();
57
  }
58
 
59
  /**
65
  */
66
  protected function initialize_pages() {
67
  $this->pages['log_list_page'] = new Page\LogListPage();
 
68
  $this->pages['settings_page'] = new Page\SettingsPage();
69
+ $this->pages['addon_list_page'] = new Page\AddonListPage();
70
  }
71
  }
include/Util/helper.php CHANGED
@@ -40,10 +40,8 @@ function sanitize_email_with_name( $string ) {
40
 
41
  $bracket_pos = strpos( $string, '<' );
42
  if ( false !== $bracket_pos ) {
43
- // Text before the bracketed email is the name.
44
  if ( $bracket_pos > 0 ) {
45
  $name = substr( $string, 0, $bracket_pos );
46
- $name = str_replace( '"', '', $name );
47
  $name = trim( $name );
48
 
49
  $email = substr( $string, $bracket_pos + 1 );
@@ -63,7 +61,7 @@ function sanitize_email_with_name( $string ) {
63
  *
64
  * @since 2.0.0
65
  *
66
- * @return array List of Columns to export.
67
  */
68
  function get_log_columns_to_export() {
69
 
@@ -72,4 +70,43 @@ function get_log_columns_to_export() {
72
  }
73
 
74
  return array( 'id', 'sent_date', 'to_email', 'subject' );
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  $bracket_pos = strpos( $string, '<' );
42
  if ( false !== $bracket_pos ) {
 
43
  if ( $bracket_pos > 0 ) {
44
  $name = substr( $string, 0, $bracket_pos );
 
45
  $name = trim( $name );
46
 
47
  $email = substr( $string, $bracket_pos + 1 );
61
  *
62
  * @since 2.0.0
63
  *
64
+ * @return string[] List of Columns to export.
65
  */
66
  function get_log_columns_to_export() {
67
 
70
  }
71
 
72
  return array( 'id', 'sent_date', 'to_email', 'subject' );
73
+ }
74
+
75
+ /**
76
+ * Is it an admin request and not an ajax request.
77
+ *
78
+ * @since 2.1
79
+ *
80
+ * @return bool True if admin non ajax request, False otherwise.
81
+ */
82
+ function is_admin_non_ajax_request() {
83
+ if ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
84
+ return false;
85
+ }
86
+
87
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
88
+ return false;
89
+ }
90
+
91
+ return is_admin();
92
+ }
93
+
94
+ /**
95
+ * Checks the Checkbox when values are present in a given array.
96
+ *
97
+ * Use this function in Checkbox fields.
98
+ *
99
+ * @since 2.1.0
100
+ *
101
+ * @param array $values List of all possible values.
102
+ * @param string $current The current value to be checked.
103
+ */
104
+ function checked_array( $values, $current ) {
105
+ if ( ! is_array( $values ) ) {
106
+ return;
107
+ }
108
+
109
+ if ( in_array( $current, $values ) ) {
110
+ echo "checked='checked'";
111
+ }
112
+ }
include/libraries/EDD_SL_Plugin_Updater.php CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.6.12
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
@@ -307,11 +307,13 @@ class EDD_SL_Plugin_Updater {
307
  * @return object $array
308
  */
309
  public function http_request_args( $args, $url ) {
310
- // If it is an https request and we are performing a package download, disable ssl verification
 
311
  if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
312
- $args['sslverify'] = false;
313
  }
314
  return $args;
 
315
  }
316
 
317
  /**
@@ -351,7 +353,8 @@ class EDD_SL_Plugin_Updater {
351
  'beta' => ! empty( $data['beta'] ),
352
  );
353
 
354
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
 
355
 
356
  if ( ! is_wp_error( $request ) ) {
357
  $request = json_decode( wp_remote_retrieve_body( $request ) );
@@ -413,7 +416,8 @@ class EDD_SL_Plugin_Updater {
413
  'beta' => ! empty( $data['beta'] )
414
  );
415
 
416
- $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
 
417
 
418
  if ( ! is_wp_error( $request ) ) {
419
  $version_info = json_decode( wp_remote_retrieve_body( $request ) );
@@ -474,4 +478,14 @@ class EDD_SL_Plugin_Updater {
474
 
475
  }
476
 
 
 
 
 
 
 
 
 
 
 
477
  }
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
+ * @version 1.6.13
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
307
  * @return object $array
308
  */
309
  public function http_request_args( $args, $url ) {
310
+
311
+ $verify_ssl = $this->verify_ssl();
312
  if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
313
+ $args['sslverify'] = $verify_ssl;
314
  }
315
  return $args;
316
+
317
  }
318
 
319
  /**
353
  'beta' => ! empty( $data['beta'] ),
354
  );
355
 
356
+ $verify_ssl = $this->verify_ssl();
357
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
358
 
359
  if ( ! is_wp_error( $request ) ) {
360
  $request = json_decode( wp_remote_retrieve_body( $request ) );
416
  'beta' => ! empty( $data['beta'] )
417
  );
418
 
419
+ $verify_ssl = $this->verify_ssl();
420
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
421
 
422
  if ( ! is_wp_error( $request ) ) {
423
  $version_info = json_decode( wp_remote_retrieve_body( $request ) );
478
 
479
  }
480
 
481
+ /**
482
+ * Returns if the SSL of the store should be verified.
483
+ *
484
+ * @since 1.6.13
485
+ * @return bool
486
+ */
487
+ private function verify_ssl() {
488
+ return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
489
+ }
490
+
491
  }
languages/email-log.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Email Log package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Email Log 2.0.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/email-log\n"
7
- "POT-Creation-Date: 2017-08-07 12:11:26+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,7 +12,7 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: dist/email-log.php:50 email-log.php:50
16
  msgid ""
17
  "Email Log requires at least PHP 5.3 to function properly. Please upgrade PHP "
18
  "or use <a href=\"%s\">v1.9.1 of Email Log</a>."
@@ -96,7 +96,7 @@ msgstr ""
96
  msgid "%s Add-on License Key"
97
  msgstr ""
98
 
99
- #: dist/include/Addon/AddonList.php:174 include/Addon/AddonList.php:174
100
  msgid ""
101
  "We are not able to retrieve the add-on list now. Please visit the <a href="
102
  "\"%s\">add-on page</a> to view the add-ons."
@@ -197,50 +197,50 @@ msgid ""
197
  "updates."
198
  msgstr ""
199
 
200
- #: dist/include/Core/Request/LogListAction.php:54
201
  #: dist/include/Core/UI/ListTable/LogListTable.php:67
202
- #: include/Core/Request/LogListAction.php:54
203
  #: include/Core/UI/ListTable/LogListTable.php:67
204
  msgid "Sent at"
205
  msgstr ""
206
 
207
- #: dist/include/Core/Request/LogListAction.php:58
208
  #: dist/include/Core/UI/ListTable/LogListTable.php:68
209
- #: include/Core/Request/LogListAction.php:58
210
  #: include/Core/UI/ListTable/LogListTable.php:68
211
  #: tmp_addon/ForwardEmailSetting.php:32
212
  msgid "To"
213
  msgstr ""
214
 
215
- #: dist/include/Core/Request/LogListAction.php:62
216
  #: dist/include/Core/UI/ListTable/LogListTable.php:69
217
- #: include/Core/Request/LogListAction.php:62
218
  #: include/Core/UI/ListTable/LogListTable.php:69
219
  msgid "Subject"
220
  msgstr ""
221
 
222
- #: dist/include/Core/Request/LogListAction.php:82
223
- #: include/Core/Request/LogListAction.php:82
224
  msgid "HTML"
225
  msgstr ""
226
 
227
- #: dist/include/Core/Request/LogListAction.php:83
228
- #: include/Core/Request/LogListAction.php:83
229
  msgid "Text"
230
  msgstr ""
231
 
232
- #: dist/include/Core/Request/LogListAction.php:94
233
- #: include/Core/Request/LogListAction.php:94
234
  msgid "Close"
235
  msgstr ""
236
 
237
- #: dist/include/Core/Request/LogListAction.php:140
238
- #: include/Core/Request/LogListAction.php:140
239
  msgid "There was some problem in deleting the email logs"
240
  msgstr ""
241
 
242
- #: dist/include/Core/Request/LogListAction.php:144
243
- #: include/Core/Request/LogListAction.php:144
244
  msgid "1 email log deleted."
245
  msgid_plural "%s email logs deleted"
246
  msgstr[0] ""
@@ -252,11 +252,11 @@ msgid "Buy Addons"
252
  msgstr ""
253
 
254
  #: dist/include/Core/UI/Component/AdminUIEnhancer.php:83
255
- #: dist/include/Core/UI/Page/LogListPage.php:61
256
- #: dist/include/Core/UI/Page/LogListPage.php:62
257
  #: include/Core/UI/Component/AdminUIEnhancer.php:83
258
- #: include/Core/UI/Page/LogListPage.php:61
259
- #: include/Core/UI/Page/LogListPage.php:62
260
  msgid "View Logs"
261
  msgstr ""
262
 
@@ -401,27 +401,27 @@ msgstr ""
401
  msgid "Support"
402
  msgstr ""
403
 
404
- #. #-#-#-#-# email-log.pot (Email Log 2.0.2) #-#-#-#-#
405
  #. Plugin Name of the plugin/theme
406
- #: dist/include/Core/UI/Page/LogListPage.php:50
407
- #: dist/include/Core/UI/Page/LogListPage.php:51
408
- #: include/Core/UI/Page/LogListPage.php:50
409
- #: include/Core/UI/Page/LogListPage.php:51
410
  msgid "Email Log"
411
  msgstr ""
412
 
413
- #: dist/include/Core/UI/Page/LogListPage.php:89
414
- #: include/Core/UI/Page/LogListPage.php:89
415
  msgid "Email Logs"
416
  msgstr ""
417
 
418
- #: dist/include/Core/UI/Page/LogListPage.php:94
419
- #: include/Core/UI/Page/LogListPage.php:94
420
  msgid "Search Logs"
421
  msgstr ""
422
 
423
- #: dist/include/Core/UI/Page/LogListPage.php:119
424
- #: include/Core/UI/Page/LogListPage.php:119
425
  msgid "Entries per page"
426
  msgstr ""
427
 
@@ -442,6 +442,51 @@ msgstr ""
442
  msgid "Save"
443
  msgstr ""
444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  #: dist/include/libraries/EDD_SL_Plugin_Updater.php:201
446
  #: include/libraries/EDD_SL_Plugin_Updater.php:201
447
  msgid ""
@@ -455,13 +500,13 @@ msgid ""
455
  "or %5$supdate now%6$s."
456
  msgstr ""
457
 
458
- #: dist/include/libraries/EDD_SL_Plugin_Updater.php:396
459
- #: include/libraries/EDD_SL_Plugin_Updater.php:396
460
  msgid "You do not have permission to install plugin updates"
461
  msgstr ""
462
 
463
- #: dist/include/libraries/EDD_SL_Plugin_Updater.php:396
464
- #: include/libraries/EDD_SL_Plugin_Updater.php:396
465
  msgid "Error"
466
  msgstr ""
467
 
@@ -540,12 +585,12 @@ msgid ""
540
  "Specify the list of email addresses to which the emails should be forwarded."
541
  msgstr ""
542
 
543
- #: tmp_addon/ForwardEmailSetting.php:33 tmp_addon/MoreFieldsAddon.php:62
544
  #: tmp_addon/ResendEmailAddon.php:113
545
  msgid "CC"
546
  msgstr ""
547
 
548
- #: tmp_addon/ForwardEmailSetting.php:34 tmp_addon/MoreFieldsAddon.php:63
549
  #: tmp_addon/ResendEmailAddon.php:117
550
  msgid "BCC"
551
  msgstr ""
@@ -554,15 +599,15 @@ msgstr ""
554
  msgid "You can enter multiple email address by separating them with comma."
555
  msgstr ""
556
 
557
- #: tmp_addon/MoreFieldsAddon.php:61 tmp_addon/ResendEmailAddon.php:109
558
  msgid "From"
559
  msgstr ""
560
 
561
- #: tmp_addon/MoreFieldsAddon.php:64 tmp_addon/ResendEmailAddon.php:121
562
  msgid "Reply To"
563
  msgstr ""
564
 
565
- #: tmp_addon/MoreFieldsAddon.php:65
566
  msgid "Attachment"
567
  msgstr ""
568
 
@@ -582,11 +627,11 @@ msgstr ""
582
  msgid "Content Type"
583
  msgstr ""
584
 
585
- #: tmp_addon/ResendEmailAddon.php:190
586
  msgid "Email was successfully resent"
587
  msgstr ""
588
 
589
- #: tmp_addon/ResendEmailAddon.php:192
590
  msgid "There was some problem in sending the email"
591
  msgstr ""
592
 
2
  # This file is distributed under the same license as the Email Log package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Email Log 2.1.0\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/email-log\n"
7
+ "POT-Creation-Date: 2017-09-21 05:15:48+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: dist/email-log.php:51 email-log.php:51
16
  msgid ""
17
  "Email Log requires at least PHP 5.3 to function properly. Please upgrade PHP "
18
  "or use <a href=\"%s\">v1.9.1 of Email Log</a>."
96
  msgid "%s Add-on License Key"
97
  msgstr ""
98
 
99
+ #: dist/include/Addon/AddonList.php:177 include/Addon/AddonList.php:177
100
  msgid ""
101
  "We are not able to retrieve the add-on list now. Please visit the <a href="
102
  "\"%s\">add-on page</a> to view the add-ons."
197
  "updates."
198
  msgstr ""
199
 
200
+ #: dist/include/Core/Request/LogListAction.php:50
201
  #: dist/include/Core/UI/ListTable/LogListTable.php:67
202
+ #: include/Core/Request/LogListAction.php:50
203
  #: include/Core/UI/ListTable/LogListTable.php:67
204
  msgid "Sent at"
205
  msgstr ""
206
 
207
+ #: dist/include/Core/Request/LogListAction.php:54
208
  #: dist/include/Core/UI/ListTable/LogListTable.php:68
209
+ #: include/Core/Request/LogListAction.php:54
210
  #: include/Core/UI/ListTable/LogListTable.php:68
211
  #: tmp_addon/ForwardEmailSetting.php:32
212
  msgid "To"
213
  msgstr ""
214
 
215
+ #: dist/include/Core/Request/LogListAction.php:58
216
  #: dist/include/Core/UI/ListTable/LogListTable.php:69
217
+ #: include/Core/Request/LogListAction.php:58
218
  #: include/Core/UI/ListTable/LogListTable.php:69
219
  msgid "Subject"
220
  msgstr ""
221
 
222
+ #: dist/include/Core/Request/LogListAction.php:78
223
+ #: include/Core/Request/LogListAction.php:78
224
  msgid "HTML"
225
  msgstr ""
226
 
227
+ #: dist/include/Core/Request/LogListAction.php:79
228
+ #: include/Core/Request/LogListAction.php:79
229
  msgid "Text"
230
  msgstr ""
231
 
232
+ #: dist/include/Core/Request/LogListAction.php:90
233
+ #: include/Core/Request/LogListAction.php:90
234
  msgid "Close"
235
  msgstr ""
236
 
237
+ #: dist/include/Core/Request/LogListAction.php:162
238
+ #: include/Core/Request/LogListAction.php:162
239
  msgid "There was some problem in deleting the email logs"
240
  msgstr ""
241
 
242
+ #: dist/include/Core/Request/LogListAction.php:166
243
+ #: include/Core/Request/LogListAction.php:166
244
  msgid "1 email log deleted."
245
  msgid_plural "%s email logs deleted"
246
  msgstr[0] ""
252
  msgstr ""
253
 
254
  #: dist/include/Core/UI/Component/AdminUIEnhancer.php:83
255
+ #: dist/include/Core/UI/Page/LogListPage.php:68
256
+ #: dist/include/Core/UI/Page/LogListPage.php:69
257
  #: include/Core/UI/Component/AdminUIEnhancer.php:83
258
+ #: include/Core/UI/Page/LogListPage.php:68
259
+ #: include/Core/UI/Page/LogListPage.php:69
260
  msgid "View Logs"
261
  msgstr ""
262
 
401
  msgid "Support"
402
  msgstr ""
403
 
404
+ #. #-#-#-#-# email-log.pot (Email Log 2.1.0) #-#-#-#-#
405
  #. Plugin Name of the plugin/theme
406
+ #: dist/include/Core/UI/Page/LogListPage.php:57
407
+ #: dist/include/Core/UI/Page/LogListPage.php:58
408
+ #: include/Core/UI/Page/LogListPage.php:57
409
+ #: include/Core/UI/Page/LogListPage.php:58
410
  msgid "Email Log"
411
  msgstr ""
412
 
413
+ #: dist/include/Core/UI/Page/LogListPage.php:100
414
+ #: include/Core/UI/Page/LogListPage.php:100
415
  msgid "Email Logs"
416
  msgstr ""
417
 
418
+ #: dist/include/Core/UI/Page/LogListPage.php:105
419
+ #: include/Core/UI/Page/LogListPage.php:105
420
  msgid "Search Logs"
421
  msgstr ""
422
 
423
+ #: dist/include/Core/UI/Page/LogListPage.php:130
424
+ #: include/Core/UI/Page/LogListPage.php:130
425
  msgid "Entries per page"
426
  msgstr ""
427
 
442
  msgid "Save"
443
  msgstr ""
444
 
445
+ #: dist/include/Core/UI/Setting/CoreSetting.php:14
446
+ #: include/Core/UI/Setting/CoreSetting.php:14
447
+ msgid "Core Email Log Settings"
448
+ msgstr ""
449
+
450
+ #: dist/include/Core/UI/Setting/CoreSetting.php:18
451
+ #: include/Core/UI/Setting/CoreSetting.php:18
452
+ msgid "Allowed User Roles"
453
+ msgstr ""
454
+
455
+ #: dist/include/Core/UI/Setting/CoreSetting.php:19
456
+ #: include/Core/UI/Setting/CoreSetting.php:19
457
+ msgid "Remove Data on Uninstall?"
458
+ msgstr ""
459
+
460
+ #: dist/include/Core/UI/Setting/CoreSetting.php:58
461
+ #: include/Core/UI/Setting/CoreSetting.php:58
462
+ msgid "Administrator"
463
+ msgstr ""
464
+
465
+ #: dist/include/Core/UI/Setting/CoreSetting.php:72
466
+ #: include/Core/UI/Setting/CoreSetting.php:72
467
+ msgid ""
468
+ "<strong>Note:</strong> Users with the above User Roles can view Email Logs."
469
+ msgstr ""
470
+
471
+ #: dist/include/Core/UI/Setting/CoreSetting.php:73
472
+ #: include/Core/UI/Setting/CoreSetting.php:73
473
+ msgid "Administrator role always has access and cannot be disabled."
474
+ msgstr ""
475
+
476
+ #: dist/include/Core/UI/Setting/CoreSetting.php:108
477
+ #: include/Core/UI/Setting/CoreSetting.php:108
478
+ msgid ""
479
+ "Check this box if you would like to completely remove all of its data when "
480
+ "the plugin is deleted."
481
+ msgstr ""
482
+
483
+ #: dist/include/Core/UI/Setting/CoreSetting.php:113
484
+ #: include/Core/UI/Setting/CoreSetting.php:113
485
+ msgid ""
486
+ "<strong>Note:</strong> You can also export the Email Logs using our <a href="
487
+ "\"%s\" rel=\"noopener noreferrer\" target=\"_blank\">Export Logs</a> add-on."
488
+ msgstr ""
489
+
490
  #: dist/include/libraries/EDD_SL_Plugin_Updater.php:201
491
  #: include/libraries/EDD_SL_Plugin_Updater.php:201
492
  msgid ""
500
  "or %5$supdate now%6$s."
501
  msgstr ""
502
 
503
+ #: dist/include/libraries/EDD_SL_Plugin_Updater.php:399
504
+ #: include/libraries/EDD_SL_Plugin_Updater.php:399
505
  msgid "You do not have permission to install plugin updates"
506
  msgstr ""
507
 
508
+ #: dist/include/libraries/EDD_SL_Plugin_Updater.php:399
509
+ #: include/libraries/EDD_SL_Plugin_Updater.php:399
510
  msgid "Error"
511
  msgstr ""
512
 
585
  "Specify the list of email addresses to which the emails should be forwarded."
586
  msgstr ""
587
 
588
+ #: tmp_addon/ForwardEmailSetting.php:33 tmp_addon/MoreFieldsAddon.php:46
589
  #: tmp_addon/ResendEmailAddon.php:113
590
  msgid "CC"
591
  msgstr ""
592
 
593
+ #: tmp_addon/ForwardEmailSetting.php:34 tmp_addon/MoreFieldsAddon.php:47
594
  #: tmp_addon/ResendEmailAddon.php:117
595
  msgid "BCC"
596
  msgstr ""
599
  msgid "You can enter multiple email address by separating them with comma."
600
  msgstr ""
601
 
602
+ #: tmp_addon/MoreFieldsAddon.php:45 tmp_addon/ResendEmailAddon.php:109
603
  msgid "From"
604
  msgstr ""
605
 
606
+ #: tmp_addon/MoreFieldsAddon.php:48 tmp_addon/ResendEmailAddon.php:121
607
  msgid "Reply To"
608
  msgstr ""
609
 
610
+ #: tmp_addon/MoreFieldsAddon.php:49
611
  msgid "Attachment"
612
  msgstr ""
613
 
627
  msgid "Content Type"
628
  msgstr ""
629
 
630
+ #: tmp_addon/ResendEmailAddon.php:193
631
  msgid "Email was successfully resent"
632
  msgstr ""
633
 
634
+ #: tmp_addon/ResendEmailAddon.php:195
635
  msgid "There was some problem in sending the email"
636
  msgstr ""
637
 
load-email-log.php CHANGED
@@ -38,18 +38,26 @@ function load_email_log( $plugin_file ) {
38
 
39
  $email_log = new \EmailLog\Core\EmailLog( $plugin_file, $loader, new \EmailLog\Core\DB\TableManager() );
40
 
41
- $email_log->set_licenser( new \EmailLog\Addon\License\Licenser() );
 
 
 
 
 
 
42
 
43
  $email_log->add_loadie( new \EmailLog\Core\EmailLogger() );
44
  $email_log->add_loadie( new \EmailLog\Core\UI\UILoader() );
45
- $email_log->add_loadie( new \EmailLog\Addon\DependencyEnforcer() );
46
 
47
  $email_log->add_loadie( new \EmailLog\Core\Request\NonceChecker() );
48
  $email_log->add_loadie( new \EmailLog\Core\Request\LogListAction() );
49
- $email_log->add_loadie( new \EmailLog\Core\Request\OverridePluginAPI() );
 
 
50
 
51
  // `register_activation_hook` can't be called from inside any hook.
52
  register_activation_hook( $plugin_file, array( $email_log->table_manager, 'on_activate' ) );
 
53
 
54
  // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`.
55
  // But some plugins like EDD are sending emails in `init` event itself,
38
 
39
  $email_log = new \EmailLog\Core\EmailLog( $plugin_file, $loader, new \EmailLog\Core\DB\TableManager() );
40
 
41
+ if ( \EmailLog\Util\is_admin_non_ajax_request() ) {
42
+ // Loading licenser in frontend or ajax request is resulting in huge performance issues.
43
+ $email_log->set_licenser( new \EmailLog\Addon\License\Licenser() );
44
+
45
+ $email_log->add_loadie( new \EmailLog\Addon\DependencyEnforcer() );
46
+ $email_log->add_loadie( new \EmailLog\Core\Request\OverridePluginAPI() );
47
+ }
48
 
49
  $email_log->add_loadie( new \EmailLog\Core\EmailLogger() );
50
  $email_log->add_loadie( new \EmailLog\Core\UI\UILoader() );
 
51
 
52
  $email_log->add_loadie( new \EmailLog\Core\Request\NonceChecker() );
53
  $email_log->add_loadie( new \EmailLog\Core\Request\LogListAction() );
54
+
55
+ $capability_giver = new \EmailLog\Core\AdminCapabilityGiver();
56
+ $email_log->add_loadie( $capability_giver );
57
 
58
  // `register_activation_hook` can't be called from inside any hook.
59
  register_activation_hook( $plugin_file, array( $email_log->table_manager, 'on_activate' ) );
60
+ register_activation_hook( $plugin_file, array( $capability_giver, 'add_cap_to_admin' ) );
61
 
62
  // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`.
63
  // But some plugins like EDD are sending emails in `init` event itself,
readme.txt CHANGED
@@ -1,9 +1,10 @@
1
  === Email Log ===
2
  Contributors: sudar
3
  Tags: email, log, log email, resend email, multisite
 
4
  Requires at least: 4.0
5
  Tested up to: 4.8
6
- Stable tag: 2.0.2
7
 
8
  Log and view all outgoing emails from WordPress. Works with WordPress Multisite as well.
9
 
@@ -114,6 +115,14 @@ Meanwhile, I have added a hack to handle this condition in v1.7.3 of my plugin.
114
  This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/wp-readme'>wp-readme</a>, which generates readme files for WordPress Plugins.
115
  == Changelog ==
116
 
 
 
 
 
 
 
 
 
117
  = v2.0.2 - (2017-08-07) =
118
  - Fix: Renamed include/util directory to correct case. This caused issues in some install.
119
 
@@ -261,6 +270,9 @@ This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/
261
 
262
  == Upgrade Notice ==
263
 
 
 
 
264
  = 2.0.2 =
265
  Fixed the case of the Util directory. This caused issues in some install.
266
 
1
  === Email Log ===
2
  Contributors: sudar
3
  Tags: email, log, log email, resend email, multisite
4
+ Requires PHP: 5.3
5
  Requires at least: 4.0
6
  Tested up to: 4.8
7
+ Stable tag: 2.1.0
8
 
9
  Log and view all outgoing emails from WordPress. Works with WordPress Multisite as well.
10
 
115
  This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/wp-readme'>wp-readme</a>, which generates readme files for WordPress Plugins.
116
  == Changelog ==
117
 
118
+ = v2.1.0 - (2017-09-21) =
119
+ - New: GUI option to choose the user roles that can access email logs.
120
+ - New: GUI option to delete email log table when the plugin is uninstalled.
121
+ - Tweak: Performance improvements.
122
+ - Tweak: Delete all traces of the plugin from DB if the user chooses to destroy data during uninstall.
123
+ - Fix: Handle cases where there is a quote in front of email address.
124
+ - Fix: Handle cases where array passed to `wp_mail` may not contain all the required fields.
125
+
126
  = v2.0.2 - (2017-08-07) =
127
  - Fix: Renamed include/util directory to correct case. This caused issues in some install.
128
 
270
 
271
  == Upgrade Notice ==
272
 
273
+ = 2.1.0 =
274
+ GUI option to choose who can access email logs and performance improvements.
275
+
276
  = 2.0.2 =
277
  Fixed the case of the Util directory. This caused issues in some install.
278
 
uninstall.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Uninstall page for Email Log Plugin to clean up db.
4
  *
5
  * This file is named uninstall.php since WordPress requires that name.
6
  */
@@ -17,31 +17,55 @@ if ( is_multisite() ) {
17
 
18
  foreach ( $sites as $site ) {
19
  switch_to_blog( $site['blog_id'] );
20
- email_log_delete_table();
21
  restore_current_blog();
22
  }
23
  } else {
24
- email_log_delete_table();
25
  }
26
 
27
  /**
28
- * Delete email log table and db option
 
 
29
  *
30
  * @since 1.7
31
  *
32
  * @global object $wpdb
33
  */
34
- function email_log_delete_table() {
35
  global $wpdb;
36
 
 
 
 
 
 
 
 
 
 
37
  // This is hardcoded on purpose, since the entire plugin is not loaded during uninstall.
38
  $table_name = $wpdb->prefix . 'email_log';
39
 
40
- if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
41
- // If table is present, drop it
42
- $wpdb->query( "DROP TABLE $table_name" );
43
- }
 
 
 
 
 
 
 
44
 
45
- // Delete the option
46
- delete_option( 'email-log-db' );
 
 
 
 
 
 
47
  }
1
  <?php
2
  /**
3
+ * Uninstall page for Email Log Plugin to clean up all plugin data.
4
  *
5
  * This file is named uninstall.php since WordPress requires that name.
6
  */
17
 
18
  foreach ( $sites as $site ) {
19
  switch_to_blog( $site['blog_id'] );
20
+ email_log_delete_db_data();
21
  restore_current_blog();
22
  }
23
  } else {
24
+ email_log_delete_db_data();
25
  }
26
 
27
  /**
28
+ * Delete all email log data from db.
29
+ *
30
+ * The data include email log table, options, capability and add-on license data.
31
  *
32
  * @since 1.7
33
  *
34
  * @global object $wpdb
35
  */
36
+ function email_log_delete_db_data() {
37
  global $wpdb;
38
 
39
+ $remove_data_on_uninstall = false;
40
+
41
+ $option = get_option( 'email-log-core' );
42
+ if ( is_array( $option ) && array_key_exists( 'remove_on_uninstall', $option ) &&
43
+ 'true' === strtolower( $option['remove_on_uninstall'] ) ) {
44
+
45
+ $remove_data_on_uninstall = true;
46
+ }
47
+
48
  // This is hardcoded on purpose, since the entire plugin is not loaded during uninstall.
49
  $table_name = $wpdb->prefix . 'email_log';
50
 
51
+ if ( $remove_data_on_uninstall ) {
52
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
53
+ $wpdb->query( "DROP TABLE $table_name" );
54
+ }
55
+
56
+ delete_option( 'email-log-db' );
57
+ delete_option( 'email-log-core' );
58
+
59
+ $roles = get_editable_roles();
60
+ foreach ( $roles as $role_name => $role_obj ) {
61
+ $role = get_role( $role_name );
62
 
63
+ if ( ! is_null( $role ) ) {
64
+ $role->remove_cap( 'manage_email_logs' );
65
+ }
66
+ }
67
+
68
+ delete_option( 'el_bundle_license' );
69
+ $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'el_license_%'" );
70
+ }
71
  }