WP Mail Logging - Version 1.6.1

Version Description

= 1.6.0 = - New: Improved modal, added view types - Tweak: Proper date if none set in WordPress settings - Tweak: Updated libraries - Tweak: Added wp_mail hook to very last priority

Download this release

Release Info

Developer No3x
Plugin Icon 128x128 WP Mail Logging
Version 1.6.1
Comparing to
See all releases

Code changes from version 1.6.0 to 1.6.1

Files changed (3) hide show
  1. WPML_Email_Log_List.php +451 -450
  2. readme.txt +108 -105
  3. wp-mail-logging.php +112 -112
WPML_Email_Log_List.php CHANGED
@@ -1,450 +1,451 @@
1
- <?php
2
-
3
- namespace No3x\WPML;
4
-
5
- use No3x\WPML\Model\WPML_Mail as Mail;
6
-
7
- // Exit if accessed directly.
8
- if ( ! defined( 'ABSPATH' ) ) exit;
9
-
10
- require_once( ABSPATH . 'wp-admin/includes/screen.php' );
11
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
12
-
13
- if ( ! class_exists( 'WP_List_Table' ) ) {
14
- require_once( plugin_dir_path( __FILE__ ) . 'inc/class-wp-list-table.php' );
15
- }
16
-
17
- /**
18
- * Renders the mails in a table list.
19
- * @author No3x
20
- * @since 1.0
21
- */
22
- class WPML_Email_Log_List extends \WP_List_Table {
23
-
24
- const NONCE_LIST_TABLE = 'wpml-list_table';
25
- private $supported_formats = array();
26
- /**
27
- * Initializes the List Table
28
- * @since 1.0
29
- */
30
- function __construct( $supported_formats = array() ) {
31
- $this->supported_formats = $supported_formats;
32
- }
33
-
34
- function addActionsAndFilters() {
35
- add_action( 'admin_init', array( $this, 'init') );
36
- add_filter( WPML_Plugin::HOOK_LOGGING_SUPPORTED_FORMATS, function() {
37
- return $this->supported_formats;
38
- } );
39
- add_action( 'wp_ajax_wpml_email_get', __CLASS__ . '::ajax_wpml_email_get' );
40
- }
41
-
42
- function init() {
43
- global $status, $page, $hook_suffix;
44
-
45
- parent::__construct( array(
46
- 'singular' => 'email', // singular name of the listed records
47
- 'plural' => 'emails', // plural name of the listed records
48
- 'ajax' => false, // does this table support ajax?
49
- ) );
50
- }
51
-
52
- /**
53
- * Is displayed if no item is available to render
54
- * @since 1.0
55
- * @see WP_List_Table::no_items()
56
- */
57
- function no_items() {
58
- _e( 'No email found.', 'wpml' );
59
- return;
60
- }
61
-
62
- /**
63
- * Defines the available columns.
64
- * @since 1.0
65
- * @see WP_List_Table::get_columns()
66
- */
67
- function get_columns() {
68
- $columns = array(
69
- 'cb' => '<input type="checkbox" />',
70
- 'mail_id' => __( 'ID', 'wpml' ),
71
- 'timestamp' => __( 'Time', 'wpml' ),
72
- 'receiver' => __( 'Receiver', 'wpml' ),
73
- 'subject' => __( 'Subject', 'wpml' ),
74
- 'message' => __( 'Message', 'wpml' ),
75
- 'headers' => __( 'Headers', 'wpml' ),
76
- 'attachments' => __( 'Attachments', 'wpml' ),
77
- 'plugin_version' => __( 'Plugin Version', 'wpml' ),
78
- );
79
-
80
- // Give a plugin the chance to edit the columns.
81
- $columns = apply_filters( WPML_Plugin::HOOK_LOGGING_COLUMNS, $columns );
82
-
83
- $reserved = array( '_title', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
84
-
85
- // Show message for reserved column names.
86
- foreach ( $reserved as $reserved_key ) {
87
- if ( array_key_exists( $reserved_key, $columns ) ) {
88
- echo "You should avoid $reserved_key as keyname since it is treated by WordPress specially: Your table would still work, but you won't be able to show/hide the columns. You can prefix your columns!";
89
- break;
90
- }
91
- }
92
- return $columns;
93
- }
94
-
95
- /**
96
- * Define which columns are hidden
97
- * @since 1.0
98
- * @return array
99
- */
100
- function get_hidden_columns() {
101
- return array(
102
- 'plugin_version',
103
- 'mail_id',
104
- );
105
- }
106
-
107
- /**
108
- * Sanitize orderby parameter.
109
- * @s
110
- * @return string sanitized orderby parameter
111
- */
112
- private function sanitize_orderby() {
113
- return WPML_Utils::sanitize_expected_value( ( !empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : null, $this->get_sortable_columns(), 'mail_id');
114
- }
115
-
116
- /**
117
- * Sanitize order parameter.
118
- * @return string sanitized order parameter
119
- */
120
- private function sanitize_order() {
121
- return WPML_Utils::sanitize_expected_value( ( !empty( $_GET['order'] ) ) ? $_GET['order'] : null, array('desc', 'asc'), 'desc');
122
- }
123
-
124
- /**
125
- * Prepares the items for rendering
126
- * @since 1.0
127
- * @param string|boolean $search string you want to search for. Default false.
128
- * @see WP_List_Table::prepare_items()
129
- */
130
- function prepare_items( $search = false ) {
131
- $orderby = $this->sanitize_orderby();
132
- $order = $this->sanitize_order();
133
-
134
- $columns = $this->get_columns();
135
- $hidden = $this->get_hidden_columns();
136
- $sortable = $this->get_sortable_columns();
137
- $this->_column_headers = array( $columns, $hidden, $sortable );
138
-
139
- $this->process_bulk_action();
140
-
141
- $per_page = $this->get_items_per_page( 'per_page', 25 );
142
- $current_page = $this->get_pagenum();
143
- $offset = ( $current_page - 1 ) * $per_page;
144
-
145
- $total_items = Mail::query()
146
- ->search( $search )
147
- ->find( true );
148
-
149
- $mails = Mail::query()
150
- ->search( $search )
151
- ->sort_by( $orderby )
152
- ->order( $order )
153
- ->limit( $per_page )
154
- ->offset( $offset )
155
- ->find();
156
-
157
- foreach ( $mails as $mail ) {
158
- /* @var $mail Mail */
159
- $this->items[] = $mail->to_array();
160
- }
161
-
162
- $this->set_pagination_args( array(
163
- 'total_items' => $total_items, // The total number of items.
164
- 'per_page' => $per_page, // Number of items per page.
165
- ) );
166
- }
167
-
168
- /**
169
- * Renders the cell.
170
- * Note: We can easily add filter for all columns if you want to / need to manipulate the content. (currently only additional column manipulation is supported)
171
- * @since 1.0
172
- * @param array $item The current item.
173
- * @param string $column_name The current column name.
174
- * @return string The cell content
175
- */
176
- function column_default( $item, $column_name ) {
177
- switch ( $column_name ) {
178
- case 'mail_id':
179
- case 'timestamp':
180
- case 'subject':
181
- case 'message':
182
- case 'headers':
183
- case 'attachments':
184
- case 'plugin_version':
185
- case 'receiver':
186
- return $item[ $column_name ];
187
- default:
188
- // If we don't know this column maybe a hook does - if no hook extracted data (string) out of the array we can avoid the output of 'Array()' (array).
189
- return ( is_array( $res = apply_filters( WPML_Plugin::HOOK_LOGGING_COLUMNS_RENDER, $item, $column_name ) ) ) ? '' : $res;
190
- }
191
- }
192
-
193
- /**
194
- * Sanitize message to remove unsafe html.
195
- * @since 1.5.1
196
- * @param string $message unsafe message.
197
- * @return string safe message.
198
- */
199
- function sanitize_message( $message ) {
200
- $allowed_tags = wp_kses_allowed_html( 'post' );
201
- $allowed_tags['a']['data-message'] = true;
202
- $allowed_tags['style'][''] = true;
203
- return wp_kses( $message, $allowed_tags );
204
- }
205
-
206
- /**
207
- * Renders the message column.
208
- * @since 1.3
209
- * @param array $item The current item.
210
- * @return void|string
211
- */
212
- function column_message( $item ) {
213
- if ( empty( $item['message'] ) ) {
214
- return '';
215
- }
216
- //$content = $this->sanitize_message( $this->render_mail_html( $item ) );
217
- $content = $item['mail_id'];
218
- $message = '<a class="wp-mail-logging-view-message button button-secondary" href="#" data-mail-id="' . esc_attr( $content ) . '">View</a>';
219
- return $message;
220
- }
221
-
222
- /**
223
- * Renders the timestamp column.
224
- * @since 1.5.0
225
- * @param array $item The current item.
226
- * @return void|string
227
- */
228
- function column_timestamp( $item ) {
229
- return date_i18n( apply_filters( 'wpml_get_date_time_format', '' ), strtotime( $item['timestamp'] ) );
230
- }
231
-
232
- /**
233
- * Renders the attachment column in compbat mode for mails prior 1.6.0.
234
- * @since 1.6.0
235
- * @param array $item The current item.
236
- * @return string The attachment column.
237
- */
238
- function column_attachments_compat_152( $item ) {
239
- $attachment_append = '';
240
- $attachments = explode( ',\n', $item['attachments'] );
241
- $attachments = is_array( $attachments ) ? $attachments : array( $attachments );
242
- foreach ( $attachments as $attachment ) {
243
- // $attachment can be an empty string ''.
244
- if ( ! empty( $attachment ) ) {
245
- $filename = basename( $attachment );
246
- $attachment_path = WP_CONTENT_DIR . $attachment;
247
- $attachment_url = WP_CONTENT_URL . $attachment;
248
- if ( is_file( $attachment_path ) ) {
249
- $attachment_append .= '<a href="' . $attachment_url . '" title="' . $filename . '">' . WPML_Utils::generate_attachment_icon( $attachment_path ) . '</a> ';
250
- } else {
251
- $message = sprintf( __( 'Attachment %s is not present', 'wpml' ), $filename );
252
- $attachment_append .= '<i class="fa fa-times" title="' . $message . '"></i>';
253
- }
254
- }
255
- }
256
- return $attachment_append;
257
- }
258
-
259
- /**
260
- * Renders the attachment column.
261
- * @since 1.3
262
- * @param array $item The current item.
263
- * @return string The attachment column.
264
- */
265
- function column_attachments( $item ) {
266
-
267
- if ( version_compare( trim( $item ['plugin_version'] ), '1.6.0', '<' ) ) {
268
- return $this->column_attachments_compat_152( $item );
269
- }
270
-
271
- $attachment_append = '';
272
- $attachments = explode( ',\n', $item['attachments'] );
273
- $attachments = is_array( $attachments ) ? $attachments : array( $attachments );
274
- foreach ( $attachments as $attachment ) {
275
- // $attachment can be an empty string ''.
276
- if ( ! empty( $attachment ) ) {
277
- $filename = basename( $attachment );
278
- $basename = '/uploads';
279
- $attachment_path = WP_CONTENT_DIR . $basename . $attachment;
280
- $attachment_url = WP_CONTENT_URL . $basename . $attachment;
281
-
282
- if ( is_file( $attachment_path ) ) {
283
- $attachment_append .= '<a href="' . $attachment_url . '" title="' . $filename . '">' . WPML_Utils::generate_attachment_icon( $attachment_path ) . '</a> ';
284
- } else {
285
- $message = sprintf( __( 'Attachment %s is not present', 'wpml' ), $filename );
286
- $attachment_append .= '<i class="fa fa-times" title="' . $message . '"></i>';
287
- }
288
- }
289
- }
290
- return $attachment_append;
291
- }
292
-
293
- /**
294
- * Renders all components of the mail.
295
- * @since 1.3
296
- * @param array $item The current item.
297
- * @return string The mail as html
298
- */
299
- function render_mail( $item ) {
300
- $mailAppend = '';
301
- foreach ( $item as $key => $value ) {
302
- if ( array_key_exists( $key, $this->get_columns() ) && ! in_array( $key, $this->get_hidden_columns() ) ) {
303
- $display = $this->get_columns();
304
- $column_name = $key;
305
- $title = "<span class=\"title\">{$display[$key]}: </span>";
306
- $content = '';
307
- if ( 'message' !== $column_name && method_exists( $this, 'column_' . $column_name ) ) {
308
- $content .= call_user_func( array( $this, 'column_' . $column_name ), $item );
309
- } else {
310
- $content .= $this->column_default( $item, $column_name );
311
- }
312
- $mailAppend .= $title . htmlentities( $content );
313
- }
314
- }
315
-
316
- return $mailAppend;
317
- }
318
-
319
- /**
320
- * Renders all components of the mail.
321
- * @since 1.6.0
322
- * @param array $item The current item.
323
- * @return string The mail as html
324
- */
325
- function render_mail_html( $item ) {
326
- $mailAppend = '';
327
- foreach ( $item as $key => $value ) {
328
- if ( array_key_exists( $key, $this->get_columns() ) && ! in_array( $key, $this->get_hidden_columns() ) ) {
329
- $display = $this->get_columns();
330
- $column_name = $key;
331
- $mailAppend .= "<span class=\"title\">{$display[$key]}: </span>";
332
- if ( 'message' !== $column_name && method_exists( $this, 'column_' . $column_name ) ) {
333
- $mailAppend .= call_user_func( array( $this, 'column_' . $column_name ), $item );
334
- } else {
335
- $mailAppend .= $this->column_default( $item, $column_name );
336
- }
337
- }
338
- }
339
- return $mailAppend;
340
- }
341
- /**
342
- * Defines available bulk actions.
343
- * @since 1.0
344
- * @see WP_List_Table::get_bulk_actions()
345
- */
346
- function get_bulk_actions() {
347
- $actions = array(
348
- 'delete' => 'Delete',
349
- );
350
- return $actions;
351
- }
352
-
353
- /**
354
- * Processes bulk actions.
355
- * @since 1.0
356
- */
357
- function process_bulk_action() {
358
- if ( false === $this->current_action() ) {
359
- return;
360
- }
361
-
362
- if ( check_admin_referer( Email_Logging_ListTable::NONCE_LIST_TABLE, Email_Logging_ListTable::NONCE_LIST_TABLE . '_nonce' ) ) {
363
- $name = $this->_args['singular'];
364
-
365
- // Detect when a bulk action is being triggered.
366
- if ( 'delete' === $this->current_action() ) {
367
- foreach ( $_REQUEST[$name] as $item_id ) {
368
- $mail = Mail::find_one( $item_id );
369
- if ( false !== $mail ) {
370
- $mail->delete();
371
- }
372
- }
373
- }
374
- }
375
- }
376
-
377
- /**
378
- * Render the cb column
379
- * @since 1.0
380
- * @param array $item The current item.
381
- * @return string the rendered cb cell content
382
- */
383
- function column_cb($item) {
384
- $name = $this->_args['singular'];
385
- return sprintf(
386
- '<input type="checkbox" name="%1$s[]" value="%2$s" />', $name, $item['mail_id']
387
- );
388
- }
389
-
390
- /**
391
- * Define the sortable columns
392
- * @since 1.0
393
- * @return array
394
- */
395
- function get_sortable_columns() {
396
- return array(
397
- // Description: column_name => array( 'display_name', true[asc] | false[desc] ).
398
- 'mail_id' => array( 'mail_id', false ),
399
- 'timestamp' => array( 'timestamp', true ),
400
- 'receiver' => array( 'receiver', true ),
401
- 'subject' => array( 'subject', true ),
402
- 'message' => array( 'message', true ),
403
- 'headers' => array( 'headers', true ),
404
- 'attachments' => array( 'attachments', true ),
405
- 'plugin_version'=> array( 'plugin_version', true ),
406
- );
407
- }
408
-
409
- /**
410
- * Ajax function to retrieve rendered mail in certain format.
411
- * @since 1.6.0
412
- */
413
- public static function ajax_wpml_email_get() {
414
- $formats = is_array( $additional = apply_filters( WPML_Plugin::HOOK_LOGGING_SUPPORTED_FORMATS, array() ) ) ? $additional : array();
415
-
416
- check_ajax_referer( 'wpml-modal-show', 'ajax_nonce', true );
417
-
418
- if( ! isset( $_POST['id'] ) )
419
- wp_die( "huh?" );
420
- $id = intval( $_POST['id'] );
421
-
422
- $format_requested = isset( $_POST['format'] ) ? $_POST['format'] : 'html';
423
- if ( ! in_array( $format_requested, $formats ) ) {
424
- echo "Unsupported Format. Using html as fallback.";
425
- $format_requested = WPML_Utils::sanitize_expected_value($format_requested, $formats, 'html');
426
- }
427
- $mail = Mail::find_one( $id );
428
- $instance = WPML_Init::getInstance()->getService( 'emailLogList' );
429
- $mailAppend = '';
430
- switch( $format_requested ) {
431
- case 'html': {
432
- $mailAppend .= $instance->render_mail_html( $mail->to_array() );
433
- break;
434
- }
435
- case 'raw': {
436
- $mailAppend .= $instance->render_mail( $mail->to_array() );
437
- break;
438
- }
439
- case 'json': {
440
- $mailAppend .= json_encode( $mail->to_array() );
441
- break;
442
- }
443
- default:
444
- $mailAppend .= apply_filters( WPML_Plugin::HOOK_LOGGING_FORMAT_CONTENT . "_{$format_requested}", $mail->to_array() );
445
- break;
446
- }
447
- echo $mailAppend;
448
- wp_die(); // this is required to terminate immediately and return a proper response
449
- }
450
- }
 
1
+ <?php
2
+
3
+ namespace No3x\WPML;
4
+
5
+ use No3x\WPML\Model\WPML_Mail as Mail;
6
+
7
+ // Exit if accessed directly.
8
+ if ( ! defined( 'ABSPATH' ) ) exit;
9
+
10
+ require_once( ABSPATH . 'wp-admin/includes/screen.php' );
11
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
12
+
13
+ if ( ! class_exists( 'WP_List_Table' ) ) {
14
+ require_once( plugin_dir_path( __FILE__ ) . 'inc/class-wp-list-table.php' );
15
+ }
16
+
17
+ /**
18
+ * Renders the mails in a table list.
19
+ * @author No3x
20
+ * @since 1.0
21
+ */
22
+ class WPML_Email_Log_List extends \WP_List_Table {
23
+
24
+ const NONCE_LIST_TABLE = 'wpml-list_table';
25
+ private $supported_formats = array();
26
+ /**
27
+ * Initializes the List Table
28
+ * @since 1.0
29
+ */
30
+ function __construct( $supported_formats = array() ) {
31
+ $this->supported_formats = $supported_formats;
32
+ }
33
+
34
+ function addActionsAndFilters() {
35
+ add_action( 'admin_init', array( $this, 'init') );
36
+ add_filter( WPML_Plugin::HOOK_LOGGING_SUPPORTED_FORMATS, function() {
37
+ return $this->supported_formats;
38
+ } );
39
+ add_action( 'wp_ajax_wpml_email_get', __CLASS__ . '::ajax_wpml_email_get' );
40
+ }
41
+
42
+ function init() {
43
+ global $status, $page, $hook_suffix;
44
+
45
+ parent::__construct( array(
46
+ 'singular' => 'email', // singular name of the listed records
47
+ 'plural' => 'emails', // plural name of the listed records
48
+ 'ajax' => false, // does this table support ajax?
49
+ ) );
50
+ }
51
+
52
+ /**
53
+ * Is displayed if no item is available to render
54
+ * @since 1.0
55
+ * @see WP_List_Table::no_items()
56
+ */
57
+ function no_items() {
58
+ _e( 'No email found.', 'wpml' );
59
+ return;
60
+ }
61
+
62
+ /**
63
+ * Defines the available columns.
64
+ * @since 1.0
65
+ * @see WP_List_Table::get_columns()
66
+ */
67
+ function get_columns() {
68
+ $columns = array(
69
+ 'cb' => '<input type="checkbox" />',
70
+ 'mail_id' => __( 'ID', 'wpml' ),
71
+ 'timestamp' => __( 'Time', 'wpml' ),
72
+ 'receiver' => __( 'Receiver', 'wpml' ),
73
+ 'subject' => __( 'Subject', 'wpml' ),
74
+ 'message' => __( 'Message', 'wpml' ),
75
+ 'headers' => __( 'Headers', 'wpml' ),
76
+ 'attachments' => __( 'Attachments', 'wpml' ),
77
+ 'plugin_version' => __( 'Plugin Version', 'wpml' ),
78
+ );
79
+
80
+ // Give a plugin the chance to edit the columns.
81
+ $columns = apply_filters( WPML_Plugin::HOOK_LOGGING_COLUMNS, $columns );
82
+
83
+ $reserved = array( '_title', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
84
+
85
+ // Show message for reserved column names.
86
+ foreach ( $reserved as $reserved_key ) {
87
+ if ( array_key_exists( $reserved_key, $columns ) ) {
88
+ echo "You should avoid $reserved_key as keyname since it is treated by WordPress specially: Your table would still work, but you won't be able to show/hide the columns. You can prefix your columns!";
89
+ break;
90
+ }
91
+ }
92
+ return $columns;
93
+ }
94
+
95
+ /**
96
+ * Define which columns are hidden
97
+ * @since 1.0
98
+ * @return array
99
+ */
100
+ function get_hidden_columns() {
101
+ return array(
102
+ 'plugin_version',
103
+ 'mail_id',
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Sanitize orderby parameter.
109
+ * @s
110
+ * @return string sanitized orderby parameter
111
+ */
112
+ private function sanitize_orderby() {
113
+ return WPML_Utils::sanitize_expected_value( ( !empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : null, $this->get_sortable_columns(), 'mail_id');
114
+ }
115
+
116
+ /**
117
+ * Sanitize order parameter.
118
+ * @return string sanitized order parameter
119
+ */
120
+ private function sanitize_order() {
121
+ return WPML_Utils::sanitize_expected_value( ( !empty( $_GET['order'] ) ) ? $_GET['order'] : null, array('desc', 'asc'), 'desc');
122
+ }
123
+
124
+ /**
125
+ * Prepares the items for rendering
126
+ * @since 1.0
127
+ * @param string|boolean $search string you want to search for. Default false.
128
+ * @see WP_List_Table::prepare_items()
129
+ */
130
+ function prepare_items( $search = false ) {
131
+ $orderby = $this->sanitize_orderby();
132
+ $order = $this->sanitize_order();
133
+
134
+ $columns = $this->get_columns();
135
+ $hidden = $this->get_hidden_columns();
136
+ $sortable = $this->get_sortable_columns();
137
+ $this->_column_headers = array( $columns, $hidden, $sortable );
138
+
139
+ $this->process_bulk_action();
140
+
141
+ $per_page = $this->get_items_per_page( 'per_page', 25 );
142
+ $current_page = $this->get_pagenum();
143
+ $offset = ( $current_page - 1 ) * $per_page;
144
+
145
+ $total_items = Mail::query()
146
+ ->search( $search )
147
+ ->find( true );
148
+
149
+ $mails = Mail::query()
150
+ ->search( $search )
151
+ ->sort_by( $orderby )
152
+ ->order( $order )
153
+ ->limit( $per_page )
154
+ ->offset( $offset )
155
+ ->find();
156
+
157
+ foreach ( $mails as $mail ) {
158
+ /* @var $mail Mail */
159
+ $this->items[] = $mail->to_array();
160
+ }
161
+
162
+ $this->set_pagination_args( array(
163
+ 'total_items' => $total_items, // The total number of items.
164
+ 'per_page' => $per_page, // Number of items per page.
165
+ ) );
166
+ }
167
+
168
+ /**
169
+ * Renders the cell.
170
+ * Note: We can easily add filter for all columns if you want to / need to manipulate the content. (currently only additional column manipulation is supported)
171
+ * @since 1.0
172
+ * @param array $item The current item.
173
+ * @param string $column_name The current column name.
174
+ * @return string The cell content
175
+ */
176
+ function column_default( $item, $column_name ) {
177
+ switch ( $column_name ) {
178
+ case 'mail_id':
179
+ case 'timestamp':
180
+ case 'subject':
181
+ case 'message':
182
+ case 'headers':
183
+ case 'attachments':
184
+ case 'plugin_version':
185
+ case 'receiver':
186
+ return $item[ $column_name ];
187
+ default:
188
+ // If we don't know this column maybe a hook does - if no hook extracted data (string) out of the array we can avoid the output of 'Array()' (array).
189
+ return ( is_array( $res = apply_filters( WPML_Plugin::HOOK_LOGGING_COLUMNS_RENDER, $item, $column_name ) ) ) ? '' : $res;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Sanitize message to remove unsafe html.
195
+ * @since 1.5.1
196
+ * @param string $message unsafe message.
197
+ * @return string safe message.
198
+ */
199
+ function sanitize_message( $message ) {
200
+ $allowed_tags = wp_kses_allowed_html( 'post' );
201
+ $allowed_tags['a']['data-message'] = true;
202
+ $allowed_tags['style'][''] = true;
203
+ return wp_kses( $message, $allowed_tags );
204
+ }
205
+
206
+ /**
207
+ * Renders the message column.
208
+ * @since 1.3
209
+ * @param array $item The current item.
210
+ * @return void|string
211
+ */
212
+ function column_message( $item ) {
213
+ if ( empty( $item['message'] ) ) {
214
+ return '';
215
+ }
216
+ //$content = $this->sanitize_message( $this->render_mail_html( $item ) );
217
+ $content = $item['mail_id'];
218
+ $message = '<a class="wp-mail-logging-view-message button button-secondary" href="#" data-mail-id="' . esc_attr( $content ) . '">View</a>';
219
+ return $message;
220
+ }
221
+
222
+ /**
223
+ * Renders the timestamp column.
224
+ * @since 1.5.0
225
+ * @param array $item The current item.
226
+ * @return void|string
227
+ */
228
+ function column_timestamp( $item ) {
229
+ return date_i18n( apply_filters( 'wpml_get_date_time_format', '' ), strtotime( $item['timestamp'] ) );
230
+ }
231
+
232
+ /**
233
+ * Renders the attachment column in compbat mode for mails prior 1.6.0.
234
+ * @since 1.6.0
235
+ * @param array $item The current item.
236
+ * @return string The attachment column.
237
+ */
238
+ function column_attachments_compat_152( $item ) {
239
+ $attachment_append = '';
240
+ $attachments = explode( ',\n', $item['attachments'] );
241
+ $attachments = is_array( $attachments ) ? $attachments : array( $attachments );
242
+ foreach ( $attachments as $attachment ) {
243
+ // $attachment can be an empty string ''.
244
+ if ( ! empty( $attachment ) ) {
245
+ $filename = basename( $attachment );
246
+ $attachment_path = WP_CONTENT_DIR . $attachment;
247
+ $attachment_url = WP_CONTENT_URL . $attachment;
248
+ if ( is_file( $attachment_path ) ) {
249
+ $attachment_append .= '<a href="' . $attachment_url . '" title="' . $filename . '">' . WPML_Utils::generate_attachment_icon( $attachment_path ) . '</a> ';
250
+ } else {
251
+ $message = sprintf( __( 'Attachment %s is not present', 'wpml' ), $filename );
252
+ $attachment_append .= '<i class="fa fa-times" title="' . $message . '"></i>';
253
+ }
254
+ }
255
+ }
256
+ return $attachment_append;
257
+ }
258
+
259
+ /**
260
+ * Renders the attachment column.
261
+ * @since 1.3
262
+ * @param array $item The current item.
263
+ * @return string The attachment column.
264
+ */
265
+ function column_attachments( $item ) {
266
+
267
+ if ( version_compare( trim( $item ['plugin_version'] ), '1.6.0', '<' ) ) {
268
+ return $this->column_attachments_compat_152( $item );
269
+ }
270
+
271
+ $attachment_append = '';
272
+ $attachments = explode( ',\n', $item['attachments'] );
273
+ $attachments = is_array( $attachments ) ? $attachments : array( $attachments );
274
+ foreach ( $attachments as $attachment ) {
275
+ // $attachment can be an empty string ''.
276
+ if ( ! empty( $attachment ) ) {
277
+ $filename = basename( $attachment );
278
+ $basename = '/uploads';
279
+ $attachment_path = WP_CONTENT_DIR . $basename . $attachment;
280
+ $attachment_url = WP_CONTENT_URL . $basename . $attachment;
281
+
282
+ if ( is_file( $attachment_path ) ) {
283
+ $attachment_append .= '<a href="' . $attachment_url . '" title="' . $filename . '">' . WPML_Utils::generate_attachment_icon( $attachment_path ) . '</a> ';
284
+ } else {
285
+ $message = sprintf( __( 'Attachment %s is not present', 'wpml' ), $filename );
286
+ $attachment_append .= '<i class="fa fa-times" title="' . $message . '"></i>';
287
+ }
288
+ }
289
+ }
290
+ return $attachment_append;
291
+ }
292
+
293
+ /**
294
+ * Renders all components of the mail.
295
+ * @since 1.3
296
+ * @param array $item The current item.
297
+ * @return string The mail as html
298
+ */
299
+ function render_mail( $item ) {
300
+ $mailAppend = '';
301
+ foreach ( $item as $key => $value ) {
302
+ if ( array_key_exists( $key, $this->get_columns() ) && ! in_array( $key, $this->get_hidden_columns() ) ) {
303
+ $display = $this->get_columns();
304
+ $column_name = $key;
305
+ $title = "<span class=\"title\">{$display[$key]}: </span>";
306
+ $content = '';
307
+ if ( 'message' !== $column_name && method_exists( $this, 'column_' . $column_name ) ) {
308
+ $content .= call_user_func( array( $this, 'column_' . $column_name ), $item );
309
+ } else {
310
+ $content .= $this->column_default( $item, $column_name );
311
+ }
312
+ $mailAppend .= $title . htmlentities( $content );
313
+ }
314
+ }
315
+
316
+ return $mailAppend;
317
+ }
318
+
319
+ /**
320
+ * Renders all components of the mail.
321
+ * @since 1.6.0
322
+ * @param array $item The current item.
323
+ * @return string The mail as html
324
+ */
325
+ function render_mail_html( $item ) {
326
+ $mailAppend = '';
327
+ foreach ( $item as $key => $value ) {
328
+ if ( array_key_exists( $key, $this->get_columns() ) && ! in_array( $key, $this->get_hidden_columns() ) ) {
329
+ $display = $this->get_columns();
330
+ $column_name = $key;
331
+ $mailAppend .= "<span class=\"title\">{$display[$key]}: </span>";
332
+ if ( 'message' !== $column_name && method_exists( $this, 'column_' . $column_name ) ) {
333
+ $mailAppend .= call_user_func( array( $this, 'column_' . $column_name ), $item );
334
+ } else {
335
+ $mailAppend .= $this->column_default( $item, $column_name );
336
+ }
337
+ }
338
+ }
339
+ return $mailAppend;
340
+ }
341
+ /**
342
+ * Defines available bulk actions.
343
+ * @since 1.0
344
+ * @see WP_List_Table::get_bulk_actions()
345
+ */
346
+ function get_bulk_actions() {
347
+ $actions = array(
348
+ 'delete' => 'Delete',
349
+ );
350
+ return $actions;
351
+ }
352
+
353
+ /**
354
+ * Processes bulk actions.
355
+ * @since 1.0
356
+ */
357
+ function process_bulk_action() {
358
+ if ( false === $this->current_action() ) {
359
+ return;
360
+ }
361
+
362
+ if ( check_admin_referer( WPML_Email_Log_List::NONCE_LIST_TABLE, WPML_Email_Log_List::NONCE_LIST_TABLE . '_nonce' ) ) {
363
+ $name = $this->_args['singular'];
364
+
365
+ // Detect when a bulk action is being triggered.
366
+ if ( 'delete' === $this->current_action() ) {
367
+ foreach ( $_REQUEST[$name] as $item_id ) {
368
+ $mail = Mail::find_one( $item_id );
369
+ if ( false !== $mail ) {
370
+ $mail->delete();
371
+ }
372
+ }
373
+ }
374
+ }
375
+ }
376
+
377
+ /**
378
+ * Render the cb column
379
+ * @since 1.0
380
+ * @param array $item The current item.
381
+ * @return string the rendered cb cell content
382
+ */
383
+ function column_cb($item) {
384
+ $name = $this->_args['singular'];
385
+ return sprintf(
386
+ '<input type="checkbox" name="%1$s[]" value="%2$s" />', $name, $item['mail_id']
387
+ );
388
+ }
389
+
390
+ /**
391
+ * Define the sortable columns
392
+ * @since 1.0
393
+ * @return array
394
+ */
395
+ function get_sortable_columns() {
396
+ return array(
397
+ // Description: column_name => array( 'display_name', true[asc] | false[desc] ).
398
+ 'mail_id' => array( 'mail_id', false ),
399
+ 'timestamp' => array( 'timestamp', true ),
400
+ 'receiver' => array( 'receiver', true ),
401
+ 'subject' => array( 'subject', true ),
402
+ 'message' => array( 'message', true ),
403
+ 'headers' => array( 'headers', true ),
404
+ 'attachments' => array( 'attachments', true ),
405
+ 'plugin_version'=> array( 'plugin_version', true ),
406
+ );
407
+ }
408
+
409
+ /**
410
+ * Ajax function to retrieve rendered mail in certain format.
411
+ * @since 1.6.0
412
+ */
413
+ public static function ajax_wpml_email_get() {
414
+ $formats = is_array( $additional = apply_filters( WPML_Plugin::HOOK_LOGGING_SUPPORTED_FORMATS, array() ) ) ? $additional : array();
415
+
416
+ check_ajax_referer( 'wpml-modal-show', 'ajax_nonce', true );
417
+
418
+ if( ! isset( $_POST['id'] ) )
419
+ wp_die( "huh?" );
420
+ $id = intval( $_POST['id'] );
421
+
422
+ $format_requested = isset( $_POST['format'] ) ? $_POST['format'] : 'html';
423
+ if ( ! in_array( $format_requested, $formats ) ) {
424
+ echo "Unsupported Format. Using html as fallback.";
425
+ $format_requested = WPML_Utils::sanitize_expected_value($format_requested, $formats, 'html');
426
+ }
427
+ $mail = Mail::find_one( $id );
428
+ /* @var $instance WPML_Email_Log_List */
429
+ $instance = WPML_Init::getInstance()->getService( 'emailLogList' );
430
+ $mailAppend = '';
431
+ switch( $format_requested ) {
432
+ case 'html': {
433
+ $mailAppend .= $instance->render_mail_html( $mail->to_array() );
434
+ break;
435
+ }
436
+ case 'raw': {
437
+ $mailAppend .= $instance->render_mail( $mail->to_array() );
438
+ break;
439
+ }
440
+ case 'json': {
441
+ $mailAppend .= json_encode( $mail->to_array() );
442
+ break;
443
+ }
444
+ default:
445
+ $mailAppend .= apply_filters( WPML_Plugin::HOOK_LOGGING_FORMAT_CONTENT . "_{$format_requested}", $mail->to_array() );
446
+ break;
447
+ }
448
+ echo $mailAppend;
449
+ wp_die(); // this is required to terminate immediately and return a proper response
450
+ }
451
+ }
readme.txt CHANGED
@@ -1,105 +1,108 @@
1
- === WP Mail Logging ===
2
- Contributors: No3x, tripflex
3
- Donate link: http://no3x.de/web/donate
4
- Tags: mail, email, log, logging, debug, list, store, collect, view
5
- License: GPLv3
6
- License URI: http://www.gnu.org/licenses/gpl-3.0.html
7
- Requires at least: 3.0
8
- Tested up to: 4.6
9
- Stable tag: 1.6.0
10
-
11
- Logs each email sent by WordPress.
12
-
13
- == Description ==
14
-
15
- Logs each email sent by WordPress. This can be useful if you don't want to lose such mail contents. It can also be useful for debugging purposes while development.
16
-
17
- Features of the plugin include:
18
-
19
- * Complete list of sent mails - view and search through the mails.
20
- * Zero-configuration - just install and enjoy.
21
- * Log rotation - decide which emails you want to keep.
22
- * Developer: Boost your development performance by keeping track of sent mails.
23
- * Developer: Filters are provided to extend the columns.
24
-
25
- [youtube https://www.youtube.com/watch?v=mQK6VPSV2-E]
26
-
27
- **Follow this plugin on [GitHub](https://github.com/No3x/wp-mail-logging)**
28
-
29
- **If you find an issue, let us know in the [Tracker](https://github.com/No3x/wp-mail-logging/issues?state=open)**
30
-
31
- **Provide feedback and suggestions on [enhancements](https://github.com/No3x/wp-mail-logging/issues?direction=desc&labels=Enhancement%2Cenhancement&page=1&sort=created&state=open)**
32
-
33
- == Installation ==
34
- Just install and activate wp-mail-logging. The plugin will do the work for you! You can list all logged mails on the plugin site.
35
-
36
-
37
- == Frequently Asked Questions ==
38
- = How do I know the Mail was delivered? =
39
- The logged email has been sent by WordPress but please note this does NOT mean it has been delivered. With the given functionality of WordPress you can't determine if a mail was sent successfully.
40
-
41
- == Screenshots ==
42
- 1. The List
43
- 2. The Detail View
44
- 3. The Settings
45
-
46
- == Upgrade Notice ==
47
- = 1.5.1 =
48
- - New: Improved modal, added view types
49
- - Tweak: Proper date if none set in WordPress settings
50
- - Tweak: Updated libraries
51
- - Tweak: Added wp_mail hook to very last priority
52
-
53
- == Changelog ==
54
-
55
- = 1.6.0, July 31, 2016 =
56
- - New: Improved modal, added view types
57
- - Tweak: Proper date if none set in WordPress settings
58
- - Tweak: Updated libraries
59
- - Tweak: Added wp_mail hook to very last priority
60
-
61
- = 1.5.1, October 11, 2015 =
62
- - Tweak: Fixed security issues
63
-
64
- = 1.5.0, June 4, 2015 =
65
- - New: Setting for date time format
66
- - Tweak: Removed admin bar menu
67
- - Fix: repetitive cron schedule
68
-
69
- = 1.4.2, April 4, 2015 =
70
- - Tweak: Library updated - settings load speed improved.
71
-
72
- = 1.4.1, March 28, 2015 =
73
- - Fix: Restrict submission data works now.
74
- - Fix: Granularity of cleanup by time slider changed to 7.
75
-
76
- = 1.4.0, December 22, 2014 =
77
- - New: Log Rotation
78
- - New: Search
79
- - Tweak: Settings
80
- - Fix: international characters are supported now
81
- - Fix: Mandrill support
82
-
83
- = 1.3.2, September 21, 2014 =
84
- - Fix: HTML mails broken in previous version.
85
-
86
- = 1.3.1, September 12, 2014 =
87
- - Fix: angle brackets notation support (e.g. John Doe <john.doe@example.org>).
88
-
89
- = 1.3, August 24, 2014 =
90
- - New: clean mail listing including:
91
- Modal window for mail details.
92
- Attachment support with appropriate icon for mime type.
93
- - Tweak: Performance improvement
94
- - Fix: screen option for mails per page
95
-
96
- = 1.2, August 12, 2014 =
97
- - New: video
98
- - Tweak: Improved help & stability
99
- - Fix: deletion of mails regardless of options (on update to 1.2 your mails will be deleted hopefully this happens for the last time)
100
-
101
- = 1.1 =
102
- - Tweak: Modified readme.
103
-
104
- = 1.0 =
105
- - Initial Revision
 
 
 
1
+ === WP Mail Logging ===
2
+ Contributors: No3x, tripflex
3
+ Donate link: http://no3x.de/web/donate
4
+ Tags: mail, email, log, logging, debug, list, store, collect, view
5
+ License: GPLv3
6
+ License URI: http://www.gnu.org/licenses/gpl-3.0.html
7
+ Requires at least: 3.0
8
+ Tested up to: 4.6
9
+ Stable tag: 1.6.1
10
+
11
+ Logs each email sent by WordPress.
12
+
13
+ == Description ==
14
+
15
+ Logs each email sent by WordPress. This can be useful if you don't want to lose such mail contents. It can also be useful for debugging purposes while development.
16
+
17
+ Features of the plugin include:
18
+
19
+ * Complete list of sent mails - view and search through the mails.
20
+ * Zero-configuration - just install and enjoy.
21
+ * Log rotation - decide which emails you want to keep.
22
+ * Developer: Boost your development performance by keeping track of sent mails.
23
+ * Developer: Filters are provided to extend the columns.
24
+
25
+ [youtube https://www.youtube.com/watch?v=mQK6VPSV2-E]
26
+
27
+ **Follow this plugin on [GitHub](https://github.com/No3x/wp-mail-logging)**
28
+
29
+ **If you find an issue, let us know in the [Tracker](https://github.com/No3x/wp-mail-logging/issues?state=open)**
30
+
31
+ **Provide feedback and suggestions on [enhancements](https://github.com/No3x/wp-mail-logging/issues?direction=desc&labels=Enhancement%2Cenhancement&page=1&sort=created&state=open)**
32
+
33
+ == Installation ==
34
+ Just install and activate wp-mail-logging. The plugin will do the work for you! You can list all logged mails on the plugin site.
35
+
36
+
37
+ == Frequently Asked Questions ==
38
+ = How do I know the Mail was delivered? =
39
+ The logged email has been sent by WordPress but please note this does NOT mean it has been delivered. With the given functionality of WordPress you can't determine if a mail was sent successfully.
40
+
41
+ == Screenshots ==
42
+ 1. The List
43
+ 2. The Detail View
44
+ 3. The Settings
45
+
46
+ == Upgrade Notice ==
47
+ = 1.6.0 =
48
+ - New: Improved modal, added view types
49
+ - Tweak: Proper date if none set in WordPress settings
50
+ - Tweak: Updated libraries
51
+ - Tweak: Added wp_mail hook to very last priority
52
+
53
+ == Changelog ==
54
+
55
+ = 1.6.1, August 1, 2016 =
56
+ - Fix: delete mails
57
+
58
+ = 1.6.0, July 31, 2016 =
59
+ - New: Improved modal, added view types
60
+ - Tweak: Proper date if none set in WordPress settings
61
+ - Tweak: Updated libraries
62
+ - Tweak: Added wp_mail hook to very last priority
63
+
64
+ = 1.5.1, October 11, 2015 =
65
+ - Tweak: Fixed security issues
66
+
67
+ = 1.5.0, June 4, 2015 =
68
+ - New: Setting for date time format
69
+ - Tweak: Removed admin bar menu
70
+ - Fix: repetitive cron schedule
71
+
72
+ = 1.4.2, April 4, 2015 =
73
+ - Tweak: Library updated - settings load speed improved.
74
+
75
+ = 1.4.1, March 28, 2015 =
76
+ - Fix: Restrict submission data works now.
77
+ - Fix: Granularity of cleanup by time slider changed to 7.
78
+
79
+ = 1.4.0, December 22, 2014 =
80
+ - New: Log Rotation
81
+ - New: Search
82
+ - Tweak: Settings
83
+ - Fix: international characters are supported now
84
+ - Fix: Mandrill support
85
+
86
+ = 1.3.2, September 21, 2014 =
87
+ - Fix: HTML mails broken in previous version.
88
+
89
+ = 1.3.1, September 12, 2014 =
90
+ - Fix: angle brackets notation support (e.g. John Doe <john.doe@example.org>).
91
+
92
+ = 1.3, August 24, 2014 =
93
+ - New: clean mail listing including:
94
+ Modal window for mail details.
95
+ Attachment support with appropriate icon for mime type.
96
+ - Tweak: Performance improvement
97
+ - Fix: screen option for mails per page
98
+
99
+ = 1.2, August 12, 2014 =
100
+ - New: video
101
+ - Tweak: Improved help & stability
102
+ - Fix: deletion of mails regardless of options (on update to 1.2 your mails will be deleted hopefully this happens for the last time)
103
+
104
+ = 1.1 =
105
+ - Tweak: Modified readme.
106
+
107
+ = 1.0 =
108
+ - Initial Revision
wp-mail-logging.php CHANGED
@@ -1,112 +1,112 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Mail Logging
4
- Plugin URI: http://wordpress.org/extend/plugins/wp-mail-logging/
5
- Support URI: https://github.com/No3x/wp-mail-logging/issues
6
- Version: 1.6.0
7
- Author: Christian Z&ouml;ller
8
- Author URI: http://no3x.de/
9
- Description: Logs each email sent by WordPress.
10
- Text Domain: wpml
11
- License: GPLv3
12
- */
13
-
14
- /*
15
- "WordPress Plugin Template" Copyright (C) 2013 Michael Simpson (email : michael.d.simpson@gmail.com)
16
-
17
- This following part of this file is part of WordPress Plugin Template for WordPress.
18
-
19
- WordPress Plugin Template is free software: you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License as published by
21
- the Free Software Foundation, either version 3 of the License, or
22
- (at your option) any later version.
23
-
24
- WordPress Plugin Template is distributed in the hope that it will be useful,
25
- but WITHOUT ANY WARRANTY; without even the implied warranty of
26
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
- GNU General Public License for more details.
28
-
29
- You should have received a copy of the GNU General Public License
30
- along with Contact Form to Database Extension.
31
- If not, see http://www.gnu.org/licenses/gpl-3.0.html
32
- */
33
-
34
- namespace No3x\WPML;
35
-
36
- use No3x\WPML\WPML_Init;
37
-
38
- // Exit if accessed directly.
39
- if ( ! defined( 'ABSPATH' ) ) exit;
40
-
41
- $WPML_minimalRequiredPhpVersion = '5.4';
42
-
43
- /**
44
- * Check the PHP version and give a useful error message if the user's version is less than the required version
45
- * @return boolean true if version check passed. If false, triggers an error which WP will handle, by displaying
46
- * an error message on the Admin page
47
- */
48
- function WPML_noticePhpVersionWrong() {
49
- global $WPML_minimalRequiredPhpVersion;
50
- echo '<div class="error">' .
51
- __( 'Error: plugin "WP Mail Logging" requires a newer version of PHP to be running.', 'wpml' ).
52
- '<br/>' . __( 'Minimal version of PHP required: ', 'wpml' ) . '<strong>' . $WPML_minimalRequiredPhpVersion . '</strong>' .
53
- '<br/>' . __( 'Your server\'s PHP version: ', 'wpml' ) . '<strong>' . phpversion() . '</strong>' .
54
- '</div>';
55
- }
56
-
57
-
58
- function WPML_PhpVersionCheck() {
59
- global $WPML_minimalRequiredPhpVersion;
60
- if ( version_compare( phpversion(), $WPML_minimalRequiredPhpVersion ) < 0 ) {
61
- add_action( 'admin_notices', __NAMESPACE__ . '\WPML_noticePhpVersionWrong' );
62
- return false;
63
- }
64
- return true;
65
- }
66
-
67
-
68
- /**
69
- * Initialize internationalization (i18n) for this plugin.
70
- * References:
71
- * http://codex.wordpress.org/I18n_for_WordPress_Developers
72
- * http://www.wdmac.com/how-to-create-a-po-language-translation#more-631
73
- * @return void
74
- */
75
- function WPML_i18n_init() {
76
- $pluginDir = dirname(plugin_basename(__FILE__));
77
- load_plugin_textdomain('wpml', false, $pluginDir . '/languages/');
78
- }
79
-
80
-
81
- //////////////////////////////////
82
- // Run initialization
83
- /////////////////////////////////
84
-
85
- // First initialize i18n
86
- WPML_i18n_init();
87
-
88
-
89
- // Next, run the version check.
90
- // If it is successful, continue with initialization for this plugin
91
- if (WPML_PhpVersionCheck()) {
92
- // Only init and run the init function if we know PHP version can parse it
93
- require __DIR__ . '/autoload.php';
94
-
95
- // Create a new instance of the autoloader
96
- $loader = new \WPML_Psr4AutoloaderClass();
97
-
98
- // Register this instance
99
- $loader->register();
100
-
101
- // Add our namespace and the folder it maps to
102
- require_once __DIR__ . '/inc/redux/admin-init.php';
103
- $loader->addNamespace('No3x\\WPML\\', __DIR__ );
104
- $loader->addNamespace('No3x\\WPML\\Model\\', __DIR__ . '/model' );
105
- $loader->addNamespace('No3x\\WPML\\Settings\\', __DIR__ . '/inc/redux');
106
- $loader->addNamespace('No3x\\WPML\\ORM\\', __DIR__ . '/lib/vendor/brandonwamboldt/wp-orm/src');
107
- $loader->addNamespace('No3x\\WPML\\Pimple\\', __DIR__ . '/lib/vendor/pimple/pimple/src');
108
- if( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
109
- require_once __DIR__ . '/vendor/autoload.php';
110
- }
111
- WPML_Init::getInstance()->init( __FILE__ );
112
- }
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Mail Logging
4
+ Plugin URI: http://wordpress.org/extend/plugins/wp-mail-logging/
5
+ Support URI: https://github.com/No3x/wp-mail-logging/issues
6
+ Version: 1.6.1
7
+ Author: Christian Z&ouml;ller
8
+ Author URI: http://no3x.de/
9
+ Description: Logs each email sent by WordPress.
10
+ Text Domain: wpml
11
+ License: GPLv3
12
+ */
13
+
14
+ /*
15
+ "WordPress Plugin Template" Copyright (C) 2013 Michael Simpson (email : michael.d.simpson@gmail.com)
16
+
17
+ This following part of this file is part of WordPress Plugin Template for WordPress.
18
+
19
+ WordPress Plugin Template is free software: you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License as published by
21
+ the Free Software Foundation, either version 3 of the License, or
22
+ (at your option) any later version.
23
+
24
+ WordPress Plugin Template is distributed in the hope that it will be useful,
25
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
26
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
+ GNU General Public License for more details.
28
+
29
+ You should have received a copy of the GNU General Public License
30
+ along with Contact Form to Database Extension.
31
+ If not, see http://www.gnu.org/licenses/gpl-3.0.html
32
+ */
33
+
34
+ namespace No3x\WPML;
35
+
36
+ use No3x\WPML\WPML_Init;
37
+
38
+ // Exit if accessed directly.
39
+ if ( ! defined( 'ABSPATH' ) ) exit;
40
+
41
+ $WPML_minimalRequiredPhpVersion = '5.4';
42
+
43
+ /**
44
+ * Check the PHP version and give a useful error message if the user's version is less than the required version
45
+ * @return boolean true if version check passed. If false, triggers an error which WP will handle, by displaying
46
+ * an error message on the Admin page
47
+ */
48
+ function WPML_noticePhpVersionWrong() {
49
+ global $WPML_minimalRequiredPhpVersion;
50
+ echo '<div class="error">' .
51
+ __( 'Error: plugin "WP Mail Logging" requires a newer version of PHP to be running.', 'wpml' ).
52
+ '<br/>' . __( 'Minimal version of PHP required: ', 'wpml' ) . '<strong>' . $WPML_minimalRequiredPhpVersion . '</strong>' .
53
+ '<br/>' . __( 'Your server\'s PHP version: ', 'wpml' ) . '<strong>' . phpversion() . '</strong>' .
54
+ '</div>';
55
+ }
56
+
57
+
58
+ function WPML_PhpVersionCheck() {
59
+ global $WPML_minimalRequiredPhpVersion;
60
+ if ( version_compare( phpversion(), $WPML_minimalRequiredPhpVersion ) < 0 ) {
61
+ add_action( 'admin_notices', __NAMESPACE__ . '\WPML_noticePhpVersionWrong' );
62
+ return false;
63
+ }
64
+ return true;
65
+ }
66
+
67
+
68
+ /**
69
+ * Initialize internationalization (i18n) for this plugin.
70
+ * References:
71
+ * http://codex.wordpress.org/I18n_for_WordPress_Developers
72
+ * http://www.wdmac.com/how-to-create-a-po-language-translation#more-631
73
+ * @return void
74
+ */
75
+ function WPML_i18n_init() {
76
+ $pluginDir = dirname(plugin_basename(__FILE__));
77
+ load_plugin_textdomain('wpml', false, $pluginDir . '/languages/');
78
+ }
79
+
80
+
81
+ //////////////////////////////////
82
+ // Run initialization
83
+ /////////////////////////////////
84
+
85
+ // First initialize i18n
86
+ WPML_i18n_init();
87
+
88
+
89
+ // Next, run the version check.
90
+ // If it is successful, continue with initialization for this plugin
91
+ if (WPML_PhpVersionCheck()) {
92
+ // Only init and run the init function if we know PHP version can parse it
93
+ require __DIR__ . '/autoload.php';
94
+
95
+ // Create a new instance of the autoloader
96
+ $loader = new \WPML_Psr4AutoloaderClass();
97
+
98
+ // Register this instance
99
+ $loader->register();
100
+
101
+ // Add our namespace and the folder it maps to
102
+ require_once __DIR__ . '/inc/redux/admin-init.php';
103
+ $loader->addNamespace('No3x\\WPML\\', __DIR__ );
104
+ $loader->addNamespace('No3x\\WPML\\Model\\', __DIR__ . '/model' );
105
+ $loader->addNamespace('No3x\\WPML\\Settings\\', __DIR__ . '/inc/redux');
106
+ $loader->addNamespace('No3x\\WPML\\ORM\\', __DIR__ . '/lib/vendor/brandonwamboldt/wp-orm/src');
107
+ $loader->addNamespace('No3x\\WPML\\Pimple\\', __DIR__ . '/lib/vendor/pimple/pimple/src');
108
+ if( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
109
+ require_once __DIR__ . '/vendor/autoload.php';
110
+ }
111
+ WPML_Init::getInstance()->init( __FILE__ );
112
+ }