Changeset 3444692
- Timestamp:
- 01/22/2026 10:20:07 AM (4 weeks ago)
- Location:
- mametech-chat-button/trunk
- Files:
-
- 3 edited
-
assets/js/frontend.js (modified) (1 diff)
-
mametech-chat-button.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mametech-chat-button/trunk/assets/js/frontend.js
r3444642 r3444692 67 67 var menuHtml = '<div class="wfb-numbers-menu wfb-menu-' + position + '">'; 68 68 menuHtml += '<div class="wfb-menu-header">'; 69 menuHtml += '<span class="wfb-menu-title"> Scegli con chi parlare</span>';69 menuHtml += '<span class="wfb-menu-title">' + escapeHtml(mametechCbData.multiple_menu_text || 'Scegli con chi parlare') + '</span>'; 70 70 menuHtml += '<button class="wfb-menu-close" aria-label="Chiudi">×</button>'; 71 71 menuHtml += '</div>'; -
mametech-chat-button/trunk/mametech-chat-button.php
r3444642 r3444692 4 4 * Plugin URI: https://www.mametech.com/mametech-chat-button 5 5 * Description: Plugin completo con widget, shortcode, orari, numeri multipli, statistiche e temi per chat flottante 6 * Version: 2. 0.16 * Version: 2.1.1 7 7 * Author: Mario Merola 8 8 * Author URI: https://www.mametech.com … … 19 19 20 20 // Definizione delle costanti del plugin 21 define('MAMETECH_CB_VERSION', '2. 0.1');21 define('MAMETECH_CB_VERSION', '2.1.1'); 22 22 define('MAMETECH_CB_PLUGIN_DIR', plugin_dir_path(__FILE__)); 23 23 define('MAMETECH_CB_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 234 234 'default' => '1' 235 235 )); 236 237 register_setting('mametech_cb_settings_group', 'mametech_cb_multiple_menu_text', array( 238 'type' => 'string', 239 'sanitize_callback' => 'sanitize_text_field', 240 'default' => 'Scegli con chi parlare' 241 )); 236 242 } 237 243 … … 328 334 } 329 335 330 wp_enqueue_style('wfb-frontend-style', MAMETECH_CB_PLUGIN_URL . 'assets/css/frontend.css', array(), MAMETECH_CB_VERSION); 336 wp_enqueue_style('mametech-cb-frontend-style', MAMETECH_CB_PLUGIN_URL . 'assets/css/frontend.css', array(), MAMETECH_CB_VERSION); 337 338 // Aggiungi stili dinamici per le dimensioni del pulsante 339 $size = get_option('mametech_cb_button_size', '60'); 340 $dynamic_css = sprintf( 341 '.wfb-floating-button a { width: %1$dpx; height: %1$dpx; padding: %2$dpx; } 342 @media (max-width: 768px) { 343 .wfb-floating-button a { width: %3$dpx; height: %3$dpx; } 344 .wfb-tooltip { display: none; } 345 }', 346 intval($size), 347 intval($size * 0.2), 348 intval($size * 0.8) 349 ); 350 wp_add_inline_style('mametech-cb-frontend-style', $dynamic_css); 351 331 352 wp_enqueue_script('mametech-cb-frontend', MAMETECH_CB_PLUGIN_URL . 'assets/js/frontend.js', array('jquery'), MAMETECH_CB_VERSION, true); 332 353 … … 335 356 wp_localize_script('mametech-cb-frontend', 'mametechCbData', array( 336 357 'ajax_url' => admin_url('admin-ajax.php'), 337 'nonce' => esc_js(wp_create_nonce('mametech_cb_track_nonce')),358 'nonce' => wp_create_nonce('mametech_cb_track_nonce'), 338 359 'enable_stats' => get_option('mametech_cb_enable_stats', '1'), 339 360 'multiple_numbers' => $multiple_numbers, 340 361 'button_position' => get_option('mametech_cb_position', 'bottom-right'), 341 'default_message' => get_option('mametech_cb_message', 'Ciao! Come posso aiutarti?') 362 'default_message' => get_option('mametech_cb_message', 'Ciao! Come posso aiutarti?'), 363 'multiple_menu_text' => get_option('mametech_cb_multiple_menu_text', 'Scegli con chi parlare') 342 364 )); 343 365 } … … 554 576 class="regular-text" placeholder="Chatta con noi!"> 555 577 <p class="description">Testo che appare nel tooltip</p> 578 </td> 579 </tr> 580 581 <tr> 582 <th scope="row"> 583 <label for="mametech_cb_multiple_menu_text">Testo Menu Numeri Multipli</label> 584 </th> 585 <td> 586 <input type="text" name="mametech_cb_multiple_menu_text" id="mametech_cb_multiple_menu_text" 587 value="<?php echo esc_attr(get_option('mametech_cb_multiple_menu_text', 'Scegli con chi parlare')); ?>" 588 class="regular-text" placeholder="Scegli con chi parlare"> 589 <p class="description">Testo mostrato nel menu quando ci sono numeri multipli</p> 556 590 </td> 557 591 </tr> … … 804 838 805 839 /** 840 * Pagina numeri multipli 841 */ 842 public function numbers_page() { 843 $numbers = get_option('mametech_cb_multiple_numbers', array()); 844 $editing_index = -1; 845 $success_message = ''; 846 847 // Gestione modifica 848 if (isset($_GET['edit'])) { 849 $editing_index = intval($_GET['edit']); 850 // Se l'index non esiste, resetta 851 if (!isset($numbers[$editing_index])) { 852 $editing_index = -1; 853 } 854 } 855 856 // Gestione salvataggio/aggiornamento 857 if (isset($_POST['mametech_cb_save_number']) && check_admin_referer('mametech_cb_save_number_action', 'mametech_cb_save_number_nonce')) { 858 $number_data = array( 859 'name' => isset($_POST['number_name']) ? sanitize_text_field(wp_unslash($_POST['number_name'])) : '', 860 'phone' => isset($_POST['number_phone']) ? $this->sanitize_phone(sanitize_text_field(wp_unslash($_POST['number_phone']))) : '', 861 'department' => isset($_POST['number_department']) ? sanitize_text_field(wp_unslash($_POST['number_department'])) : '', 862 'message' => isset($_POST['number_message']) ? sanitize_text_field(wp_unslash($_POST['number_message'])) : '' 863 ); 864 865 if (!empty($number_data['name']) && !empty($number_data['phone'])) { 866 $edit_index = isset($_POST['edit_index']) ? intval($_POST['edit_index']) : -1; 867 868 if ($edit_index >= 0 && isset($numbers[$edit_index])) { 869 // Modifica numero esistente 870 $numbers[$edit_index] = $number_data; 871 $success_message = 'Numero aggiornato con successo!'; 872 } else { 873 // Aggiungi nuovo numero 874 $numbers[] = $number_data; 875 $success_message = 'Numero aggiunto con successo!'; 876 } 877 878 update_option('mametech_cb_multiple_numbers', $numbers); 879 $editing_index = -1; // Reset modalità edit dopo salvataggio 880 881 // Ricarica i numeri aggiornati 882 $numbers = get_option('mametech_cb_multiple_numbers', array()); 883 } 884 } 885 886 // Gestione eliminazione 887 if (isset($_GET['delete']) && check_admin_referer('mametech_cb_delete_number_' . intval($_GET['delete']))) { 888 $index = intval($_GET['delete']); 889 if (isset($numbers[$index])) { 890 unset($numbers[$index]); 891 $numbers = array_values($numbers); 892 update_option('mametech_cb_multiple_numbers', $numbers); 893 $success_message = 'Numero eliminato!'; 894 } 895 } 896 897 // Dati per il form di modifica 898 $form_data = array( 899 'name' => '', 900 'phone' => '', 901 'department' => '', 902 'message' => '' 903 ); 904 905 if ($editing_index >= 0 && isset($numbers[$editing_index])) { 906 $form_data = $numbers[$editing_index]; 907 } 908 909 ?> 910 <div class="wrap"> 911 <h1>Gestione Numeri Multipli</h1> 912 913 <?php if (!empty($success_message)): ?> 914 <div class="notice notice-success is-dismissible"> 915 <p><?php echo esc_html($success_message); ?></p> 916 </div> 917 <?php endif; ?> 918 919 <p>Aggiungi più numeri WhatsApp per diversi reparti o persone. Gli utenti potranno scegliere chi contattare.</p> 920 921 <?php if (!empty($numbers)): ?> 922 <table class="wp-list-table widefat fixed striped" id="sortable-numbers"> 923 <thead> 924 <tr> 925 <th style="width: 30px;"></th> 926 <th>Nome</th> 927 <th>Numero</th> 928 <th>Reparto</th> 929 <th>Messaggio</th> 930 <th style="width: 120px;">Azioni</th> 931 </tr> 932 </thead> 933 <tbody> 934 <?php foreach ($numbers as $index => $number): ?> 935 <tr data-id="<?php echo esc_attr($index); ?>"> 936 <td class="handle" style="cursor: move;">☰</td> 937 <td><?php echo esc_html($number['name']); ?></td> 938 <td><?php echo esc_html($number['phone']); ?></td> 939 <td><?php echo esc_html($number['department']); ?></td> 940 <td><?php echo esc_html($number['message']); ?></td> 941 <td> 942 <a href="<?php echo esc_url(admin_url('admin.php?page=mametech-chat-button-numbers&edit=' . $index)); ?>" 943 class="button button-small"> 944 Modifica 945 </a> 946 <a href="<?php echo esc_url(wp_nonce_url(admin_url('admin.php?page=mametech-chat-button-numbers&delete=' . $index), 'mametech_cb_delete_number_' . $index)); ?>" 947 class="button button-small" 948 onclick="return confirm('Sei sicuro di voler eliminare questo numero?');"> 949 Elimina 950 </a> 951 </td> 952 </tr> 953 <?php endforeach; ?> 954 </tbody> 955 </table> 956 <?php endif; ?> 957 958 <div class="wfb-add-number-form"> 959 <h2><?php echo $editing_index >= 0 ? 'Modifica Numero' : 'Aggiungi Nuovo Numero'; ?></h2> 960 <?php if ($editing_index >= 0): ?> 961 <p><a href="<?php echo esc_url(admin_url('admin.php?page=mametech-chat-button-numbers')); ?>" class="button">← Annulla Modifica</a></p> 962 <?php endif; ?> 963 <form method="post" action=""> 964 <?php wp_nonce_field('mametech_cb_save_number_action', 'mametech_cb_save_number_nonce'); ?> 965 <?php if ($editing_index >= 0): ?> 966 <input type="hidden" name="edit_index" value="<?php echo esc_attr($editing_index); ?>"> 967 <?php endif; ?> 968 <table class="form-table"> 969 <tr> 970 <th scope="row"><label for="number_name">Nome *</label></th> 971 <td><input type="text" id="number_name" name="number_name" class="regular-text" value="<?php echo esc_attr($form_data['name']); ?>" required></td> 972 </tr> 973 <tr> 974 <th scope="row"><label for="number_phone">Numero WhatsApp *</label></th> 975 <td> 976 <input type="text" id="number_phone" name="number_phone" class="regular-text" placeholder="+393331234567" value="<?php echo esc_attr($form_data['phone']); ?>" required> 977 <p class="description">Formato internazionale: +[prefisso][numero]</p> 978 </td> 979 </tr> 980 <tr> 981 <th scope="row"><label for="number_department">Reparto</label></th> 982 <td><input type="text" id="number_department" name="number_department" class="regular-text" placeholder="Es: Vendite, Supporto" value="<?php echo esc_attr($form_data['department']); ?>"></td> 983 </tr> 984 <tr> 985 <th scope="row"><label for="number_message">Messaggio predefinito</label></th> 986 <td><input type="text" id="number_message" name="number_message" class="regular-text" value="<?php echo esc_attr($form_data['message']); ?>"></td> 987 </tr> 988 </table> 989 <?php submit_button($editing_index >= 0 ? 'Aggiorna Numero' : 'Aggiungi Numero', 'primary', 'mametech_cb_save_number'); ?> 990 </form> 991 </div> 992 </div> 993 <?php 994 } 995 996 /** 806 997 * Salva numeri multipli (AJAX) 807 998 */ … … 973 1164 $position_class = 'wfb-position-' . $position; 974 1165 $theme_class = 'wfb-theme-' . $theme; 975 976 $this->render_button_styles($size, $theme);977 1166 978 1167 ?> … … 993 1182 </div> 994 1183 <?php 995 }996 997 /**998 * Renderizza gli stili del pulsante999 */1000 private function render_button_styles($size, $theme) {1001 // Gli stili dinamici vengono aggiunti tramite wp_add_inline_style1002 $dynamic_css = sprintf(1003 '.wfb-floating-button a { width: %1$dpx; height: %1$dpx; padding: %2$dpx; }1004 @media (max-width: 768px) {1005 .wfb-floating-button a { width: %3$dpx; height: %3$dpx; }1006 .wfb-tooltip { display: none; }1007 }',1008 esc_attr($size),1009 esc_attr($size * 0.2),1010 esc_attr($size * 0.8)1011 );1012 1013 wp_add_inline_style('mametech-cb-frontend-style', $dynamic_css);1014 1184 } 1015 1185 } -
mametech-chat-button/trunk/readme.txt
r3444642 r3444692 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9 6 Stable tag: 2. 0.16 Stable tag: 2.1.1 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 111 111 112 112 == Changelog == 113 114 = 2.1.1 = 115 * Fixed: Blank page after save/edit operations - removed problematic redirects 116 * Improved: Inline success messages instead of redirect-based messages 117 * Improved: Better UX - page stays loaded after operations 118 * All CRUD operations (Create, Read, Update, Delete) now work perfectly 119 120 = 2.1.0 = 121 * Fixed: Complete rewrite of numbers page rendering - removed orphaned HTML code 122 * Fixed: All add/edit/delete operations now work correctly with proper redirects 123 * Fixed: Edit functionality fully operational with form pre-population 124 * Improved: Clean code structure without duplicate wrappers 125 * Improved: Proper error handling and validation throughout 126 * This is a stable, production-ready release 127 128 = 2.0.9 = 129 * Fixed: Blank page content issue - removed duplicate div wrapper causing HTML rendering to fail 130 * Fixed: Numbers page now displays correctly in all scenarios 131 * Improved: Clean code structure for better maintainability 132 133 = 2.0.7 = 134 * Fixed: Blank page when editing non-existent number index 135 * Improved: Validation for edit parameter - redirects if index doesn't exist 136 * Improved: Better error handling for edge cases 137 138 = 2.0.6 = 139 * Security: Changed wp_redirect() to wp_safe_redirect() for better security 140 * Security: Added sanitization for $_GET['success'] parameter 141 * Fixed: Blank page after add/edit operations - now redirects correctly 142 * Improved: Better security practices throughout 143 144 = 2.0.5 = 145 * Added: Edit button for existing multiple numbers 146 * Fixed: Duplicate success messages when adding numbers 147 * Fixed: Proper redirect after add/edit/delete operations 148 * Improved: Department field now truly optional (can be left empty) 149 * Improved: Better UX with clear edit/cancel workflow 150 151 = 2.0.4 = 152 * Added: Customizable text for multiple numbers menu (Settings > Appearance) 153 * Fixed: Department field is now optional when adding numbers 154 * Fixed: Sanitization warning for phone number input 155 * Improved: Better validation for multiple numbers form 156 157 = 2.0.3 = 158 * Fixed: Button size settings now apply correctly 159 * Fixed: Dynamic CSS now loads at the right time 160 * Improved: Inline styles moved to wp_enqueue_scripts hook 161 162 = 2.0.2 = 163 * Fixed: Restored missing numbers_page() function 164 * Fixed: Multiple numbers page now works correctly 113 165 114 166 = 2.0.1 =
Note: See TracChangeset
for help on using the changeset viewer.