Plugin Directory

Changeset 3441985


Ignore:
Timestamp:
01/18/2026 03:52:40 PM (2 months ago)
Author:
supportfromrichard
Message:

Version 1.0.7: Added deactivation feedback popup feature

Location:
sfr-directory-analytics/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • sfr-directory-analytics/trunk

    • Property svn:ignore set to
      .DS_Store
  • sfr-directory-analytics/trunk/includes/class-sfrda-admin.php

    r3440479 r3441985  
    99if ( ! defined( 'ABSPATH' ) ) {
    1010    exit;
     11}
     12
     13// Prevent class redeclaration (in case Pro version already loaded it)
     14if ( class_exists( 'SFRDA_Admin' ) ) {
     15    return;
    1116}
    1217
  • sfr-directory-analytics/trunk/includes/class-sfrda-analytics.php

    r3392964 r3441985  
    1111}
    1212
     13// Prevent class redeclaration (in case Pro version already loaded it)
     14if ( class_exists( 'SFRDA_Analytics' ) ) {
     15    return;
     16}
     17
    1318/**
    1419 * Processes and aggregates analytics data
  • sfr-directory-analytics/trunk/includes/class-sfrda-integrations.php

    r3392964 r3441985  
    99if ( ! defined( 'ABSPATH' ) ) {
    1010    exit;
     11}
     12
     13// Prevent class redeclaration (in case Pro version already loaded it)
     14if ( class_exists( 'SFRDA_Integrations' ) ) {
     15    return;
    1116}
    1217
  • sfr-directory-analytics/trunk/includes/class-sfrda-tracker.php

    r3440479 r3441985  
    1111}
    1212
     13// Prevent class redeclaration (in case Pro version already loaded it)
     14if ( class_exists( 'SFRDA_Tracker' ) ) {
     15    return;
     16}
     17
    1318/**
    1419 * Tracks directory listing and category views
  • sfr-directory-analytics/trunk/readme.txt

    r3440479 r3441985  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.6
     7Stable tag: 1.0.7
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    435435
    436436== Changelog ==
     437
     438= 1.0.7 =
     439* Feature: Added deactivation feedback popup to collect user feedback when plugin is deactivated
     440* Enhancement: Improved user experience with optional feedback collection for support and plugin improvements
     441* Technical: Added AJAX handlers for deactivation feedback submission to license server
    437442
    438443= 1.0.6 =
     
    495500== Upgrade Notice ==
    496501
     502= 1.0.7 =
     503Adds deactivation feedback popup feature. Safe to update - no action required.
     504
    497505= 1.0.6 =
    498506Security improvements, WordPress 6.9 compatibility, and translation loading fixes for WordPress 6.7+. Safe to update - no action required.
  • sfr-directory-analytics/trunk/sfr-directory-analytics.php

    r3440479 r3441985  
    44 * Plugin URI: https://supportfromrichard.co.uk/plugins/sfr-directory-analytics/
    55 * Description: Track views, categories, and listings for Directorist, GeoDirectory, and Business Directory with beautiful analytics dashboards.
    6  * Version: 1.0.6
     6 * Version: 1.0.7
    77 * Requires at least: 5.8
    88 * Tested up to: 6.9
     
    2121}
    2222
     23// Check if Pro version is active - if so, stop loading Free version
     24if ( defined( 'SFRDA_PRO_VERSION' ) || class_exists( 'SFRDA_Pro_Main' ) ) {
     25    // Pro version is already loaded - stop here
     26    add_action( 'admin_notices', function() {
     27        ?>
     28        <div class="notice notice-warning">
     29            <p><strong>SFR Directory Analytics (Free)</strong> is not needed - the Pro version is already active.</p>
     30            <p>The Pro version includes all free features plus advanced functionality.</p>
     31        </div>
     32        <?php
     33    });
     34    return; // Stop loading the free plugin
     35}
     36
    2337// Define plugin constants - all prefixed with SFRDA_
    2438// Check if already defined (Pro version may have defined them first)
    2539if ( ! defined( 'SFRDA_VERSION' ) ) {
    26     define( 'SFRDA_VERSION', '1.0.6' );
     40    define( 'SFRDA_VERSION', '1.0.7' );
    2741}
    2842if ( ! defined( 'SFRDA_PLUGIN_DIR' ) ) {
     
    7791        // Deactivation hook
    7892        register_deactivation_hook( __FILE__, array( $this, 'sfrda_deactivate' ) );
     93       
     94        // AJAX handlers
     95        add_action( 'wp_ajax_sfrda_submit_deactivation_feedback', array( $this, 'sfrda_submit_deactivation_feedback_ajax' ) );
    7996    }
    8097   
     
    83100     */
    84101    public function sfrda_enqueue_admin_assets( $hook ) {
     102        // Load deactivation modal on plugins.php
     103        if ( $hook === 'plugins.php' ) {
     104            wp_enqueue_style(
     105                'sfrda-deactivation-modal',
     106                SFRDA_PLUGIN_URL . 'assets/admin-deactivation-modal.css',
     107                array(),
     108                SFRDA_VERSION
     109            );
     110           
     111            wp_enqueue_script(
     112                'sfrda-deactivation-modal',
     113                SFRDA_PLUGIN_URL . 'assets/admin-deactivation-modal.js',
     114                array( 'jquery' ),
     115                SFRDA_VERSION,
     116                true
     117            );
     118           
     119            wp_localize_script( 'sfrda-deactivation-modal', 'sfrdaDeactivationModal', array(
     120                'ajax_url' => admin_url( 'admin-ajax.php' ),
     121                'nonce' => wp_create_nonce( 'sfrda_deactivation_feedback' ),
     122                'support_url' => 'https://supportfromrichard.co.uk/support/'
     123            ) );
     124        }
     125       
    85126        // Only load on our admin pages
    86127        $allowed_pages = array(
     
    210251     */
    211252    private function sfrda_load_dependencies() {
    212         require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-integrations.php';
    213         require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-tracker.php';
    214         require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-analytics.php';
    215         require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-admin.php';
     253        // Load classes only if not already loaded by Pro version
     254        if (!class_exists('SFRDA_Integrations')) {
     255            require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-integrations.php';
     256        }
     257        if (!class_exists('SFRDA_Tracker')) {
     258            require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-tracker.php';
     259        }
     260        if (!class_exists('SFRDA_Analytics')) {
     261            require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-analytics.php';
     262        }
     263        if (!class_exists('SFRDA_Admin')) {
     264            require_once SFRDA_PLUGIN_DIR . 'includes/class-sfrda-admin.php';
     265        }
    216266       
    217267        // Initialize classes
     
    254304   
    255305    /**
     306     * AJAX handler for deactivation feedback
     307     */
     308    public function sfrda_submit_deactivation_feedback_ajax() {
     309        check_ajax_referer( 'sfrda_deactivation_feedback', 'nonce' );
     310       
     311        $reason = isset( $_POST['reason'] ) ? sanitize_text_field( wp_unslash( $_POST['reason'] ) ) : '';
     312        $feedback = isset( $_POST['feedback'] ) ? sanitize_textarea_field( wp_unslash( $_POST['feedback'] ) ) : '';
     313        $plugin = isset( $_POST['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) : '';
     314       
     315        // Log feedback (WordPress.org compliant - no personal data)
     316        if ( $reason || $feedback ) {
     317            // Send to license server for centralized collection (WordPress.org compliant - anonymized)
     318            $this->send_deactivation_feedback_to_server( $reason, $feedback, $plugin );
     319        }
     320       
     321        // Always return success - don't block deactivation
     322        wp_send_json_success( array(
     323            'message' => __( 'Thank you for your feedback!', 'sfr-directory-analytics' )
     324        ) );
     325    }
     326   
     327    /**
     328     * Send deactivation feedback to license server
     329     * WordPress.org compliant - only sends anonymized, non-personal data
     330     */
     331    private function send_deactivation_feedback_to_server( $reason, $feedback, $plugin_slug ) {
     332        $license_server_url = 'https://supportfromrichard.co.uk';
     333       
     334        // Prepare feedback data (WordPress.org compliant - no personal data)
     335        $feedback_data = array(
     336            'plugin_slug' => 'sfr-directory-analytics',
     337            'plugin_version' => SFRDA_VERSION,
     338            'reason' => $reason,
     339            'feedback' => $feedback,
     340            'wp_version' => get_bloginfo( 'version' ),
     341            'php_version' => PHP_VERSION,
     342            'timestamp' => current_time( 'mysql' )
     343        );
     344       
     345        // Send via POST to license server (non-blocking)
     346        wp_remote_post(
     347            $license_server_url . '/wp-json/sfr-licence/v1/track/deactivation',
     348            array(
     349                'body' => wp_json_encode( $feedback_data ),
     350                'headers' => array(
     351                    'Content-Type' => 'application/json',
     352                ),
     353                'timeout' => 5, // Short timeout to not delay deactivation
     354                'blocking' => false // Non-blocking - don't wait for response
     355            )
     356        );
     357    }
     358   
     359    /**
    256360     * Plugin deactivation
    257361     */
Note: See TracChangeset for help on using the changeset viewer.