Plugin Directory

Changeset 3377114


Ignore:
Timestamp:
10/12/2025 10:13:18 PM (6 months ago)
Author:
yournotify
Message:

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

Location:
yournotify/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • yournotify/trunk/includes/class-yournotify-optin.php

    r3377110 r3377114  
    6161  }
    6262});
     63
     64
     65add_action('init', function(){
     66  if (!shortcode_exists('yournotify_subscribe')) {
     67    add_shortcode('yournotify_subscribe', function($atts = []){
     68      $atts = shortcode_atts([
     69        'name_placeholder'  => __('Full name','yournotify'),
     70        'email_placeholder' => __('Email','yournotify'),
     71        'tel_placeholder'   => __('Telephone','yournotify'),
     72        'button_text'       => __('Subscribe','yournotify'),
     73      ], $atts, 'yournotify_subscribe');
     74
     75      $action = esc_url(admin_url('admin-ajax.php'));
     76      $nonce  = wp_create_nonce('yournotify_subscribe');
     77
     78      $html  = '<form method="post" action="'.$action.'" class="yournotify-subscribe-form">';
     79      $html .= '<input type="hidden" name="action" value="yournotify_subscribe_submit">';
     80      $html .= '<input type="hidden" name="_wpnonce" value="'.$nonce.'">';
     81
     82      // Name
     83      $html .= '<p><input type="text" name="name" required placeholder="'.esc_attr($atts['name_placeholder']).'"></p>';
     84
     85      // Email (required)
     86      $html .= '<p><input type="email" name="email" required placeholder="'.esc_attr($atts['email_placeholder']).'"></p>';
     87
     88      // Telephone (optional)
     89      $html .= '<p><input type="tel" name="telephone" placeholder="'.esc_attr($atts['tel_placeholder']).'"></p>';
     90
     91      $html .= '<p><button type="submit">'.esc_html($atts['button_text']).'</button></p>';
     92      $html .= '</form>';
     93
     94      return $html;
     95    });
     96  }
     97});
     98
     99
     100/**
     101 * Normalize/prepare submit payload for backend.
     102 * - Ensure 'phone' is set if only 'telephone' was provided
     103 * - Basic sanitization
     104 */
     105function yournotify__normalize_submit_fields() {
     106  if (!empty($_POST['telephone']) && empty($_POST['phone'])) {
     107    $_POST['phone'] = $_POST['telephone'];
     108  }
     109  if (isset($_POST['name'])) {
     110    $_POST['name'] = sanitize_text_field($_POST['name']);
     111  }
     112  if (isset($_POST['email'])) {
     113    $_POST['email'] = sanitize_email($_POST['email']);
     114  }
     115  if (isset($_POST['telephone'])) {
     116    $_POST['telephone'] = preg_replace('/[^0-9+\-\s\(\)]/', '', $_POST['telephone']);
     117  }
     118  if (isset($_POST['phone'])) {
     119    $_POST['phone'] = preg_replace('/[^0-9+\-\s\(\)]/', '', $_POST['phone']);
     120  }
     121}
     122add_action('wp_ajax_yournotify_subscribe_submit', 'yournotify__normalize_submit_fields', 2);
     123add_action('wp_ajax_nopriv_yournotify_subscribe_submit', 'yournotify__normalize_submit_fields', 2);
     124add_action('wp_ajax_yournotify_optin_submit', 'yournotify__normalize_submit_fields', 2);
     125add_action('wp_ajax_nopriv_yournotify_optin_submit', 'yournotify__normalize_submit_fields', 2);
     126
  • yournotify/trunk/readme.txt

    r3377110 r3377114  
    44Requires at least: 4.6
    55Tested up to: 6.7
    6 Stable tag: 2.0.0
     6Stable tag: 2.0.1
    77License: GPLv3 or later
    88
  • yournotify/trunk/yournotify.php

    r3377110 r3377114  
    44 * Plugin URI: https://yournotify.com
    55 * Description: Yournotify WP Plugin — Subscriber Form and SMTP override. Minimal build.
    6  * Version: 2.0.0
     6 * Version: 2.0.1
    77 * Author: Yournotify
    88 * Author URI: https://yournotify.com
Note: See TracChangeset for help on using the changeset viewer.