check-email
Last commit date
assets
2 months ago
include
2 months ago
languages
2 months ago
vendor
2 months ago
changelog.txt
2 months ago
check-email.php
2 months ago
readme.txt
2 months ago
uninstall.php
2 months ago
check-email.php
236 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.13.1 |
| 7 | * Author URI: https://check-email.tech/ |
| 8 | * Plugin URI: https://check-email.tech/ |
| 9 | * License: GPLv3 or later |
| 10 | * License URI: http://www.gnu.org/licenses/gpl-3.0.html |
| 11 | * Requires PHP: 5.6 |
| 12 | * Text Domain: check-email |
| 13 | * Domain Path: /languages |
| 14 | * |
| 15 | * Copyright 2015-2020 Chris Taylor chris@stillbreathing.co.uk |
| 16 | * Copyright 2020 MachoThemes office@machothemes.com |
| 17 | * Copyright 2020 WPChill heyyy@wpchill.com |
| 18 | * Copyright 2023 WPOmnia contact@wpomnia.com |
| 19 | * |
| 20 | * NOTE: |
| 21 | * Chris Taylor transferred ownership rights on: 2020-06-19 07:52:03 GMT when ownership was handed over to MachoThemes |
| 22 | * The MachoThemes ownership period started on: 2020-06-19 07:52:03 GMT |
| 23 | * MachoThemes sold the plugin to WPOmnia on: 2023-10-15 15:52:03 GMT |
| 24 | * |
| 25 | * This program is free software; you can redistribute it and/or modify |
| 26 | * it under the terms of the GNU General Public License, version 3, as |
| 27 | * published by the Free Software Foundation. |
| 28 | * |
| 29 | * This program is distributed in the hope that it will be useful, |
| 30 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 31 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 32 | * GNU General Public License for more details. |
| 33 | * |
| 34 | * You should have received a copy of the GNU General Public License |
| 35 | * along with this program; if not, write to the Free software |
| 36 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 37 | */ |
| 38 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 39 | |
| 40 | define( 'CK_MAIL_TOC_DIR_NAME', plugin_basename( dirname( __FILE__ ) ) ); |
| 41 | define( 'CK_MAIL_TOC_BASE_NAME', plugin_basename( __FILE__ ) ); |
| 42 | define( 'CK_MAIL_PATH', dirname( __FILE__ ) ); |
| 43 | define( 'CK_MAIL_URL', plugin_dir_url( __FILE__ ) ); |
| 44 | define( 'CK_MAIL_VERSION', '2.0.13.1' ); |
| 45 | |
| 46 | require_once(CK_MAIL_PATH. "/include/helper-function.php" ); |
| 47 | if ( is_admin() ) { |
| 48 | require_once(CK_MAIL_PATH. "/include/class-check-email-newsletter.php" ); |
| 49 | } |
| 50 | require_once(CK_MAIL_PATH. "/include/Check_Email_SMTP_Tab.php" ); |
| 51 | |
| 52 | |
| 53 | if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) { |
| 54 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 55 | function check_email_compatibility_notice() { |
| 56 | ?> |
| 57 | <div class="error"> |
| 58 | <p> |
| 59 | <?php |
| 60 | echo esc_html__( 'Check & Log Email requires at least PHP 5.6 to function properly. Please upgrade PHP.', 'check-email' ); |
| 61 | ?> |
| 62 | </p> |
| 63 | </div> |
| 64 | <?php |
| 65 | } |
| 66 | |
| 67 | add_action( 'admin_notices', 'check_email_compatibility_notice' ); |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * Deactivate Email Log. |
| 72 | */ |
| 73 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 74 | function check_email_deactivate() { |
| 75 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
| 76 | } |
| 77 | |
| 78 | add_action( 'admin_init', 'check_email_deactivate' ); |
| 79 | |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | if(!defined('CK_MAIL_PRO_VERSION')){ |
| 84 | // Register a reusable filter to render the Upgrade banner. |
| 85 | add_filter('check_mail_pro_upgrade_banner', function ($html, $args = []) { |
| 86 | |
| 87 | $args = wp_parse_args($args, [ |
| 88 | 'title' => __('Solve email delivery issues faster with PRO version (50% discount)', 'check-email'), |
| 89 | 'message' => __('Unlock advanced features like real-time monitoring and detailed analytics.', 'check-email'), |
| 90 | 'cta_text' => __('Upgrade Now', 'check-email'), |
| 91 | 'cta_url' => 'https://check-email.tech/pricing/#pricings', |
| 92 | 'icon' => '🎉', |
| 93 | 'style' => 'yellow', |
| 94 | 'class' => '', |
| 95 | 'dismissible' => false, // true/false |
| 96 | 'dismiss_key' => 'my_ck', // unique key if dismissible (stored in localStorage) |
| 97 | ]); |
| 98 | ob_start(); |
| 99 | |
| 100 | $classes = 'celog-banner celog-banner--' . $args['style'] . ' ' . $args['class']; |
| 101 | ?> |
| 102 | <div class="celog-header"> |
| 103 | <div class="<?php echo esc_attr( $classes );?>"> |
| 104 | <div class="celog-banner__icon"><?php echo esc_html( $args['icon'] );?></div> |
| 105 | <div class="celog-banner__body"> |
| 106 | <div class="celog-banner__title"><?php echo esc_html( $args['title'] );?></div> |
| 107 | <a href="<?php echo esc_url( $args['cta_url'] );?>" target="_blank" class="check-mail-premium-btn" style="background:#f57429; border-color:#f57429"><?php echo esc_html( $args['cta_text'] );?></a> |
| 108 | </div> |
| 109 | </div> |
| 110 | <?php |
| 111 | if ($args['dismissible']) { |
| 112 | ?><button type="button" class="celog-banner__close" aria-label="<?php echo esc_attr__('Dismiss', 'check-email');?>">×</button> <?php |
| 113 | } |
| 114 | ?> |
| 115 | </div> |
| 116 | <?php |
| 117 | if ($args['dismissible'] && $args['dismiss_key']) { |
| 118 | echo '<script> |
| 119 | (function(){ |
| 120 | try { |
| 121 | var key = "celog_dismiss_" + ' . json_encode($args['dismiss_key']) . '; |
| 122 | var box = document.querySelector("[data-dismiss-key=\'' . esc_attr($args['dismiss_key']) . '\']"); |
| 123 | if (localStorage.getItem(key)) { box.style.display="none"; return; } |
| 124 | var btn = box.querySelector(".celog-banner__close"); |
| 125 | if (btn) btn.addEventListener("click", function(){ |
| 126 | box.remove(); |
| 127 | localStorage.setItem(key, "1"); |
| 128 | }); |
| 129 | } catch(e){} |
| 130 | })(); |
| 131 | </script>'; |
| 132 | } |
| 133 | return ob_get_clean(); |
| 134 | }, 10, 2); |
| 135 | |
| 136 | } |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | /** |
| 143 | * Load Check Email Log. |
| 144 | */ |
| 145 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 146 | function check_email_log( $plugin_file ) { |
| 147 | global $check_email; |
| 148 | |
| 149 | $plugin_dir = plugin_dir_path( $plugin_file ); |
| 150 | |
| 151 | // setup autoloader. |
| 152 | require_once 'include/class-check-email-log-autoloader.php'; |
| 153 | |
| 154 | $loader = new \CheckEmail\Check_Email_Log_Autoloader(); |
| 155 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'include' ); |
| 156 | |
| 157 | if ( file_exists( $plugin_dir . 'tests/' ) ) { |
| 158 | // if tests are present, then add them. |
| 159 | $loader->add_namespace( 'CheckEmail', $plugin_dir . 'tests/wp-tests' ); |
| 160 | } |
| 161 | |
| 162 | $loader->add_file( $plugin_dir . 'include/Util/helper.php' ); |
| 163 | |
| 164 | $loader->register(); |
| 165 | |
| 166 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 167 | $check_email = new \CheckEmail\Core\Check_Email_Log( $plugin_file, $loader, new \CheckEmail\Core\DB\Check_Email_Table_Manager() ); |
| 168 | |
| 169 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Multisite() ); |
| 170 | $check_email->add_loadie( new \CheckEmail\Check_Email_Encode_Tab() ); |
| 171 | $check_email->add_loadie( new \CheckEmail\Check_Email_Notify_Tab() ); |
| 172 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Logger() ); |
| 173 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Review() ); |
| 174 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_Export_Log() ); |
| 175 | $check_email->add_loadie( new \CheckEmail\Core\UI\Check_Email_UI_Loader() ); |
| 176 | |
| 177 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Nonce_Checker() ); |
| 178 | $check_email->add_loadie( new \CheckEmail\Core\Request\Check_Email_Log_List_Action() ); |
| 179 | |
| 180 | $capability_giver = new \CheckEmail\Core\Check_Email_Admin_Capability_Giver(); |
| 181 | $check_email->add_loadie( $capability_giver ); |
| 182 | $capability_giver->add_cap_to_admin(); |
| 183 | |
| 184 | $check_email->add_loadie( new \CheckEmail\Core\Check_Email_From_Handler() ); |
| 185 | |
| 186 | // `register_activation_hook` can't be called from inside any hook. |
| 187 | register_activation_hook( $plugin_file, array( $check_email->table_manager, 'on_activate' ) ); |
| 188 | |
| 189 | // Ideally the plugin should be loaded in a later event like `init` or `wp_loaded`. |
| 190 | // But some plugins like EDD are sending emails in `init` event itself, |
| 191 | // which won't be logged if the plugin is loaded in `wp_loaded` or `init`. |
| 192 | add_action( 'plugins_loaded', array( $check_email, 'load' ), 101 ); |
| 193 | } |
| 194 | |
| 195 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 196 | function wpchill_check_email() { |
| 197 | global $check_email; |
| 198 | return $check_email; |
| 199 | } |
| 200 | |
| 201 | check_email_log( __FILE__ ); |
| 202 | |
| 203 | |
| 204 | /** |
| 205 | * Add settings link to plugin actions |
| 206 | * |
| 207 | * @param array $plugin_actions |
| 208 | * @param string $plugin_file |
| 209 | * @since 1.0.11 |
| 210 | * @return array |
| 211 | */ |
| 212 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 213 | function check_email_add_plugin_link( $links ) { |
| 214 | |
| 215 | $url = add_query_arg( 'page', 'check-email-settings', self_admin_url( 'admin.php' ) ); |
| 216 | $setting_link = '<a href="' . esc_url( $url ) . '">' . __( 'Settings', 'check-email' ) . '</a> |'; |
| 217 | $setting_link .= '<a href="https://check-email.tech/contact/" target="_blank">' . __( ' Support', 'check-email' ) . '</a>'; |
| 218 | array_push( $links, $setting_link ); |
| 219 | return $links; |
| 220 | } |
| 221 | add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'check_email_add_plugin_link', 10, 2 ); |
| 222 | |
| 223 | // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 224 | function checkMail_is_plugins_page() { |
| 225 | |
| 226 | if(function_exists('get_current_screen')){ |
| 227 | $screen = get_current_screen(); |
| 228 | if(is_object($screen)){ |
| 229 | if($screen->id == 'plugins' || $screen->id == 'plugins-network'){ |
| 230 | return true; |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | return false; |
| 235 | } |
| 236 |