Plugin Directory

Changeset 3770725


Ignore:
Timestamp:
10/28/2026 01:05:04 PM (3 days ago)
Author:
lvmdev
Message:

1.0.1: tracker check by script id, keep data on uninstall

Location:
lvm-chat-click-stats/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • lvm-chat-click-stats/trunk/assets/js/admin-check.js

    r3770681 r3770725  
    2727                        .then(function (r) { return r.text(); })
    2828                        .then(function (html) {
    29                                 render(el, html.indexOf('cswaConfig') !== -1 ? 'ok' : 'missing');
     29                                /* WordPress prints our script as <script id="cswa-tracker-js" ...> and its config as id="cswa-tracker-js-extra".
     30                                   Optimizers (LiteSpeed, WP Rocket, Autoptimize) may combine, defer or base64-encode the contents, but keep the id. */
     31                                render(el, /id=["']cswa-tracker-js(-extra)?["']/.test(html) ? 'ok' : 'missing');
    3032                        })
    3133                        .catch(function () { render(el, 'error'); });
  • lvm-chat-click-stats/trunk/includes/admin-settings.php

    r3770681 r3770725  
    4444        $out['button_text']      = isset( $in['button_text'] ) ? sanitize_text_field( (string) $in['button_text'] ) : '';
    4545        $out['button_position']  = ( isset( $in['button_position'] ) && 'left' === $in['button_position'] ) ? 'left' : 'right';
     46        $out['delete_on_uninstall'] = empty( $in['delete_on_uninstall'] ) ? 0 : 1;
    4647
    4748        return $out;
    … …  
    172173                <div class="cswa-card cswa-danger">
    173174                        <h2><?php esc_html_e( 'Delete all data', 'lvm-chat-click-stats' ); ?></h2>
     175                        <form method="post" action="options.php" style="margin-bottom:14px">
     176                                <?php settings_fields( 'cswa_settings_group' ); ?>
     177                                <?php foreach ( $s as $k => $v ) : if ( 'delete_on_uninstall' === $k ) { continue; } ?>
     178                                        <input type="hidden" name="cswa_settings[<?php echo esc_attr( $k ); ?>]" value="<?php echo esc_attr( $v ); ?>">
     179                                <?php endforeach; ?>
     180                                <label><input type="checkbox" name="cswa_settings[delete_on_uninstall]" value="1" <?php checked( $s['delete_on_uninstall'], 1 ); ?>> <?php esc_html_e( 'Also delete all click data when the plugin is uninstalled', 'lvm-chat-click-stats' ); ?></label>
     181                                <p class="description"><?php esc_html_e( 'Off by default: your statistics survive uninstalling and reinstalling the plugin. Turn it on only if you want a clean removal.', 'lvm-chat-click-stats' ); ?></p>
     182                                <?php submit_button( __( 'Save', 'lvm-chat-click-stats' ), 'secondary', 'submit', false ); ?>
     183                        </form>
    174184                        <p class="description"><?php esc_html_e( 'Removes every recorded click. This cannot be undone.', 'lvm-chat-click-stats' ); ?></p>
    175185                        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" onsubmit="return confirm('<?php echo esc_js( __( 'Delete all click data?', 'lvm-chat-click-stats' ) ); ?>');">
  • lvm-chat-click-stats/trunk/includes/helpers.php

    r3770681 r3770725  
    2525                'button_text'      => '',
    2626                'button_position'  => 'right',
     27                'delete_on_uninstall' => 0,
    2728        );
    2829}
  • lvm-chat-click-stats/trunk/lvm-chat-click-stats.php

    r3770681 r3770725  
    33 * Plugin Name:       LVM Chat Click Stats
    44 * Description:       Counts every click on the WhatsApp links and buttons of your site, with no setup. See clicks per day, page, source and link right from your dashboard.
    5  * Version:           1.0.0
     5 * Version:           1.0.1
    66 * Requires at least: 6.2
    77 * Requires PHP:      7.4
    … …  
    2020}
    2121
    22 define( 'CSWA_VERSION', '1.0.0' );
     22define( 'CSWA_VERSION', '1.0.1' );
    2323define( 'CSWA_FILE', __FILE__ );
    2424define( 'CSWA_DIR', plugin_dir_path( __FILE__ ) );
  • lvm-chat-click-stats/trunk/readme.txt

    r3770681 r3770725  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    4343**Privacy first**
    4444
    45 No cookies, no IP addresses, no personal data, nothing sent to external servers. Everything stays in your WordPress database. Clicks by administrators are ignored by default, and old data is deleted automatically after the number of days you choose.
     45No cookies, no IP addresses, no personal data, nothing sent to external servers. Everything stays in your WordPress database. Clicks by administrators are ignored by default, and old data is deleted automatically after the number of days you choose. Your statistics are kept if you uninstall and reinstall the plugin, unless you choose otherwise in Settings.
    4646
    4747**Lightweight**
    … …  
    102102== Changelog ==
    103103
     104= 1.0.1 =
     105* Tracker status check now looks for the script tag id, so it also works when LiteSpeed, WP Rocket or Autoptimize defer or combine scripts.
     106* Uninstalling no longer deletes click data by default; a new option in Settings lets you opt in to a full cleanup.
     107
    104108= 1.0.0 =
    105109* First release.
    … …  
    107111== Upgrade Notice ==
    108112
    109 = 1.0.0 =
    110 First release.
     113= 1.0.1 =
     114Fixes a false "tracker missing" warning on sites with cache or CDN.
  • lvm-chat-click-stats/trunk/uninstall.php

    r3770681 r3770725  
    1212global $wpdb;
    1313
    14 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- uninstall cleanup.
    15 $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . 'cswa_clicks' ) );
     14$cswa_settings = get_option( 'cswa_settings', array() );
     15$cswa_wipe     = is_array( $cswa_settings ) && ! empty( $cswa_settings['delete_on_uninstall'] );
    1616
    17 delete_option( 'cswa_settings' );
    18 delete_option( 'cswa_db_version' );
     17// Click data is kept unless the user opted in (Settings → Delete all data), so reinstalling never loses history.
     18if ( $cswa_wipe ) {
     19        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- uninstall cleanup.
     20        $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->prefix . 'cswa_clicks' ) );
     21        delete_option( 'cswa_settings' );
     22        delete_option( 'cswa_db_version' );
     23}
     24
    1925wp_clear_scheduled_hook( 'cswa_daily_cleanup' );
    2026
Note: See TracChangeset for help on using the changeset viewer.