Plugin Directory

Changeset 3822017


Ignore:
Timestamp:
11/25/2026 04:36:32 AM (less than one hour ago)
Author:
markutos987
Message:

Update ux

Location:
bens-email-marketing-automation
Files:
140 added
8 edited

Legend:

Unmodified
Added
Removed
  • bens-email-marketing-automation/trunk/assets/js/deactivation-feedback.js

    r3499580 r3822017  
    11(function ($) {
    2         'use strict';
     2  "use strict";
    33
    4         $(document).ready(function () {
    5                 var pluginSlug = bensemma_deactivation.slug;
    6                 var deactivateLink = $('tr[data-plugin="' + pluginSlug + '"] .deactivate a');
     4  $(document).ready(function () {
     5    var $modal = $("#bensemma-deactivation-modal");
     6    var deactivateUrl = "";
    77
    8                 if (!deactivateLink.length) {
    9                         return;
    10                 }
     8    // Intercept the deactivate link click for this plugin
     9    $(
     10      'tr[data-slug="' +
     11        bensemma_deactivation.slug +
     12        '"] .deactivate a, tr[data-plugin="' +
     13        bensemma_deactivation.slug +
     14        '/bens-email-marketing-automation.php"] .deactivate a'
     15    ).on("click", function (e) {
     16      e.preventDefault();
     17      deactivateUrl = $(this).attr("href");
     18      $modal.fadeIn(200);
     19    });
    1120
    12                 var deactivateUrl = deactivateLink.attr('href');
    13                 var $modal = $('#bensemma-deactivation-modal');
    14                 var $feedbackField = $modal.find('.bensemma-deactivation-feedback-field');
     21    // Close modal: overlay, X button, or Esc key
     22    function closeModal() {
     23      $modal.fadeOut(200);
     24    }
     25    $modal
     26      .find(".bensemma-deactivation-modal-overlay, .bensemma-deactivation-close")
     27      .on("click", closeModal);
     28    $(document).on("keydown", function (e) {
     29      if (e.key === "Escape" && $modal.is(":visible")) {
     30        closeModal();
     31      }
     32    });
    1533
    16                 // Intercept deactivate click
    17                 deactivateLink.on('click', function (e) {
    18                         e.preventDefault();
    19                         $modal.show();
    20                 });
     34    // Highlight selected row
     35    $modal
     36      .find('input[name="bensemma_deactivation_reason"]')
     37      .on("change", function () {
     38        $modal.find(".bensemma-deactivation-reasons li").removeClass("is-selected");
     39        $(this).closest("li").addClass("is-selected");
    2140
    22                 // Toggle feedback textarea for "other" and "complicated"
    23                 $modal.on('change', 'input[name="bensemma_deactivation_reason"]', function () {
    24                         var val = $(this).val();
    25                         if (val === 'other' || val === 'complicated') {
    26                                 $feedbackField.slideDown(150);
    27                         } else {
    28                                 $feedbackField.slideUp(150);
    29                         }
    30                 });
     41        // Enable submit button
     42        $modal.find(".bensemma-deactivation-submit").prop("disabled", false);
     43      });
    3144
    32                 // Cancel
    33                 $('#bensemma-deactivation-cancel, .bensemma-deactivation-overlay').on('click', function () {
    34                         $modal.hide();
    35                         // Reset form
    36                         $modal.find('input[value="temporary"]').prop('checked', true);
    37                         $feedbackField.hide();
    38                         $('#bensemma-deactivation-feedback-text').val('');
    39                 });
     45    // Enable submit when user types in the manual box
     46    $modal.find(".bensemma-deactivation-message").on("input", function () {
     47      var hasReason = $modal.find('input[name="bensemma_deactivation_reason"]:checked').length > 0;
     48      var hasText = $.trim($(this).val()) !== "";
     49      $modal.find(".bensemma-deactivation-submit").prop("disabled", !(hasReason || hasText));
     50    });
    4051
    41                 // Submit and deactivate
    42                 $('#bensemma-deactivation-submit').on('click', function () {
    43                         var $btn = $(this);
    44                         var reason = $modal.find('input[name="bensemma_deactivation_reason"]:checked').val();
    45                         var feedback = $('#bensemma-deactivation-feedback-text').val();
     52    // Send feedback to API, then deactivate (always deactivates, even on error)
     53    function sendAndDeactivate(reason, $btn) {
     54      var message = $.trim($modal.find(".bensemma-deactivation-message").val() || "");
    4655
    47                         $btn.prop('disabled', true).text($btn.data('loading') || 'Deactivating...');
     56      $modal.find(".bensemma-deactivation-modal-footer button").prop("disabled", true);
     57      $btn.text("Deactivating...");
    4858
    49                         $.ajax({
    50                                 url: bensemma_deactivation.ajax_url,
    51                                 type: 'POST',
    52                                 data: {
    53                                         action: 'bensemma_deactivation_feedback',
    54                                         nonce: bensemma_deactivation.nonce,
    55                                         reason: reason,
    56                                         feedback: feedback
    57                                 },
    58                                 complete: function () {
    59                                         window.location.href = deactivateUrl;
    60                                 }
    61                         });
    62                 });
    63         });
     59      $.ajax({
     60        url: bensemma_deactivation.ajax_url,
     61        type: "POST",
     62        timeout: 8000,
     63        data: {
     64          action: "bensemma_deactivation_feedback",
     65          nonce: bensemma_deactivation.nonce,
     66          reason: reason || "",
     67          message: message,
     68        },
     69        complete: function () {
     70          window.location.href = deactivateUrl;
     71        },
     72      });
     73    }
     74
     75    // Skip & Deactivate — still send data (reason "skipped" + any manual text)
     76    $modal.find(".bensemma-deactivation-skip").on("click", function () {
     77      sendAndDeactivate("skipped", $(this));
     78    });
     79
     80    // Submit & Deactivate — send selected reason + manual text
     81    $modal.find(".bensemma-deactivation-submit").on("click", function () {
     82      var reason = $modal
     83        .find('input[name="bensemma_deactivation_reason"]:checked')
     84        .val();
     85      sendAndDeactivate(reason || "", $(this));
     86    });
     87  });
    6488})(jQuery);
  • bens-email-marketing-automation/trunk/base/deactivation-feedback.php

    r3499580 r3822017  
    11<?php
     2/**
     3 * Deactivation Feedback
     4 *
     5 * Shows a feedback modal when the user deactivates the plugin.
     6 *
     7 * @package BensEmailMarketingAutomation
     8 */
    29
    310namespace MailerHub\Base;
    … …  
    714use MailerHub\Utils\Singleton;
    815
    9 /**
    10  * Deactivation feedback modal
    11  */
    1216class DeactivationFeedback {
    1317
    … …  
    1519
    1620        /**
    17          * Plugin basename
     21         * Plugin basename.
    1822         *
    1923         * @var string
    … …  
    2226
    2327        /**
    24          * Initialize
     28         * API endpoint to receive feedback.
     29         *
     30         * @var string
     31         */
     32        private $api_url = 'https://wpbens.com/wp-json/bens/v1/deactivation-feedback';
     33
     34        /**
     35         * Initialize hooks.
     36         *
     37         * @return void
    2538         */
    2639        public function init() {
    … …  
    3346
    3447        /**
    35          * Only load on the plugins page
     48         * Only load on the plugins page.
     49         *
     50         * @return bool
    3651         */
    3752        private function is_plugins_page() {
    … …  
    4156
    4257        /**
    43          * Enqueue modal assets on plugins page
     58         * Enqueue modal assets on plugins page only.
     59         *
     60         * @return void
    4461         */
    4562        public function enqueue_assets() {
    … …  
    4764                        return;
    4865                }
     66
     67                $css_file = \BensEmailMarketingAutomation::assets_dir() . 'css/deactivation-feedback.css';
     68                $js_file  = \BensEmailMarketingAutomation::assets_dir() . 'js/deactivation-feedback.js';
     69
     70                // Version by file modified time so browsers never serve a stale copy.
     71                wp_enqueue_style(
     72                        'bensemma-deactivation-feedback',
     73                        \BensEmailMarketingAutomation::assets_url() . 'css/deactivation-feedback.css',
     74                        array(),
     75                        file_exists( $css_file ) ? filemtime( $css_file ) : \BensEmailMarketingAutomation::get_version()
     76                );
    4977
    5078                wp_enqueue_script(
    … …  
    5280                        \BensEmailMarketingAutomation::assets_url() . 'js/deactivation-feedback.js',
    5381                        array( 'jquery' ),
    54                         \BensEmailMarketingAutomation::get_version(),
     82                        file_exists( $js_file ) ? filemtime( $js_file ) : \BensEmailMarketingAutomation::get_version(),
    5583                        true
    5684                );
    5785
    58                 wp_localize_script( 'bensemma-deactivation-feedback', 'bensemma_deactivation', array(
    59                         'ajax_url' => admin_url( 'admin-ajax.php' ),
    60                         'nonce'    => wp_create_nonce( 'bensemma_deactivation_feedback' ),
    61                         'slug'     => $this->plugin_basename,
    62                 ) );
    63         }
    64 
    65         /**
    66          * Render the deactivation modal HTML
     86                wp_localize_script(
     87                        'bensemma-deactivation-feedback',
     88                        'bensemma_deactivation',
     89                        array(
     90                                'ajax_url' => admin_url( 'admin-ajax.php' ),
     91                                'nonce'    => wp_create_nonce( 'bensemma_deactivation_feedback' ),
     92                                'slug'     => dirname( $this->plugin_basename ),
     93                        )
     94                );
     95        }
     96
     97        /**
     98         * Get feedback reasons.
     99         *
     100         * @return array
     101         */
     102        private function get_reasons() {
     103                return array(
     104                        'no_longer_needed'        => esc_html__( 'I no longer need the plugin', 'bens-email-marketing-automation' ),
     105                        'found_better_plugin'     => esc_html__( 'I found a better plugin', 'bens-email-marketing-automation' ),
     106                        'could_not_get_to_work'   => esc_html__( 'I couldn\'t get the plugin to work', 'bens-email-marketing-automation' ),
     107                        'temporary_deactivation'  => esc_html__( 'It\'s a temporary deactivation', 'bens-email-marketing-automation' ),
     108                        'plugin_broke_site'       => esc_html__( 'The plugin broke my site', 'bens-email-marketing-automation' ),
     109                        'missing_feature'         => esc_html__( 'I need a specific feature that is missing', 'bens-email-marketing-automation' ),
     110                        'other'                   => esc_html__( 'Other', 'bens-email-marketing-automation' ),
     111                );
     112        }
     113
     114        /**
     115         * Render the feedback modal HTML in the admin footer.
     116         *
     117         * @return void
    67118         */
    68119        public function render_modal() {
    … …  
    70121                        return;
    71122                }
     123
     124                $reasons = $this->get_reasons();
    72125                ?>
    73                 <div id="bensemma-deactivation-modal" style="display:none;">
    74                         <div class="bensemma-deactivation-overlay"></div>
    75                         <div class="bensemma-deactivation-dialog">
    76                                 <h3><?php esc_html_e( 'Why are you deactivating the plugin?', 'bens-email-marketing-automation' ); ?></h3>
    77 
    78                                 <ul class="bensemma-deactivation-reasons">
    79                                         <li>
    80                                                 <label>
    81                                                         <input type="radio" name="bensemma_deactivation_reason" value="temporary" checked>
    82                                                         <?php esc_html_e( 'The deactivation is temporary', 'bens-email-marketing-automation' ); ?>
    83                                                 </label>
    84                                         </li>
    85                                         <li>
    86                                                 <label>
    87                                                         <input type="radio" name="bensemma_deactivation_reason" value="complicated">
    88                                                         <?php esc_html_e( 'Plugin is too complicated', 'bens-email-marketing-automation' ); ?>
    89                                                 </label>
    90                                         </li>
    91                                         <li>
    92                                                 <label>
    93                                                         <input type="radio" name="bensemma_deactivation_reason" value="other">
    94                                                         <?php esc_html_e( 'Other', 'bens-email-marketing-automation' ); ?>
    95                                                 </label>
    96                                         </li>
    97                                 </ul>
    98 
    99                                 <div class="bensemma-deactivation-feedback-field" style="display:none;">
    100                                         <textarea id="bensemma-deactivation-feedback-text" rows="3" placeholder="<?php esc_attr_e( 'Please share your feedback...', 'bens-email-marketing-automation' ); ?>"></textarea>
     126                <div id="bensemma-deactivation-modal" class="bensemma-deactivation-modal" style="display:none;">
     127                        <div class="bensemma-deactivation-modal-overlay"></div>
     128                        <div class="bensemma-deactivation-modal-content">
     129                                <div class="bensemma-deactivation-modal-header">
     130                                        <button type="button" class="bensemma-deactivation-close" aria-label="<?php esc_attr_e( 'Close', 'bens-email-marketing-automation' ); ?>">&times;</button>
     131                                        <h3><?php esc_html_e( 'Quick Feedback', 'bens-email-marketing-automation' ); ?></h3>
     132                                        <p><?php esc_html_e( 'If you have a moment, please let us know why you are deactivating Bens Email Marketing & Automation:', 'bens-email-marketing-automation' ); ?></p>
    101133                                </div>
    102 
    103                                 <div class="bensemma-deactivation-actions">
    104                                         <button class="button button-primary" id="bensemma-deactivation-submit">
    105                                                 <?php esc_html_e( 'Deactivate', 'bens-email-marketing-automation' ); ?>
     134                                <div class="bensemma-deactivation-modal-body">
     135                                        <ul class="bensemma-deactivation-reasons">
     136                                                <?php foreach ( $reasons as $key => $label ) : ?>
     137                                                        <li>
     138                                                                <label>
     139                                                                        <input type="radio" name="bensemma_deactivation_reason" value="<?php echo esc_attr( $key ); ?>" />
     140                                                                        <span><?php echo esc_html( $label ); ?></span>
     141                                                                </label>
     142                                                        </li>
     143                                                <?php endforeach; ?>
     144                                        </ul>
     145                                        <div class="bensemma-deactivation-manual">
     146                                                <label for="bensemma-deactivation-message"><?php esc_html_e( 'Anything else you want to tell us?', 'bens-email-marketing-automation' ); ?></label>
     147                                                <textarea id="bensemma-deactivation-message" class="bensemma-deactivation-message" rows="3" placeholder="<?php esc_attr_e( 'Write your feedback here...', 'bens-email-marketing-automation' ); ?>"></textarea>
     148                                        </div>
     149                                </div>
     150                                <div class="bensemma-deactivation-modal-footer">
     151                                        <button type="button" class="button-link bensemma-deactivation-skip">
     152                                                <?php esc_html_e( 'Skip & Deactivate', 'bens-email-marketing-automation' ); ?>
    106153                                        </button>
    107                                         <button class="button" id="bensemma-deactivation-cancel">
    108                                                 <?php esc_html_e( 'Cancel', 'bens-email-marketing-automation' ); ?>
     154                                        <button type="button" class="button button-primary bensemma-deactivation-submit" disabled>
     155                                                <?php esc_html_e( 'Submit & Deactivate', 'bens-email-marketing-automation' ); ?>
    109156                                        </button>
    110157                                </div>
    111158                        </div>
    112159                </div>
    113 
    114                 <style>
    115                         #bensemma-deactivation-modal {
    116                                 position: fixed;
    117                                 top: 0;
    118                                 left: 0;
    119                                 width: 100%;
    120                                 height: 100%;
    121                                 z-index: 100000;
    122                         }
    123                         .bensemma-deactivation-overlay {
    124                                 position: absolute;
    125                                 top: 0;
    126                                 left: 0;
    127                                 width: 100%;
    128                                 height: 100%;
    129                                 background: rgba(0, 0, 0, 0.5);
    130                         }
    131                         .bensemma-deactivation-dialog {
    132                                 position: absolute;
    133                                 top: 50%;
    134                                 left: 50%;
    135                                 transform: translate(-50%, -50%);
    136                                 background: #fff;
    137                                 padding: 24px 30px;
    138                                 border-radius: 4px;
    139                                 width: 460px;
    140                                 max-width: 90%;
    141                                 box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
    142                         }
    143                         .bensemma-deactivation-dialog h3 {
    144                                 margin: 0 0 16px;
    145                                 font-size: 15px;
    146                                 font-weight: 600;
    147                                 line-height: 1.4;
    148                         }
    149                         .bensemma-deactivation-reasons {
    150                                 list-style: none;
    151                                 margin: 0 0 16px;
    152                                 padding: 0;
    153                         }
    154                         .bensemma-deactivation-reasons li {
    155                                 margin: 0 0 10px;
    156                         }
    157                         .bensemma-deactivation-reasons label {
    158                                 cursor: pointer;
    159                                 font-size: 13px;
    160                         }
    161                         .bensemma-deactivation-reasons input[type="radio"] {
    162                                 margin-right: 8px;
    163                         }
    164                         .bensemma-deactivation-feedback-field textarea {
    165                                 width: 100%;
    166                                 resize: vertical;
    167                                 margin-bottom: 16px;
    168                         }
    169                         .bensemma-deactivation-actions {
    170                                 display: flex;
    171                                 justify-content: space-between;
    172                                 align-items: center;
    173                                 padding-top: 10px;
    174                                 border-top: 1px solid #e2e4e7;
    175                         }
    176                         .bensemma-deactivation-actions .button {
    177                                 min-width: 90px;
    178                                 text-align: center;
    179                         }
    180                 </style>
    181160                <?php
    182161        }
    183162
    184163        /**
    185          * Handle AJAX feedback submission
     164         * Handle the AJAX feedback submission.
     165         *
     166         * @return void
    186167         */
    187168        public function handle_feedback() {
    … …  
    189170
    190171                if ( ! current_user_can( 'activate_plugins' ) ) {
    191                         wp_send_json_error();
    192                 }
    193 
    194                 $reason   = isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '';
    195                 $feedback = isset( $_POST['feedback'] ) ? sanitize_textarea_field( wp_unslash( $_POST['feedback'] ) ) : '';
    196 
    197                 // Send feedback to wpbens API
    198                 $api_url = 'https://wpbens.com/wp-json/bens/v1/deactivation-feedback';
    199 
    200                 wp_remote_post( $api_url, array(
    201                         'timeout' => 15,
    202                         'body'    => array(
    203                                 'plugin_name' => 'Bens Email Marketing & Automation',
    204                                 'reason'      => $reason,
    205                                 'feedback'    => $feedback,
    206                                 'site_url'    => home_url(),
    207                         ),
    208                 ) );
    209 
    210                 wp_send_json_success();
     172                        wp_send_json_error( array( 'message' => 'Permission denied.' ) );
     173                }
     174
     175                $reason = isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '';
     176                $message = isset( $_POST['message'] ) ? sanitize_textarea_field( wp_unslash( $_POST['message'] ) ) : '';
     177
     178                $allowed = array_merge( array_keys( $this->get_reasons() ), array( 'skipped' ) );
     179
     180                if ( empty( $reason ) ) {
     181                        $reason = '' !== $message ? 'other' : 'skipped';
     182                }
     183
     184                if ( ! in_array( $reason, $allowed, true ) ) {
     185                        wp_send_json_error( array( 'message' => 'Invalid reason.' ) );
     186                }
     187
     188                $body = array(
     189                        'plugin_name' => 'Bens Email Marketing & Automation',
     190                        'reason'      => $reason,
     191                        'feedback'    => $message,
     192                        'site_url'    => home_url(),
     193                );
     194
     195                // Blocking request: non-blocking calls are often dropped before
     196                // they reach the server, so the feedback never arrives.
     197                $response = wp_remote_post(
     198                        $this->api_url,
     199                        array(
     200                                'timeout' => 5,
     201                                'body'    => $body,
     202                        )
     203                );
     204
     205                if ( is_wp_error( $response ) ) {
     206                        wp_send_json_error( array( 'message' => $response->get_error_message() ) );
     207                }
     208
     209                wp_send_json_success( array( 'code' => wp_remote_retrieve_response_code( $response ) ) );
    211210        }
    212211}
  • bens-email-marketing-automation/trunk/base/promo-banner.php

    r3784345 r3822017  
    88
    99/**
    10  * Enterprise LTD 50% discount banner.
    11  * Shown only on MailerHub admin pages while MailerHub Pro is not active.
     10 * Displays the Pro discount banner on MailerHub admin pages.
    1211 */
    1312class PromoBanner {
    … …  
    1514        use Singleton;
    1615
    17         const META_KEY     = 'bensemma_enterprise_ltd_banner_dismissed';
     16        const META_KEY     = 'mailerhub_pro_discount_banner_dismissed';
    1817        const DISMISS_DAYS = 7;
    1918        const URL          = 'https://wpbens.com/deals/#mailerhub';
    2019
    21         /**
    22          * Initialize
    23          */
    2420        public function init() {
    2521                add_action( 'admin_notices', array( $this, 'render' ) );
    26                 add_action( 'wp_ajax_bensemma_dismiss_enterprise_banner', array( $this, 'dismiss' ) );
     22                add_action( 'wp_ajax_mailerhub_dismiss_discount_banner', array( $this, 'dismiss' ) );
    2723        }
    2824
    29         /**
    30          * Is Pro active
    31          */
    32         private function is_pro_active() {
    33                 return class_exists( '\MailerHubPro\Wrapper' ) || class_exists( 'BensEmailMarketingAutomationPro' );
    34         }
    35 
    36         /**
    37          * Should banner be shown for current user
    38          */
    3925        private function should_show() {
    40                 if ( $this->is_pro_active() || ! current_user_can( 'manage_options' ) ) {
     26                if ( class_exists( '\\MailerHubPro\\Wrapper' ) || class_exists( 'BensEmailMarketingAutomationPro' ) || ! current_user_can( 'manage_options' ) ) {
    4127                        return false;
    4228                }
    4329
    44                 // Show only on MailerHub admin pages (all slugs prefixed "bema-").
    45                 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
    46                 $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
    47                 if ( 0 !== strpos( $page, 'bema-' ) ) {
     30                $screen = get_current_screen();
     31                if ( ! $screen || ! in_array( $screen->id, \MailerHub\Utils\Helper::admin_pages_id(), true ) ) {
    4832                        return false;
    4933                }
    5034
    5135                $dismissed = (int) get_user_meta( get_current_user_id(), self::META_KEY, true );
    52 
    5336                return ! $dismissed || ( time() - $dismissed ) > ( self::DISMISS_DAYS * DAY_IN_SECONDS );
    5437        }
    5538
    56         /**
    57          * Render banner
    58          */
    5939        public function render() {
    6040                if ( ! $this->should_show() ) {
    … …  
    6242                }
    6343
    64                 $nonce = wp_create_nonce( 'bensemma_dismiss_enterprise_banner' );
     44                $nonce = wp_create_nonce( 'mailerhub_dismiss_discount_banner' );
    6545                ?>
    66                 <div class="notice inline bensemma-ltd-banner is-dismissible" data-nonce="<?php echo esc_attr( $nonce ); ?>">
    67                         <div class="bensemma-ltd-banner__badge"><?php echo esc_html__( '50% OFF', 'bens-email-marketing-automation' ); ?></div>
    68                         <div class="bensemma-ltd-banner__content">
    69                                 <strong><?php echo esc_html__( 'MailerHub Enterprise Lifetime Deal — 50% Off!', 'bens-email-marketing-automation' ); ?></strong>
    70                                 <span><?php echo esc_html__( 'Unlock automation, abandoned cart recovery, smart links and every Pro feature forever with a one-time payment.', 'bens-email-marketing-automation' ); ?></span>
     46                <div class="notice inline mailerhub-ltd-banner is-dismissible" data-nonce="<?php echo esc_attr( $nonce ); ?>">
     47                        <div class="mailerhub-ltd-banner__badge"><?php echo esc_html__( '50% OFF', 'bens-email-marketing-automation' ); ?></div>
     48                        <div class="mailerhub-ltd-banner__content">
     49                                <strong><?php echo esc_html__( 'MailerHub Pro — 50% Off!', 'bens-email-marketing-automation' ); ?></strong>
     50                                <span><?php echo esc_html__( 'Unlock advanced automations, abandoned cart recovery, smart links and every Pro feature at half price.', 'bens-email-marketing-automation' ); ?></span>
    7151                        </div>
    72                         <div class="bensemma-ltd-banner__price">
    73                                 <del>$149</del>
    74                                 <span>$75</span>
    75                         </div>
    76                         <a class="bensemma-ltd-banner__btn" href="<?php echo esc_url( self::URL ); ?>" target="_blank" rel="noopener noreferrer">
    77                                 <?php echo esc_html__( 'Grab the Deal', 'bens-email-marketing-automation' ); ?>
    78                         </a>
     52                        <a class="mailerhub-ltd-banner__btn" href="<?php echo esc_url( self::URL ); ?>" target="_blank" rel="noopener noreferrer"><?php echo esc_html__( 'Grab the Deal', 'bens-email-marketing-automation' ); ?></a>
    7953                </div>
    8054                <style>
    81                         .bensemma-ltd-banner{display:flex;align-items:center;gap:18px;padding:16px 44px 16px 20px!important;margin:0!important;border:0!important;border-radius:0;background:linear-gradient(120deg,#4f46e5 0%,#7c3aed 55%,#db2777 100%)!important;box-shadow:0 6px 20px rgba(79,70,229,.25);color:#fff}
    82                         .bensemma-ltd-banner__badge{flex-shrink:0;background:#facc15;color:#1e1b4b;font-weight:800;font-size:15px;padding:10px 12px;border-radius:6px;line-height:1;transform:rotate(-3deg);box-shadow:0 3px 8px rgba(0,0,0,.2)}
    83                         .bensemma-ltd-banner__content{flex:1;display:flex;flex-direction:column;gap:4px;font-size:13px;color:rgba(255,255,255,.88)}
    84                         .bensemma-ltd-banner__content strong{font-size:16px;color:#fff}
    85                         .bensemma-ltd-banner__price{flex-shrink:0;display:flex;align-items:baseline;gap:8px;line-height:1}
    86                         .bensemma-ltd-banner__price del{color:rgba(255,255,255,.65);font-size:16px}
    87                         .bensemma-ltd-banner__price span{color:#facc15;font-size:28px;font-weight:800}
    88                         .bensemma-ltd-banner__btn{flex-shrink:0;background:#facc15;color:#1e1b4b!important;text-decoration:none;font-weight:700;padding:10px 20px;border-radius:6px;transition:transform .15s,background .15s}
    89                         .bensemma-ltd-banner__btn:hover{background:#fde047;transform:translateY(-1px)}
    90                         .bensemma-ltd-banner .notice-dismiss:before{color:rgba(255,255,255,.8)}
    91                         .bensemma-ltd-banner .notice-dismiss:hover:before{color:#fff}
    92                         @media (max-width:782px){.bensemma-ltd-banner{flex-wrap:wrap}}
     55                        .mailerhub-ltd-banner{display:flex;align-items:center;gap:18px;padding:16px 44px 16px 20px!important;margin:0!important;border:0!important;border-radius:0;background:linear-gradient(120deg,#4f46e5 0%,#7c3aed 55%,#db2777 100%)!important;box-shadow:0 6px 20px rgba(79,70,229,.25);color:#fff}
     56                        .mailerhub-ltd-banner__badge{flex-shrink:0;background:#facc15;color:#1e1b4b;font-weight:800;font-size:15px;padding:10px 12px;border-radius:6px;line-height:1;transform:rotate(-3deg);box-shadow:0 3px 8px rgba(0,0,0,.2)}
     57                        .mailerhub-ltd-banner__content{flex:1;display:flex;flex-direction:column;gap:4px;font-size:13px;color:rgba(255,255,255,.88)}
     58                        .mailerhub-ltd-banner__content strong{font-size:16px;color:#fff}
     59                        .mailerhub-ltd-banner__btn{flex-shrink:0;background:#facc15;color:#1e1b4b!important;text-decoration:none;font-weight:700;padding:10px 20px;border-radius:6px;transition:transform .15s,background .15s}
     60                        .mailerhub-ltd-banner__btn:hover{background:#fde047;transform:translateY(-1px)}
     61                        .mailerhub-ltd-banner .notice-dismiss:before{color:rgba(255,255,255,.8)}
     62                        .mailerhub-ltd-banner .notice-dismiss:hover:before{color:#fff}
     63                        @media (max-width:782px){.mailerhub-ltd-banner{flex-wrap:wrap}}
    9364                </style>
    9465                <script>
    9566                        jQuery(function($){
    96                                 $(document).on('click', '.bensemma-ltd-banner .notice-dismiss', function(){
    97                                         var $b = $(this).closest('.bensemma-ltd-banner');
    98                                         $.post(ajaxurl, { action: 'bensemma_dismiss_enterprise_banner', nonce: $b.data('nonce') });
     67                                $(document).on('click', '.mailerhub-ltd-banner .notice-dismiss', function(){
     68                                        var $banner = $(this).closest('.mailerhub-ltd-banner');
     69                                        $.post(ajaxurl, { action: 'mailerhub_dismiss_discount_banner', nonce: $banner.data('nonce') });
    9970                                });
    10071                        });
    … …  
    10374        }
    10475
    105         /**
    106          * AJAX dismiss
    107          */
    10876        public function dismiss() {
    109                 check_ajax_referer( 'bensemma_dismiss_enterprise_banner', 'nonce' );
     77                check_ajax_referer( 'mailerhub_dismiss_discount_banner', 'nonce' );
    11078
    11179                if ( ! current_user_can( 'manage_options' ) ) {
  • bens-email-marketing-automation/trunk/bens-email-marketing-automation.php

    r3784345 r3822017  
    44 * Plugin URI:        https://wpbens.com/plugin/mailerhub
    55 * Description:       All-in-one email marketing & automation plugin for WordPress. Grow lists, send campaigns & boost conversions easily.
    6  * Version:           1.0.34
     6 * Version:           1.0.35
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    4343                $plugin_data = get_plugin_data( __FILE__, false, false );
    4444
    45                 return ! empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : '1.0.16';
     45                return ! empty( $plugin_data['Version'] ) ? $plugin_data['Version'] : '1.0.35';
    4646        }
    4747
  • bens-email-marketing-automation/trunk/core/admin/header.php

    r3507588 r3822017  
    1717                                'url'    => admin_url( 'admin.php?page=mailerhub' ),
    1818                                'target' => '_self',
     19                        ),
     20                        array(
     21                                'name'    => esc_html__( 'MCP', 'bens-email-marketing-automation' ),
     22                                'url'    => admin_url( 'admin.php?page=bema-mcp' ),
     23                                'target' => '_self',
     24                                'slug'   => 'bema-mcp',
    1925                        ),
    2026                        array(
  • bens-email-marketing-automation/trunk/core/admin/menus.php

    r3497978 r3822017  
    153153                                'position'    => 15,
    154154                        ),
     155                        array(
     156                                'parent_slug' => $this->parent_slug,
     157                                'page_title'  => esc_html__( 'MCP Connections', 'bens-email-marketing-automation' ),
     158                                'menu_title'  => esc_html__( 'MCP', 'bens-email-marketing-automation' ),
     159                                'capability'  => 'manage_options',
     160                                'menu_slug'   => 'bema-mcp',
     161                                'cb_function' => array( $this, 'render_mcp_page' ),
     162                                'position'    => 16,
     163                        ),
    155164                );
    156165
    157166                return $sub_pages;
     167        }
     168
     169        /** Render MCP connection settings. Pro supplies the connection functionality. */
     170        public function render_mcp_page() {
     171                if ( ! current_user_can( 'manage_options' ) ) {
     172                        return;
     173                }
     174
     175                $header = \BensEmailMarketingAutomation::core_dir() . 'admin/header.php';
     176                if ( file_exists( $header ) ) {
     177                        require_once $header;
     178                }
     179
     180                $option_key = 'mailerhub_mcp_connections';
     181                $clients    = array( 'claude' => 'Claude', 'codex' => 'Codex', 'cursor' => 'Cursor' );
     182                $settings   = get_option( $option_key, array() );
     183                $logs       = get_option( 'mailerhub_mcp_logs', array() );
     184                $logs       = is_array( $logs ) ? $logs : array();
     185                $is_pro     = class_exists( 'BensEmailMarketingAutomationPro' ) || class_exists( '\\MailerHubPro\\Wrapper' );
     186                $prompts    = array(
     187                        __( 'Show the status of my latest campaign.', 'bens-email-marketing-automation' ),
     188                        __( 'List subscriptions created in the last 7 days.', 'bens-email-marketing-automation' ),
     189                        __( 'Summarize campaign activity from the last 7 days.', 'bens-email-marketing-automation' ),
     190                );
     191                $last_campaigns = get_posts( array(
     192                        'post_type'      => 'bema-campaigns',
     193                        'post_status'    => array( 'publish', 'draft', 'pending', 'future' ),
     194                        'posts_per_page' => 1,
     195                        'orderby'        => 'date',
     196                        'order'          => 'DESC',
     197                ) );
     198                $last_campaign = ! empty( $last_campaigns ) ? $last_campaigns[0] : null;
     199                $recent_subscriptions = post_type_exists( 'shop_subscription' ) ? get_posts( array(
     200                        'post_type'      => 'shop_subscription',
     201                        'post_status'    => 'any',
     202                        'posts_per_page' => 50,
     203                        'orderby'        => 'date',
     204                        'order'          => 'DESC',
     205                        'date_query'     => array(
     206                                array(
     207                                        'after'     => wp_date( 'Y-m-d H:i:s', current_time( 'timestamp' ) - WEEK_IN_SECONDS ),
     208                                        'inclusive' => true,
     209                                ),
     210                        ),
     211                ) ) : array();
     212
     213                if ( isset( $_POST['mailerhub_mcp_save'] ) ) {
     214                        check_admin_referer( 'mailerhub_mcp_save_settings', 'mailerhub_mcp_nonce' );
     215                        if ( ! $is_pro ) {
     216                                echo '<div class="notice notice-error"><p>' . esc_html__( 'Saving MCP connection settings requires MailerHub Pro.', 'bens-email-marketing-automation' ) . '</p></div>';
     217                        } else {
     218                                $input    = isset( $_POST['mailerhub_mcp'] ) && is_array( $_POST['mailerhub_mcp'] ) ? wp_unslash( $_POST['mailerhub_mcp'] ) : array();
     219                                $settings = array();
     220                                foreach ( $clients as $slug => $label ) {
     221                                        $row = isset( $input[ $slug ] ) && is_array( $input[ $slug ] ) ? $input[ $slug ] : array();
     222                                        $settings[ $slug ] = array(
     223                                                'url'   => isset( $row['url'] ) ? esc_url_raw( $row['url'] ) : '',
     224                                                'token' => isset( $row['token'] ) ? sanitize_text_field( $row['token'] ) : '',
     225                                        );
     226                                }
     227                                update_option( $option_key, $settings );
     228                                echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'MCP connection settings saved.', 'bens-email-marketing-automation' ) . '</p></div>';
     229                        }
     230                }
     231                ?>
     232                <div class="wrap">
     233                        <h1><?php echo esc_html__( 'MCP Connections', 'bens-email-marketing-automation' ); ?><?php if ( ! $is_pro ) : ?><span class="bensemma-pro-badge"><?php echo esc_html__( 'Pro', 'bens-email-marketing-automation' ); ?></span><?php endif; ?></h1>
     234                        <p><?php echo esc_html__( 'Add connection details for your preferred MCP clients. MCP connections and saving settings require MailerHub Pro.', 'bens-email-marketing-automation' ); ?></p>
     235                        <div class="mailerhub-mcp-layout">
     236                                <div class="mailerhub-mcp-section-tabs" role="tablist" aria-label="<?php echo esc_attr__( 'MCP sections', 'bens-email-marketing-automation' ); ?>">
     237                                        <button type="button" class="mailerhub-mcp-section-tab is-active" id="mailerhub-mcp-section-tab-connections" role="tab" aria-selected="true" aria-controls="mailerhub-mcp-section-connections" tabindex="0"><?php echo esc_html__( 'Connections', 'bens-email-marketing-automation' ); ?></button>
     238                                        <button type="button" class="mailerhub-mcp-section-tab" id="mailerhub-mcp-section-tab-prompts" role="tab" aria-selected="false" aria-controls="mailerhub-mcp-section-prompts" tabindex="-1"><?php echo esc_html__( 'Prompts', 'bens-email-marketing-automation' ); ?></button>
     239                                        <button type="button" class="mailerhub-mcp-section-tab" id="mailerhub-mcp-section-tab-logs" role="tab" aria-selected="false" aria-controls="mailerhub-mcp-section-logs" tabindex="-1"><?php echo esc_html__( 'Logs', 'bens-email-marketing-automation' ); ?></button>
     240                                </div>
     241                                <div class="mailerhub-mcp-section-panels">
     242                                <section class="mailerhub-mcp-section-panel is-active" id="mailerhub-mcp-section-connections" role="tabpanel" aria-labelledby="mailerhub-mcp-section-tab-connections" aria-hidden="false">
     243                        <form method="post">
     244                                <?php wp_nonce_field( 'mailerhub_mcp_save_settings', 'mailerhub_mcp_nonce' ); ?>
     245                                <div class="mailerhub-mcp-card">
     246                                        <div class="mailerhub-mcp-tabs" role="tablist" aria-label="<?php echo esc_attr__( 'MCP clients', 'bens-email-marketing-automation' ); ?>">
     247                                                <?php $tab_index = 0; foreach ( $clients as $slug => $label ) :
     248                                                        $is_active = 0 === $tab_index;
     249                                                ?>
     250                                                        <button type="button" class="mailerhub-mcp-tab<?php echo $is_active ? ' is-active' : ''; ?>" id="mailerhub-mcp-tab-<?php echo esc_attr( $slug ); ?>" role="tab" aria-selected="<?php echo $is_active ? 'true' : 'false'; ?>" aria-controls="mailerhub-mcp-panel-<?php echo esc_attr( $slug ); ?>" tabindex="<?php echo $is_active ? '0' : '-1'; ?>">
     251                                                                <?php echo esc_html( $label ); ?>
     252                                                        </button>
     253                                                <?php $tab_index++; endforeach; ?>
     254                                        </div>
     255                                        <?php $panel_index = 0; foreach ( $clients as $slug => $label ) :
     256                                                $row        = isset( $settings[ $slug ] ) && is_array( $settings[ $slug ] ) ? $settings[ $slug ] : array();
     257                                                $is_active  = 0 === $panel_index;
     258                                        ?>
     259                                                <section class="mailerhub-mcp-panel" id="mailerhub-mcp-panel-<?php echo esc_attr( $slug ); ?>" role="tabpanel" aria-labelledby="mailerhub-mcp-tab-<?php echo esc_attr( $slug ); ?>" <?php echo $is_active ? '' : 'hidden'; ?>>
     260                                                        <h2><?php echo esc_html( $label ); ?></h2>
     261                                                        <p class="description"><?php echo esc_html( sprintf( __( 'Enter the MCP server details to use with %s.', 'bens-email-marketing-automation' ), $label ) ); ?></p>
     262                                                        <table class="form-table" role="presentation">
     263                                                                <tr>
     264                                                                        <th scope="row"><label for="mailerhub-mcp-<?php echo esc_attr( $slug ); ?>-url"><?php echo esc_html__( 'MCP Server URL', 'bens-email-marketing-automation' ); ?></label></th>
     265                                                                        <td><input class="regular-text" type="url" id="mailerhub-mcp-<?php echo esc_attr( $slug ); ?>-url" name="mailerhub_mcp[<?php echo esc_attr( $slug ); ?>][url]" value="<?php echo esc_attr( isset( $row['url'] ) ? $row['url'] : '' ); ?>" placeholder="https://"><p class="description"><?php echo esc_html__( 'The server endpoint provided for your MCP connection.', 'bens-email-marketing-automation' ); ?></p></td>
     266                                                                </tr>
     267                                                                <tr>
     268                                                                        <th scope="row"><label for="mailerhub-mcp-<?php echo esc_attr( $slug ); ?>-token"><?php echo esc_html__( 'Access Token', 'bens-email-marketing-automation' ); ?></label></th>
     269                                                                        <td><input class="regular-text" type="password" autocomplete="new-password" id="mailerhub-mcp-<?php echo esc_attr( $slug ); ?>-token" name="mailerhub_mcp[<?php echo esc_attr( $slug ); ?>][token]" value="<?php echo esc_attr( isset( $row['token'] ) ? $row['token'] : '' ); ?>"></td>
     270                                                                </tr>
     271                                                        </table>
     272                                                </section>
     273                                        <?php $panel_index++; endforeach; ?>
     274                                </div>
     275                                <style>
     276                                        .mailerhub-mcp-card{width:100%;max-width:1100px;margin-top:0;background:#fff;border:1px solid #dcdcde;border-radius:10px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,.04)}
     277                                        .mailerhub-mcp-tabs{display:flex;align-items:stretch;gap:8px;padding:10px 18px 0;border-bottom:1px solid #dcdcde;background:#f8f9fb}
     278                                        .mailerhub-mcp-tab{display:flex;align-items:center;justify-content:center;min-width:100px;margin:0 0 -1px;padding:11px 18px;border:1px solid transparent;border-bottom:3px solid transparent;border-radius:7px 7px 0 0;background:transparent;color:#50575e;font-size:13px;font-weight:600;line-height:1.4;cursor:pointer;transition:background .15s,border-color .15s,color .15s}
     279                                        .mailerhub-mcp-tab:hover{border-bottom-color:#9bbff4}
     280                                        .mailerhub-mcp-tab:focus-visible{outline:2px solid #2271b1;outline-offset:2px}
     281                                        .mailerhub-mcp-tab.is-active{border-bottom-color:#0d6efd}
     282                                        .mailerhub-mcp-panel{padding:14px 26px 24px}
     283                                        .mailerhub-mcp-panel h2{margin-top:8px;margin-bottom:8px;font-size:19px}
     284                                        .mailerhub-mcp-panel .description{max-width:660px}
     285                                        .mailerhub-mcp-panel .form-table{max-width:850px;margin-top:18px}
     286                                        .mailerhub-mcp-panel .form-table th{width:190px;padding-left:0}
     287                                        .mailerhub-mcp-panel .form-table td{padding-right:0}
     288                                        .mailerhub-mcp-panel input.regular-text{width:min(100%,520px);max-width:100%;min-height:40px;padding:6px 12px;border-color:#c3c4c7;border-radius:5px;box-shadow:0 1px 2px rgba(0,0,0,.03)}
     289                                        .mailerhub-mcp-panel input.regular-text:focus{border-color:#2271b1;box-shadow:0 0 0 1px #2271b1;outline:2px solid transparent}
     290                                        .mailerhub-mcp-panel .description{margin-top:7px;color:#646970}
     291                                        .mailerhub-mcp-layout{display:flex;align-items:flex-start;gap:30px;margin-top:24px}
     292                                        .mailerhub-mcp-section-tabs{display:flex;flex:0 0 200px;flex-direction:column;gap:10px}
     293                                        .mailerhub-mcp-section-tab{width:100%;min-height:44px;padding:12px 18px;border:1px solid #dcdcde;border-radius:9px;background:#fff;color:#1d2327;text-align:left;font-size:14px;cursor:pointer;transition:background .15s,border-color .15s,color .15s}
     294                                        .mailerhub-mcp-section-tab:hover{border-color:#9bbff4}
     295                                        .mailerhub-mcp-section-tab:focus-visible{outline:2px solid #2271b1;outline-offset:2px}
     296                                        .mailerhub-mcp-section-tab.is-active{border-color:#0d6efd;background:#0d6efd;color:#fff;box-shadow:0 2px 5px rgba(13,110,253,.2)}
     297                                        .mailerhub-mcp-section-panels{flex:1;min-width:0}
     298                                        .mailerhub-mcp-section-panel{display:none;max-width:1100px}
     299                                        .mailerhub-mcp-section-panel.is-active{display:block}
     300                                        .mailerhub-mcp-section-panel>section{margin:0;padding:20px 22px;background:#fff;border:1px solid #dcdcde;border-radius:10px;box-shadow:0 2px 8px rgba(0,0,0,.04)}
     301                                        .mailerhub-mcp-section-panel>section h2{margin-top:0}
     302                                        .mailerhub-mcp-overview{max-width:1100px;margin-top:28px}
     303                                        .mailerhub-mcp-overview section{margin:0 0 22px;padding:20px 22px;background:#fff;border:1px solid #dcdcde;border-radius:10px;box-shadow:0 2px 8px rgba(0,0,0,.04)}
     304                                        .mailerhub-mcp-overview h2{margin:0 0 14px;font-size:17px}
     305                                        .mailerhub-mcp-overview .widefat{border:0;box-shadow:none}
     306                                        .mailerhub-mcp-overview .widefat th{font-weight:600}
     307                                        .mailerhub-mcp-empty{margin:0;padding:15px 16px;border:1px dashed #c3c4c7;border-radius:6px;color:#646970;background:#f9f9f9}
     308                                        .mailerhub-mcp-prompt-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px;margin:0 0 24px}
     309                                        .mailerhub-mcp-prompt{margin:0;padding:16px 18px;border:1px solid #dcdcde;border-radius:8px;background:#fff;color:#2c3338;line-height:1.5}
     310                                        .mailerhub-mcp-data-section{margin-top:24px;padding:20px 22px;border:1px solid #dcdcde;border-radius:10px;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,.04)}
     311                                        .mailerhub-mcp-data-section h3{margin:0 0 14px;font-size:16px}
     312                                        @media(max-width:782px){.mailerhub-mcp-layout{flex-direction:column;gap:16px}.mailerhub-mcp-section-tabs{flex:0 0 auto;width:100%;flex-direction:row;gap:8px}.mailerhub-mcp-section-tab{min-height:40px;padding:10px 12px;text-align:center}.mailerhub-mcp-section-panels{width:100%}}
     313                                        @media(max-width:782px){.mailerhub-mcp-panel .form-table th,.mailerhub-mcp-panel .form-table td{display:block;width:100%;padding:8px 0}.mailerhub-mcp-panel .form-table th{padding-bottom:0}}
     314                                        @media(max-width:600px){.mailerhub-mcp-tabs{gap:4px;padding:9px 8px;overflow-x:auto}.mailerhub-mcp-tab{flex:1 0 auto;min-width:80px;padding:9px 8px;font-size:12px}.mailerhub-mcp-panel{padding:12px 16px 18px}.mailerhub-mcp-overview section{padding:16px 12px}}
     315                                </style>
     316                                <script>
     317                                        (function(){
     318                                                var sectionTabs = document.querySelectorAll('.mailerhub-mcp-section-tab');
     319                                                sectionTabs.forEach(function(tab){
     320                                                        tab.addEventListener('click', function(){
     321                                                                sectionTabs.forEach(function(item){
     322                                                                        item.classList.remove('is-active');
     323                                                                        item.setAttribute('aria-selected', 'false');
     324                                                                        item.setAttribute('tabindex', '-1');
     325                                                                        var panel = document.getElementById(item.getAttribute('aria-controls'));
     326                                                                        panel.classList.remove('is-active');
     327                                                                        panel.setAttribute('aria-hidden', 'true');
     328                                                                });
     329                                                                tab.classList.add('is-active');
     330                                                                tab.setAttribute('aria-selected', 'true');
     331                                                                tab.setAttribute('tabindex', '0');
     332                                                                var panel = document.getElementById(tab.getAttribute('aria-controls'));
     333                                                                panel.classList.add('is-active');
     334                                                                panel.setAttribute('aria-hidden', 'false');
     335                                                        });
     336                                                });
     337                                                var tabs = document.querySelectorAll('.mailerhub-mcp-tab');
     338                                                tabs.forEach(function(tab){
     339                                                        tab.addEventListener('click', function(){
     340                                                                tabs.forEach(function(item){
     341                                                                        item.classList.remove('is-active');
     342                                                                        item.setAttribute('aria-selected', 'false');
     343                                                                        item.setAttribute('tabindex', '-1');
     344                                                                        document.getElementById(item.getAttribute('aria-controls')).hidden = true;
     345                                                                });
     346                                                                tab.classList.add('is-active');
     347                                                                tab.setAttribute('aria-selected', 'true');
     348                                                                tab.setAttribute('tabindex', '0');
     349                                                                document.getElementById(tab.getAttribute('aria-controls')).hidden = false;
     350                                                        });
     351                                                        tab.addEventListener('keydown', function(event){
     352                                                                if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
     353                                                                event.preventDefault();
     354                                                                var list = Array.prototype.slice.call(tabs);
     355                                                                var next = list.indexOf(tab) + (event.key === 'ArrowRight' ? 1 : -1);
     356                                                                if (next < 0) next = list.length - 1;
     357                                                                if (next >= list.length) next = 0;
     358                                                                list[next].click();
     359                                                                list[next].focus();
     360                                                        });
     361                                                });
     362                                        })();
     363                                </script>
     364                                <?php submit_button( __( 'Save Connection Settings', 'bens-email-marketing-automation' ), 'primary', 'mailerhub_mcp_save', true, $is_pro ? array() : array( 'disabled' => 'disabled' ) ); ?>
     365                        </form>
     366                        <div class="mailerhub-mcp-overview">
     367                                <section aria-labelledby="mailerhub-mcp-list-heading">
     368                                        <h2 id="mailerhub-mcp-list-heading"><?php echo esc_html__( 'Connection List', 'bens-email-marketing-automation' ); ?></h2>
     369                                        <?php
     370                                        $connection_count = 0;
     371                                        foreach ( $clients as $slug => $label ) {
     372                                                $row = isset( $settings[ $slug ] ) && is_array( $settings[ $slug ] ) ? $settings[ $slug ] : array();
     373                                                if ( ! empty( $row['url'] ) ) {
     374                                                        $connection_count++;
     375                                                }
     376                                        }
     377                                        if ( ! $connection_count ) :
     378                                        ?>
     379                                                <p class="mailerhub-mcp-empty"><?php echo esc_html__( 'No MCP connections configured yet.', 'bens-email-marketing-automation' ); ?></p>
     380                                        <?php else : ?>
     381                                                <table class="widefat striped">
     382                                                        <thead><tr><th><?php echo esc_html__( 'Client', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'MCP Server URL', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Status', 'bens-email-marketing-automation' ); ?></th></tr></thead>
     383                                                        <tbody>
     384                                                                <?php foreach ( $clients as $slug => $label ) :
     385                                                                        $row = isset( $settings[ $slug ] ) && is_array( $settings[ $slug ] ) ? $settings[ $slug ] : array();
     386                                                                        if ( empty( $row['url'] ) ) { continue; }
     387                                                                ?>
     388                                                                        <tr><td><?php echo esc_html( $label ); ?></td><td><code><?php echo esc_html( $row['url'] ); ?></code></td><td><?php echo esc_html__( 'Configured', 'bens-email-marketing-automation' ); ?></td></tr>
     389                                                                <?php endforeach; ?>
     390                                                        </tbody>
     391                                                </table>
     392                                        <?php endif; ?>
     393                                </section>
     394                        </div>
     395                        </section>
     396                        <section class="mailerhub-mcp-section-panel" id="mailerhub-mcp-section-logs" role="tabpanel" aria-labelledby="mailerhub-mcp-section-tab-logs" aria-hidden="true">
     397                                <section aria-labelledby="mailerhub-mcp-logs-heading">
     398                                        <h2 id="mailerhub-mcp-logs-heading"><?php echo esc_html__( 'Connection Logs', 'bens-email-marketing-automation' ); ?></h2>
     399                                        <?php if ( empty( $logs ) ) : ?>
     400                                                <p class="mailerhub-mcp-empty"><?php echo esc_html__( 'No connection activity has been logged yet.', 'bens-email-marketing-automation' ); ?></p>
     401                                        <?php else : ?>
     402                                                <table class="widefat striped">
     403                                                        <thead><tr><th><?php echo esc_html__( 'Time', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Client', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Event', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Details', 'bens-email-marketing-automation' ); ?></th></tr></thead>
     404                                                        <tbody>
     405                                                                <?php foreach ( array_slice( $logs, 0, 50 ) as $log ) :
     406                                                                        if ( ! is_array( $log ) ) { continue; }
     407                                                                        $timestamp = isset( $log['time'] ) ? absint( $log['time'] ) : 0;
     408                                                                ?>
     409                                                                        <tr><td><?php echo $timestamp ? esc_html( wp_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $timestamp ) ) : '&mdash;'; ?></td><td><?php echo esc_html( isset( $log['client'] ) ? $log['client'] : '—' ); ?></td><td><?php echo esc_html( isset( $log['event'] ) ? $log['event'] : '—' ); ?></td><td><?php echo esc_html( isset( $log['details'] ) ? $log['details'] : '—' ); ?></td></tr>
     410                                                                <?php endforeach; ?>
     411                                                        </tbody>
     412                                                </table>
     413                                        <?php endif; ?>
     414                                </section>
     415                        </section>
     416                        <section class="mailerhub-mcp-section-panel" id="mailerhub-mcp-section-prompts" role="tabpanel" aria-labelledby="mailerhub-mcp-section-tab-prompts" aria-hidden="true">
     417                                <section aria-labelledby="mailerhub-mcp-prompts-heading">
     418                                        <h2 id="mailerhub-mcp-prompts-heading"><?php echo esc_html__( 'Default Prompts', 'bens-email-marketing-automation' ); ?></h2>
     419                                        <p class="description"><?php echo esc_html__( 'Example prompts available with MCP in MailerHub Pro.', 'bens-email-marketing-automation' ); ?></p>
     420                                        <div class="mailerhub-mcp-prompt-list">
     421                                                <?php foreach ( $prompts as $prompt ) : ?>
     422                                                        <p class="mailerhub-mcp-prompt"><?php echo esc_html( $prompt ); ?></p>
     423                                                <?php endforeach; ?>
     424                                        </div>
     425                                        <div class="mailerhub-mcp-data-section">
     426                                                <h3><?php echo esc_html__( 'Latest Campaign Status', 'bens-email-marketing-automation' ); ?></h3>
     427                                                <?php if ( $last_campaign ) :
     428                                                        $campaign_status = get_post_meta( $last_campaign->ID, 'status', true );
     429                                                        if ( ! $campaign_status ) {
     430                                                                $campaign_status = get_post_status( $last_campaign->ID );
     431                                                        }
     432                                                ?>
     433                                                        <table class="widefat striped"><thead><tr><th><?php echo esc_html__( 'Campaign', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Status', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Last Updated', 'bens-email-marketing-automation' ); ?></th></tr></thead><tbody><tr><td><?php echo esc_html( get_the_title( $last_campaign ) ); ?></td><td><?php echo esc_html( ucwords( str_replace( array( '-', '_' ), ' ', $campaign_status ) ) ); ?></td><td><?php echo esc_html( get_the_modified_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $last_campaign ) ); ?></td></tr></tbody></table>
     434                                                <?php else : ?>
     435                                                        <p class="mailerhub-mcp-empty"><?php echo esc_html__( 'No campaigns found.', 'bens-email-marketing-automation' ); ?></p>
     436                                                <?php endif; ?>
     437                                        </div>
     438                                        <div class="mailerhub-mcp-data-section">
     439                                                <h3><?php echo esc_html__( 'Subscriptions from the Last 7 Days', 'bens-email-marketing-automation' ); ?></h3>
     440                                                <?php if ( ! post_type_exists( 'shop_subscription' ) ) : ?>
     441                                                        <p class="mailerhub-mcp-empty"><?php echo esc_html__( 'WooCommerce Subscriptions is not available on this site.', 'bens-email-marketing-automation' ); ?></p>
     442                                                <?php elseif ( empty( $recent_subscriptions ) ) : ?>
     443                                                        <p class="mailerhub-mcp-empty"><?php echo esc_html__( 'No subscriptions were created in the last 7 days.', 'bens-email-marketing-automation' ); ?></p>
     444                                                <?php else : ?>
     445                                                        <table class="widefat striped"><thead><tr><th><?php echo esc_html__( 'Subscription', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Customer', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Status', 'bens-email-marketing-automation' ); ?></th><th><?php echo esc_html__( 'Created', 'bens-email-marketing-automation' ); ?></th></tr></thead><tbody>
     446                                                                <?php foreach ( $recent_subscriptions as $subscription ) :
     447                                                                        $customer_email = get_post_meta( $subscription->ID, '_billing_email', true );
     448                                                                        $subscription_status = str_replace( 'wc-', '', get_post_status( $subscription->ID ) );
     449                                                                ?>
     450                                                                        <tr><td>#<?php echo esc_html( $subscription->ID ); ?></td><td><?php echo esc_html( $customer_email ? $customer_email : '—' ); ?></td><td><?php echo esc_html( ucwords( str_replace( '-', ' ', $subscription_status ) ) ); ?></td><td><?php echo esc_html( get_the_date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $subscription ) ); ?></td></tr>
     451                                                                <?php endforeach; ?>
     452                                                        </tbody></table>
     453                                                <?php endif; ?>
     454                                        </div>
     455                                </section>
     456                        </section>
     457                                </div>
     458                        </div>
     459                </div>
     460                <?php
    158461        }
    159462        /**
  • bens-email-marketing-automation/trunk/readme.txt

    r3784345 r3822017  
    44Requires at least: 6.0
    55Tested up to: 7.0
    6 Stable tag: 1.0.34
     6Stable tag: 1.0.35
    77Requires PHP: 7.4
    88License: GPLv2 or later
    … …  
    107107
    108108== Changelog ==
     109
     110= 1.0.35 (November 25, 2026)=
     111- Add MCP admin page with Claude, Codex, and Cursor connection settings
     112- Add MCP connection list, logs, default prompts, latest campaign status, and subscriptions created in the last 7 days
     113- Require MailerHub Pro to save and use MCP connections
     114- Improve MCP tab styling, responsive layout, and keyboard navigation
    109115
    110116= 1.0.34 (November 04, 2026)=
  • bens-email-marketing-automation/trunk/utils/helper.php

    r3783528 r3822017  
    276276                        'mailerhub_page_bema-campaigns',
    277277                        'mailerhub_page_bema-settings',
     278                        'mailerhub_page_bema-mcp',
    278279                        'mailerhub_page_lf-license',
    279280                        'mailerhub_page_bema-campaigns',
Note: See TracChangeset for help on using the changeset viewer.