Plugin Directory

Changeset 3462630


Ignore:
Timestamp:
02/16/2026 03:16:59 PM (4 days ago)
Author:
jneshipping
Message:

Update to 1.8.0

Location:
jne-shipping-official
Files:
9 edited
38 copied

Legend:

Unmodified
Added
Removed
  • jne-shipping-official/tags/1.8.0/composer.json

    r3462262 r3462630  
    22    "name": "jne-shipping/jne-shipping-official",
    33    "description": "WordPress plugin integrated with WooCommerce for JNE shipping services",
    4     "version": "1.7.1",
     4    "version": "1.8.0",
    55    "type": "wordpress-plugin",
    66    "license": "GPL-2.0+",
  • jne-shipping-official/tags/1.8.0/includes/class-jne-woocommerce-activator.php

    r3387194 r3462630  
    3939    add_option('jneshof_shipping_indonesia_version', '1.0.0');
    4040
     41    // Schedule cron job to clear old webhook logs daily
     42    if (!wp_next_scheduled('jneshof_clear_old_webhook_logs')) {
     43      wp_schedule_event(time(), 'daily', 'jneshof_clear_old_webhook_logs');
     44    }
     45
    4146    flush_rewrite_rules();
    4247  }
  • jne-shipping-official/tags/1.8.0/includes/class-jne-woocommerce-deactivator.php

    r3387194 r3462630  
    4444    }
    4545
     46    // Clear scheduled cron job for webhook log cleanup
     47    wp_clear_scheduled_hook('jneshof_clear_old_webhook_logs');
     48
    4649    delete_option('jneshof_shipping_indonesia_version');
    4750    delete_option(JNESHOF_OPTION_ACCESS_KEY);
  • jne-shipping-official/tags/1.8.0/includes/class-jne-woocommerce-webhook-logger.php

    r3399074 r3462630  
    163163
    164164  /**
     165   * Clear logs older than specified days
     166   *
     167   * @param int $days Number of days to keep (default: 30)
     168   * @return int Number of logs deleted
     169   */
     170  public function clear_old_logs($days = 30)
     171  {
     172    $logs = $this->get_logs(0); // Get all logs
     173    $original_count = count($logs);
     174
     175    if (empty($logs)) {
     176      return 0;
     177    }
     178
     179    // Calculate cutoff timestamp (current time - specified days)
     180    $cutoff_timestamp = current_time('timestamp') - ($days * 24 * 60 * 60);
     181
     182    // Filter logs that are newer than cutoff timestamp
     183    $logs = array_filter($logs, function ($log) use ($cutoff_timestamp) {
     184      // Keep logs that have timestamp_unix and are newer than cutoff
     185      if (isset($log['timestamp_unix']) && is_numeric($log['timestamp_unix'])) {
     186        return $log['timestamp_unix'] >= $cutoff_timestamp;
     187      }
     188      // If timestamp_unix is missing, try to use timestamp string
     189      if (isset($log['timestamp']) && !empty($log['timestamp'])) {
     190        $log_timestamp = strtotime($log['timestamp']);
     191        return $log_timestamp >= $cutoff_timestamp;
     192      }
     193      // If no timestamp found, keep the log (shouldn't happen, but safer)
     194      return true;
     195    });
     196
     197    $logs = array_values($logs); // Re-index array
     198    $deleted_count = $original_count - count($logs);
     199
     200    // Update option with filtered logs
     201    if ($deleted_count > 0) {
     202      update_option(self::OPTION_KEY, $logs, false);
     203    }
     204
     205    return $deleted_count;
     206  }
     207
     208  /**
     209   * Cron callback to clear old logs
     210   * This method is called by WordPress cron
     211   *
     212   * @return void
     213   */
     214  public static function cron_clear_old_logs()
     215  {
     216    $logger = self::get_instance();
     217    $deleted_count = $logger->clear_old_logs(30); // Clear logs older than 30 days (1 month)
     218   
     219    // Optional: Log the cleanup action (for debugging)
     220    if (defined('WP_DEBUG') && WP_DEBUG) {
     221      error_log(sprintf('[JNE Shipping] Auto-cleared %d webhook logs older than 30 days', $deleted_count));
     222    }
     223  }
     224
     225  /**
    165226   * Get client IP address
    166227   *
  • jne-shipping-official/tags/1.8.0/includes/class-jne-woocommerce.php

    r3399074 r3462630  
    189189        $this->loader->add_action( 'rest_api_init', $webhook_handler, 'register_routes' );
    190190
     191        // Register cron hook for clearing old webhook logs
     192        // Use direct WordPress add_action for static method callback
     193        add_action( 'jneshof_clear_old_webhook_logs', array( 'Jneshof_Woocommerce_Webhook_Logger', 'cron_clear_old_logs' ) );
     194
    191195    }
    192196
  • jne-shipping-official/tags/1.8.0/jne-shipping-official.php

    r3462262 r3462630  
    2020 * Plugin Name:       JNE Shipping Official
    2121 * Description:       WordPress plugin integrated with WooCommerce for JNE shipping services
    22  * Version:           1.7.1
     22 * Version:           1.8.0
    2323 * Author:            PT. Tiki Jalur Nugraha Ekakurir
    2424 * Author URI:        https://jne.co.id/
     
    4848 * Rename this for your plugin and update it as you release new versions.
    4949 */
    50 define('JNESHOF_PLUGIN_VERSION', '1.7.1');
     50define('JNESHOF_PLUGIN_VERSION', '1.8.0');
    5151
    5252/**
  • jne-shipping-official/tags/1.8.0/readme.txt

    r3462262 r3462630  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.7.1
     8Stable tag: 1.8.0
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    9090
    9191== Changelog ==
     92
     93= 1.8.0 =
     94* Added: Auto-clear webhook logs feature - Webhook logs older than 1 month are automatically deleted daily via WordPress cron job
     95* Improved: Webhook log management with automatic cleanup to prevent database bloat
    9296
    9397= 1.7.1 =
  • jne-shipping-official/trunk/composer.json

    r3462262 r3462630  
    22    "name": "jne-shipping/jne-shipping-official",
    33    "description": "WordPress plugin integrated with WooCommerce for JNE shipping services",
    4     "version": "1.7.1",
     4    "version": "1.8.0",
    55    "type": "wordpress-plugin",
    66    "license": "GPL-2.0+",
  • jne-shipping-official/trunk/includes/class-jne-woocommerce-activator.php

    r3387194 r3462630  
    3939    add_option('jneshof_shipping_indonesia_version', '1.0.0');
    4040
     41    // Schedule cron job to clear old webhook logs daily
     42    if (!wp_next_scheduled('jneshof_clear_old_webhook_logs')) {
     43      wp_schedule_event(time(), 'daily', 'jneshof_clear_old_webhook_logs');
     44    }
     45
    4146    flush_rewrite_rules();
    4247  }
  • jne-shipping-official/trunk/includes/class-jne-woocommerce-deactivator.php

    r3387194 r3462630  
    4444    }
    4545
     46    // Clear scheduled cron job for webhook log cleanup
     47    wp_clear_scheduled_hook('jneshof_clear_old_webhook_logs');
     48
    4649    delete_option('jneshof_shipping_indonesia_version');
    4750    delete_option(JNESHOF_OPTION_ACCESS_KEY);
  • jne-shipping-official/trunk/includes/class-jne-woocommerce-webhook-logger.php

    r3399074 r3462630  
    163163
    164164  /**
     165   * Clear logs older than specified days
     166   *
     167   * @param int $days Number of days to keep (default: 30)
     168   * @return int Number of logs deleted
     169   */
     170  public function clear_old_logs($days = 30)
     171  {
     172    $logs = $this->get_logs(0); // Get all logs
     173    $original_count = count($logs);
     174
     175    if (empty($logs)) {
     176      return 0;
     177    }
     178
     179    // Calculate cutoff timestamp (current time - specified days)
     180    $cutoff_timestamp = current_time('timestamp') - ($days * 24 * 60 * 60);
     181
     182    // Filter logs that are newer than cutoff timestamp
     183    $logs = array_filter($logs, function ($log) use ($cutoff_timestamp) {
     184      // Keep logs that have timestamp_unix and are newer than cutoff
     185      if (isset($log['timestamp_unix']) && is_numeric($log['timestamp_unix'])) {
     186        return $log['timestamp_unix'] >= $cutoff_timestamp;
     187      }
     188      // If timestamp_unix is missing, try to use timestamp string
     189      if (isset($log['timestamp']) && !empty($log['timestamp'])) {
     190        $log_timestamp = strtotime($log['timestamp']);
     191        return $log_timestamp >= $cutoff_timestamp;
     192      }
     193      // If no timestamp found, keep the log (shouldn't happen, but safer)
     194      return true;
     195    });
     196
     197    $logs = array_values($logs); // Re-index array
     198    $deleted_count = $original_count - count($logs);
     199
     200    // Update option with filtered logs
     201    if ($deleted_count > 0) {
     202      update_option(self::OPTION_KEY, $logs, false);
     203    }
     204
     205    return $deleted_count;
     206  }
     207
     208  /**
     209   * Cron callback to clear old logs
     210   * This method is called by WordPress cron
     211   *
     212   * @return void
     213   */
     214  public static function cron_clear_old_logs()
     215  {
     216    $logger = self::get_instance();
     217    $deleted_count = $logger->clear_old_logs(30); // Clear logs older than 30 days (1 month)
     218   
     219    // Optional: Log the cleanup action (for debugging)
     220    if (defined('WP_DEBUG') && WP_DEBUG) {
     221      error_log(sprintf('[JNE Shipping] Auto-cleared %d webhook logs older than 30 days', $deleted_count));
     222    }
     223  }
     224
     225  /**
    165226   * Get client IP address
    166227   *
  • jne-shipping-official/trunk/includes/class-jne-woocommerce.php

    r3399074 r3462630  
    189189        $this->loader->add_action( 'rest_api_init', $webhook_handler, 'register_routes' );
    190190
     191        // Register cron hook for clearing old webhook logs
     192        // Use direct WordPress add_action for static method callback
     193        add_action( 'jneshof_clear_old_webhook_logs', array( 'Jneshof_Woocommerce_Webhook_Logger', 'cron_clear_old_logs' ) );
     194
    191195    }
    192196
  • jne-shipping-official/trunk/jne-shipping-official.php

    r3462262 r3462630  
    2020 * Plugin Name:       JNE Shipping Official
    2121 * Description:       WordPress plugin integrated with WooCommerce for JNE shipping services
    22  * Version:           1.7.1
     22 * Version:           1.8.0
    2323 * Author:            PT. Tiki Jalur Nugraha Ekakurir
    2424 * Author URI:        https://jne.co.id/
     
    4848 * Rename this for your plugin and update it as you release new versions.
    4949 */
    50 define('JNESHOF_PLUGIN_VERSION', '1.7.1');
     50define('JNESHOF_PLUGIN_VERSION', '1.8.0');
    5151
    5252/**
  • jne-shipping-official/trunk/readme.txt

    r3462262 r3462630  
    66Tested up to: 6.9
    77Requires PHP: 7.4
    8 Stable tag: 1.7.1
     8Stable tag: 1.8.0
    99License: GPL-2.0+
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.txt
     
    9090
    9191== Changelog ==
     92
     93= 1.8.0 =
     94* Added: Auto-clear webhook logs feature - Webhook logs older than 1 month are automatically deleted daily via WordPress cron job
     95* Improved: Webhook log management with automatic cleanup to prevent database bloat
    9296
    9397= 1.7.1 =
Note: See TracChangeset for help on using the changeset viewer.