check-email
Last commit date
assets
5 years ago
include
5 years ago
changelog.txt
5 years ago
check-email.php
5 years ago
readme.txt
5 years ago
uninstall.php
5 years ago
check-email.php
117 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Plugin Name: Check & Log Email |
| 4 | * Description: Check & Log email allows you to test if your WordPress installation is sending emails correctly and logs every email. |
| 5 | * Author: WPChill |
| 6 | * Version: 1.0.0 |
| 7 | * Author URI: https://wpchill.com/ |
| 8 | * License: GPLv3 or later |
| 9 | * License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 10 | * Requires PHP: 5.6 |
| 11 | * Text Domain: check-email |
| 12 | * Domain Path: /languages |
| 13 | * |
| 14 | * Copyright 2015-2020 Chris Taylor chris@stillbreathing.co.uk |
| 15 | * Copyright 2020 MachoThemes office@machothemes.com |
| 16 | * Copyright 2020 WPChill heyyy@wpchill.com |
| 17 | * |
| 18 | * NOTE: |
| 19 | * Chris Taylor transferred ownership rights on: 2020-06-19 07:52:03 GMT when ownership was handed over to MachoThemes |
| 20 | * The MachoThemes ownership period started on: 2020-06-19 07:52:03 GMT |
| 21 | * |
| 22 | * This program is free software; you can redistribute it and/or modify |
| 23 | * it under the terms of the GNU General Public License, version 3, as |
| 24 | * published by the Free Software Foundation. |
| 25 | * |
| 26 | * This program is distributed in the hope that it will be useful, |
| 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 29 | * GNU General Public License for more details. |
| 30 | * |
| 31 | * You should have received a copy of the GNU General Public License |
| 32 | * along with this program; if not, write to the Free software |
| 33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 34 | */ |
| 35 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 36 | |
| 37 | if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { |
| 38 | function check_email_compatibility_notice() { |
| 39 | ?> |
| 40 | <div class="error"> |
| 41 | <p> |
| 42 | <?php |
| 43 | printf( |
| 44 | __( 'Check & Log Email requires at least PHP 5.6 to function properly. Please upgrade PHP.', 'check-email' ) |
| 45 | ); |
| 46 | ?> |
| 47 | </p> |
| 48 | </div> |
| 49 | <?php |
| 50 | } |
| 51 | |
| 52 | add_action( 'admin_notices', 'check_email_compatibility_notice' ); |
| 53 | |
| 54 | /** |
| 55 | * Deactivate Email Log. |
| 56 | */ |
| 57 | function check_email_deactivate() { |
| 58 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 59 | } |
| 60 | |
| 61 | add_action( 'admin_init', 'check_email_deactivate' ); |
| 62 | |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Load Check Email Log. |
| 68 | */ |
| 69 | function check_email_log( $plugin_file ) { |
| 70 | global $check_email; |
| 71 | |
| 72 | $plugin_dir = plugin_dir_path( $plugin_file ); |
| 73 | |
| 74 | // setup autoloader. |
| 75 | require_once 'include/class-check-email-log-autoloader.php'; |
| 76 | |
| 77 | $loader = new \CheckEmail\Check_Email_Log_Autoloader(); |
| 78 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'include' ); |
| 79 | |
| 80 | if ( file_exists( $plugin_dir . 'tests/' ) ) { |
| 81 | // if tests are present, then add them. |
| 82 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'tests/wp-tests' ); |
| 83 | } |
| 84 | |
| 85 | $loader->add_file( $plugin_dir . 'include/Util/helper.php' ); |
| 86 | |
| 87 | $loader->register(); |
| 88 | |
| 89 | $check_email = new \CheckEmail\Core\Check_Email_Log( $plugin_file, $loader, new \CheckEmail\Core\DB\Check_Email_Table_Manager() ); |
| 90 | |
| 91 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Logger() ); |
| 92 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Review() ); |
| 93 | $check_email->add_loadie( new \CheckEmail\Core\UI\Check_Email_UI_Loader() ); |
| 94 | |
| 95 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Nonce_Checker() ); |
| 96 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Log_List_Action() ); |
| 97 | |
| 98 | $capability_giver = new \CheckEmail\Core\Check_Email_Admin_Capability_Giver(); |
| 99 | $check_email->add_loadie( $capability_giver ); |
| 100 | |
| 101 | |
| 102 | // `register_activation_hook` can't be called from inside any hook. |
| 103 | register_activation_hook( $plugin_file, array( $check_email->table_manager, 'on_activate' ) ); |
| 104 | register_activation_hook( $plugin_file, array( $capability_giver, 'add_cap_to_admin' ) ); |
| 105 | |
| 106 | // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`. |
| 107 | // But some plugins like EDD are sending emails in `init` event itself, |
| 108 | // which won't be logged if the plugin is loaded in `wp_loaded` or `init`. |
| 109 | add_action( 'plugins_loaded', array( $check_email, 'load' ), 101 ); |
| 110 | } |
| 111 | |
| 112 | function check_email() { |
| 113 | global $check_email; |
| 114 | return $check_email; |
| 115 | } |
| 116 | |
| 117 | check_email_log( __FILE__ ); |