Email Log - Version 1.7

Version Description

Download this release

Release Info

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

Code changes from version 1.6.2 to 1.7

email-log.php CHANGED
@@ -1,386 +1,347 @@
1
- <?php
2
- /**
3
- Plugin Name: Email Log
4
- Plugin URI: http://sudarmuthu.com/wordpress/email-log
5
- Description: Logs every email sent through WordPress
6
- Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me
7
- Author: Sudar
8
- Version: 1.6.2
9
- Author URI: http://sudarmuthu.com/
10
- Text Domain: email-log
11
- Domain Path: languages/
12
-
13
- === RELEASE NOTES ===
14
- Check readme file for full release notes
15
- */
16
-
17
- /* Copyright 2009 Sudar Muthu (email : sudar@sudarmuthu.com)
18
-
19
- This program is free software; you can redistribute it and/or modify
20
- it under the terms of the GNU General Public License, version 2, as
21
- published by the Free Software Foundation.
22
-
23
- This program is distributed in the hope that it will be useful,
24
- but WITHOUT ANY WARRANTY; without even the implied warranty of
25
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
- GNU General Public License for more details.
27
-
28
- You should have received a copy of the GNU General Public License
29
- along with this program; if not, write to the Free Software
30
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
- */
32
-
33
- /**
34
- * The main Plugin class
35
- */
36
- class EmailLog {
37
-
38
- private $admin_screen;
39
-
40
- const FILTER_NAME = 'wp_mail_log';
41
- const PAGE_SLUG = 'email-log';
42
- const DELETE_LOG_NONCE_FIELD = 'sm-delete-email-log-nonce';
43
- const DELETE_LOG_ACTION = 'sm-delete-email-log';
44
-
45
- // DB stuff
46
- const TABLE_NAME = 'email_log'; /* Database table name */
47
- const DB_OPTION_NAME = 'email-log-db'; /* Database option name */
48
- const DB_VERSION = '0.1'; /* Database version */
49
-
50
- //hooks
51
- const HOOK_LOG_COLUMNS = 'email_log_manage_log_columns';
52
- const HOOK_LOG_DISPLAY_COLUMNS = 'email_log_display_log_columns';
53
-
54
- /**
55
- * Initalize the plugin by registering the hooks
56
- */
57
- function __construct() {
58
-
59
- global $wpdb;
60
-
61
- // Load localization domain
62
- $this->translations = dirname(plugin_basename(__FILE__)) . '/languages/' ;
63
- load_plugin_textdomain( 'email-log', false, $this->translations);
64
-
65
- // Register hooks
66
- add_action( 'admin_menu', array(&$this, 'register_settings_page') );
67
-
68
- // Register Filter
69
- add_filter('wp_mail', array(&$this, 'log_email'));
70
- add_filter('set-screen-option', array(&$this, 'save_screen_options'), 10, 3);
71
- add_filter( 'plugin_row_meta', array( &$this, 'add_plugin_links' ), 10, 2 );
72
-
73
- $plugin = plugin_basename(__FILE__);
74
- add_filter("plugin_action_links_$plugin", array(&$this, 'add_action_links'));
75
-
76
- //Add our ajax call
77
- add_action( 'wp_ajax_display_content', array(&$this, 'display_content_callback'));
78
-
79
- // Add our javascript in the footer
80
- add_action( 'admin_footer', array(&$this, 'include_js') );
81
-
82
- $this->table_name = $wpdb->prefix . self::TABLE_NAME;
83
- }
84
-
85
- /**
86
- * Adds additional links in the Plugin listing. Based on http://zourbuth.com/archives/751/creating-additional-wordpress-plugin-links-row-meta/
87
- */
88
- function add_plugin_links($links, $file) {
89
- $plugin = plugin_basename(__FILE__);
90
-
91
- if ($file == $plugin) // only for this plugin
92
- return array_merge( $links,
93
- array( '<a href="http://sudarmuthu.com/wordpress/email-log/pro-addons" target="_blank">' . __('Buy Addons', 'email-log') . '</a>' )
94
- );
95
- return $links;
96
- }
97
-
98
- /**
99
- * Register the settings page
100
- */
101
- function register_settings_page() {
102
- //Save the handle to your admin page - you'll need it to create a WP_Screen object
103
- $this->admin_page = add_submenu_page( 'tools.php', __('Email Log', 'email-log'), __('Email Log', 'email-log'), 'manage_options', self::PAGE_SLUG , array( &$this, 'display_logs') );
104
-
105
- add_action("load-{$this->admin_page}",array(&$this,'create_settings_panel'));
106
- }
107
-
108
- /**
109
- * Display email logs
110
- */
111
- function display_logs() {
112
-
113
- $this->logs_table->prepare_items( $this->get_per_page() );
114
- ?>
115
- <div class="wrap">
116
- <h2><?php _e('Email Logs', 'email-log');?></h2>
117
- <?php
118
- if ( isset( $this->logs_deleted ) && $this->logs_deleted != '' ) {
119
- $logs_deleted = intval( $this->logs_deleted );
120
-
121
- if ( $logs_deleted > 0 ) {
122
- echo "<div class = 'updated'><p>" . sprintf( _n( '1 email log deleted.', '%s email logs deleted', $logs_deleted, 'email-log' ), $logs_deleted ) . "</p></div>";
123
- } else {
124
- echo "<div class = 'updated'><p>" . __( 'There was some problem in deleting the email logs' , 'email-log') . "</p></div>";
125
- }
126
- unset($this->logs_deleted);
127
- }
128
- ?>
129
- <form id="email-logs-search" method="get">
130
- <input type="hidden" name="page" value="<?php echo self::PAGE_SLUG; ?>" >
131
- <?php
132
- $this->logs_table->search_box( __('Search Logs', 'email-log'), 'search_id' );
133
- ?>
134
- </form>
135
-
136
- <form id="email-logs-filter" method="get">
137
- <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
138
- <?php
139
- wp_nonce_field( self::DELETE_LOG_ACTION, self::DELETE_LOG_NONCE_FIELD );
140
- $this->logs_table->display();
141
- ?>
142
- </form>
143
- </div>
144
- <?php
145
- // Display credits in Footer
146
- add_action( 'in_admin_footer', array(&$this, 'add_footer_links'));
147
- }
148
-
149
- /**
150
- * Add settings Panel
151
- */
152
- function create_settings_panel() {
153
-
154
- /**
155
- * Create the WP_Screen object against your admin page handle
156
- * This ensures we're working with the right admin page
157
- */
158
- $this->admin_screen = WP_Screen::get($this->admin_page);
159
-
160
- /**
161
- * Content specified inline
162
- */
163
- $this->admin_screen->add_help_tab(
164
- array(
165
- 'title' => __('About Plugin', 'email-log'),
166
- 'id' => 'about_tab',
167
- 'content' => '<p>' . __('Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress.', 'email-log') . '</p>',
168
- 'callback' => false
169
- )
170
- );
171
-
172
- // Add help sidebar
173
- $this->admin_screen->set_help_sidebar(
174
- '<p><strong>' . __('More information', 'email-log') . '</strong></p>' .
175
- '<p><a href = "http://sudarmuthu.com/wordpress/email-log">' . __('Plugin Homepage/support', 'email-log') . '</a></p>' .
176
- '<p><a href = "http://sudarmuthu.com/blog">' . __("Plugin author's blog", 'email-log') . '</a></p>' .
177
- '<p><a href = "http://sudarmuthu.com/wordpress/">' . __("Other Plugin's by Author", 'email-log') . '</a></p>'
178
- );
179
-
180
- // Add screen options
181
- $this->admin_screen->add_option(
182
- 'per_page',
183
- array(
184
- 'label' => __('Entries per page', 'email-log'),
185
- 'default' => 20,
186
- 'option' => 'per_page'
187
- )
188
- );
189
-
190
- if(!class_exists('WP_List_Table')){
191
- require_once( ABSPATH . WPINC . '/class-wp-list-table.php' );
192
- }
193
-
194
- if (!class_exists( 'Email_Log_List_Table' ) ) {
195
- require_once dirname( __FILE__ ) . '/include/class-email-log-list-table.php';
196
- }
197
-
198
- //Prepare Table of elements
199
- $this->logs_table = new Email_Log_List_Table();
200
- }
201
-
202
- /**
203
- * Include JavaScript displaying email content
204
- *
205
- * @since 1.6
206
- */
207
- function include_js() {
208
- ?>
209
- <script type="text/javascript">
210
- jQuery(document).ready(function($) {
211
-
212
- $(".email_content").click(function() {
213
-
214
- var w = window.open('', 'newwin', 'width=650,height=500');
215
-
216
- var email_id = $(this).attr('id').replace('email_content_','');
217
- data = {
218
- action: 'display_content',
219
- email_id: email_id
220
- };
221
-
222
- $.post(ajaxurl, data, function (response) {
223
- $(w.document.body).html(response);
224
- });
225
-
226
- });
227
- });
228
- </script>
229
- <?php
230
- }
231
-
232
- /**
233
- * AJAX callback for displaying email content
234
- *
235
- * @since 1.6
236
- */
237
- function display_content_callback() {
238
- global $wpdb;
239
- global $EmailLog;
240
- $email_id = absint( $_POST['email_id'] );
241
-
242
- // Select the matching item from the database
243
- $query = $wpdb->prepare( "SELECT * FROM " . $EmailLog->table_name . " WHERE id = %d", $email_id );
244
- $content = $wpdb->get_results( $query );
245
-
246
- // Write the message content to the screen
247
- echo $content[0]->message;
248
-
249
- die(); // this is required to return a proper result
250
- }
251
-
252
- /**
253
- * Save Screen option
254
- */
255
- function save_screen_options($status, $option, $value) {
256
- if ( 'per_page' == $option ) return $value;
257
- }
258
-
259
- /**
260
- * Get the per page option
261
- *
262
- * @static
263
- * @access public
264
- * @return int $per_page Number of logs a user wanted to be displayed in a page
265
- *
266
- */
267
- public static function get_per_page() {
268
- $screen = get_current_screen();
269
- $option = $screen->get_option('per_page', 'option');
270
-
271
- $per_page = get_user_meta(get_current_user_id(), $option, TRUE);
272
-
273
- if ( empty ( $per_page) || $per_page < 1 ) {
274
- $per_page = $screen->get_option( 'per_page', 'default' );
275
- }
276
-
277
- return $per_page;
278
- }
279
-
280
- /**
281
- * hook to add action links
282
- *
283
- * @param <type> $links
284
- * @return <type>
285
- */
286
- function add_action_links( $links ) {
287
- // Add a link to this plugin's settings page
288
- $settings_link = '<a href="tools.php?page=email-log">' . __("Log", 'email-log') . '</a>';
289
- array_unshift( $links, $settings_link );
290
- return $links;
291
- }
292
-
293
- /**
294
- * Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
295
- */
296
- function add_footer_links() {
297
- $plugin_data = get_plugin_data( __FILE__ );
298
- printf('%1$s ' . __("plugin", 'email-log') .' | ' . __("Version", 'email-log') . ' %2$s | '. __('by', 'email-log') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
299
- }
300
-
301
- /**
302
- * Log all email to database
303
- *
304
- * @global object $wpdb
305
- * @param array $mail_info Information about email
306
- * @return array Information about email
307
- */
308
- function log_email($mail_info) {
309
-
310
- global $wpdb;
311
-
312
- $attachment_present = (count ($mail_info['attachments']) > 0) ? "true" : "false";
313
-
314
- // return filtered array
315
- $mail_info = apply_filters(self::FILTER_NAME, $mail_info);
316
-
317
- // Log into the database
318
- $wpdb->insert($this->table_name, array(
319
- 'to_email' => is_array($mail_info['to']) ? $mail_info['to'][0] : $mail_info['to'],
320
- 'subject' => $mail_info['subject'],
321
- 'message' => $mail_info['message'],
322
- 'headers' => is_array($mail_info['headers']) ? implode("\n", $mail_info['headers']) : $mail_info['headers'],
323
- 'attachments' => $attachment_present,
324
- 'sent_date' => current_time('mysql')
325
- ));
326
-
327
- return $mail_info;
328
- }
329
-
330
- /**
331
- * Check whether a key is present. If present returns the value, else returns the default value
332
- *
333
- * @param <array> $array - Array whose key has to be checked
334
- * @param <string> $key - key that has to be checked
335
- * @param <string> $default - the default value that has to be used, if the key is not found (optional)
336
- *
337
- * @return <mixed> If present returns the value, else returns the default value
338
- * @author Sudar
339
- */
340
- private function array_get($array, $key, $default = NULL) {
341
- return isset($array[$key]) ? $array[$key] : $default;
342
- }
343
- }
344
-
345
- /**
346
- * Helper class to create and maintain tables
347
- */
348
- class EmailLogInit {
349
-
350
- /**
351
- * Create database table when the Plugin is installed for the first time
352
- *
353
- * @global object $wpdb
354
- * @global string $smel_table_name Table Name
355
- */
356
- public static function on_activate() {
357
- global $wpdb;
358
- $table_name = $wpdb->prefix . EmailLog::TABLE_NAME;
359
-
360
- if($wpdb->get_var("show tables like '{$table_name}'") != $table_name) {
361
-
362
- $sql = "CREATE TABLE " . $table_name . " (
363
- id mediumint(9) NOT NULL AUTO_INCREMENT,
364
- to_email VARCHAR(100) NOT NULL,
365
- subject VARCHAR(250) NOT NULL,
366
- message TEXT NOT NULL,
367
- headers TEXT NOT NULL,
368
- attachments TEXT NOT NULL,
369
- sent_date timestamp NOT NULL,
370
- PRIMARY KEY (id)
371
- );";
372
-
373
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
374
- dbDelta($sql);
375
-
376
- add_option(EmailLog::DB_OPTION_NAME, EmailLog::DB_VERSION);
377
- }
378
- }
379
- }
380
-
381
- // When the Plugin installed
382
- register_activation_hook(__FILE__, array('EmailLogInit', 'on_activate'));
383
-
384
- // Start this plugin once all other plugins are fully loaded
385
- add_action( 'init', 'EmailLog' ); function EmailLog() { global $EmailLog; $EmailLog = new EmailLog(); }
386
- ?>
1
+ <?php
2
+ /**
3
+ Plugin Name: Email Log
4
+ Plugin URI: http://sudarmuthu.com/wordpress/email-log
5
+ Description: Logs every email sent through WordPress
6
+ Donate Link: http://sudarmuthu.com/if-you-wanna-thank-me
7
+ Author: Sudar
8
+ Version: 1.7
9
+ Author URI: http://sudarmuthu.com/
10
+ Text Domain: email-log
11
+ Domain Path: languages/
12
+
13
+ === RELEASE NOTES ===
14
+ Check readme file for full release notes
15
+ */
16
+
17
+ /* Copyright 2009 Sudar Muthu (email : sudar@sudarmuthu.com)
18
+
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License, version 2, as
21
+ published by the Free Software Foundation.
22
+
23
+ This program is distributed in the hope that it will be useful,
24
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+ GNU General Public License for more details.
27
+
28
+ You should have received a copy of the GNU General Public License
29
+ along with this program; if not, write to the Free Software
30
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
+ */
32
+
33
+ // handle installation and table creation
34
+ require_once dirname( __FILE__ ) . '/include/install.php';
35
+
36
+ /**
37
+ * The main Plugin class
38
+ */
39
+ class EmailLog {
40
+
41
+ private $admin_screen;
42
+
43
+ const FILTER_NAME = 'wp_mail_log';
44
+ const PAGE_SLUG = 'email-log';
45
+ const DELETE_LOG_NONCE_FIELD = 'sm-delete-email-log-nonce';
46
+ const DELETE_LOG_ACTION = 'sm-delete-email-log';
47
+
48
+ // DB stuff
49
+ const TABLE_NAME = 'email_log'; /* Database table name */
50
+ const DB_OPTION_NAME = 'email-log-db'; /* Database option name */
51
+ const DB_VERSION = '0.1'; /* Database version */
52
+
53
+ //hooks
54
+ const HOOK_LOG_COLUMNS = 'email_log_manage_log_columns';
55
+ const HOOK_LOG_DISPLAY_COLUMNS = 'email_log_display_log_columns';
56
+
57
+ /**
58
+ * Initalize the plugin by registering the hooks
59
+ */
60
+ function __construct() {
61
+ // Load localization domain
62
+ $this->translations = dirname(plugin_basename(__FILE__)) . '/languages/' ;
63
+ load_plugin_textdomain( 'email-log', false, $this->translations);
64
+
65
+ // Register hooks
66
+ add_action( 'admin_menu', array(&$this, 'register_settings_page') );
67
+
68
+ // Register Filter
69
+ add_filter('wp_mail', array(&$this, 'log_email'));
70
+ add_filter('set-screen-option', array(&$this, 'save_screen_options'), 10, 3);
71
+ add_filter( 'plugin_row_meta', array( &$this, 'add_plugin_links' ), 10, 2 );
72
+
73
+ $plugin = plugin_basename(__FILE__);
74
+ add_filter("plugin_action_links_$plugin", array(&$this, 'add_action_links'));
75
+
76
+ //Add our ajax call
77
+ add_action( 'wp_ajax_display_content', array(&$this, 'display_content_callback'));
78
+
79
+ // Add our javascript in the footer
80
+ add_action( 'admin_footer', array(&$this, 'include_js') );
81
+ }
82
+
83
+ /**
84
+ * Adds additional links in the Plugin listing. Based on http://zourbuth.com/archives/751/creating-additional-wordpress-plugin-links-row-meta/
85
+ */
86
+ function add_plugin_links($links, $file) {
87
+ $plugin = plugin_basename(__FILE__);
88
+
89
+ if ($file == $plugin) // only for this plugin
90
+ return array_merge( $links,
91
+ array( '<a href="http://sudarmuthu.com/wordpress/email-log/pro-addons" target="_blank">' . __('Buy Addons', 'email-log') . '</a>' )
92
+ );
93
+ return $links;
94
+ }
95
+
96
+ /**
97
+ * Register the settings page
98
+ */
99
+ function register_settings_page() {
100
+ //Save the handle to your admin page - you'll need it to create a WP_Screen object
101
+ $this->admin_page = add_submenu_page( 'tools.php', __('Email Log', 'email-log'), __('Email Log', 'email-log'), 'manage_options', self::PAGE_SLUG , array( &$this, 'display_logs') );
102
+
103
+ add_action("load-{$this->admin_page}",array(&$this,'create_settings_panel'));
104
+ }
105
+
106
+ /**
107
+ * Display email logs
108
+ */
109
+ function display_logs() {
110
+
111
+ $this->logs_table->prepare_items( $this->get_per_page() );
112
+ ?>
113
+ <div class="wrap">
114
+ <h2><?php _e('Email Logs', 'email-log');?></h2>
115
+ <?php
116
+ if ( isset( $this->logs_deleted ) && $this->logs_deleted != '' ) {
117
+ $logs_deleted = intval( $this->logs_deleted );
118
+
119
+ if ( $logs_deleted > 0 ) {
120
+ echo "<div class = 'updated'><p>" . sprintf( _n( '1 email log deleted.', '%s email logs deleted', $logs_deleted, 'email-log' ), $logs_deleted ) . "</p></div>";
121
+ } else {
122
+ echo "<div class = 'updated'><p>" . __( 'There was some problem in deleting the email logs' , 'email-log') . "</p></div>";
123
+ }
124
+ unset($this->logs_deleted);
125
+ }
126
+ ?>
127
+ <form id="email-logs-search" method="get">
128
+ <input type="hidden" name="page" value="<?php echo self::PAGE_SLUG; ?>" >
129
+ <?php
130
+ $this->logs_table->search_box( __('Search Logs', 'email-log'), 'search_id' );
131
+ ?>
132
+ </form>
133
+
134
+ <form id="email-logs-filter" method="get">
135
+ <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
136
+ <?php
137
+ wp_nonce_field( self::DELETE_LOG_ACTION, self::DELETE_LOG_NONCE_FIELD );
138
+ $this->logs_table->display();
139
+ ?>
140
+ </form>
141
+ </div>
142
+ <?php
143
+ // Display credits in Footer
144
+ add_action( 'in_admin_footer', array(&$this, 'add_footer_links'));
145
+ }
146
+
147
+ /**
148
+ * Add settings Panel
149
+ */
150
+ function create_settings_panel() {
151
+
152
+ /**
153
+ * Create the WP_Screen object against your admin page handle
154
+ * This ensures we're working with the right admin page
155
+ */
156
+ $this->admin_screen = WP_Screen::get($this->admin_page);
157
+
158
+ /**
159
+ * Content specified inline
160
+ */
161
+ $this->admin_screen->add_help_tab(
162
+ array(
163
+ 'title' => __('About Plugin', 'email-log'),
164
+ 'id' => 'about_tab',
165
+ 'content' => '<p>' . __('Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress.', 'email-log') . '</p>',
166
+ 'callback' => false
167
+ )
168
+ );
169
+
170
+ // Add help sidebar
171
+ $this->admin_screen->set_help_sidebar(
172
+ '<p><strong>' . __('More information', 'email-log') . '</strong></p>' .
173
+ '<p><a href = "http://sudarmuthu.com/wordpress/email-log">' . __('Plugin Homepage/support', 'email-log') . '</a></p>' .
174
+ '<p><a href = "http://sudarmuthu.com/blog">' . __("Plugin author's blog", 'email-log') . '</a></p>' .
175
+ '<p><a href = "http://sudarmuthu.com/wordpress/">' . __("Other Plugin's by Author", 'email-log') . '</a></p>'
176
+ );
177
+
178
+ // Add screen options
179
+ $this->admin_screen->add_option(
180
+ 'per_page',
181
+ array(
182
+ 'label' => __('Entries per page', 'email-log'),
183
+ 'default' => 20,
184
+ 'option' => 'per_page'
185
+ )
186
+ );
187
+
188
+ if(!class_exists('WP_List_Table')){
189
+ require_once( ABSPATH . WPINC . '/class-wp-list-table.php' );
190
+ }
191
+
192
+ if (!class_exists( 'Email_Log_List_Table' ) ) {
193
+ require_once dirname( __FILE__ ) . '/include/class-email-log-list-table.php';
194
+ }
195
+
196
+ //Prepare Table of elements
197
+ $this->logs_table = new Email_Log_List_Table();
198
+ }
199
+
200
+ /**
201
+ * Include JavaScript displaying email content
202
+ *
203
+ * @since 1.6
204
+ */
205
+ function include_js() {
206
+ // TODO: Move this to a separate js file
207
+ ?>
208
+ <script type="text/javascript">
209
+ jQuery(document).ready(function($) {
210
+
211
+ $(".email_content").click(function() {
212
+
213
+ var w = window.open('', 'newwin', 'width=650,height=500');
214
+
215
+ var email_id = $(this).attr('id').replace('email_content_','');
216
+ data = {
217
+ action: 'display_content',
218
+ email_id: email_id
219
+ };
220
+
221
+ $.post(ajaxurl, data, function (response) {
222
+ $(w.document.body).html(response);
223
+ });
224
+ });
225
+ });
226
+ </script>
227
+ <?php
228
+ }
229
+
230
+ /**
231
+ * AJAX callback for displaying email content
232
+ *
233
+ * @since 1.6
234
+ */
235
+ function display_content_callback() {
236
+ global $wpdb;
237
+
238
+ $table_name = $wpdb->prefix . self::TABLE_NAME;
239
+ $email_id = absint( $_POST['email_id'] );
240
+
241
+ // Select the matching item from the database
242
+ $query = $wpdb->prepare( "SELECT * FROM " . $table_name . " WHERE id = %d", $email_id );
243
+ $content = $wpdb->get_results( $query );
244
+
245
+ // Write the message content to the screen
246
+ echo $content[0]->message;
247
+
248
+ die(); // this is required to return a proper result
249
+ }
250
+
251
+ /**
252
+ * Save Screen option
253
+ */
254
+ function save_screen_options($status, $option, $value) {
255
+ if ( 'per_page' == $option ) return $value;
256
+ }
257
+
258
+ /**
259
+ * Get the per page option
260
+ *
261
+ * @static
262
+ * @access public
263
+ * @return int $per_page Number of logs a user wanted to be displayed in a page
264
+ *
265
+ */
266
+ public static function get_per_page() {
267
+ $screen = get_current_screen();
268
+ $option = $screen->get_option('per_page', 'option');
269
+
270
+ $per_page = get_user_meta(get_current_user_id(), $option, TRUE);
271
+
272
+ if ( empty ( $per_page) || $per_page < 1 ) {
273
+ $per_page = $screen->get_option( 'per_page', 'default' );
274
+ }
275
+
276
+ return $per_page;
277
+ }
278
+
279
+ /**
280
+ * hook to add action links
281
+ *
282
+ * @param <type> $links
283
+ * @return <type>
284
+ */
285
+ function add_action_links( $links ) {
286
+ // Add a link to this plugin's settings page
287
+ $settings_link = '<a href="tools.php?page=email-log">' . __("Log", 'email-log') . '</a>';
288
+ array_unshift( $links, $settings_link );
289
+ return $links;
290
+ }
291
+
292
+ /**
293
+ * Adds Footer links. Based on http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
294
+ */
295
+ function add_footer_links() {
296
+ $plugin_data = get_plugin_data( __FILE__ );
297
+ printf('%1$s ' . __("plugin", 'email-log') .' | ' . __("Version", 'email-log') . ' %2$s | '. __('by', 'email-log') . ' %3$s<br />', $plugin_data['Title'], $plugin_data['Version'], $plugin_data['Author']);
298
+ }
299
+
300
+ /**
301
+ * Log all email to database
302
+ *
303
+ * @global object $wpdb
304
+ * @param array $mail_info Information about email
305
+ * @return array Information about email
306
+ */
307
+ function log_email($mail_info) {
308
+
309
+ global $wpdb;
310
+
311
+ $attachment_present = (count ($mail_info['attachments']) > 0) ? "true" : "false";
312
+
313
+ // return filtered array
314
+ $mail_info = apply_filters(self::FILTER_NAME, $mail_info);
315
+ $table_name = $wpdb->prefix . self::TABLE_NAME;
316
+
317
+ // Log into the database
318
+ $wpdb->insert( $table_name, array(
319
+ 'to_email' => is_array($mail_info['to']) ? $mail_info['to'][0] : $mail_info['to'],
320
+ 'subject' => $mail_info['subject'],
321
+ 'message' => $mail_info['message'],
322
+ 'headers' => is_array($mail_info['headers']) ? implode("\n", $mail_info['headers']) : $mail_info['headers'],
323
+ 'attachments' => $attachment_present,
324
+ 'sent_date' => current_time('mysql')
325
+ ));
326
+
327
+ return $mail_info;
328
+ }
329
+
330
+ /**
331
+ * Check whether a key is present. If present returns the value, else returns the default value
332
+ *
333
+ * @param <array> $array - Array whose key has to be checked
334
+ * @param <string> $key - key that has to be checked
335
+ * @param <string> $default - the default value that has to be used, if the key is not found (optional)
336
+ *
337
+ * @return <mixed> If present returns the value, else returns the default value
338
+ * @author Sudar
339
+ */
340
+ private function array_get($array, $key, $default = NULL) {
341
+ return isset($array[$key]) ? $array[$key] : $default;
342
+ }
343
+ }
344
+
345
+ // Start this plugin once all other plugins are fully loaded
346
+ add_action( 'init', 'EmailLog' ); function EmailLog() { global $EmailLog; $EmailLog = new EmailLog(); }
347
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
include/class-email-log-list-table.php CHANGED
@@ -8,14 +8,14 @@
8
  * @author Sudar
