| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Email Log |
| 4 |
* Plugin URI: https://wpemaillog.com/ |
| 5 |
* Description: Logs every email sent through WordPress |
| 6 |
* Author: WebFactory Ltd |
| 7 |
* Version: 2.63 |
| 8 |
* Author URI: https://www.webfactoryltd.com/ |
| 9 |
* Text Domain: email-log |
| 10 |
* License: GPLv2 or later |
| 11 |
* Requires at least: 4.0 |
| 12 |
* Tested up to: 7.0 |
| 13 |
* Requires PHP: 5.6 |
| 14 |
*/ |
| 15 |
|
| 16 |
/** |
| 17 |
* Copyright 2026 WebFactory Ltd |
| 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 |
* This program is distributed in the hope that it will be useful, |
| 23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
* GNU General Public License for more details. |
| 26 |
* You should have received a copy of the GNU General Public License |
| 27 |
* along with this program; if not, write to the Free Software |
| 28 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 29 |
*/ |
| 30 |
|
| 31 |
defined('ABSPATH') || exit; // Exit if accessed directly. |
| 32 |
|
| 33 |
define('EMAIL_LOG_FILE', __FILE__); |
| 34 |
define('EMAIL_LOG_URL', trailingslashit(plugins_url('', __FILE__))); |
| 35 |
define('EMAIL_LOG_PATH', trailingslashit(plugin_dir_path(__FILE__))); |
| 36 |
define('EMAIL_LOG_URI', trailingslashit(plugin_dir_url(__FILE__))); |
| 37 |
|
| 38 |
require_once dirname(__FILE__) . '/wf-flyout/wf-flyout.php'; |
| 39 |
|
| 40 |
function load_email_log($plugin_file) |
| 41 |
{ |
| 42 |
global $email_log; |
| 43 |
|
| 44 |
$plugin_dir = plugin_dir_path($plugin_file); |
| 45 |
|
| 46 |
if (is_admin()) { |
| 47 |
new wf_flyout(__FILE__); |
| 48 |
} |
| 49 |
|
| 50 |
// setup autoloader. |
| 51 |
require_once 'include/EmailLogAutoloader.php'; |
| 52 |
|
| 53 |
$loader = new \EmailLog\EmailLogAutoloader(); |
| 54 |
$loader->add_namespace('EmailLog', $plugin_dir . 'include'); |
| 55 |
$loader->add_namespace('Sudar\\WPSystemInfo', $plugin_dir . 'vendor/sudar/wp-system-info/src/'); |
| 56 |
|
| 57 |
if (file_exists($plugin_dir . 'tests/')) { |
| 58 |
// if tests are present, then add them. |
| 59 |
$loader->add_namespace('EmailLog', $plugin_dir . 'tests/wp-tests'); |
| 60 |
} |
| 61 |
|
| 62 |
$loader->add_file($plugin_dir . 'include/Util/helper.php'); |
| 63 |
$loader->add_file($plugin_dir . 'include/Addon/addon-helper.php'); |
| 64 |
|
| 65 |
$loader->register(); |
| 66 |
|
| 67 |
$email_log = new \EmailLog\Core\EmailLog($plugin_file, $loader, new \EmailLog\Core\DB\TableManager()); |
| 68 |
|
| 69 |
$email_log->add_loadie(new \EmailLog\Core\EmailLogger()); |
| 70 |
|
| 71 |
$email_log->add_loadie(new \EmailLog\Core\UI\UILoader(), true); |
| 72 |
|
| 73 |
$email_log->add_loadie(new \EmailLog\Core\Request\NonceChecker()); |
| 74 |
$email_log->add_loadie(new \EmailLog\Core\Request\LogListAction()); |
| 75 |
|
| 76 |
$capability_giver = new \EmailLog\Core\AdminCapabilityGiver(); |
| 77 |
$email_log->add_loadie($capability_giver); |
| 78 |
|
| 79 |
// `register_activation_hook` can't be called from inside any hook. |
| 80 |
register_activation_hook($plugin_file, array($email_log->table_manager, 'on_activate')); |
| 81 |
register_activation_hook($plugin_file, array($capability_giver, 'add_cap_to_admin')); |
| 82 |
|
| 83 |
// Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`. |
| 84 |
// But some plugins like EDD are sending emails in `init` event itself, |
| 85 |
// which won't be logged if the plugin is loaded in `wp_loaded` or `init`. |
| 86 |
add_action('plugins_loaded', array($email_log, 'load'), 101); |
| 87 |
} |
| 88 |
|
| 89 |
function email_log_plugin_version() |
| 90 |
{ |
| 91 |
$plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin'); |
| 92 |
|
| 93 |
return $plugin_data['version']; |
| 94 |
} // get_plugin_version |
| 95 |
|
| 96 |
/** |
| 97 |
* Return the global instance of Email Log plugin. |
| 98 |
* Eventually the EmailLog class might become singleton. |
| 99 |
* |
| 100 |
* @since 2.0 |
| 101 |
* |
| 102 |
* @global \EmailLog\Core\EmailLog $email_log |
| 103 |
* |
| 104 |
* @return \EmailLog\Core\EmailLog |
| 105 |
*/ |
| 106 |
function email_log() |
| 107 |
{ |
| 108 |
global $email_log; |
| 109 |
return $email_log; |
| 110 |
} |
| 111 |
|
| 112 |
load_email_log(__FILE__); |
| 113 |
|