Plugin Directory

Changeset 3213943


Ignore:
Timestamp:
12/27/2024 07:47:03 PM (14 months ago)
Author:
chrsinteractive
Message:

Release version 1.1.0: Added external link display option, improved settings page with dynamic preview and two-column layout, fixed default exception class behavior, updated admin script handling.

Location:
simple-exit-notifier
Files:
20 added
5 edited

Legend:

Unmodified
Added
Removed
  • simple-exit-notifier/trunk/assets/js/frontend.js

    r3209994 r3213943  
    44
    55    // Get the exception class from a localized variable
    6     const exceptionClass = simple_exit_notifier_data.exceptionClass || null; // Default to null if empty
     6    const exceptionClass = simple_exit_notifier_data.exceptionClass || 'noexit'; // Default to 'noexit' if empty
    77
    88    // Detect clicks on links
     
    2121            // Update the "Proceed" button with the link
    2222            $('#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            }
    2329
    2430            // Show the modal
  • simple-exit-notifier/trunk/includes/class-simple-exit-notifier-admin.php

    r3209994 r3213943  
    1010        add_action('admin_init', [$this, 'chrssen_register_settings']);
    1111        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']);
    1214    }
     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
    1343
    1444    /**
     
    2151        register_setting('chrssen_settings_group', 'chrssen_cancel_text', ['sanitize_callback' => 'sanitize_text_field']);
    2252        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']);
    2354    }
    2455
     
    4677        <div class="wrap">
    4778            <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
    80151        </div>
    81152        <?php
  • simple-exit-notifier/trunk/includes/class-simple-exit-notifier-frontend.php

    r3209994 r3213943  
    3030     */
    3131    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
    3646        ?>
    37            
    3847        <div id="simple-exit-notifier-modal" style="display: none;">
    3948            <div class="simple-exit-notifier-overlay"></div>
     
    4453                <div class="simple-exit-notifier-message">
    4554                    <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
    4660                </div>
    4761                <div class="simple-exit-notifier-actions">
     62                    <a id="simple-exit-notifier-proceed" href="#" target="_blank"><?php echo esc_html($proceed_text); ?></a>
    4863                    <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>
    5064                </div>
    5165            </div>
     
    5367        <?php
    5468    }
     69
    5570}
  • simple-exit-notifier/trunk/readme.txt

    r3209994 r3213943  
    11=== Simple Exit Notifier ===
    22Contributors: chrsinteractive
     3Plugin URI: https://wordpress.org/plugins/simple-exit-notifier/
    34Tags: exit popup, external links, link notifier, external link warning
    45Requires at least: 6.0.0
    56Tested up to: 6.7.1
    67Requires PHP: 8.1
    7 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    89License: GPLv2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2021- Compatible with both `http` and `https` links.
    2122- Works with links that open in the same or a new tab.
     23- Preview popup in admin panel
    2224- Lightweight and easy to configure via the WordPress admin panel.
    2325
     
    6769== Changelog ==
    6870
     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
    6980= 1.0.0 =
    7081* Initial release.
  • simple-exit-notifier/trunk/simple-exit-notifier.php

    r3209994 r3213943  
    44Plugin URI:         https://wordpress.org/plugins/simple-exit-notifier/
    55Description:        Display a notification when a user clicks on an external link.
    6 Version:            1.0.0
     6Version:            1.1.0
    77Requires at least:  6.0.0
    88Tested up to:       6.7.1
     
    2020define('CHRSSEN_PLUGIN_URL', plugin_dir_url(__FILE__));
    2121define('CHRSSEN_PLUGIN_PATH', plugin_dir_path(__FILE__));
    22 define('CHRSSEN_VERSION', '1.0.0');
     22define('CHRSSEN_VERSION', '1.1.0');
    2323
    2424// Include necessary files
Note: See TracChangeset for help on using the changeset viewer.