9
  */
10
  class Email_Log_List_Table extends WP_List_Table {
11
-
12
- /**
13
- * Set up a constructor that references the parent constructor. We
14
  * use the parent reference to set some default configs.
15
  */
16
  function __construct(){
17
  global $status, $page;
18
-
19
  //Set parent defaults
20
  parent::__construct( array(
21
  'singular' => 'email-log', //singular name of the listed records
@@ -68,17 +68,17 @@ class Email_Log_List_Table extends WP_List_Table {
68
  echo '</ul>';
69
  }
70
  }
71
-
72
  /** ************************************************************************
73
  * REQUIRED! This method dictates the table's columns and titles. This should
74
- * return an array where the key is the column slug (and class) and the value
75
  * is the column's title text. If you need a checkbox for bulk actions, refer
76
  * to the $columns array below.
77
- *
78
  * The 'cb' column is treated differently than the rest. If including a checkbox
79
  * column in your table you must create a column_cb() method. If you don't need
80
  * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
81
- *
82
  * @see WP_List_Table::::single_row_columns()
83
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
84
  **************************************************************************/
@@ -92,19 +92,19 @@ class Email_Log_List_Table extends WP_List_Table {
92
 
93
  return apply_filters( EmailLog::HOOK_LOG_COLUMNS, $columns );
94
  }
95
-
96
  /** ************************************************************************
97
- * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
98
- * you will need to register it here. This should return an array where the
99
- * key is the column that needs to be sortable, and the value is db column to
100
  * sort by. Often, the key and value will be the same, but this is not always
101
  * the case (as the value is a column name from the database, not the list table).
102
- *
103
  * This method merely defines which columns should be sortable and makes them
104
  * clickable - it does not handle the actual sorting. You still need to detect
105
  * the ORDERBY and ORDER querystring variables within prepare_items() and sort
106
  * your data accordingly (usually by modifying your query).
107
- *
108
  * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
109
  **************************************************************************/
110
  function get_sortable_columns() {
@@ -115,24 +115,24 @@ class Email_Log_List_Table extends WP_List_Table {
115
  );
116
  return $sortable_columns;
117
  }
118
-
119
  /** ************************************************************************
120
  * Recommended. This method is called when the parent class can't find a method
121
  * specifically build for a given column. Generally, it's recommended to include
122
  * one method for each column you want to render, keeping your package class
123
  * neat and organized. For example, if the class needs to process a column
124
- * named 'title', it would first see if a method named $this->column_title()
125
  * exists - if it does, that method will be used. If it doesn't, this one will
126
- * be used. Generally, you should try to use custom column methods as much as
127
- * possible.
128
- *
129
  * Since we have defined a column_title() method later on, this method doesn't
130
  * need to concern itself with any column with a name of 'title'. Instead, it
131
  * needs to handle everything else.
132
- *
133
- * For more detailed insight into how columns are handled, take a look at
134
  * WP_List_Table::single_row_columns()
135
- *
136
  * @param array $item A singular item (one full row's worth of data)
137
  * @param array $column_name The name/slug of the column to be processed
138
  * @return string Text or HTML to be placed inside the column <td>
@@ -140,30 +140,30 @@ class Email_Log_List_Table extends WP_List_Table {
140
  function column_default( $item, $column_name ){
141
  do_action( EmailLog::HOOK_LOG_DISPLAY_COLUMNS, $column_name, $item );
142
  }
143
-
144
  /** ************************************************************************
145
  * Recommended. This is a custom column method and is responsible for what
146
  * is rendered in any column with a name/slug of 'title'. Every time the class
147
- * needs to render a column, it first looks for a method named
148
  * column_{$column_title} - if it exists, that method is run. If it doesn't
149
  * exist, column_default() is called instead.
150
- *
151
  * This example also illustrates how to implement rollover actions. Actions
152
  * should be an associative array formatted as 'slug'=>'link html' - and you
153
  * will need to generate the URLs yourself. You could even ensure the links
154
- *
155
- *
156
  * @see WP_List_Table::::single_row_columns()
157
  * @param array $item A singular item (one full row's worth of data)
158
  * @return string Text to be placed inside the column <td>
159
  **************************************************************************/
160
  function column_sent_date($item){
161
-
162
  //Build row actions
163
  $actions = array(
164
- 'delete' => sprintf( '<a href="?page=%s&action=%s&%s=%s&%s=%s">%s</a>',
165
- $_REQUEST['page'],
166
- 'delete',
167
  $this->_args['singular'],
168
  $item->id,
169
  EmailLog::DELETE_LOG_NONCE_FIELD,
@@ -182,7 +182,7 @@ class Email_Log_List_Table extends WP_List_Table {
182
  /*$5%s*/ $this->row_actions($actions)
183
  );
184
  }
185
-
186
  /**
187
  * To field
188
  */
@@ -201,7 +201,7 @@ class Email_Log_List_Table extends WP_List_Table {
201
  * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
202
  * is given special treatment when columns are processed. It ALWAYS needs to
203
  * have it's own method.
204
- *
205
  * @see WP_List_Table::::single_row_columns()
206
  * @param array $item A singular item (one full row's worth of data)
207
  * @return string Text to be placed inside the column <td> (movie title only)
@@ -213,40 +213,32 @@ class Email_Log_List_Table extends WP_List_Table {
213
  /*$2%s*/ $item->id
214
  );
215
  }
216
-
217
-
218
- /** ************************************************************************
219
- * Optional. If you need to include bulk actions in your list table, this is
220
- * the place to define them. Bulk actions are an associative array in the format
221
- * 'slug'=>'Visible Title'
222
- *
223
- * If this method returns an empty value, no bulk action will be rendered. If
224
- * you specify any bulk actions, the bulk actions box will be rendered with
225
- * the table automatically on display().
226
- *
227
- * Also note that list tables are not automatically wrapped in <form> elements,
228
- * so you will need to create those manually in order for bulk actions to function.
229
- *
230
  * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
231
- **************************************************************************/
232
  function get_bulk_actions() {
233
  $actions = array(
234
- 'delete' => __('Delete', 'email-log')
 
235
  );
236
  return $actions;
237
  }
238
-
239
  /**
240
  * Handle bulk actions
241
- *
242
  * @see $this->prepare_items()
243
  */
244
  function process_bulk_action() {
245
- global $EmailLog;
246
  global $wpdb;
 
247
 
248
- //Detect when a bulk action is being triggered...
249
  if( 'delete' === $this->current_action() ) {
 
 
250
  $nouce = $_REQUEST[EmailLog::DELETE_LOG_NONCE_FIELD ];
251
  if ( wp_verify_nonce( $nouce, EmailLog::DELETE_LOG_ACTION ) ) {
252
 
@@ -263,29 +255,40 @@ class Email_Log_List_Table extends WP_List_Table {
263
 
264
  $selected_ids = esc_sql( $selected_ids );
265
 
266
- $EmailLog->logs_deleted = $wpdb->query( "DELETE FROM $EmailLog->table_name where id IN ( $selected_ids )" );
 
 
 
 
 
 
 
 
 
 
 
267
  } else {
268
  wp_die( 'Cheating, Huh? ');
269
  }
270
  }
271
  }
272
-
273
  /**
274
  * Prepare data for display.
275
  */
276
  function prepare_items() {
277
  global $wpdb;
278
- global $EmailLog;
279
 
 
280
  $this->_column_headers = $this->get_column_info();
281
-
282
  // Handle bulk actions
283
  $this->process_bulk_action();
284
-
285
  // get current page number
286
  $current_page = $this->get_pagenum();
287
-
288
- $query = "SELECT * FROM " . $EmailLog->table_name;
289
 
290
  if ( isset( $_GET['s'] ) ) {
291
  $search_term = trim( esc_sql( $_GET['s'] ) );
@@ -294,10 +297,10 @@ class Email_Log_List_Table extends WP_List_Table {
294
 
295
  // Ordering parameters
296
  $orderby = !empty( $_GET["orderby"] ) ? esc_sql( $_GET["orderby"] ) : 'sent_date';
297
- $order = !empty( $_GET["order"] ) ? esc_sql( $_GET["order"] ) : 'DESC';
298
 
299
  if(!empty($orderby) & !empty($order)) {
300
- $query .= ' ORDER BY ' . $orderby . ' ' . $order;
301
  }
302
 
303
  // Pagination parameters
@@ -312,7 +315,7 @@ class Email_Log_List_Table extends WP_List_Table {
312
 
313
  // Fetch the items
314
  $this->items = $wpdb->get_results( $query );
315
-
316
  // register pagination options & calculations.
317
  $this->set_pagination_args( array(
318
  'total_items' => $total_items,
@@ -320,7 +323,7 @@ class Email_Log_List_Table extends WP_List_Table {
320
  'total_pages' => ceil( $total_items/$per_page )
321
  ) );
322
  }
323
-
324
  /**
325
  * If no items are found
326
  */
8
  * @author Sudar
9
  */
10
  class Email_Log_List_Table extends WP_List_Table {
11
+
12
+ /**
13
+ * Set up a constructor that references the parent constructor. We
14
  * use the parent reference to set some default configs.
15
  */
16
  function __construct(){
17
  global $status, $page;
18
+
19
  //Set parent defaults
20
  parent::__construct( array(
21
  'singular' => 'email-log', //singular name of the listed records
68
  echo '</ul>';
69
  }
70
  }
71
+
72
  /** ************************************************************************
73
  * REQUIRED! This method dictates the table's columns and titles. This should
74
+ * return an array where the key is the column slug (and class) and the value
75
  * is the column's title text. If you need a checkbox for bulk actions, refer
76
  * to the $columns array below.
77
+ *
78
  * The 'cb' column is treated differently than the rest. If including a checkbox
79
  * column in your table you must create a column_cb() method. If you don't need
80
  * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
81
+ *
82
  * @see WP_List_Table::::single_row_columns()
83
  * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
84
  **************************************************************************/
92
 
93
  return apply_filters( EmailLog::HOOK_LOG_COLUMNS, $columns );
94
  }
95
+
96
  /** ************************************************************************
97
+ * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
98
+ * you will need to register it here. This should return an array where the
99
+ * key is the column that needs to be sortable, and the value is db column to
100
  * sort by. Often, the key and value will be the same, but this is not always
101
  * the case (as the value is a column name from the database, not the list table).
102
+ *
103
  * This method merely defines which columns should be sortable and makes them
104
  * clickable - it does not handle the actual sorting. You still need to detect
105
  * the ORDERBY and ORDER querystring variables within prepare_items() and sort
106
  * your data accordingly (usually by modifying your query).
107
+ *
108
  * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
109
  **************************************************************************/
110
  function get_sortable_columns() {
115
  );
116
  return $sortable_columns;
117
  }
118
+
119
  /** ************************************************************************
120
  * Recommended. This method is called when the parent class can't find a method
121
  * specifically build for a given column. Generally, it's recommended to include
122
  * one method for each column you want to render, keeping your package class
123
  * neat and organized. For example, if the class needs to process a column
124
+ * named 'title', it would first see if a method named $this->column_title()
125
  * exists - if it does, that method will be used. If it doesn't, this one will
126
+ * be used. Generally, you should try to use custom column methods as much as
127
+ * possible.
128
+ *
129
  * Since we have defined a column_title() method later on, this method doesn't
130
  * need to concern itself with any column with a name of 'title'. Instead, it
131
  * needs to handle everything else.
132
+ *
133
+ * For more detailed insight into how columns are handled, take a look at
134
  * WP_List_Table::single_row_columns()
135
+ *
136
  * @param array $item A singular item (one full row's worth of data)
137
  * @param array $column_name The name/slug of the column to be processed
138
  * @return string Text or HTML to be placed inside the column <td>
140
  function column_default( $item, $column_name ){
141
  do_action( EmailLog::HOOK_LOG_DISPLAY_COLUMNS, $column_name, $item );
142
  }
143
+
144
  /** ************************************************************************
145
  * Recommended. This is a custom column method and is responsible for what
146
  * is rendered in any column with a name/slug of 'title'. Every time the class
147
+ * needs to render a column, it first looks for a method named
148
  * column_{$column_title} - if it exists, that method is run. If it doesn't
149
  * exist, column_default() is called instead.
150
+ *
151
  * This example also illustrates how to implement rollover actions. Actions
152
  * should be an associative array formatted as 'slug'=>'link html' - and you
153
  * will need to generate the URLs yourself. You could even ensure the links
154
+ *
155
+ *
156
  * @see WP_List_Table::::single_row_columns()
157
  * @param array $item A singular item (one full row's worth of data)
158
  * @return string Text to be placed inside the column <td>
159
  **************************************************************************/
160
  function column_sent_date($item){
161
+
162
  //Build row actions
163
  $actions = array(
164
+ 'delete' => sprintf( '<a href="?page=%s&action=%s&%s=%s&%s=%s">%s</a>',
165
+ $_REQUEST['page'],
166
+ 'delete',
167
  $this->_args['singular'],
168
  $item->id,
169
  EmailLog::DELETE_LOG_NONCE_FIELD,
182
  /*$5%s*/ $this->row_actions($actions)
183
  );
184
  }
185
+
186
  /**
187
  * To field
188
  */
201
  * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
202
  * is given special treatment when columns are processed. It ALWAYS needs to
203
  * have it's own method.
204
+ *
205
  * @see WP_List_Table::::single_row_columns()
206
  * @param array $item A singular item (one full row's worth of data)
207
  * @return string Text to be placed inside the column <td> (movie title only)
213
  /*$2%s*/ $item->id
214
  );
215
  }
216
+
217
+ /**
218
+ * Specify the list of bulk actions
219
+ *
 
 
 
 
 
 
 
 
 
 
220
  * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
221
+ */
222
  function get_bulk_actions() {
223
  $actions = array(
224
+ 'delete' => __( 'Delete', 'email-log' ),
225
+ 'delete-all' => __( 'Delete All Logs', 'email-log' )
226
  );
227
  return $actions;
228
  }
229
+
230
  /**
231
  * Handle bulk actions
232
+ *
233
  * @see $this->prepare_items()
234
  */
235
  function process_bulk_action() {
 
236
  global $wpdb;
237
+ global $EmailLog;
238
 
 
239
  if( 'delete' === $this->current_action() ) {
240
+ // delete a list of logs by id
241
+
242
  $nouce = $_REQUEST[EmailLog::DELETE_LOG_NONCE_FIELD ];
243
  if ( wp_verify_nonce( $nouce, EmailLog::DELETE_LOG_ACTION ) ) {
244
 
255
 
256
  $selected_ids = esc_sql( $selected_ids );
257
 
258
+ $table_name = $wpdb->prefix . EmailLog::TABLE_NAME;
259
+ $EmailLog->logs_deleted = $wpdb->query( "DELETE FROM $table_name where id IN ( $selected_ids )" );
260
+ } else {
261
+ wp_die( 'Cheating, Huh? ');
262
+ }
263
+ } else if( 'delete-all' === $this->current_action() ) {
264
+ // delete all logs
265
+
266
+ $nouce = $_REQUEST[EmailLog::DELETE_LOG_NONCE_FIELD ];
267
+ if ( wp_verify_nonce( $nouce, EmailLog::DELETE_LOG_ACTION ) ) {
268
+ $table_name = $wpdb->prefix . EmailLog::TABLE_NAME;
269
+ $EmailLog->logs_deleted = $wpdb->query( "DELETE FROM $table_name" );
270
  } else {
271
  wp_die( 'Cheating, Huh? ');
272
  }
273
  }
274
  }
275
+
276
  /**
277
  * Prepare data for display.
278
  */
279
  function prepare_items() {
280
  global $wpdb;
 
281
 
282
+ $table_name = $wpdb->prefix . EmailLog::TABLE_NAME;
283
  $this->_column_headers = $this->get_column_info();
284
+
285
  // Handle bulk actions
286
  $this->process_bulk_action();
287
+
288
  // get current page number
289
  $current_page = $this->get_pagenum();
290
+
291
+ $query = "SELECT * FROM " . $table_name;
292
 
293
  if ( isset( $_GET['s'] ) ) {
294
  $search_term = trim( esc_sql( $_GET['s'] ) );
297
 
298
  // Ordering parameters
299
  $orderby = !empty( $_GET["orderby"] ) ? esc_sql( $_GET["orderby"] ) : 'sent_date';
300
+ $order = !empty( $_GET["order"] ) ? esc_sql( $_GET["order"] ) : 'DESC';
301
 
302
  if(!empty($orderby) & !empty($order)) {
303
+ $query .= ' ORDER BY ' . $orderby . ' ' . $order;
304
  }
305
 
306
  // Pagination parameters
315
 
316
  // Fetch the items
317
  $this->items = $wpdb->get_results( $query );
318
+
319
  // register pagination options & calculations.
320
  $this->set_pagination_args( array(
321
  'total_items' => $total_items,
323
  'total_pages' => ceil( $total_items/$per_page )
324
  ) );
325
  }
326
+
327
  /**
328
  * If no items are found
329
  */
include/install.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handle installation and db table creation
4
+ *
5
+ * @package Email Log
6
+ * @subpackage Install
7
+ * @author Sudar
8
+ * @since 1.7
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ /**
15
+ * Helper class to create and maintain tables
16
+ *
17
+ * @author Sudar
18
+ */
19
+ class Email_Log_Init {
20
+
21
+ /**
22
+ * Perform activation based on multisite or not
23
+ *
24
+ * @since 1.7
25
+ * @static
26
+ * @access public
27
+ *
28
+ * @global object $wpdb
29
+ */
30
+ public static function activate( $network_wide ) {
31
+ global $wpdb;
32
+
33
+ if ( is_multisite() && $network_wide ) {
34
+ // store the current blog id
35
+ $current_blog = $wpdb->blogid;
36
+
37
+ // Get all blogs in the network and activate plugin on each one
38
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
39
+ foreach ( $blog_ids as $blog_id ) {
40
+ switch_to_blog( $blog_id );
41
+ self::create_emaillog_table();
42
+ }
43
+
44
+ // Switch back to the current blog
45
+ switch_to_blog( $current_blog );
46
+
47
+ } else {
48
+ self::create_emaillog_table();
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Create email log table when a new blog is created
54
+ *
55
+ * @since 1.7
56
+ * @static
57
+ * @access public
58
+ */
59
+ public static function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
60
+ if ( is_plugin_active_for_network( 'email-log/email-log.php' ) ) {
61
+ switch_to_blog( $blog_id );
62
+ self::create_emaillog_table();
63
+ restore_current_blog();
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Delete email log table when a blog is deleted
69
+ *
70
+ * @since 1.7
71
+ * @static
72
+ * @access public
73
+ *
74
+ * @global object $wpdb
75
+ * @param $tables - List of tables to be deleted
76
+ * @return $tables - List of tables to be deleted with the plugin's table name
77
+ */
78
+ public static function on_delete_blog( $tables ) {
79
+ global $wpdb;
80
+ $tables[] = $wpdb->prefix . EmailLog::TABLE_NAME;
81
+ return $tables;
82
+ }
83
+
84
+ /**
85
+ * Create email log table
86
+ *
87
+ * @since 1.7
88
+ * @static
89
+ * @access private
90
+ *
91
+ * @global object $wpdb
92
+ */
93
+ private static function create_emaillog_table() {
94
+ global $wpdb;
95
+ $table_name = $wpdb->prefix . EmailLog::TABLE_NAME;
96
+
97
+ if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) {
98
+
99
+ $sql = "CREATE TABLE " . $table_name . " (
100
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
101
+ to_email VARCHAR(100) NOT NULL,
102
+ subject VARCHAR(250) NOT NULL,
103
+ message TEXT NOT NULL,
104
+ headers TEXT NOT NULL,
105
+ attachments TEXT NOT NULL,
106
+ sent_date timestamp NOT NULL,
107
+ PRIMARY KEY (id)
108
+ );";
109
+
110
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
111
+ dbDelta( $sql );
112
+
113
+ add_option( EmailLog::DB_OPTION_NAME, EmailLog::DB_VERSION );
114
+ }
115
+ }
116
+ }
117
+
118
+ // When the Plugin installed
119
+ register_activation_hook( __FILE__, array( 'Email_Log_Init', 'on_activate' ) );
120
+
121
+ // when a new blog is created in multisite
122
+ add_action( 'wpmu_new_blog', array( 'Email_Log_Init', 'on_create_blog' ), 10, 6 );
123
+
124
+ // when a blog is deleted in multisite
125
+ add_filter( 'wpmu_drop_tables', array( 'Email_Log_Init', 'on_delete_blog' ) );
126
+ ?>
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 1.6.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/email-log\n"
7
- "POT-Creation-Date: 2014-01-27 11:15:01+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,73 +12,77 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: email-log.php:93
16
  msgid "Buy Addons"
17
  msgstr ""
18
 
19
- #: email-log.php:103
 
 
20
  msgid "Email Log"
21
  msgstr ""
22
 
23
- #: email-log.php:116
24
  msgid "Email Logs"
25
  msgstr ""
26
 
27
- #: email-log.php:122
28
  msgid "1 email log deleted."
29
  msgid_plural "%s email logs deleted"
30
  msgstr[0] ""
31
  msgstr[1] ""
32
 
33
- #: email-log.php:124
34
  msgid "There was some problem in deleting the email logs"
35
  msgstr ""
36
 
37
- #: email-log.php:132
38
  msgid "Search Logs"
39
  msgstr ""
40
 
41
- #: email-log.php:165 tmp_addon/email-log-forward-email.php:152
42
  msgid "About Plugin"
43
  msgstr ""
44
 
45
- #: email-log.php:167 tmp_addon/email-log-forward-email.php:154
46
- msgid "Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress."
 
 
47
  msgstr ""
48
 
49
- #: email-log.php:174 tmp_addon/email-log-forward-email.php:162
50
  msgid "More information"
51
  msgstr ""
52
 
53
- #: email-log.php:175 tmp_addon/email-log-forward-email.php:163
54
  msgid "Plugin Homepage/support"
55
  msgstr ""
56
 
57
- #: email-log.php:176 tmp_addon/email-log-forward-email.php:164
58
  msgid "Plugin author's blog"
59
  msgstr ""
60
 
61
- #: email-log.php:177 tmp_addon/email-log-forward-email.php:165
62
  msgid "Other Plugin's by Author"
63
  msgstr ""
64
 
65
- #: email-log.php:184
66
  msgid "Entries per page"
67
  msgstr ""
68
 
69
- #: email-log.php:288
70
  msgid "Log"
71
  msgstr ""
72
 
73
- #: email-log.php:298
74
  msgid "plugin"
75
  msgstr ""
76
 
77
- #: email-log.php:298
78
  msgid "Version"
79
  msgstr ""
80
 
81
- #: email-log.php:298
82
  msgid "by"
83
  msgstr ""
84
 
@@ -91,7 +95,9 @@ msgid "Buy Now"
91
  msgstr ""
92
 
93
  #: include/class-email-log-list-table.php:49
94
- msgid "The following are the list of pro addons that are currently available for purchase."
 
 
95
  msgstr ""
96
 
97
  #: include/class-email-log-list-table.php:55
@@ -99,7 +105,9 @@ msgid "Email Log - Forward Email"
99
  msgstr ""
100
 
101
  #: include/class-email-log-list-table.php:56
102
- msgid "This addon allows you to send a copy of all emails send from WordPress to another email address"
 
 
103
  msgstr ""
104
 
105
  #: include/class-email-log-list-table.php:57
@@ -117,7 +125,8 @@ msgid "Email Log - More fields"
117
  msgstr ""
118
 
119
  #: include/class-email-log-list-table.php:63
120
- msgid "Adds more fields (From, CC, BCC, Reply To, Attachment) to the logs page."
 
121
  msgstr ""
122
 
123
  #: include/class-email-log-list-table.php:88
@@ -134,7 +143,7 @@ msgid "Subject"
134
  msgstr ""
135
 
136
  #: include/class-email-log-list-table.php:171
137
- #: include/class-email-log-list-table.php:234
138
  msgid "Delete"
139
  msgstr ""
140
 
@@ -146,7 +155,11 @@ msgstr ""
146
  msgid "View Content"
147
  msgstr ""
148
 
149
- #: include/class-email-log-list-table.php:328
 
 
 
 
150
  msgid "Your email log is empty"
151
  msgstr ""
152
 
@@ -190,9 +203,6 @@ msgstr ""
190
  #: tmp_addon/email-log-more-fields.php:84
191
  msgid "Attachment"
192
  msgstr ""
193
- #. Plugin Name of the plugin/theme
194
- msgid "Email Log"
195
- msgstr ""
196
 
197
  #. Plugin URI of the plugin/theme
198
  msgid "http://sudarmuthu.com/wordpress/email-log"
2
  # This file is distributed under the same license as the Email Log package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Email Log 1.7\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/email-log\n"
7
+ "POT-Creation-Date: 2014-03-30 07:34:34+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
+ #: email-log.php:91
16
  msgid "Buy Addons"
17
  msgstr ""
18
 
19
+ #. #-#-#-#-# email-log.pot (Email Log 1.7) #-#-#-#-#
20
+ #. Plugin Name of the plugin/theme
21
+ #: email-log.php:101
22
  msgid "Email Log"
23
  msgstr ""
24
 
25
+ #: email-log.php:114
26
  msgid "Email Logs"
27
  msgstr ""
28
 
29
+ #: email-log.php:120
30
  msgid "1 email log deleted."
31
  msgid_plural "%s email logs deleted"
32
  msgstr[0] ""
33
  msgstr[1] ""
34
 
35
+ #: email-log.php:122
36
  msgid "There was some problem in deleting the email logs"
37
  msgstr ""
38
 
39
+ #: email-log.php:130
40
  msgid "Search Logs"
41
  msgstr ""
42
 
43
+ #: email-log.php:163 tmp_addon/email-log-forward-email.php:152
44
  msgid "About Plugin"
45
  msgstr ""
46
 
47
+ #: email-log.php:165 tmp_addon/email-log-forward-email.php:154
48
+ msgid ""
49
+ "Email Log WordPress Plugin, allows you to log all emails that are sent "
50
+ "through WordPress."
51
  msgstr ""
52
 
53
+ #: email-log.php:172 tmp_addon/email-log-forward-email.php:162
54
  msgid "More information"
55
  msgstr ""
56
 
57
+ #: email-log.php:173 tmp_addon/email-log-forward-email.php:163
58
  msgid "Plugin Homepage/support"
59
  msgstr ""
60
 
61
+ #: email-log.php:174 tmp_addon/email-log-forward-email.php:164
62
  msgid "Plugin author's blog"
63
  msgstr ""
64
 
65
+ #: email-log.php:175 tmp_addon/email-log-forward-email.php:165
66
  msgid "Other Plugin's by Author"
67
  msgstr ""
68
 
69
+ #: email-log.php:182
70
  msgid "Entries per page"
71
  msgstr ""
72
 
73
+ #: email-log.php:287
74
  msgid "Log"
75
  msgstr ""
76
 
77
+ #: email-log.php:297
78
  msgid "plugin"
79
  msgstr ""
80
 
81
+ #: email-log.php:297
82
  msgid "Version"
83
  msgstr ""
84
 
85
+ #: email-log.php:297
86
  msgid "by"
87
  msgstr ""
88
 
95
  msgstr ""
96
 
97
  #: include/class-email-log-list-table.php:49
98
+ msgid ""
99
+ "The following are the list of pro addons that are currently available for "
100
+ "purchase."
101
  msgstr ""
102
 
103
  #: include/class-email-log-list-table.php:55
105
  msgstr ""
106
 
107
  #: include/class-email-log-list-table.php:56
108
+ msgid ""
109
+ "This addon allows you to send a copy of all emails send from WordPress to "
110
+ "another email address"
111
  msgstr ""
112
 
113
  #: include/class-email-log-list-table.php:57
125
  msgstr ""
126
 
127
  #: include/class-email-log-list-table.php:63
128
+ msgid ""
129
+ "Adds more fields (From, CC, BCC, Reply To, Attachment) to the logs page."
130
  msgstr ""
131
 
132
  #: include/class-email-log-list-table.php:88
143
  msgstr ""
144
 
145
  #: include/class-email-log-list-table.php:171
146
+ #: include/class-email-log-list-table.php:224
147
  msgid "Delete"
148
  msgstr ""
149
 
155
  msgid "View Content"
156
  msgstr ""
157
 
158
+ #: include/class-email-log-list-table.php:225
159
+ msgid "Delete All Logs"
160
+ msgstr ""
161
+
162
+ #: include/class-email-log-list-table.php:331
163
  msgid "Your email log is empty"
164
  msgstr ""
165
 
203
  #: tmp_addon/email-log-more-fields.php:84
204
  msgid "Attachment"
205
  msgstr ""
 
 
 
206
 
207
  #. Plugin URI of the plugin/theme
208
  msgid "http://sudarmuthu.com/wordpress/email-log"
readme.txt CHANGED
@@ -1,117 +1,122 @@
1
- === Email Log ===
2
- Contributors: sudar
3
- Tags: email, wpmu, wordpress-mu, log
4
- Requires at least: 3.3
5
- Tested up to: 3.8.1
6
- Stable tag: 1.6.2
7
-
8
- Logs every email sent through WordPress
9
-
10
- == Description ==
11
-
12
  Logs every email sent through WordPress and provides a UI where you can view them.
13
-
14
- ### Viewing logged emails
15
-
16
- The logged emails will be stored in a separate table and can be viewed from the admin interface. While viewing the logs, the emails can be filtered or sorted based on the date, email, subject etc.
17
-
18
- ### Deleting logged emails
19
-
20
- In the admin interface, all the logged emails can be delete in bulk or can also be selectively deleted based on date, email and subject.
21
-
22
- ### Forward email (Pro addon)
23
-
24
- You can [buy the Forward email pro addon](http://sudarmuthu.com/wordpress/email-log/pro-addons#forward-email-addon), which allows you to send a copy of all the emails send from WordPress, to another email address. The addon 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. The cost of the addon is $15 and you can buy it through [paypal](http://sudarmuthu.com/out/buy-email-log-forward-email-addon).
25
-
26
- ### More Fields (Pro addon)
27
-
28
- You can [buy the More Fields pro addon](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon), which shows additional fields in the email log page. The following are the additional fields that are added by this addon.
29
-
30
- - From
31
- - CC
32
- - BCC
33
- - Reply To
34
- - Attachment
35
-
36
- The cost of the addon is $15 and you can buy it through [paypal](http://sudarmuthu.com/out/buy-email-log-more-fields-addon).
37
-
38
-
39
- ### Cleaning up db on uninstall
40
-
41
- As [recommended by Ozh][1], the Plugin has an uninstall hook which will clean up the database when the Plugin is uninstalled.
42
-
43
- [1]: http://sudarmuthu.com/blog/2009/10/07/lessons-from-wordpress-plugin-competition.html
44
-
45
- ### Development
46
-
47
- The development of the Plugin happens over at [github](http://github.com/sudar/email-log). If you want to contribute to the Plugin, [fork the project at github](http://github.com/sudar/email-log) and send me a pull request.
48
-
49
- If you are not familiar with either git or Github then refer to this [guide to see how fork and send pull request](http://sudarmuthu.com/blog/contributing-to-project-hosted-in-github).
50
-
51
- If you are looking for ideas, then you can start with one of the following TODO items :)
52
-
53
- ### TODO for Future releases
54
-
55
- The following are the features that I am thinking of adding to the Plugin, when I get some free time. If you have any feature request or want to increase the priority of a particular feature, then let me know.
56
-
57
- - Add option to automatically delete the logs periodically
58
- - Make it MU compatible
59
- - Add the ability to resend the emails
60
-
61
- ### Support
62
-
63
- - If you have found a bug/issue or have a feature request, then post them in [github issues](https://github.com/sudar/email-log/issues)
64
- - If you have a question about usage or need help to troubleshoot, then post in WordPress forums or leave a comment in [Plugins's home page][1]
65
- - If you like the Plugin, then kindly leave a review/feedback at [WordPress repo page][7].
66
- - If you find this Plugin useful or and wanted to say thank you, then there are ways to [make me happy](http://sudarmuthu.com/if-you-wanna-thank-me) :) and I would really appreciate if you can do one of those.
67
- - If anything else, then contact me in [twitter][2].
68
-
69
- ### Stay updated
70
-
71
- I would be posting updates about this Plugin in my [blog][3] and in [Twitter][2]. If you want to be informed when new version of this Plugin is released, then you can either subscribe to this [blog's RSS feed][4] or [follow me in Twitter][2].
72
-
73
- You can also checkout some of the [other Plugins that I have released][5].
74
-
75
- [1]: http://sudarmuthu.com/wordpress/email-log
76
- [2]: http://twitter.com/sudarmuthu
77
- [3]: http://sudarmuthu.com/blog
78
- [4]: http://sudarmuthu.com/feed
79
- [5]: http://sudarmuthu.com/wordpress
80
- [7]: http://wordpress.org/extend/plugins/email-log
81
-
82
- == Translation ==
83
-
84
- The Plugin currently has translations for the following languages.
85
-
86
- * German (Thanks Frank)
87
- * Lithuanian (Thanks Vincent G)
88
- * Dutch (Thanks Zjan Preijde)
89
-
90
- The pot file is available with the Plugin. If you are willing to do translation for the Plugin, use the pot file to create the .po files for your language and let me know. I will add it to the Plugin after giving credit to you.
91
-
92
- == Installation ==
93
-
94
- ### Normal WordPress installations
95
-
96
- Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
97
-
98
- == Screenshots ==
99
-
100
- 1. The above screenshot shows how the logged emails will be displayed by the Plugin
101
-
102
- 2. This screenshot shows how you can configure the email display screen. You can choose the fields and the number of emails per page
103
-
104
- 3. This screenshot shows the additional fields that will be added by the [more fields](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon) addon
105
-
106
- 4. The above screenshot shows how the logged emails will be displayed by the Plugin after you install the [more fields](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon) addon
107
-
108
- 5. This screenshot shows the settings page of [forward email](http://sudarmuthu.com/wordpress/email-log/pro-addons#forward-email-addon) addon
109
-
110
- == Readme Generator ==
111
-
112
- This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/wp-readme'>wp-readme</a>, which generates readme files for WordPress Plugins.
113
  == Changelog ==
114
 
 
 
 
 
 
115
  = v1.6.2 (2014-01-27) - (Dev time: 0.5 hours) =
116
  - Fix: Fix unexpected output while activating the plugin
117
 
@@ -175,7 +180,7 @@ This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/
175
  = v0.6 (2012-04-29) (Dev time: 2 hours) =
176
  - Added option to delete individual email logs
177
  - Moved pages per screen option to Screen options panel
178
- - Added information to the screen help tab
179
  - Added Lithuanian translations
180
 
181
  = v0.5 (2012-01-01) =
1
+ === Email Log ===
2
+ Contributors: sudar
3
+ Tags: email, wpmu, wordpress-mu, log
4
+ Requires at least: 3.3
5
+ Tested up to: 3.8.1
6
+ Stable tag: 1.7
7
+
8
+ Logs every email sent through WordPress. Works with WordPress Multisite as well
9
+
10
+ == Description ==
11
+
12
  Logs every email sent through WordPress and provides a UI where you can view them.
13
+
14
+ ### Viewing logged emails
15
+
16
+ The logged emails will be stored in a separate table and can be viewed from the admin interface. While viewing the logs, the emails can be filtered or sorted based on the date, email, subject etc.
17
+
18
+ ### Deleting logged emails
19
+
20
+ In the admin interface, all the logged emails can be delete in bulk or can also be selectively deleted based on date, email and subject.
21
+
22
+ ### Forward email (Pro addon)
23
+
24
+ You can [buy the Forward email pro addon](http://sudarmuthu.com/wordpress/email-log/pro-addons#forward-email-addon), which allows you to send a copy of all the emails send from WordPress, to another email address. The addon 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. The cost of the addon is $15 and you can buy it through [paypal](http://sudarmuthu.com/out/buy-email-log-forward-email-addon).
25
+
26
+ ### More Fields (Pro addon)
27
+
28
+ You can [buy the More Fields pro addon](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon), which shows additional fields in the email log page. The following are the additional fields that are added by this addon.
29
+
30
+ - From
31
+ - CC
32
+ - BCC
33
+ - Reply To
34
+ - Attachment
35
+
36
+ The cost of the addon is $15 and you can buy it through [paypal](http://sudarmuthu.com/out/buy-email-log-more-fields-addon).
37
+
38
+
39
+ ### Cleaning up db on uninstall
40
+
41
+ As [recommended by Ozh][1], the Plugin has an uninstall hook which will clean up the database when the Plugin is uninstalled.
42
+
43
+ [1]: http://sudarmuthu.com/blog/2009/10/07/lessons-from-wordpress-plugin-competition.html
44
+
45
+ ### Development
46
+
47
+ The development of the Plugin happens over at [github](http://github.com/sudar/email-log). If you want to contribute to the Plugin, [fork the project at github](http://github.com/sudar/email-log) and send me a pull request.
48
+
49
+ If you are not familiar with either git or Github then refer to this [guide to see how fork and send pull request](http://sudarmuthu.com/blog/contributing-to-project-hosted-in-github).
50
+
51
+ If you are looking for ideas, then you can start with one of the following TODO items :)
52
+
53
+ ### TODO for Future releases
54
+
55
+ The following are the features that I am thinking of adding to the Plugin, when I get some free time. If you have any feature request or want to increase the priority of a particular feature, then let me know.
56
+
57
+ - Add option to automatically delete the logs periodically
58
+ - Add the ability to resend the emails
59
+ - <strike>Make it MU compatible</strike>. Done in v1.7
60
+
61
+ ### Support
62
+
63
+ - If you have found a bug/issue or have a feature request, then post them in [github issues](https://github.com/sudar/email-log/issues)
64
+ - If you have a question about usage or need help to troubleshoot, then post in WordPress forums or leave a comment in [Plugins's home page][1]
65
+ - If you like the Plugin, then kindly leave a review/feedback at [WordPress repo page][7].
66
+ - If you find this Plugin useful or and wanted to say thank you, then there are ways to [make me happy](http://sudarmuthu.com/if-you-wanna-thank-me) :) and I would really appreciate if you can do one of those.
67
+ - If anything else, then contact me in [twitter][2].
68
+
69
+ ### Stay updated
70
+
71
+ I would be posting updates about this Plugin in my [blog][3] and in [Twitter][2]. If you want to be informed when new version of this Plugin is released, then you can either subscribe to this [blog's RSS feed][4] or [follow me in Twitter][2].
72
+
73
+ You can also checkout some of the [other Plugins that I have released][5].
74
+
75
+ [1]: http://sudarmuthu.com/wordpress/email-log
76
+ [2]: http://twitter.com/sudarmuthu
77
+ [3]: http://sudarmuthu.com/blog
78
+ [4]: http://sudarmuthu.com/feed
79
+ [5]: http://sudarmuthu.com/wordpress
80
+ [7]: http://wordpress.org/extend/plugins/email-log
81
+
82
+ == Translation ==
83
+
84
+ The Plugin currently has translations for the following languages.
85
+
86
+ * German (Thanks Frank)
87
+ * Lithuanian (Thanks Vincent G)
88
+ * Dutch (Thanks Zjan Preijde)
89
+
90
+ The pot file is available with the Plugin. If you are willing to do translation for the Plugin, use the pot file to create the .po files for your language and let me know. I will add it to the Plugin after giving credit to you.
91
+
92
+ == Installation ==
93
+
94
+ ### Normal WordPress installations
95
+
96
+ Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from Plugins page.
97
+
98
+ == Screenshots ==
99
+
100
+ 1. The above screenshot shows how the logged emails will be displayed by the Plugin
101
+
102
+ 2. This screenshot shows how you can configure the email display screen. You can choose the fields and the number of emails per page
103
+
104
+ 3. This screenshot shows the additional fields that will be added by the [more fields](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon) addon
105
+
106
+ 4. The above screenshot shows how the logged emails will be displayed by the Plugin after you install the [more fields](http://sudarmuthu.com/wordpress/email-log/pro-addons#more-fields-addon) addon
107
+
108
+ 5. This screenshot shows the settings page of [forward email](http://sudarmuthu.com/wordpress/email-log/pro-addons#forward-email-addon) addon
109
+
110
+ == Readme Generator ==
111
+
112
+ This Readme file was generated using <a href = 'http://sudarmuthu.com/wordpress/wp-readme'>wp-readme</a>, which generates readme files for WordPress Plugins.
113
  == Changelog ==
114
 
115
+ = v1.7 (2014-03-29) - (Dev time: 2.5 hours) =
116
+ - Fix: Fix whitespace
117
+ - New: Add support for WordPress Multisite (issue #18)
118
+ - New: Add ability to delete all logs at once (issue #19)
119
+
120
  = v1.6.2 (2014-01-27) - (Dev time: 0.5 hours) =
121
  - Fix: Fix unexpected output while activating the plugin
122
 
180
  = v0.6 (2012-04-29) (Dev time: 2 hours) =
181
  - Added option to delete individual email logs
182
  - Moved pages per screen option to Screen options panel
183
+ - Added information to the screen help tab
184
  - Added Lithuanian translations
185
 
186
  = v0.5 (2012-01-01) =
uninstall.php CHANGED
@@ -1,19 +1,50 @@
1
  <?php
 
 
 
 
 
 
 
2
  // uninstall page for Email Log Plugin to clean up db.
3
- // Code based on this article http://jacobsantos.com/2008/general/wordpress-27-plugin-uninstall-methods/
4
-
5
- if( !defined( 'ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') )
6
  exit();
7
 
8
- global $wpdb;
9
- $smel_table_name = $wpdb->prefix . "email_log"; // This is hardcoded on purpose
 
 
 
 
 
 
 
 
 
10
 
11
- if($wpdb->get_var("show tables like '{$smel_table_name}'") == $smel_table_name) {
12
- // If table is present, drop it
13
- $sql = "DROP TABLE $smel_table_name";
14
- $wpdb->query($sql);
15
  }
16
 
17
- // Delete the option
18
- delete_option('email-log-db');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ?>
1
  <?php
2
+ /**
3
+ * Uninstall Email Log plugin
4
+ *
5
+ * @package Email Log
6
+ * @subpackage Uninstall
7
+ * @author Sudar
8
+ */
9
  // uninstall page for Email Log Plugin to clean up db.
10
+ if( !defined( 'ABSPATH' ) && !defined( 'WP_UNINSTALL_PLUGIN' ) )
 
 
11
  exit();
12
 
13
+ if ( is_multisite() ) {
14
+ global $wpdb;
15
+
16
+ $original_blog_id = get_current_blog_id();
17
+
18
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
19
+
20
+ foreach ( $blog_ids as $blog_id ) {
21
+ switch_to_blog( $blog_id );
22
+ email_log_delete_table();
23
+ }
24
 
25
+ switch_to_blog( $original_blog_id );
26
+
27
+ } else {
28
+ email_log_delete_table();
29
  }
30
 
31
+ /**
32
+ * Delete email log table and db option
33
+ *
34
+ * @since 1.7
35
+ *
36
+ * @global object $wpdb
37
+ */
38
+ function email_log_delete_table() {
39
+ global $wpdb;
40
+ $table_name = $wpdb->prefix . "email_log"; // This is hardcoded on purpose
41
+
42
+ if( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) {
43
+ // If table is present, drop it
44
+ $wpdb->query( "DROP TABLE $table_name" );
45
+ }
46
+
47
+ // Delete the option
48
+ delete_option('email-log-db');
49
+ }
50
  ?>