Changeset 3377114
- Timestamp:
- 10/12/2025 10:13:18 PM (6 months ago)
- Location:
- yournotify/trunk
- Files:
-
- 3 edited
-
includes/class-yournotify-optin.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
yournotify.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yournotify/trunk/includes/class-yournotify-optin.php
r3377110 r3377114 61 61 } 62 62 }); 63 64 65 add_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 */ 105 function 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 } 122 add_action('wp_ajax_yournotify_subscribe_submit', 'yournotify__normalize_submit_fields', 2); 123 add_action('wp_ajax_nopriv_yournotify_subscribe_submit', 'yournotify__normalize_submit_fields', 2); 124 add_action('wp_ajax_yournotify_optin_submit', 'yournotify__normalize_submit_fields', 2); 125 add_action('wp_ajax_nopriv_yournotify_optin_submit', 'yournotify__normalize_submit_fields', 2); 126 -
yournotify/trunk/readme.txt
r3377110 r3377114 4 4 Requires at least: 4.6 5 5 Tested up to: 6.7 6 Stable tag: 2.0. 06 Stable tag: 2.0.1 7 7 License: GPLv3 or later 8 8 -
yournotify/trunk/yournotify.php
r3377110 r3377114 4 4 * Plugin URI: https://yournotify.com 5 5 * Description: Yournotify WP Plugin — Subscriber Form and SMTP override. Minimal build. 6 * Version: 2.0. 06 * Version: 2.0.1 7 7 * Author: Yournotify 8 8 * Author URI: https://yournotify.com
Note: See TracChangeset
for help on using the changeset viewer.