Plugin Directory

Changeset 3697440


Ignore:
Timestamp:
09/15/2026 05:14:32 PM (2 months ago)
Author:
shiprazor
Message:

3.0.3

Location:
shiprazor-shipping-price
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • shiprazor-shipping-price/tags/3.0.2/shiprazor-shipping-price.php

    r3697418 r3697440  
    371371add_action('admin_init', 'sspssp_maybe_repair_shipping_instances', 5);
    372372
     373/**
     374 * Zone-enabled methods are hidden from Shipping sub-tabs by default — add Shiprazor (Connect) back.
     375 *
     376 * @param array<string, string> $sections Shipping settings sections.
     377 * @return array<string, string>
     378 */
     379function sspssp_add_shiprazor_shipping_settings_section($sections) {
     380    $sections[SSPSSP_SHIPPING_METHOD_ID] = __('Shiprazor', 'shiprazor-shipping-price');
     381    return $sections;
     382}
     383add_filter('woocommerce_get_sections_shipping', 'sspssp_add_shiprazor_shipping_settings_section');
     384
     385/**
     386 * WooCommerce skips global settings UI for zone methods unless "settings" is supported.
     387 *
     388 * @param bool               $supported Whether the feature is supported.
     389 * @param string             $feature   Feature name.
     390 * @param WC_Shipping_Method $method    Shipping method instance.
     391 * @return bool
     392 */
     393function sspssp_shiprazor_supports_global_settings($supported, $feature, $method) {
     394    if ('settings' !== $feature || !is_object($method) || SSPSSP_SHIPPING_METHOD_ID !== $method->id) {
     395        return $supported;
     396    }
     397
     398    if (!is_admin()) {
     399        return $supported;
     400    }
     401
     402    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     403    $section = isset($_GET['section']) ? sanitize_text_field(wp_unslash($_GET['section'])) : '';
     404
     405    if (SSPSSP_SHIPPING_METHOD_ID === $section) {
     406        return true;
     407    }
     408
     409    return $supported;
     410}
     411add_filter('woocommerce_shipping_method_supports', 'sspssp_shiprazor_supports_global_settings', 10, 3);
    373412
    374413/**
    … …  
    391430function sspssp_enqueue_admin_styles($hook) {
    392431    if (strpos($hook, 'woocommerce_page_wc-settings') === false) {
     432        return;
     433    }
     434
     435    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     436    $section = isset($_GET['section']) ? sanitize_text_field(wp_unslash($_GET['section'])) : '';
     437    if (SSPSSP_SHIPPING_METHOD_ID !== $section) {
    393438        return;
    394439    }
    … …  
    565610    function init()
    566611    {
    567         $this->sspssp_init_form_fields();
    568         $this->init_settings();
    569         // Remove any legacy full credentials, keeping only the last 5 digits.
    570         if (!$this->instance_id) {
     612        if ($this->instance_id) {
     613            $this->sspssp_init_form_fields();
     614            $this->init_settings();
     615        } else {
     616            // Same bootstrap order as 3.0.1 (credentials + connect UI on the Shiprazor tab).
     617            $this->form_fields = array();
     618            $this->init_settings();
    571619            $this->sspssp_migrate_stored_credentials();
    572620            $this->sspssp_sync_api_key_status();
    573         }
    574         // Save the settings
     621            $this->sspssp_init_form_fields();
     622        }
     623
    575624        add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
    576625   
    … …  
    648697    function sspssp_init_form_fields()
    649698    {
     699        if ($this->instance_id) {
     700            $this->form_fields = array(
     701                'title' => array(
     702                    'title'       => __('Method title', 'shiprazor-shipping-price'),
     703                    'type'        => 'text',
     704                    'description' => __('Shown to customers at checkout.', 'shiprazor-shipping-price'),
     705                    'default'     => __('Shiprazor Shipping', 'shiprazor-shipping-price'),
     706                    'desc_tip'    => true,
     707                ),
     708            );
     709            return;
     710        }
     711
    650712        $this->form_fields = array(
    651             'title' => array(
    652                 'title'       => __('Method title', 'shiprazor-shipping-price'),
    653                 'type'        => 'text',
    654                 'description' => __('Shown to customers at checkout.', 'shiprazor-shipping-price'),
    655                 'default'     => __('Shiprazor Shipping', 'shiprazor-shipping-price'),
    656                 'desc_tip'    => true,
     713            'connect' => array(
     714                'title' => '',
     715                'type'  => 'connect_button',
    657716            ),
    658717        );
    659 
    660         if (!$this->instance_id) {
    661             $this->form_fields['connect'] = array(
    662                 'title' => '',
    663                 'type'  => 'connect_button',
    664             );
    665         }
    666718    }
    667719
  • shiprazor-shipping-price/trunk/README.txt

    r3697418 r3697440  
    33Tags: WooCommerce, shipping, Shiprazor, shipping rate, shipping calculator
    44Tested up to: 7.0
    5 Stable tag: 3.0.2
     5Stable tag: 3.0.3
    66License: GPLv2 or later
    77License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1031035. Store connection credentials apply to all zone instances for live rates at checkout.
    104104
     105= 3.0.3 =
     1061. Restored the Shiprazor sub-tab under WooCommerce > Settings > Shipping (zone methods no longer hide it).
     1072. Restored the Connect with Shiprazor screen and automatic API key setup on that tab (same flow as 3.0.1).
     1083. Fixed global method init order so stored credentials and connection status load correctly before the connect UI renders.
     1094. Admin connect scripts and styles load only on the Shiprazor settings section.
     110
    105111== Upgrade Notice ==
     112
     113= 3.0.3 =
     114Restores the Shiprazor settings tab and Connect / API key admin experience. Update if the Shiprazor tab or connect screen was missing after 3.0.2.
    106115
    107116= 3.0.2 =
  • shiprazor-shipping-price/trunk/shiprazor-shipping-price.php

    r3697418 r3697440  
    44 * Plugin URI: https://shiprazor.com/
    55 * Description: A WooCommerce plugin for calculating dynamic shipping rates using Shiprazor's API.
    6  * Version: 3.0.2
     6 * Version: 3.0.3
    77 * Author: Team Shiprazor
    88 * Author URI: https://shiprazor.com
    … …  
    3030
    3131if (!defined('SSPSSP_PLUGIN_VERSION')) {
    32     define('SSPSSP_PLUGIN_VERSION', '3.0.2');
     32    define('SSPSSP_PLUGIN_VERSION', '3.0.3');
    3333}
    3434
    … …  
    371371add_action('admin_init', 'sspssp_maybe_repair_shipping_instances', 5);
    372372
     373/**
     374 * Zone-enabled methods are hidden from Shipping sub-tabs by default — add Shiprazor (Connect) back.
     375 *
     376 * @param array<string, string> $sections Shipping settings sections.
     377 * @return array<string, string>
     378 */
     379function sspssp_add_shiprazor_shipping_settings_section($sections) {
     380    $sections[SSPSSP_SHIPPING_METHOD_ID] = __('Shiprazor', 'shiprazor-shipping-price');
     381    return $sections;
     382}
     383add_filter('woocommerce_get_sections_shipping', 'sspssp_add_shiprazor_shipping_settings_section');
     384
     385/**
     386 * WooCommerce skips global settings UI for zone methods unless "settings" is supported.
     387 *
     388 * @param bool               $supported Whether the feature is supported.
     389 * @param string             $feature   Feature name.
     390 * @param WC_Shipping_Method $method    Shipping method instance.
     391 * @return bool
     392 */
     393function sspssp_shiprazor_supports_global_settings($supported, $feature, $method) {
     394    if ('settings' !== $feature || !is_object($method) || SSPSSP_SHIPPING_METHOD_ID !== $method->id) {
     395        return $supported;
     396    }
     397
     398    if (!is_admin()) {
     399        return $supported;
     400    }
     401
     402    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     403    $section = isset($_GET['section']) ? sanitize_text_field(wp_unslash($_GET['section'])) : '';
     404
     405    if (SSPSSP_SHIPPING_METHOD_ID === $section) {
     406        return true;
     407    }
     408
     409    return $supported;
     410}
     411add_filter('woocommerce_shipping_method_supports', 'sspssp_shiprazor_supports_global_settings', 10, 3);
    373412
    374413/**
    … …  
    391430function sspssp_enqueue_admin_styles($hook) {
    392431    if (strpos($hook, 'woocommerce_page_wc-settings') === false) {
     432        return;
     433    }
     434
     435    // phpcs:ignore WordPress.Security.NonceVerification.Recommended
     436    $section = isset($_GET['section']) ? sanitize_text_field(wp_unslash($_GET['section'])) : '';
     437    if (SSPSSP_SHIPPING_METHOD_ID !== $section) {
    393438        return;
    394439    }
    … …  
    565610    function init()
    566611    {
    567         $this->sspssp_init_form_fields();
    568         $this->init_settings();
    569         // Remove any legacy full credentials, keeping only the last 5 digits.
    570         if (!$this->instance_id) {
     612        if ($this->instance_id) {
     613            $this->sspssp_init_form_fields();
     614            $this->init_settings();
     615        } else {
     616            // Same bootstrap order as 3.0.3 (credentials + connect UI on the Shiprazor tab).
     617            $this->form_fields = array();
     618            $this->init_settings();
    571619            $this->sspssp_migrate_stored_credentials();
    572620            $this->sspssp_sync_api_key_status();
    573         }
    574         // Save the settings
     621            $this->sspssp_init_form_fields();
     622        }
     623
    575624        add_action('woocommerce_update_options_shipping_' . $this->id, array($this, 'process_admin_options'));
    576625   
    … …  
    648697    function sspssp_init_form_fields()
    649698    {
     699        if ($this->instance_id) {
     700            $this->form_fields = array(
     701                'title' => array(
     702                    'title'       => __('Method title', 'shiprazor-shipping-price'),
     703                    'type'        => 'text',
     704                    'description' => __('Shown to customers at checkout.', 'shiprazor-shipping-price'),
     705                    'default'     => __('Shiprazor Shipping', 'shiprazor-shipping-price'),
     706                    'desc_tip'    => true,
     707                ),
     708            );
     709            return;
     710        }
     711
    650712        $this->form_fields = array(
    651             'title' => array(
    652                 'title'       => __('Method title', 'shiprazor-shipping-price'),
    653                 'type'        => 'text',
    654                 'description' => __('Shown to customers at checkout.', 'shiprazor-shipping-price'),
    655                 'default'     => __('Shiprazor Shipping', 'shiprazor-shipping-price'),
    656                 'desc_tip'    => true,
     713            'connect' => array(
     714                'title' => '',
     715                'type'  => 'connect_button',
    657716            ),
    658717        );
    659 
    660         if (!$this->instance_id) {
    661             $this->form_fields['connect'] = array(
    662                 'title' => '',
    663                 'type'  => 'connect_button',
    664             );
    665         }
    666718    }
    667719
Note: See TracChangeset for help on using the changeset viewer.