Plugin Directory

Changeset 3286996


Ignore:
Timestamp:
05/03/2025 09:57:17 PM (11 months ago)
Author:
ashleysmith1
Message:

Fix: upgrade version change – version 3.3.35

Location:
abmsense/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • abmsense/trunk/abmsense.php

    r3286869 r3286996  
    33Plugin Name: ABMsense - Visitor Identification for B2B Pipeline Growth
    44Description: Turn Site Visitors into Hot Leads– It's Marketing Magic! ABMsense is a powerful tool that helps you to identify and track your website visitors. It provides you with the information you need to turn your website visitors into hot leads. With ABMsense, you can track your website visitors, identify their company, and get detailed information about their visit. Go to Settings -> ABMsense to configure the plugin.
    5 Version: 3.3.17
     5Version: 3.3.35
    66Author: Ashley Smith
    77Requires PHP: 7.2
     
    2626define('ABMSENSE_PREFIX', 'abmsense_');
    2727if (!defined('ABMSENSE_VERSION')) {
    28     define('ABMSENSE_VERSION', '3.3.17');
     28    define('ABMSENSE_VERSION', '3.3.35');
    2929}
    3030
  • abmsense/trunk/activation_deactivation.php

    r3286869 r3286996  
    5353}
    5454
    55 function abmsense_version_check() {
    56     $current_version = abmsense_get_version();
    57     $stored_version = get_option(ABMSENSE_PREFIX . 'version_installed');
    58 
    59     // Return true if versions are different or if stored_version doesn't exist
    60     return ($current_version !== $stored_version || !$stored_version);
    61 }
    62 
    6355// Function to deactivate the plugin
    6456function abmsense_deactivate() {
     
    7567   
    7668    // Check if upgrade is needed
     69    $current_version = abmsense_get_version();
     70    $stored_version = get_option(ABMSENSE_PREFIX . 'version_installed');
    7771    if (abmsense_version_check()) {
    7872        // Set a longer-lived transient to prevent multiple upgrade attempts
     
    8680            $current_version = abmsense_get_version();
    8781           
    88             // Update the version in WordPress options first
    89             update_option(ABMSENSE_PREFIX . 'version_installed', $current_version);
     82            // Update plugin data with the new version
     83            $api_result = abmsense_update_plugin_data();
    9084           
    91             // Update plugin data with the new version
    92             abmsense_update_plugin_data();
     85            // Only update the local version if the API call succeeded
     86            if ($api_result) {
     87                update_option(ABMSENSE_PREFIX . 'version_installed', $current_version);
     88            }
    9389           
    9490            // Run any additional upgrade tasks
     
    10399// Function to update plugin data
    104100function abmsense_update_plugin_data() {
    105     // Check if we're in the middle of an upgrade
    106     if (get_transient(ABMSENSE_PREFIX . 'upgrade_in_progress')) {
    107         return;
    108     }
    109    
    110101    $current_user = wp_get_current_user();
    111102    $server_name = isset($_SERVER['SERVER_NAME']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME'])) : '';
    112103    $admin_email = $current_user->user_email ?: 'no-reply@' . $server_name;
    113    
    114     // Get existing values or set defaults
    115104    $report_email = get_option(ABMSENSE_PREFIX . 'report_email') ?: $admin_email;
    116105    $report_frequency = get_option(ABMSENSE_PREFIX . 'report_frequency', 'weekly');
    117106    $is_consent = get_option(ABMSENSE_PREFIX . 'is_consent') ?: 0;
    118107    $date_registered = get_option(ABMSENSE_PREFIX . 'date_registered') ?: gmdate('Y-m-d');
    119    
    120     // Always use the current version from the plugin file
    121108    $version_installed = abmsense_get_version();
    122    
    123     // Get the user's full name from WordPress if available
    124109    $full_name = $current_user->display_name ?: '';
    125110    update_option(ABMSENSE_PREFIX . 'full_name', $full_name);
    126111
    127     // Save/update all plugin data with additional fields
     112    // Use the same values as the settings page
     113    $consent_update = true; // Match settings page logic for remote update
     114    $sku = 'ABM-1000-ID-MONTHLY-FREE-TIER';
     115    $real_time_alert = 'No';
     116
     117    // Call the same function as the settings page
    128118    $result = abmsense_save_data(
    129119        $server_name,
     
    132122        $is_consent,
    133123        $date_registered,
    134         $version_installed
     124        $version_installed,
     125        $full_name,
     126        $consent_update,
     127        $sku,
     128        $real_time_alert
    135129    );
    136130
     
    159153add_action('admin_init', 'abmsense_upgrade_completed');
    160154register_deactivation_hook(__FILE__, 'abmsense_deactivate');
     155function abmsense_check_version_on_plugins_page($upgrader_object, $options) {
     156    if ($options['action'] === 'update' && $options['type'] === 'plugin') {
     157        // Check if our plugin was updated
     158        $our_plugin = plugin_basename(__FILE__);
     159        if (isset($options['plugins']) && in_array($our_plugin, $options['plugins'])) {
     160            delete_option(ABMSENSE_PREFIX . 'version_installed');
     161        }
     162    }
     163}
     164add_action('upgrader_process_complete', 'abmsense_check_version_on_plugins_page', 10, 2);
    161165
    162 // // Optional: Add this if you want to force an upgrade check on plugins page
    163 // function abmsense_check_version_on_plugins_page($upgrader_object, $options) {
    164 //     if ($options['action'] === 'update' && $options['type'] === 'plugin') {
    165 //         // Check if our plugin was updated
    166 //         $our_plugin = plugin_basename(__FILE__);
    167 //         if (isset($options['plugins']) && in_array($our_plugin, $options['plugins'])) {
    168 //             delete_transient(ABMSENSE_PREFIX . 'upgrade_completed');
    169 //         }
    170 //     }
    171 // }
    172 // add_action('upgrader_process_complete', 'abmsense_check_version_on_plugins_page', 10, 2);
  • abmsense/trunk/readme.txt

    r3286869 r3286996  
    77Tested up to: 6.8
    88Requires PHP: 7.2
    9 Stable tag: 3.3.17
     9Stable tag: 3.3.35
    1010License: GPLv2 or later
    1111License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    125125* Adding Export CSV inside the Identified Companies table
    126126
    127 = 3.3.17 =
     127= 3.3.35 =
    128128* Added: User Management table
    129129* Added: Hot Lead Alerts
  • abmsense/trunk/settings.php

    r3286855 r3286996  
    111111
    112112// Update the save_data function in settings.php
    113 function abmsense_save_data($server_name, $report_email, $report_frequency, $is_consent, $date_registered, $version_installed) {
     113function abmsense_save_data(
     114    $server_name,
     115    $report_email,
     116    $report_frequency,
     117    $is_consent,
     118    $date_registered,
     119    $version_installed,
     120    $full_name = '',
     121    $consent_update = false,
     122    $sku = '',
     123    $real_time_alert = ''
     124) {
    114125    $config = include('db_config.php');
    115126    $api_url = $config['upsert_abmsense_our_customers_details'];
    116127    $public_key = $config['public_key'];
    117128
    118     // Get existing full_name if available
    119     $full_name = get_option(ABMSENSE_PREFIX . 'full_name', '');
    120    
    121129    $data = [
    122130        'customer_name' => $server_name,
     
    127135        'version_installed' => $version_installed,
    128136        'full_name' => $full_name,
    129         'real_time_alert' => 'No',
    130         'sku' => 'ABM-1000-ID-MONTHLY-FREE-TIER'
     137        'consent_update' => $consent_update,
     138        'sku' => $sku,
     139        'real_time_alert' => $real_time_alert
    131140    ];
    132141
     
    217226
    218227    if ($user_response_code !== 200 || !isset($user_response_data['success']) || !$user_response_data['success']) {
     228        // Check for "Email already exists" and treat as success
     229        if (strpos($user_response_body, 'Email already exists') !== false) {
     230            return true;
     231        }
    219232        abmsense_log('API Error: Failed to create user - ' . $user_response_body . ' - Maybe Customer is reactivated', 'error');
    220233        return false;
     
    232245    // Set a transient to indicate successful registration
    233246    set_transient(ABMSENSE_PREFIX . 'registration_complete', true, HOUR_IN_SECONDS);
    234    
     247
     248    if ($user_response_code === 200 && isset($user_response_data['success']) && $user_response_data['success']) {
     249        update_option(ABMSENSE_PREFIX . 'version_installed', $version_installed);
     250    }
     251
    235252    return true;
    236253}
  • abmsense/trunk/utility.php

    r3268419 r3286996  
    198198    return $response;
    199199}
     200
     201function abmsense_version_check() {
     202    $current_version = abmsense_get_version();
     203    $stored_version = get_option(ABMSENSE_PREFIX . 'version_installed');
     204    return ($current_version !== $stored_version || !$stored_version);
     205}
     206
     207add_action('upgrader_process_complete', 'abmsense_check_version_on_plugins_page', 10, 2);
Note: See TracChangeset for help on using the changeset viewer.