Plugin Directory

Changeset 3377292


Ignore:
Timestamp:
10/13/2025 07:55:31 AM (6 months ago)
Author:
yournotify
Message:

v2.1.1: stable release (Subscriber Form + SMTP tabs, fixed save, preconfigured smtp.yournotify.com:587 TLS).

Location:
yournotify/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • yournotify/trunk/assets/js/frontend.js

    r3377287 r3377292  
    33 */
    44(function ($) {
    5 
    6 }(jQuery));
    75    function ensureNotice($form) {
    86        var $notice = $form.find('.js-yournotify-frontend-notice');
    97        if (!$notice.length) {
    108            $notice = $('<div class="js-yournotify-frontend-notice"/>');
    11             // place after submit button area
    129            var $submit = $form.find('button[type="submit"], input[type="submit"]').last();
    13             if ($submit.length) {
    14                 $notice.insertAfter($submit);
    15             } else {
    16                 $form.append($notice);
    17             }
     10            if ($submit.length) { $notice.insertAfter($submit); }
     11            else { $form.append($notice); }
    1812        }
    1913        return $notice;
     
    2418        if (submitting) {
    2519            $btn.data('yn-text', $btn.is('input,button') ? ($btn.is('input') ? $btn.val() : $btn.text()) : '');
    26             if ($btn.is('input')) $btn.val(YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.loading : 'Submitting…');
    27             else $btn.text(YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.loading : 'Submitting…');
     20            if ($btn.is('input')) $btn.val(window.YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.loading : 'Submitting…');
     21            else $btn.text(window.YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.loading : 'Submitting…');
    2822            $btn.prop('disabled', true).addClass('is-loading');
    2923        } else {
    3024            var original = $btn.data('yn-text');
    31             if (typeof original === 'string') {
    32                 if ($btn.is('input')) $btn.val(original); else $btn.text(original);
    33             }
     25            if (typeof original === 'string') { if ($btn.is('input')) $btn.val(original); else $btn.text(original); }
    3426            $btn.prop('disabled', false).removeClass('is-loading');
    3527        }
     
    3729
    3830    function gatherData($form) {
    39         // Support both shortcode and widget fields
    4031        var name = ($form.find('input[name="name"]').val() || $form.find('.yournotify-subscribe__name-input').val() || '').trim();
    4132        var email = ($form.find('input[name="email"]').val() || $form.find('.yournotify-subscribe__email-input').val() || '').trim();
     
    5142            telephone: tel
    5243        };
    53         if (apiKey) data.api_key = apiKey; // server will also map to jwt
     44        if (apiKey) data.api_key = apiKey;
    5445        if (listId) data.list_id = listId;
    5546        return data;
     
    6354
    6455    function handleSubmit(e) {
    65         e.preventDefault();
     56        if (e) e.preventDefault();
    6657        var $form = $(this);
    6758        var $btn = $form.find('button[type="submit"], input[type="submit"]').first();
     
    7061
    7162        var data = gatherData($form);
    72 
    7363        if (!data.email) {
    7464            renderMessage($notice, '<div class="alert alert-danger">Email is required.</div>', true);
     
    8777                var msg = (resp.data && resp.data.message) ? resp.data.message : '<div class="alert alert-success">Subscribed successfully.</div>';
    8878                renderMessage($notice, msg, false);
    89                 // Do not auto-redirect; show message inline
    90                 try { $form[0].reset(); } catch(e){}
     79                try { $form[0].reset(); } catch(err){}
    9180            } else {
    92                 var err = (resp && resp.data && resp.data.message) ? resp.data.message : (YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.generic_error : 'Something went wrong. Please try again.');
    93                 renderMessage($notice, '<div class="alert alert-danger">'+ err +'</div>', true);
     81                var errMsg = (resp && resp.data && resp.data.message) ? resp.data.message : (window.YournotifyVars && YournotifyVars.i18n ? YournotifyVars.i18n.generic_error : 'Something went wrong. Please try again.');
     82                renderMessage($notice, '<div class="alert alert-danger">'+ errMsg +'</div>', true);
    9483            }
    9584        }).fail(function(){
    96             var err = (YournotifyVars && YournotifyVars.i18n) ? YournotifyVars.i18n.generic_error : 'Something went wrong. Please try again.';
     85            var err = (window.YournotifyVars && YournotifyVars.i18n) ? YournotifyVars.i18n.generic_error : 'Something went wrong. Please try again.';
    9786            renderMessage($notice, '<div class="alert alert-danger">'+ err +'</div>', true);
    9887        }).always(function(){
     
    10392    }
    10493
     94    // Submit intercept
    10595    $(document).on('submit', '.yournotify-subscribe-form', handleSubmit);
    10696    $(document).on('submit', 'form.yournotify-subscribe', handleSubmit);
     97    // Guard: prevent default click submits and route to handler
     98    $(document).on('click', '.yournotify-subscribe-form button[type="submit"], .yournotify-subscribe-form input[type="submit"], form.yournotify-subscribe button[type="submit"], form.yournotify-subscribe input[type="submit"]', function(e){
     99        e.preventDefault();
     100        $(this).closest('form').trigger('submit');
     101        return false;
     102    });
     103
     104}(jQuery));
  • yournotify/trunk/includes/class-yournotify-optin.php

    r3377287 r3377292  
    1818      ], $atts, 'yournotify_subscribe');
    1919
    20       $action   = admin_url('admin-ajax.php');
     20  // We'll submit via AJAX; avoid native navigation to admin-ajax.php
     21  $action   = '';
    2122      $nonce    = wp_create_nonce('yournotify_subscribe');
    2223      $api_key  = get_option('yournotify_api_key','');
    2324      $list_id  = get_option('yournotify_list_id','');
    2425
    25       $html  = '<form method="post" action="'.esc_url($action).'" class="yournotify-subscribe-form">';
     26  $html  = '<form method="post" action="'.esc_url($action).'" class="yournotify-subscribe-form" onsubmit="return false">';
    2627      $html .= '<input type="hidden" name="action" value="yournotify_subscribe_submit">';
    2728      $html .= '<input type="hidden" name="_wpnonce" value="'.esc_attr($nonce).'">';
  • yournotify/trunk/readme.txt

    r3377287 r3377292  
    44Requires at least: 4.6
    55Tested up to: 6.7
    6 Stable tag: 2.1.0
     6Stable tag: 2.1.1
    77License: GPLv3 or later
    88
  • yournotify/trunk/yournotify.php

    r3377287 r3377292  
    44 * Plugin URI: https://yournotify.com
    55 * Description: Yournotify WP Plugin — Subscriber Form and SMTP override.
    6  * Version: 2.1.0
     6 * Version: 2.1.1
    77 * Author: Yournotify
    88 * Author URI: https://yournotify.com
Note: See TracChangeset for help on using the changeset viewer.