@@ -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.1'; |
|
| 79 | + const VERSION = '1.9.1'; |
|
| 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 | |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | public function display_content_callback() { |
| 298 | 298 | global $wpdb; |
| 299 | 299 | |
| 300 | - if ( current_user_can( 'manage_options' ) ) { |
|
| 300 | + if (current_user_can('manage_options')) { |
|
| 301 | 301 | $table_name = $wpdb->prefix . self::TABLE_NAME; |
| 302 | - $email_id = absint( $_GET['email_id'] ); |
|
| 302 | + $email_id = absint($_GET['email_id']); |
|
| 303 | 303 | |
| 304 | - $query = $wpdb->prepare( 'SELECT * FROM ' . $table_name . ' WHERE id = %d', $email_id ); |
|
| 305 | - $content = $wpdb->get_results( $query ); |
|
| 304 | + $query = $wpdb->prepare('SELECT * FROM ' . $table_name . ' WHERE id = %d', $email_id); |
|
| 305 | + $content = $wpdb->get_results($query); |
|
| 306 | 306 | |
| 307 | - echo wpautop( $content[0]->message ); |
|
| 307 | + echo wpautop($content[0]->message); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | die(); // this is required to return a proper result |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @param int $value The number of rows to use. |
| 321 | 321 | * @return bool|int |
| 322 | 322 | */ |
| 323 | - function save_screen_options( $status, $option, $value ) { |
|
| 324 | - if ( 'per_page' == $option ) { |
|
| 323 | + function save_screen_options($status, $option, $value) { |
|
| 324 | + if ('per_page' == $option) { |
|
| 325 | 325 | return $value; |
| 326 | 326 | } else { |
| 327 | 327 | return $status; |
@@ -337,12 +337,12 @@ discard block |
||
| 337 | 337 | */ |
| 338 | 338 | public static function get_per_page() { |
| 339 | 339 | $screen = get_current_screen(); |
| 340 | - $option = $screen->get_option( 'per_page', 'option' ); |
|
| 340 | + $option = $screen->get_option('per_page', 'option'); |
|
| 341 | 341 | |
| 342 | - $per_page = get_user_meta( get_current_user_id(), $option, true ); |
|
| 342 | + $per_page = get_user_meta(get_current_user_id(), $option, true); |
|
| 343 | 343 | |
| 344 | - if ( empty( $per_page ) || $per_page < 1 ) { |
|
| 345 | - $per_page = $screen->get_option( 'per_page', 'default' ); |
|
| 344 | + if (empty($per_page) || $per_page < 1) { |
|
| 345 | + $per_page = $screen->get_option('per_page', 'default'); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | return $per_page; |
@@ -356,10 +356,10 @@ discard block |
||
| 356 | 356 | * @param array $links |
| 357 | 357 | * @return array |
| 358 | 358 | */ |
| 359 | - public function add_action_links( $links ) { |
|
| 359 | + public function add_action_links($links) { |
|
| 360 | 360 | // Add a link to this plugin's settings page |
| 361 | - $settings_link = '<a href="tools.php?page=email-log">' . __( 'Log', 'email-log' ) . '</a>'; |
|
| 362 | - array_unshift( $links, $settings_link ); |
|
| 361 | + $settings_link = '<a href="tools.php?page=email-log">' . __('Log', 'email-log') . '</a>'; |
|
| 362 | + array_unshift($links, $settings_link); |
|
| 363 | 363 | return $links; |
| 364 | 364 | } |
| 365 | 365 | |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | * @link http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/ |
| 373 | 373 | */ |
| 374 | 374 | public function add_footer_links() { |
| 375 | - $plugin_data = get_plugin_data( __FILE__ ); |
|
| 376 | - 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 | + $plugin_data = get_plugin_data(__FILE__); |
|
| 376 | + 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']); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | /** |
@@ -386,21 +386,21 @@ discard block |
||
| 386 | 386 | * @param array $mail_info Information about email. |
| 387 | 387 | * @return array Information about email. |
| 388 | 388 | */ |
| 389 | - public function log_email( $mail_info ) { |
|
| 389 | + public function log_email($mail_info) { |
|
| 390 | 390 | global $wpdb; |
| 391 | 391 | |
| 392 | - $attachment_present = ( count( $mail_info['attachments'] ) > 0 ) ? 'true' : 'false'; |
|
| 392 | + $attachment_present = (count($mail_info['attachments']) > 0) ? 'true' : 'false'; |
|
| 393 | 393 | |
| 394 | 394 | // return filtered array |
| 395 | - $mail_info = apply_filters( self::FILTER_NAME, $mail_info ); |
|
| 395 | + $mail_info = apply_filters(self::FILTER_NAME, $mail_info); |
|
| 396 | 396 | $table_name = $wpdb->prefix . self::TABLE_NAME; |
| 397 | 397 | |
| 398 | - if ( isset( $mail_info['message'] ) ) { |
|
| 398 | + if (isset($mail_info['message'])) { |
|
| 399 | 399 | $message = $mail_info['message']; |
| 400 | 400 | } else { |
| 401 | 401 | // wpmandrill plugin is changing "message" key to "html". See https://github.com/sudar/email-log/issues/20 |
| 402 | 402 | // Ideally this should be fixed in wpmandrill, but I am including this hack here till it is fixed by them. |
| 403 | - if ( isset( $mail_info['html'] ) ) { |
|
| 403 | + if (isset($mail_info['html'])) { |
|
| 404 | 404 | $message = $mail_info['html']; |
| 405 | 405 | } else { |
| 406 | 406 | $message = ''; |
@@ -408,14 +408,14 @@ discard block |
||
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | // Log into the database |
| 411 | - $wpdb->insert( $table_name, array( |
|
| 412 | - 'to_email' => is_array( $mail_info['to'] ) ? implode( ',', $mail_info['to'] ) : $mail_info['to'], |
|
| 411 | + $wpdb->insert($table_name, array( |
|
| 412 | + 'to_email' => is_array($mail_info['to']) ? implode(',', $mail_info['to']) : $mail_info['to'], |
|
| 413 | 413 | 'subject' => $mail_info['subject'], |
| 414 | 414 | 'message' => $message, |
| 415 | - 'headers' => is_array( $mail_info['headers'] ) ? implode( "\n", $mail_info['headers'] ) : $mail_info['headers'], |
|
| 415 | + 'headers' => is_array($mail_info['headers']) ? implode("\n", $mail_info['headers']) : $mail_info['headers'], |
|
| 416 | 416 | 'attachments' => $attachment_present, |
| 417 | - 'sent_date' => current_time( 'mysql' ), |
|
| 418 | - ) ); |
|
| 417 | + 'sent_date' => current_time('mysql'), |
|
| 418 | + )); |
|
| 419 | 419 | |
| 420 | 420 | return $mail_info; |
| 421 | 421 | } |
@@ -433,5 +433,5 @@ discard block |
||
| 433 | 433 | global $EmailLog; |
| 434 | 434 | $EmailLog = new EmailLog(); |
| 435 | 435 | } |
| 436 | -add_action( 'init', 'email_log' ); |
|
| 436 | +add_action('init', 'email_log'); |
|
| 437 | 437 | ?> |