check-email
Last commit date
assets
1 year ago
include
1 year ago
languages
1 year ago
vendor
1 year ago
changelog.txt
1 year ago
check-email.php
1 year ago
readme.txt
1 year ago
uninstall.php
1 year ago
check-email.php
167 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Plugin Name: Check & Log Email - Easy Email Testing & Mail logging |
| 4 | * Description: Check & Log email allows you to test if your WordPress installation is sending emails correctly and logs every email. |
| 5 | * Author: checkemail |
| 6 | * Version: 2.0.4 |
| 7 | * Author URI: https://check-email.tech/ |
| 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 | * Copyright 2023 WPOmnia contact@wpomnia.com |
| 18 | * |
| 19 | * NOTE: |
| 20 | * Chris Taylor transferred ownership rights on: 2020-06-19 07:52:03 GMT when ownership was handed over to MachoThemes |
| 21 | * The MachoThemes ownership period started on: 2020-06-19 07:52:03 GMT |
| 22 | * MachoThemes sold the plugin to WPOmnia on: 2023-10-15 15:52:03 GMT |
| 23 | * |
| 24 | * This program is free software; you can redistribute it and/or modify |
| 25 | * it under the terms of the GNU General Public License, version 3, as |
| 26 | * published by the Free Software Foundation. |
| 27 | * |
| 28 | * This program is distributed in the hope that it will be useful, |
| 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | * GNU General Public License for more details. |
| 32 | * |
| 33 | * You should have received a copy of the GNU General Public License |
| 34 | * along with this program; if not, write to the Free software |
| 35 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 36 | */ |
| 37 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 38 | |
| 39 | define( 'CK_MAIL_TOC_DIR_NAME', plugin_basename( dirname( __FILE__ ) ) ); |
| 40 | define( 'CK_MAIL_TOC_BASE_NAME', plugin_basename( __FILE__ ) ); |
| 41 | define( 'CK_MAIL_PATH', dirname( __FILE__ ) ); |
| 42 | define( 'CK_MAIL_URL', plugin_dir_url( __FILE__ ) ); |
| 43 | define( 'CK_MAIL_VERSION', '2.0.4' ); |
| 44 | |
| 45 | require_once(CK_MAIL_PATH. "/include/helper-function.php" ); |
| 46 | if ( is_admin() ) { |
| 47 | require_once(CK_MAIL_PATH. "/include/class-check-email-newsletter.php" ); |
| 48 | require_once(CK_MAIL_PATH. "/include/Check_Email_SMTP_Tab.php" ); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { |
| 53 | function check_email_compatibility_notice() { |
| 54 | ?> |
| 55 | <div class="error"> |
| 56 | <p> |
| 57 | <?php |
| 58 | echo esc_html__( 'Check & Log Email requires at least PHP 5.6 to function properly. Please upgrade PHP.', 'check-email' ); |
| 59 | ?> |
| 60 | </p> |
| 61 | </div> |
| 62 | <?php |
| 63 | } |
| 64 | |
| 65 | add_action( 'admin_notices', 'check_email_compatibility_notice' ); |
| 66 | |
| 67 | /** |
| 68 | * Deactivate Email Log. |
| 69 | */ |
| 70 | function check_email_deactivate() { |
| 71 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 72 | } |
| 73 | |
| 74 | add_action( 'admin_init', 'check_email_deactivate' ); |
| 75 | |
| 76 | return; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Load Check Email Log. |
| 81 | */ |
| 82 | function check_email_log( $plugin_file ) { |
| 83 | global $check_email; |
| 84 | |
| 85 | $plugin_dir = plugin_dir_path( $plugin_file ); |
| 86 | |
| 87 | // setup autoloader. |
| 88 | require_once 'include/class-check-email-log-autoloader.php'; |
| 89 | |
| 90 | $loader = new \CheckEmail\Check_Email_Log_Autoloader(); |
| 91 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'include' ); |
| 92 | |
| 93 | if ( file_exists( $plugin_dir . 'tests/' ) ) { |
| 94 | // if tests are present, then add them. |
| 95 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'tests/wp-tests' ); |
| 96 | } |
| 97 | |
| 98 | $loader->add_file( $plugin_dir . 'include/Util/helper.php' ); |
| 99 | |
| 100 | $loader->register(); |
| 101 | |
| 102 | $check_email = new \CheckEmail\Core\Check_Email_Log( $plugin_file, $loader, new \CheckEmail\Core\DB\Check_Email_Table_Manager() ); |
| 103 | |
| 104 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Multisite() ); |
| 105 | $check_email->add_loadie( new \CheckEmail\Check_Email_Encode_Tab() ); |
| 106 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Logger() ); |
| 107 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Review() ); |
| 108 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Export_Log() ); |
| 109 | $check_email->add_loadie( new \CheckEmail\Core\UI\Check_Email_UI_Loader() ); |
| 110 | |
| 111 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Nonce_Checker() ); |
| 112 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Log_List_Action() ); |
| 113 | |
| 114 | $capability_giver = new \CheckEmail\Core\Check_Email_Admin_Capability_Giver(); |
| 115 | $check_email->add_loadie( $capability_giver ); |
| 116 | $capability_giver->add_cap_to_admin(); |
| 117 | |
| 118 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_From_Handler() ); |
| 119 | |
| 120 | // `register_activation_hook` can't be called from inside any hook. |
| 121 | register_activation_hook( $plugin_file, array( $check_email->table_manager, 'on_activate' ) ); |
| 122 | |
| 123 | // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`. |
| 124 | // But some plugins like EDD are sending emails in `init` event itself, |
| 125 | // which won't be logged if the plugin is loaded in `wp_loaded` or `init`. |
| 126 | add_action( 'plugins_loaded', array( $check_email, 'load' ), 101 ); |
| 127 | } |
| 128 | |
| 129 | function wpchill_check_email() { |
| 130 | global $check_email; |
| 131 | return $check_email; |
| 132 | } |
| 133 | |
| 134 | check_email_log( __FILE__ ); |
| 135 | |
| 136 | |
| 137 | /** |
| 138 | * Add settings link to plugin actions |
| 139 | * |
| 140 | * @param array $plugin_actions |
| 141 | * @param string $plugin_file |
| 142 | * @since 1.0.11 |
| 143 | * @return array |
| 144 | */ |
| 145 | function check_email_add_plugin_link( $links ) { |
| 146 | |
| 147 | $url = add_query_arg( 'page', 'check-email-settings', self_admin_url( 'admin.php' ) ); |
| 148 | $setting_link = '<a href="' . esc_url( $url ) . '">' . __( 'Settings', 'check-email' ) . '</a> |'; |
| 149 | $setting_link .= '<a href="https://check-email.tech/contact/" target="_blank">' . __( ' Support', 'check-email' ) . '</a>'; |
| 150 | array_push( $links, $setting_link ); |
| 151 | return $links; |
| 152 | } |
| 153 | add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'check_email_add_plugin_link', 10, 2 ); |
| 154 | |
| 155 | function checkMail_is_plugins_page() { |
| 156 | |
| 157 | if(function_exists('get_current_screen')){ |
| 158 | $screen = get_current_screen(); |
| 159 | if(is_object($screen)){ |
| 160 | if($screen->id == 'plugins' || $screen->id == 'plugins-network'){ |
| 161 | return true; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | return false; |
| 166 | } |
| 167 |