Plugin Directory

Changeset 3348048


Ignore:
Timestamp:
08/21/2025 10:43:21 AM (7 months ago)
Author:
Jyria
Message:

trunk version 1.2.2

Location:
omppm-override-phpmail-mailpoet/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • omppm-override-phpmail-mailpoet/trunk/README.md

    r3347023 r3348048  
    44**Tags:** mailpoet, smtp, wp_mail, gmail-api, phpmailer
    55**Tested up to:** 6.8
    6 **Stable tag:** 1.2.0
     6**Stable tag:** 1.2.2
    77**License:** GPLv2 or later
    88**License URI:** https://www.gnu.org/licenses/gpl-2.0.html
     
    9898
    9999## Changelog ##
     100
     101**1.2.2**
     102* Release date: August 21st 2025
     103* **NEW: Dynamic MailPoet email type detection using reflection**
     104* **NEW: Automatic support for all official MailPoet email types**
     105* **NEW: Future-proof email type validation system**
     106* **NEW: Reflection-based email type discovery**
     107* **NEW: Cached email type detection for performance**
     108* **NEW: Enhanced admin interface with dynamic email type count**
     109* **NEW: Automatic updates when MailPoet adds new email types**
     110* **NEW: Support for all MailPoet email types:**
     111  * automation, automation_notification, automation_transactional
     112  * standard, notification, notification_history
     113  * re_engagement, wc_transactional, confirmation_email
     114  * automatic, welcome (legacy support)
     115* **NEW: Intelligent fallback system for email type detection**
     116* **NEW: Enhanced debugging for email type matching**
     117* **NEW: Performance-optimized reflection with caching**
     118* Improved compatibility with MailPoet's latest email type system
     119* Enhanced support for WooCommerce transactional emails
     120* Better error handling and logging for email type detection
     121* Future-proof architecture that automatically adapts to MailPoet updates
     122
     123**1.2.1**
     124* Release date: August 20th 2025
     125* **NEW: Enhanced email type support with pattern matching**
     126* **NEW: Support for preview emails**
     127* **NEW: Support for email stats notifications**
     128* **NEW: Support for new subscriber notifications**
     129* **NEW: Intelligent pattern matching for automatic emails**
     130* **NEW: WooCommerce automatic email support (automatic_woocommerce_*)**
     131* **NEW: Generic automatic email pattern support (automatic_*_*)**
     132* **NEW: Enhanced email type validation with regex patterns**
     133* **NEW: Improved debugging for email type matching**
     134* **NEW: Admin interface shows supported email types count**
     135* **NEW: Future-proof email type detection system**
     136* Improved compatibility with MailPoet's latest automatic email system
     137* Enhanced support for complex email type patterns
     138* Better error handling and logging for email type detection
    100139
    101140**1.2.0**
  • omppm-override-phpmail-mailpoet/trunk/includes/class-omppm-admin.php

    r3347023 r3348048  
    88
    99namespace OMPPM\Admin;
     10
     11use ReflectionClass;
     12use ReflectionException;
    1013
    1114// Prevent direct access
     
    3538     * Plugin version constant
    3639     */
    37     private const PLUGIN_VERSION = '1.2.0';
     40    private const PLUGIN_VERSION = '1.2.2';
    3841   
    3942    /**
     
    232235                                <span class="omppm-status-value <?php echo class_exists('\\MailPoet\\Mailer\\Methods\\PHPMail') ? 'omppm-success' : 'omppm-warning'; ?>">
    233236                                    <?php echo class_exists('\\MailPoet\\Mailer\\Methods\\PHPMail') ? __('Yes', 'omppm-override-phpmail-mailpoet') : __('No', 'omppm-override-phpmail-mailpoet'); ?>
     237                                </span>
     238                            </div>
     239                            <div class="omppm-status-item">
     240                                <span class="omppm-status-label"><?php _e('Supported Email Types:', 'omppm-override-phpmail-mailpoet'); ?></span>
     241                                <span class="omppm-status-value omppm-success">
     242                                    <?php echo count($this->get_supported_email_types()); ?> <?php _e('types', 'omppm-override-phpmail-mailpoet'); ?>
    234243                                </span>
    235244                            </div>
     
    581590        return $plugin_data['Version'] ?? '1.0.11';
    582591    }
     592   
     593    /**
     594     * Get supported email types for display
     595     */
     596    private function get_supported_email_types(): array {
     597        $emailTypes = [
     598            'newsletter',
     599            'post_notification',
     600            'welcome_email',
     601            'automatic',
     602            'sending_test',
     603            'confirmation',
     604            'unsubscribe',
     605            're_engagement',
     606            'transactional',
     607            'notification',
     608            'preview',
     609            'email_stats_notification',
     610            'new_subscriber_notification',
     611            'automatic_woocommerce_*',
     612            'automatic_*_*'
     613        ];
     614       
     615        // Add dynamic MailPoet email types
     616        $mailpoetTypes = $this->get_mailpoet_email_types();
     617        $emailTypes = array_merge($emailTypes, $mailpoetTypes);
     618       
     619        return array_unique($emailTypes);
     620    }
     621   
     622    /**
     623     * Get MailPoet email types dynamically
     624     */
     625    private function get_mailpoet_email_types(): array {
     626        if (!class_exists('MailPoet\Entities\NewsletterEntity')) {
     627            return [];
     628        }
     629       
     630        try {
     631            $reflection = new ReflectionClass('MailPoet\Entities\NewsletterEntity');
     632            $constants = $reflection->getConstants();
     633           
     634            $mailpoetTypes = [];
     635            foreach ($constants as $name => $value) {
     636                if (strpos($name, 'TYPE_') === 0) {
     637                    $mailpoetTypes[] = $value;
     638                }
     639            }
     640           
     641            return $mailpoetTypes;
     642           
     643        } catch (ReflectionException $e) {
     644            return [];
     645        }
     646    }
    583647}
  • omppm-override-phpmail-mailpoet/trunk/omppm-override-phpmail-mailpoet.php

    r3347023 r3348048  
    66 * Plugin URI:        https://saskialund.de/
    77 * Description:       The missing link between MailPoet and your SMTP plugin – for reliable email delivery!
    8  * Version:           1.2.0
     8 * Version:           1.2.2
    99 * Requires at least: 6.5
    1010 * Requires PHP:      8.0
     
    5151use MailPoet\Mailer\Mailer as MailPoetMailer;
    5252use PHPMailer\PHPMailer\PHPMailer;
     53use ReflectionClass;
     54use ReflectionException;
    5355
    5456/**
     
    6870        case TRANSACTIONAL = 'transactional';
    6971        case NOTIFICATION = 'notification';
     72        case PREVIEW = 'preview';
     73        case EMAIL_STATS_NOTIFICATION = 'email_stats_notification';
     74        case NEW_SUBSCRIBER_NOTIFICATION = 'new_subscriber_notification';
    7075    }
    7176} else {
     
    8287        public const TRANSACTIONAL = 'transactional';
    8388        public const NOTIFICATION = 'notification';
     89        public const PREVIEW = 'preview';
     90        public const EMAIL_STATS_NOTIFICATION = 'email_stats_notification';
     91        public const NEW_SUBSCRIBER_NOTIFICATION = 'new_subscriber_notification';
    8492    }
    8593}
     
    172180            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::RE_ENGAGEMENT->value : EmailType::RE_ENGAGEMENT,
    173181            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::TRANSACTIONAL->value : EmailType::TRANSACTIONAL,
    174             version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::NOTIFICATION->value : EmailType::NOTIFICATION
     182            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::NOTIFICATION->value : EmailType::NOTIFICATION,
     183            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::PREVIEW->value : EmailType::PREVIEW,
     184            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::EMAIL_STATS_NOTIFICATION->value : EmailType::EMAIL_STATS_NOTIFICATION,
     185            version_compare(PHP_VERSION, '8.1.0', '>=') ? EmailType::NEW_SUBSCRIBER_NOTIFICATION->value : EmailType::NEW_SUBSCRIBER_NOTIFICATION
    175186        ];
    176187       
     
    184195    }
    185196   
     197    /**
     198     * Enhanced email type validation with dynamic MailPoet type detection
     199     * Supports all official MailPoet email types and pattern matching
     200     */
     201    private function isSupportedEmailType(string $email_type): bool {
     202        // Get dynamic MailPoet email types using reflection
     203        $mailpoetTypes = $this->getMailPoetEmailTypes();
     204       
     205        // Direct match with MailPoet email types
     206        if (in_array($email_type, $mailpoetTypes, true)) {
     207            if (OMPPM_DEBUG) {
     208                error_log("OMPPM: MailPoet email type matched: " . $email_type);
     209            }
     210            return true;
     211        }
     212       
     213        // Direct match with our supported email types
     214        if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
     215            if (in_array($email_type, $this->supported_email_types, strict: true)) {
     216                if (OMPPM_DEBUG) {
     217                    error_log("OMPPM: Supported email type matched: " . $email_type);
     218                }
     219                return true;
     220            }
     221        } else {
     222            if (in_array($email_type, $this->supported_email_types, true)) {
     223                if (OMPPM_DEBUG) {
     224                    error_log("OMPPM: Supported email type matched: " . $email_type);
     225                }
     226                return true;
     227            }
     228        }
     229       
     230        // Pattern matching for automatic emails (automatic_{group}_{event})
     231        if (strpos($email_type, 'automatic_') === 0) {
     232            if (OMPPM_DEBUG) {
     233                error_log("OMPPM: Automatic email pattern matched: " . $email_type);
     234            }
     235            return true;
     236        }
     237       
     238        // Pattern matching for WooCommerce automatic emails
     239        if (strpos($email_type, 'automatic_woocommerce_') === 0) {
     240            if (OMPPM_DEBUG) {
     241                error_log("OMPPM: WooCommerce automatic email pattern matched: " . $email_type);
     242            }
     243            return true;
     244        }
     245       
     246        // Pattern matching for other automatic email patterns
     247        if (preg_match('/^automatic_[a-zA-Z0-9_]+_[a-zA-Z0-9_]+$/', $email_type)) {
     248            if (OMPPM_DEBUG) {
     249                error_log("OMPPM: Generic automatic email pattern matched: " . $email_type);
     250            }
     251            return true;
     252        }
     253       
     254        if (OMPPM_DEBUG) {
     255            error_log("OMPPM: Email type not supported: " . $email_type);
     256        }
     257       
     258        return false;
     259    }
     260   
     261    /**
     262     * Dynamically get all MailPoet email types using reflection
     263     * This ensures we always support the latest MailPoet email types
     264     */
     265    private function getMailPoetEmailTypes(): array {
     266        static $mailpoetTypes = null;
     267       
     268        // Cache the result to avoid repeated reflection calls
     269        if ($mailpoetTypes !== null) {
     270            return $mailpoetTypes;
     271        }
     272       
     273        $mailpoetTypes = [];
     274       
     275        // Check if NewsletterEntity class exists
     276        if (!class_exists('MailPoet\Entities\NewsletterEntity')) {
     277            if (OMPPM_DEBUG) {
     278                error_log("OMPPM: NewsletterEntity class not found");
     279            }
     280            return $mailpoetTypes;
     281        }
     282       
     283        try {
     284            $reflection = new ReflectionClass('MailPoet\Entities\NewsletterEntity');
     285            $constants = $reflection->getConstants();
     286           
     287            foreach ($constants as $name => $value) {
     288                if (strpos($name, 'TYPE_') === 0) {
     289                    $mailpoetTypes[] = $value;
     290                }
     291            }
     292           
     293            if (OMPPM_DEBUG) {
     294                error_log("OMPPM: Found " . count($mailpoetTypes) . " MailPoet email types: " . implode(', ', $mailpoetTypes));
     295            }
     296           
     297        } catch (ReflectionException $e) {
     298            if (OMPPM_DEBUG) {
     299                error_log("OMPPM: Reflection error: " . $e->getMessage());
     300            }
     301        }
     302       
     303        return $mailpoetTypes;
     304    }
     305   
    186306    public function send($newsletter, $subscriber, $extraParams = []): array {
    187307        if (OMPPM_DEBUG) {
     
    201321            if ($email_type) {
    202322                $email_type = sanitize_text_field($email_type);
    203                 // Use named arguments for PHP 8.0+, fallback for older versions
    204                 if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
    205                     $is_mailpoet_mail = in_array($email_type, $this->supported_email_types, strict: true);
    206                 } else {
    207                     $is_mailpoet_mail = in_array($email_type, $this->supported_email_types, true);
    208                 }
     323               
     324                // Enhanced email type validation with pattern matching
     325                $is_mailpoet_mail = $this->isSupportedEmailType($email_type);
    209326            }
    210327           
  • omppm-override-phpmail-mailpoet/trunk/readme.txt

    r3347023 r3348048  
    44Tags: mailpoet, smtp, wp_mail, gmail-api, phpmailer
    55Tested up to: 6.8
    6 Stable tag: 1.2.0
     6Stable tag: 1.2.2
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6666
    6767== Changelog ==
     68
     69= 1.2.2 =
     70
     71Release date: August 21st 2025
     72
     73- **NEU: Dynamische MailPoet E-Mail-Typ-Erkennung mit Reflection**
     74- **NEU: Automatische Unterstützung für alle offiziellen MailPoet E-Mail-Typen**
     75- **NEU: Zukunftssichere E-Mail-Typ-Validierung**
     76- **NEU: Reflection-basierte E-Mail-Typ-Entdeckung**
     77- **NEU: Gecachte E-Mail-Typ-Erkennung für Performance**
     78- **NEU: Erweitertes Admin-Interface mit dynamischer E-Mail-Typ-Anzahl**
     79- **NEU: Automatische Updates wenn MailPoet neue E-Mail-Typen hinzufügt**
     80- **NEU: Unterstützung für alle MailPoet E-Mail-Typen:**
     81  * automation, automation_notification, automation_transactional
     82  * standard, notification, notification_history
     83  * re_engagement, wc_transactional, confirmation_email
     84  * automatic, welcome (Legacy-Support)
     85- **NEU: Intelligentes Fallback-System für E-Mail-Typ-Erkennung**
     86- **NEU: Verbessertes Debugging für E-Mail-Typ-Matching**
     87- **NEU: Performance-optimierte Reflection mit Caching**
     88- Verbesserte Kompatibilität mit MailPoets neuestem E-Mail-Typ-System
     89- Erweiterte Unterstützung für WooCommerce transaktionale E-Mails
     90- Bessere Fehlerbehandlung und Logging für E-Mail-Typ-Erkennung
     91- Zukunftssichere Architektur die sich automatisch an MailPoet-Updates anpasst
     92
     93= 1.2.1 =
     94
     95Release date: August 20th 2025
     96
     97- **NEU: Erweiterte E-Mail-Typ-Unterstützung mit Pattern-Matching**
     98- **NEU: Unterstützung für Preview-E-Mails**
     99- **NEU: Unterstützung für E-Mail-Statistik-Benachrichtigungen**
     100- **NEU: Unterstützung für neue Abonnenten-Benachrichtigungen**
     101- **NEU: Intelligentes Pattern-Matching für automatische E-Mails**
     102- **NEU: WooCommerce automatische E-Mail-Unterstützung (automatic_woocommerce_*)**
     103- **NEU: Generische automatische E-Mail-Pattern-Unterstützung (automatic_*_*)**
     104- **NEU: Erweiterte E-Mail-Typ-Validierung mit Regex-Patterns**
     105- **NEU: Verbessertes Debugging für E-Mail-Typ-Matching**
     106- **NEU: Admin-Interface zeigt Anzahl unterstützter E-Mail-Typen**
     107- **NEU: Zukunftssichere E-Mail-Typ-Erkennung**
     108- Verbesserte Kompatibilität mit MailPoets neuestem automatischen E-Mail-System
     109- Erweiterte Unterstützung für komplexe E-Mail-Typ-Patterns
     110- Bessere Fehlerbehandlung und Logging für E-Mail-Typ-Erkennung
    68111
    69112= 1.2.0 =
Note: See TracChangeset for help on using the changeset viewer.