Changeset 3213943
- Timestamp:
- 12/27/2024 07:47:03 PM (14 months ago)
- Location:
- simple-exit-notifier
- Files:
-
- 20 added
- 5 edited
-
tags/1.1.0 (added)
-
tags/1.1.0/assets (added)
-
tags/1.1.0/assets/css (added)
-
tags/1.1.0/assets/css/admin.css (added)
-
tags/1.1.0/assets/css/frontend.css (added)
-
tags/1.1.0/assets/js (added)
-
tags/1.1.0/assets/js/frontend.js (added)
-
tags/1.1.0/assets/js/settings.js (added)
-
tags/1.1.0/assets/screenshots (added)
-
tags/1.1.0/assets/screenshots/screenshot-1.png (added)
-
tags/1.1.0/assets/screenshots/screenshot-2.png (added)
-
tags/1.1.0/includes (added)
-
tags/1.1.0/includes/class-simple-exit-notifier-admin.php (added)
-
tags/1.1.0/includes/class-simple-exit-notifier-frontend.php (added)
-
tags/1.1.0/includes/class-simple-exit-notifier-init.php (added)
-
tags/1.1.0/index.php (added)
-
tags/1.1.0/readme.txt (added)
-
tags/1.1.0/simple-exit-notifier.php (added)
-
trunk/assets/css/admin.css (added)
-
trunk/assets/js/frontend.js (modified) (2 diffs)
-
trunk/assets/js/settings.js (added)
-
trunk/includes/class-simple-exit-notifier-admin.php (modified) (3 diffs)
-
trunk/includes/class-simple-exit-notifier-frontend.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/simple-exit-notifier.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-exit-notifier/trunk/assets/js/frontend.js
r3209994 r3213943 4 4 5 5 // Get the exception class from a localized variable 6 const exceptionClass = simple_exit_notifier_data.exceptionClass || null; // Default to nullif empty6 const exceptionClass = simple_exit_notifier_data.exceptionClass || 'noexit'; // Default to 'noexit' if empty 7 7 8 8 // Detect clicks on links … … 21 21 // Update the "Proceed" button with the link 22 22 $('#simple-exit-notifier-proceed').attr('href', externalLink); 23 24 // Update the external link display if enabled 25 const externalLinkElement = $('#simple-exit-notifier-external-link'); 26 if (externalLinkElement.length) { 27 externalLinkElement.text(`Visit: ${externalLink}`).show(); // Display the link 28 } 23 29 24 30 // Show the modal -
simple-exit-notifier/trunk/includes/class-simple-exit-notifier-admin.php
r3209994 r3213943 10 10 add_action('admin_init', [$this, 'chrssen_register_settings']); 11 11 add_action('admin_menu', [$this, 'chrssen_add_admin_menu']); 12 add_action('admin_enqueue_scripts', [$this, 'chrssen_enqueue_admin_scripts']); 13 add_filter('plugin_action_links_' . plugin_basename(CHRSSEN_PLUGIN_PATH . 'simple-exit-notifier.php'), [$this, 'chrssen_add_settings_link']); 12 14 } 15 16 /** 17 * Enqueue admin scripts for the settings page. 18 * 19 * @param string $hook The current admin page. 20 */ 21 public function chrssen_enqueue_admin_scripts($hook) { 22 if ($hook === 'settings_page_simple-exit-notifier') { 23 // Enqueue admin-specific CSS 24 wp_enqueue_style('chrssen-admin-css', CHRSSEN_PLUGIN_URL . 'assets/css/admin.css', [], CHRSSEN_VERSION); 25 26 // Enqueue admin-specific JS 27 wp_enqueue_script('chrssen-settings-js', CHRSSEN_PLUGIN_URL . 'assets/js/settings.js', [], CHRSSEN_VERSION, true); 28 } 29 } 30 31 /** 32 * Add a "Settings" link to the plugin on the plugins page. 33 * 34 * @param array $links Existing plugin action links. 35 * @return array Modified plugin action links. 36 */ 37 public function chrssen_add_settings_link($links) { 38 $settings_link = '<a href="' . admin_url('options-general.php?page=simple-exit-notifier') . '">' . __('Settings', 'simple-exit-notifier') . '</a>'; 39 array_unshift($links, $settings_link); 40 return $links; 41 } 42 13 43 14 44 /** … … 21 51 register_setting('chrssen_settings_group', 'chrssen_cancel_text', ['sanitize_callback' => 'sanitize_text_field']); 22 52 register_setting('chrssen_settings_group', 'chrssen_exception_class', ['sanitize_callback' => 'sanitize_text_field']); 53 register_setting('chrssen_settings_group', 'chrssen_display_external_link', ['sanitize_callback' => 'sanitize_text_field']); 23 54 } 24 55 … … 46 77 <div class="wrap"> 47 78 <h1><?php esc_html_e('Simple Exit Notifier', 'simple-exit-notifier'); ?></h1> 48 <form method="post" action="options.php"> 49 <?php 50 settings_fields('chrssen_settings_group'); 51 do_settings_sections('chrssen_settings_group'); 52 ?> 53 <table class="form-table"> 54 <tr> 55 <th scope="row"><label for="chrssen_heading"><?php esc_html_e('Popup Heading', 'simple-exit-notifier'); ?></label></th> 56 <td><input type="text" id="chrssen_heading" name="chrssen_heading" value="<?php echo esc_attr(get_option('chrssen_heading', 'Leaving Our Site')); ?>" class="regular-text" /></td> 57 </tr> 58 <tr> 59 <th scope="row"><label for="chrssen_message"><?php esc_html_e('Popup Message', 'simple-exit-notifier'); ?></label></th> 60 <td><textarea id="chrssen_message" name="chrssen_message" rows="5" class="large-text"><?php echo esc_textarea(get_option('chrssen_message', 'You are about to leave our website. Do you want to proceed?')); ?></textarea></td> 61 </tr> 62 <tr> 63 <th scope="row"><label for="chrssen_proceed_text"><?php esc_html_e('Proceed Button Text', 'simple-exit-notifier'); ?></label></th> 64 <td><input type="text" id="chrssen_proceed_text" name="chrssen_proceed_text" value="<?php echo esc_attr(get_option('chrssen_proceed_text', 'Proceed')); ?>" class="regular-text" /></td> 65 </tr> 66 <tr> 67 <th scope="row"><label for="chrssen_cancel_text"><?php esc_html_e('Cancel Button Text', 'simple-exit-notifier'); ?></label></th> 68 <td><input type="text" id="chrssen_cancel_text" name="chrssen_cancel_text" value="<?php echo esc_attr(get_option('chrssen_cancel_text', 'Cancel')); ?>" class="regular-text" /></td> 69 </tr> 70 <tr> 71 <th scope="row"><label for="chrssen_exception_class"><?php esc_html_e('Exception Class', 'simple-exit-notifier'); ?></label></th> 72 <td> 73 <input type="text" id="chrssen_exception_class" name="chrssen_exception_class" value="<?php echo esc_attr(get_option('chrssen_exception_class', 'noexit')); ?>" class="regular-text" /> 74 <p class="description"><?php esc_html_e('Add a CSS class to exclude certain links from showing the exit popup (e.g., "noexit").', 'simple-exit-notifier'); ?></p> 75 </td> 76 </tr> 77 </table> 78 <?php submit_button(); ?> 79 </form> 79 80 <div class="chrssen-container col-half"> 81 <div class="chrssen-col postbox"> 82 <div class="inside"> 83 <h2><?php esc_html_e('Settings', 'simple-exit-notifier'); ?></h2> 84 <form method="post" action="options.php"> 85 <?php 86 settings_fields('chrssen_settings_group'); 87 do_settings_sections('chrssen_settings_group'); 88 ?> 89 <table class="form-table"> 90 <tr> 91 <th scope="row"><label for="chrssen_heading"><?php esc_html_e('Popup Heading', 'simple-exit-notifier'); ?></label></th> 92 <td><input type="text" id="chrssen_heading" name="chrssen_heading" value="<?php echo esc_attr(get_option('chrssen_heading', 'Leaving Our Site')); ?>" class="regular-text" /></td> 93 </tr> 94 <tr> 95 <th scope="row"><label for="chrssen_message"><?php esc_html_e('Popup Message', 'simple-exit-notifier'); ?></label></th> 96 <td><textarea id="chrssen_message" name="chrssen_message" rows="5" class="large-text"><?php echo esc_textarea(get_option('chrssen_message', 'You are about to leave our website. Do you want to proceed?')); ?></textarea></td> 97 </tr> 98 <tr> 99 <th scope="row"><label for="chrssen_proceed_text"><?php esc_html_e('Proceed Button Text', 'simple-exit-notifier'); ?></label></th> 100 <td><input type="text" id="chrssen_proceed_text" name="chrssen_proceed_text" value="<?php echo esc_attr(get_option('chrssen_proceed_text', 'Proceed')); ?>" class="regular-text" /></td> 101 </tr> 102 <tr> 103 <th scope="row"><label for="chrssen_cancel_text"><?php esc_html_e('Cancel Button Text', 'simple-exit-notifier'); ?></label></th> 104 <td><input type="text" id="chrssen_cancel_text" name="chrssen_cancel_text" value="<?php echo esc_attr(get_option('chrssen_cancel_text', 'Cancel')); ?>" class="regular-text" /></td> 105 </tr> 106 <tr> 107 <th scope="row"><label for="chrssen_display_external_link"><?php esc_html_e('Display External Link in Popup', 'simple-exit-notifier'); ?></label></th> 108 <td> 109 <input type="checkbox" id="chrssen_display_external_link" name="chrssen_display_external_link" value="1" <?php checked(1, get_option('chrssen_display_external_link', 0)); ?> /> 110 <p class="description"><?php esc_html_e('If enabled, the external link (href) will be displayed in the popup.', 'simple-exit-notifier'); ?></p> 111 <p class="description"><?php esc_html_e('(Visit: https://www.xyz.com)', 'simple-exit-notifier'); ?></p> 112 </td> 113 </tr> 114 <tr> 115 <th scope="row"><label for="chrssen_exception_class"><?php esc_html_e('Exception Class', 'simple-exit-notifier'); ?></label></th> 116 <td> 117 <input type="text" id="chrssen_exception_class" name="chrssen_exception_class" value="<?php echo esc_attr(get_option('chrssen_exception_class', 'noexit')); ?>" class="regular-text" /> 118 <p class="description"><?php esc_html_e('Add a CSS class to exclude certain links from showing the exit popup (default: "noexit").', 'simple-exit-notifier'); ?></p> 119 </td> 120 </tr> 121 </table> 122 <?php submit_button(); ?> 123 </form> 124 </div> 125 </div> 126 <div class="chrssen-col postbox"> 127 <div class="inside"> 128 <h2><?php esc_html_e('Preview', 'simple-exit-notifier'); ?></h2> 129 130 <div id="chrssen-preview-modal"> 131 <div class="simple-exit-notifier-content" style="background: #fff;box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);margin-top:20px;"> 132 <div class="simple-exit-notifier-header" style="padding: 10px 20px;background: #ccc;"> 133 <h2 id="chrssen-preview-heading"><?php echo esc_html(get_option('chrssen_heading', 'Leaving Our Site')); ?></h2> 134 </div> 135 <div class="simple-exit-notifier-message" style="padding: 20px 20px 0;"> 136 <p id="chrssen-preview-message"><?php echo wp_kses_post(get_option('chrssen_message', 'You are about to leave our website. Do you want to proceed?')); ?></p> 137 <p id="chrssen-preview-external-link" style="text-align: center; <?php echo get_option('chrssen_display_external_link', 0) ? '' : 'display: none;'; ?>"> 138 <?php esc_html_e('Visit: https://www.xyz.com', 'simple-exit-notifier'); ?> 139 </p> 140 </div> 141 <div class="simple-exit-notifier-actions" style="padding-bottom: 20px;text-align: center;"> 142 <a id="chrssen-preview-proceed" href="#" style="margin: 10px;background: #4caf50; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 4px;"><?php echo esc_html(get_option('chrssen_proceed_text', 'Proceed')); ?></a> 143 <button id="chrssen-preview-cancel" style="margin: 10px;background: #f44336; color: #fff; padding: 10px 20px; border: none; border-radius: 4px;"><?php echo esc_html(get_option('chrssen_cancel_text', 'Cancel')); ?></button> 144 </div> 145 </div> 146 </div> 147 </div> 148 </div> 149 </div> 150 80 151 </div> 81 152 <?php -
simple-exit-notifier/trunk/includes/class-simple-exit-notifier-frontend.php
r3209994 r3213943 30 30 */ 31 31 public function chrssen_add_modal_html() { 32 $heading = get_option('chrssen_heading', 'Leaving Our Site'); 33 $message = get_option('chrssen_message', 'You are about to leave our website. Do you want to proceed?'); 34 $proceed_text = get_option('chrssen_proceed_text', 'Proceed'); 35 $cancel_text = get_option('chrssen_cancel_text', 'Cancel'); 32 // Retrieve saved options 33 $heading = get_option('chrssen_heading'); 34 $message = get_option('chrssen_message'); 35 $proceed_text = get_option('chrssen_proceed_text'); 36 $cancel_text = get_option('chrssen_cancel_text'); 37 $display_external_link = get_option('chrssen_display_external_link', 0); 38 39 40 // Set defaults if the options are empty 41 $heading = !empty($heading) ? esc_html($heading) : 'Leaving Our Site'; 42 $message = !empty($message) ? wp_kses_post($message) : 'You are about to leave our website. Do you want to proceed?'; 43 $proceed_text = !empty($proceed_text) ? esc_html($proceed_text) : 'Proceed'; 44 $cancel_text = !empty($cancel_text) ? esc_html($cancel_text) : 'Cancel'; 45 36 46 ?> 37 38 47 <div id="simple-exit-notifier-modal" style="display: none;"> 39 48 <div class="simple-exit-notifier-overlay"></div> … … 44 53 <div class="simple-exit-notifier-message"> 45 54 <p><?php echo wp_kses_post($message); ?></p> 55 56 <?php if ($display_external_link): ?> 57 <p id="simple-exit-notifier-external-link" style="text-align: center;"></p> 58 <?php endif; ?> 59 46 60 </div> 47 61 <div class="simple-exit-notifier-actions"> 62 <a id="simple-exit-notifier-proceed" href="#" target="_blank"><?php echo esc_html($proceed_text); ?></a> 48 63 <button id="simple-exit-notifier-cancel"><?php echo esc_html($cancel_text); ?></button> 49 <a id="simple-exit-notifier-proceed" href="#" target="_blank"><?php echo esc_html($proceed_text); ?></a>50 64 </div> 51 65 </div> … … 53 67 <?php 54 68 } 69 55 70 } -
simple-exit-notifier/trunk/readme.txt
r3209994 r3213943 1 1 === Simple Exit Notifier === 2 2 Contributors: chrsinteractive 3 Plugin URI: https://wordpress.org/plugins/simple-exit-notifier/ 3 4 Tags: exit popup, external links, link notifier, external link warning 4 5 Requires at least: 6.0.0 5 6 Tested up to: 6.7.1 6 7 Requires PHP: 8.1 7 Stable tag: 1. 0.08 Stable tag: 1.1.0 8 9 License: GPLv2 or later 9 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 20 21 - Compatible with both `http` and `https` links. 21 22 - Works with links that open in the same or a new tab. 23 - Preview popup in admin panel 22 24 - Lightweight and easy to configure via the WordPress admin panel. 23 25 … … 67 69 == Changelog == 68 70 71 = 1.1.0 = 72 * Added: "Settings" link on the Plugins page for quick access to the settings page. 73 * Added: "Display External Link in Popup" option to display the external link (href) within the popup. 74 * Added: Dynamic preview on the settings page that updates as fields are edited. 75 * Fixed: Fallback to default "noexit" exception class when the "Exception Class" field is empty. 76 * Fixed: Default text now displays for popup title, message, and buttons if settings fields are left blank. 77 * Updated: Improved localization handling for fallback text and checkbox behavior. 78 * Enhancement: Two-column layout for the settings page on desktop for better usability. 79 69 80 = 1.0.0 = 70 81 * Initial release. -
simple-exit-notifier/trunk/simple-exit-notifier.php
r3209994 r3213943 4 4 Plugin URI: https://wordpress.org/plugins/simple-exit-notifier/ 5 5 Description: Display a notification when a user clicks on an external link. 6 Version: 1. 0.06 Version: 1.1.0 7 7 Requires at least: 6.0.0 8 8 Tested up to: 6.7.1 … … 20 20 define('CHRSSEN_PLUGIN_URL', plugin_dir_url(__FILE__)); 21 21 define('CHRSSEN_PLUGIN_PATH', plugin_dir_path(__FILE__)); 22 define('CHRSSEN_VERSION', '1. 0.0');22 define('CHRSSEN_VERSION', '1.1.0'); 23 23 24 24 // Include necessary files
Note: See TracChangeset
for help on using the changeset viewer.