@@ -32,19 +32,19 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @since 1.7.2 |
34 | 34 | */ |
35 | -if ( ! defined( 'EMAIL_LOG_PLUGIN_FILE' ) ) { |
|
36 | - define( 'EMAIL_LOG_PLUGIN_FILE', __FILE__ ); |
|
35 | +if ( ! defined('EMAIL_LOG_PLUGIN_FILE')) { |
|
36 | + define('EMAIL_LOG_PLUGIN_FILE', __FILE__); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Handles installation and table creation. |
41 | 41 | */ |
42 | -require_once plugin_dir_path( __FILE__ ) . 'include/install.php'; |
|
42 | +require_once plugin_dir_path(__FILE__) . 'include/install.php'; |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Helper functions. |
46 | 46 | */ |
47 | -require_once plugin_dir_path( __FILE__ ) . 'include/util/helper.php'; |
|
47 | +require_once plugin_dir_path(__FILE__) . 'include/util/helper.php'; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * The main plugin class. |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @since Genesis |
77 | 77 | * @var const VERSION |
78 | 78 | */ |
79 | - const VERSION = '1.9'; |
|
79 | + const VERSION = '1.9'; |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Filter name. |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @since Genesis |
85 | 85 | * @var const FILTER_NAME |
86 | 86 | */ |
87 | - const FILTER_NAME = 'wp_mail_log'; |
|
87 | + const FILTER_NAME = 'wp_mail_log'; |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * Page slug to be used in admin dashboard hyperlinks. |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @since Genesis |
93 | 93 | * @var const PAGE_SLUG |
94 | 94 | */ |
95 | - const PAGE_SLUG = 'email-log'; |
|
95 | + const PAGE_SLUG = 'email-log'; |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * String value to generate nonce. |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @since Genesis |
101 | 101 | * @var const DELETE_LOG_NONCE_FIELD |
102 | 102 | */ |
103 | - const DELETE_LOG_NONCE_FIELD = 'sm-delete-email-log-nonce'; |
|
103 | + const DELETE_LOG_NONCE_FIELD = 'sm-delete-email-log-nonce'; |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * String value to generate nonce. |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | const DELETE_LOG_ACTION = 'sm-delete-email-log'; |
112 | 112 | |
113 | 113 | // DB stuff |
114 | - const TABLE_NAME = 'email_log'; /* Database table name */ |
|
115 | - const DB_OPTION_NAME = 'email-log-db'; /* Database option name */ |
|
116 | - const DB_VERSION = '0.1'; /* Database version */ |
|
114 | + const TABLE_NAME = 'email_log'; /* Database table name */ |
|
115 | + const DB_OPTION_NAME = 'email-log-db'; /* Database option name */ |
|
116 | + const DB_VERSION = '0.1'; /* Database version */ |
|
117 | 117 | |
118 | 118 | // JS Stuff |
119 | 119 | const JS_HANDLE = 'email-log'; |
@@ -126,25 +126,25 @@ discard block |
||
126 | 126 | * Initialize the plugin by registering the hooks. |
127 | 127 | */ |
128 | 128 | function __construct() { |
129 | - $this->include_path = plugin_dir_path( __FILE__ ); |
|
129 | + $this->include_path = plugin_dir_path(__FILE__); |
|
130 | 130 | |
131 | 131 | // Load localization domain. |
132 | - $this->translations = dirname( plugin_basename( __FILE__ ) ) . '/languages/' ; |
|
133 | - load_plugin_textdomain( 'email-log', false, $this->translations ); |
|
132 | + $this->translations = dirname(plugin_basename(__FILE__)) . '/languages/'; |
|
133 | + load_plugin_textdomain('email-log', false, $this->translations); |
|
134 | 134 | |
135 | 135 | // Register hooks. |
136 | - add_action( 'admin_menu', array( $this, 'register_settings_page' ) ); |
|
136 | + add_action('admin_menu', array($this, 'register_settings_page')); |
|
137 | 137 | |
138 | 138 | // Register Filter. |
139 | - add_filter( 'wp_mail', array( $this, 'log_email' ) ); |
|
140 | - add_filter( 'set-screen-option', array( $this, 'save_screen_options' ), 10, 3 ); |
|
141 | - add_filter( 'plugin_row_meta', array( $this, 'add_plugin_links' ), 10, 2 ); |
|
139 | + add_filter('wp_mail', array($this, 'log_email')); |
|
140 | + add_filter('set-screen-option', array($this, 'save_screen_options'), 10, 3); |
|
141 | + add_filter('plugin_row_meta', array($this, 'add_plugin_links'), 10, 2); |
|
142 | 142 | |
143 | - $plugin = plugin_basename( __FILE__ ); |
|
144 | - add_filter( "plugin_action_links_$plugin", array( $this, 'add_action_links' ) ); |
|
143 | + $plugin = plugin_basename(__FILE__); |
|
144 | + add_filter("plugin_action_links_$plugin", array($this, 'add_action_links')); |
|
145 | 145 | |
146 | 146 | // Add our ajax call. |
147 | - add_action( 'wp_ajax_display_content', array( $this, 'display_content_callback' ) ); |
|
147 | + add_action('wp_ajax_display_content', array($this, 'display_content_callback')); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -159,13 +159,13 @@ discard block |
||
159 | 159 | * @param string $file The name of the plugin file. |
160 | 160 | * @return array Array with links to display in plugins page. |
161 | 161 | */ |
162 | - public function add_plugin_links( $links, $file ) { |
|
163 | - $plugin = plugin_basename( __FILE__ ); |
|
162 | + public function add_plugin_links($links, $file) { |
|
163 | + $plugin = plugin_basename(__FILE__); |
|
164 | 164 | |
165 | - if ( $file == $plugin ) { |
|
165 | + if ($file == $plugin) { |
|
166 | 166 | // only for this plugin |
167 | - return array_merge( $links, |
|
168 | - array( '<a href="http://sudarmuthu.com/wordpress/email-log/pro-addons" target="_blank">' . __( 'Buy Addons', 'email-log' ) . '</a>' ) |
|
167 | + return array_merge($links, |
|
168 | + array('<a href="http://sudarmuthu.com/wordpress/email-log/pro-addons" target="_blank">' . __('Buy Addons', 'email-log') . '</a>') |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | return $links; |
@@ -178,9 +178,9 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function register_settings_page() { |
180 | 180 | // Save the handle to your admin page - you'll need it to create a WP_Screen object |
181 | - $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' ) ); |
|
181 | + $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')); |
|
182 | 182 | |
183 | - add_action( "load-{$this->admin_page}", array( $this, 'create_settings_panel' ) ); |
|
183 | + add_action("load-{$this->admin_page}", array($this, 'create_settings_panel')); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -191,33 +191,33 @@ discard block |
||
191 | 191 | public function display_logs() { |
192 | 192 | add_thickbox(); |
193 | 193 | |
194 | - $this->logs_table->prepare_items( $this->get_per_page() ); |
|
194 | + $this->logs_table->prepare_items($this->get_per_page()); |
|
195 | 195 | ?> |
196 | 196 | <div class="wrap"> |
197 | - <h2><?php _e( 'Email Logs', 'email-log' );?></h2> |
|
197 | + <h2><?php _e('Email Logs', 'email-log'); ?></h2> |
|
198 | 198 | <?php |
199 | - if ( isset( $this->logs_deleted ) && $this->logs_deleted != '' ) { |
|
200 | - $logs_deleted = intval( $this->logs_deleted ); |
|
199 | + if (isset($this->logs_deleted) && $this->logs_deleted != '') { |
|
200 | + $logs_deleted = intval($this->logs_deleted); |
|
201 | 201 | |
202 | - if ( $logs_deleted > 0 ) { |
|
203 | - echo '<div class="updated"><p>' . sprintf( _n( '1 email log deleted.', '%s email logs deleted', $logs_deleted, 'email-log' ), $logs_deleted ) . '</p></div>'; |
|
202 | + if ($logs_deleted > 0) { |
|
203 | + echo '<div class="updated"><p>' . sprintf(_n('1 email log deleted.', '%s email logs deleted', $logs_deleted, 'email-log'), $logs_deleted) . '</p></div>'; |
|
204 | 204 | } else { |
205 | - echo '<div class="updated"><p>' . __( 'There was some problem in deleting the email logs' , 'email-log' ) . '</p></div>'; |
|
205 | + echo '<div class="updated"><p>' . __('There was some problem in deleting the email logs', 'email-log') . '</p></div>'; |
|
206 | 206 | } |
207 | - unset( $this->logs_deleted ); |
|
207 | + unset($this->logs_deleted); |
|
208 | 208 | } |
209 | 209 | ?> |
210 | 210 | <form id="email-logs-search" method="get"> |
211 | 211 | <input type="hidden" name="page" value="<?php echo self::PAGE_SLUG; ?>" > |
212 | 212 | <?php |
213 | - $this->logs_table->search_box( __( 'Search Logs', 'email-log' ), 'search_id' ); |
|
213 | + $this->logs_table->search_box(__('Search Logs', 'email-log'), 'search_id'); |
|
214 | 214 | ?> |
215 | 215 | </form> |
216 | 216 | |
217 | 217 | <form id="email-logs-filter" method="get"> |
218 | 218 | <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" /> |
219 | 219 | <?php |
220 | - wp_nonce_field( self::DELETE_LOG_ACTION, self::DELETE_LOG_NONCE_FIELD ); |
|
220 | + wp_nonce_field(self::DELETE_LOG_ACTION, self::DELETE_LOG_NONCE_FIELD); |
|
221 | 221 | $this->logs_table->display(); |
222 | 222 | ?> |
223 | 223 | </form> |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @since 1.8 |
230 | 230 | */ |
231 | - do_action( 'el_admin_footer' ); |
|
231 | + do_action('el_admin_footer'); |
|
232 | 232 | |
233 | 233 | // Display credits in Footer |
234 | - add_action( 'in_admin_footer', array( $this, 'add_footer_links' ) ); |
|
234 | + add_action('in_admin_footer', array($this, 'add_footer_links')); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -245,43 +245,43 @@ discard block |
||
245 | 245 | * Create the WP_Screen object against your admin page handle |
246 | 246 | * This ensures we're working with the right admin page |
247 | 247 | */ |
248 | - $this->admin_screen = WP_Screen::get( $this->admin_page ); |
|
248 | + $this->admin_screen = WP_Screen::get($this->admin_page); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Content specified inline |
252 | 252 | */ |
253 | 253 | $this->admin_screen->add_help_tab( |
254 | 254 | array( |
255 | - 'title' => __( 'About Plugin', 'email-log' ), |
|
255 | + 'title' => __('About Plugin', 'email-log'), |
|
256 | 256 | 'id' => 'about_tab', |
257 | - 'content' => '<p>' . __( 'Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress.', 'email-log' ) . '</p>', |
|
257 | + 'content' => '<p>' . __('Email Log WordPress Plugin, allows you to log all emails that are sent through WordPress.', 'email-log') . '</p>', |
|
258 | 258 | 'callback' => false, |
259 | 259 | ) |
260 | 260 | ); |
261 | 261 | |
262 | 262 | // Add help sidebar |
263 | 263 | $this->admin_screen->set_help_sidebar( |
264 | - '<p><strong>' . __( 'More information', 'email-log' ) . '</strong></p>' . |
|
265 | - '<p><a href = "http://sudarmuthu.com/wordpress/email-log">' . __( 'Plugin Homepage/support', 'email-log' ) . '</a></p>' . |
|
266 | - '<p><a href = "http://sudarmuthu.com/blog">' . __( "Plugin author's blog", 'email-log' ) . '</a></p>' . |
|
267 | - '<p><a href = "http://sudarmuthu.com/wordpress/">' . __( "Other Plugin's by Author", 'email-log' ) . '</a></p>' |
|
264 | + '<p><strong>' . __('More information', 'email-log') . '</strong></p>' . |
|
265 | + '<p><a href = "http://sudarmuthu.com/wordpress/email-log">' . __('Plugin Homepage/support', 'email-log') . '</a></p>' . |
|
266 | + '<p><a href = "http://sudarmuthu.com/blog">' . __("Plugin author's blog", 'email-log') . '</a></p>' . |
|
267 | + '<p><a href = "http://sudarmuthu.com/wordpress/">' . __("Other Plugin's by Author", 'email-log') . '</a></p>' |
|
268 | 268 | ); |
269 | 269 | |
270 | 270 | // Add screen options |
271 | 271 | $this->admin_screen->add_option( |
272 | 272 | 'per_page', |
273 | 273 | array( |
274 | - 'label' => __( 'Entries per page', 'email-log' ), |
|
274 | + 'label' => __('Entries per page', 'email-log'), |
|
275 | 275 | 'default' => 20, |
276 | 276 | 'option' => 'per_page', |
277 | 277 | ) |
278 | 278 | ); |
279 | 279 | |
280 | - if ( ! class_exists( 'WP_List_Table' ) ) { |
|
280 | + if ( ! class_exists('WP_List_Table')) { |
|
281 | 281 | require_once ABSPATH . WPINC . '/class-wp-list-table.php'; |
282 | 282 | } |
283 | 283 | |
284 | - if ( ! class_exists( 'Email_Log_List_Table' ) ) { |
|
284 | + if ( ! class_exists('Email_Log_List_Table')) { |
|
285 | 285 | require_once $this->include_path . 'include/class-email-log-list-table.php'; |
286 | 286 | } |
287 | 287 | |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | global $wpdb; |
299 | 299 | |
300 | 300 | $table_name = $wpdb->prefix . self::TABLE_NAME; |
301 | - $email_id = absint( $_GET['email_id'] ); |
|
301 | + $email_id = absint($_GET['email_id']); |
|
302 | 302 | |
303 | - $query = $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE id = %d', $email_id ); |
|
304 | - $content = $wpdb->get_results( $query ); |
|
303 | + $query = $wpdb->prepare('SELECT * FROM ' . $table_name . ' WHERE id = %d', $email_id); |
|
304 | + $content = $wpdb->get_results($query); |
|
305 | 305 | |
306 | - echo wpautop( $content[0]->message ); |
|
306 | + echo wpautop($content[0]->message); |
|
307 | 307 | |
308 | 308 | die(); // this is required to return a proper result |
309 | 309 | } |
@@ -318,8 +318,8 @@ discard block |
||
318 | 318 | * @param int $value The number of rows to use. |
319 | 319 | * @return bool|int |
320 | 320 | */ |
321 | - function save_screen_options( $status, $option, $value ) { |
|
322 | - if ( 'per_page' == $option ) { |
|
321 | + function save_screen_options($status, $option, $value) { |
|
322 | + if ('per_page' == $option) { |
|
323 | 323 | return $value; |
324 | 324 | } else { |
325 | 325 | return $status; |
@@ -335,12 +335,12 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public static function get_per_page() { |
337 | 337 | $screen = get_current_screen(); |
338 | - $option = $screen->get_option( 'per_page', 'option' ); |
|
338 | + $option = $screen->get_option('per_page', 'option'); |
|
339 | 339 | |
340 | - $per_page = get_user_meta( get_current_user_id(), $option, true ); |
|
340 | + $per_page = get_user_meta(get_current_user_id(), $option, true); |
|
341 | 341 | |
342 | - if ( empty( $per_page ) || $per_page < 1 ) { |
|
343 | - $per_page = $screen->get_option( 'per_page', 'default' ); |
|
342 | + if (empty($per_page) || $per_page < 1) { |
|
343 | + $per_page = $screen->get_option('per_page', 'default'); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | return $per_page; |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | * @param array $links |
355 | 355 | * @return array |
356 | 356 | */ |
357 | - public function add_action_links( $links ) { |
|
357 | + public function add_action_links($links) { |
|
358 | 358 | // Add a link to this plugin's settings page |
359 | - $settings_link = '<a href="tools.php?page=email-log">' . __( 'Log', 'email-log' ) . '</a>'; |
|
360 | - array_unshift( $links, $settings_link ); |
|
359 | + $settings_link = '<a href="tools.php?page=email-log">' . __('Log', 'email-log') . '</a>'; |
|
360 | + array_unshift($links, $settings_link); |
|
361 | 361 | return $links; |
362 | 362 | } |
363 | 363 | |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | * @link http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/ |
371 | 371 | */ |
372 | 372 | public function add_footer_links() { |
373 | - $plugin_data = get_plugin_data( __FILE__ ); |
|
374 | - 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'] ); |
|
373 | + $plugin_data = get_plugin_data(__FILE__); |
|
374 | + 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']); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -384,21 +384,21 @@ discard block |
||
384 | 384 | * @param array $mail_info Information about email. |
385 | 385 | * @return array Information about email. |
386 | 386 | */ |
387 | - public function log_email( $mail_info ) { |
|
387 | + public function log_email($mail_info) { |
|
388 | 388 | global $wpdb; |
389 | 389 | |
390 | - $attachment_present = ( count( $mail_info['attachments'] ) > 0 ) ? 'true' : 'false'; |
|
390 | + $attachment_present = (count($mail_info['attachments']) > 0) ? 'true' : 'false'; |
|
391 | 391 | |
392 | 392 | // return filtered array |
393 | - $mail_info = apply_filters( self::FILTER_NAME, $mail_info ); |
|
393 | + $mail_info = apply_filters(self::FILTER_NAME, $mail_info); |
|
394 | 394 | $table_name = $wpdb->prefix . self::TABLE_NAME; |
395 | 395 | |
396 | - if ( isset( $mail_info['message'] ) ) { |
|
396 | + if (isset($mail_info['message'])) { |
|
397 | 397 | $message = $mail_info['message']; |
398 | 398 | } else { |
399 | 399 | // wpmandrill plugin is changing "message" key to "html". See https://github.com/sudar/email-log/issues/20 |
400 | 400 | // Ideally this should be fixed in wpmandrill, but I am including this hack here till it is fixed by them. |
401 | - if ( isset( $mail_info['html'] ) ) { |
|
401 | + if (isset($mail_info['html'])) { |
|
402 | 402 | $message = $mail_info['html']; |
403 | 403 | } else { |
404 | 404 | $message = ''; |
@@ -406,14 +406,14 @@ discard block |
||
406 | 406 | } |
407 | 407 | |
408 | 408 | // Log into the database |
409 | - $wpdb->insert( $table_name, array( |
|
410 | - 'to_email' => is_array( $mail_info['to'] ) ? implode( ',', $mail_info['to'] ) : $mail_info['to'], |
|
409 | + $wpdb->insert($table_name, array( |
|
410 | + 'to_email' => is_array($mail_info['to']) ? implode(',', $mail_info['to']) : $mail_info['to'], |
|
411 | 411 | 'subject' => $mail_info['subject'], |
412 | 412 | 'message' => $message, |
413 | - 'headers' => is_array( $mail_info['headers'] ) ? implode( "\n", $mail_info['headers'] ) : $mail_info['headers'], |
|
413 | + 'headers' => is_array($mail_info['headers']) ? implode("\n", $mail_info['headers']) : $mail_info['headers'], |
|
414 | 414 | 'attachments' => $attachment_present, |
415 | - 'sent_date' => current_time( 'mysql' ), |
|
416 | - ) ); |
|
415 | + 'sent_date' => current_time('mysql'), |
|
416 | + )); |
|
417 | 417 | |
418 | 418 | return $mail_info; |
419 | 419 | } |
@@ -431,5 +431,5 @@ discard block |
||
431 | 431 | global $EmailLog; |
432 | 432 | $EmailLog = new EmailLog(); |
433 | 433 | } |
434 | -add_action( 'init', 'email_log' ); |
|
434 | +add_action('init', 'email_log'); |
|
435 | 435 | ?> |