Plugin Directory

Changeset 3478438


Ignore:
Timestamp:
03/09/2026 06:26:05 PM (3 weeks ago)
Author:
sendbox
Message:

Version 5.5.2: Add Reset Plugin button to settings page

Location:
sendbox-shipping
Files:
34 deleted
14 edited
16 copied

Legend:

Unmodified
Added
Removed
  • sendbox-shipping/tags/5.5.2/README.txt

    r3478390 r3478438  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 5.5.1
     7Stable tag: 5.5.2
    88Requires PHP: 7.4
    99License: GPLv2 or later
  • sendbox-shipping/tags/5.5.2/assets/js/admin-settings.js

    r3478358 r3478438  
    115115        }
    116116
     117        // Reset plugin button
     118        var resetBtn = document.querySelector(".wooss-reset-plugin");
     119        if (resetBtn) {
     120            resetBtn.addEventListener("click", function (e) {
     121                e.preventDefault();
     122
     123                if (!confirm("Are you sure? This will delete all Sendbox Shipping settings and disconnect your account.")) {
     124                    return;
     125                }
     126
     127                resetBtn.disabled = true;
     128                resetBtn.textContent = "Resetting...";
     129
     130                var formData = new FormData();
     131                formData.append("action", "wooss_reset_plugin");
     132                formData.append("security", wooss_ajax.nonce);
     133
     134                fetch(wooss_ajax.ajax_url, { method: "POST", body: formData })
     135                    .then(function (res) { return res.json(); })
     136                    .then(function (response) {
     137                        if (response.success) {
     138                            showSuccess("Plugin reset. Reloading...");
     139                            setTimeout(function () { window.location.reload(); }, 2000);
     140                        } else {
     141                            var msg = response.data && response.data.message ? response.data.message : "Reset failed.";
     142                            showError(msg);
     143                            resetBtn.disabled = false;
     144                            resetBtn.textContent = "Reset Plugin";
     145                        }
     146                    })
     147                    .catch(function () {
     148                        showError("Network error. Please try again.");
     149                        resetBtn.disabled = false;
     150                        resetBtn.textContent = "Reset Plugin";
     151                    });
     152            });
     153        }
     154
    117155        function showError(msg) {
    118156            var el = document.querySelector(".wooss-errors-message");
  • sendbox-shipping/tags/5.5.2/src/Admin/Ajax.php

    r3478358 r3478438  
    212212    }
    213213
     214    public function reset_plugin() {
     215        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
     216
     217        if ( ! current_user_can( 'manage_woocommerce' ) ) {
     218            wp_send_json_error( array( 'message' => __( 'Permission denied.', 'wooss' ) ), 403 );
     219        }
     220
     221        delete_option( 'sendbox_data' );
     222        delete_option( 'wooss_connection_status' );
     223        delete_option( 'wooss_db_version' );
     224        Cache::flush_all();
     225
     226        wp_send_json_success( array( 'message' => __( 'Plugin data has been reset. Reloading...', 'wooss' ) ) );
     227    }
     228
    214229    public function request_states() {
    215230        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
  • sendbox-shipping/tags/5.5.2/src/Admin/SettingsPage.php

    r3478358 r3478438  
    153153                    <?php esc_html_e( 'Sync changes', 'wooss' ); ?>
    154154                </button>
     155                <button type="button" class="button wooss-reset-plugin" style="margin-left:10px;color:#d63638;">
     156                    <?php esc_html_e( 'Reset Plugin', 'wooss' ); ?>
     157                </button>
    155158            </div>
    156159            <span class="wooss-errors-message"></span>
  • sendbox-shipping/tags/5.5.2/src/Plugin.php

    r3478358 r3478438  
    7171        add_action( 'wp_ajax_request_shipments', array( $ajax, 'request_shipments' ) );
    7272        add_action( 'wp_ajax_request_states', array( $ajax, 'request_states' ) );
     73        add_action( 'wp_ajax_wooss_reset_plugin', array( $ajax, 'reset_plugin' ) );
    7374    }
    7475
  • sendbox-shipping/tags/5.5.2/trunk/README.txt

    r3478390 r3478438  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 5.5.1
     7Stable tag: 5.5.2
    88Requires PHP: 7.4
    99License: GPLv2 or later
  • sendbox-shipping/tags/5.5.2/trunk/assets/js/admin-settings.js

    r3478358 r3478438  
    115115        }
    116116
     117        // Reset plugin button
     118        var resetBtn = document.querySelector(".wooss-reset-plugin");
     119        if (resetBtn) {
     120            resetBtn.addEventListener("click", function (e) {
     121                e.preventDefault();
     122
     123                if (!confirm("Are you sure? This will delete all Sendbox Shipping settings and disconnect your account.")) {
     124                    return;
     125                }
     126
     127                resetBtn.disabled = true;
     128                resetBtn.textContent = "Resetting...";
     129
     130                var formData = new FormData();
     131                formData.append("action", "wooss_reset_plugin");
     132                formData.append("security", wooss_ajax.nonce);
     133
     134                fetch(wooss_ajax.ajax_url, { method: "POST", body: formData })
     135                    .then(function (res) { return res.json(); })
     136                    .then(function (response) {
     137                        if (response.success) {
     138                            showSuccess("Plugin reset. Reloading...");
     139                            setTimeout(function () { window.location.reload(); }, 2000);
     140                        } else {
     141                            var msg = response.data && response.data.message ? response.data.message : "Reset failed.";
     142                            showError(msg);
     143                            resetBtn.disabled = false;
     144                            resetBtn.textContent = "Reset Plugin";
     145                        }
     146                    })
     147                    .catch(function () {
     148                        showError("Network error. Please try again.");
     149                        resetBtn.disabled = false;
     150                        resetBtn.textContent = "Reset Plugin";
     151                    });
     152            });
     153        }
     154
    117155        function showError(msg) {
    118156            var el = document.querySelector(".wooss-errors-message");
  • sendbox-shipping/tags/5.5.2/trunk/src/Admin/Ajax.php

    r3478358 r3478438  
    212212    }
    213213
     214    public function reset_plugin() {
     215        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
     216
     217        if ( ! current_user_can( 'manage_woocommerce' ) ) {
     218            wp_send_json_error( array( 'message' => __( 'Permission denied.', 'wooss' ) ), 403 );
     219        }
     220
     221        delete_option( 'sendbox_data' );
     222        delete_option( 'wooss_connection_status' );
     223        delete_option( 'wooss_db_version' );
     224        Cache::flush_all();
     225
     226        wp_send_json_success( array( 'message' => __( 'Plugin data has been reset. Reloading...', 'wooss' ) ) );
     227    }
     228
    214229    public function request_states() {
    215230        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
  • sendbox-shipping/tags/5.5.2/trunk/src/Admin/SettingsPage.php

    r3478358 r3478438  
    153153                    <?php esc_html_e( 'Sync changes', 'wooss' ); ?>
    154154                </button>
     155                <button type="button" class="button wooss-reset-plugin" style="margin-left:10px;color:#d63638;">
     156                    <?php esc_html_e( 'Reset Plugin', 'wooss' ); ?>
     157                </button>
    155158            </div>
    156159            <span class="wooss-errors-message"></span>
  • sendbox-shipping/tags/5.5.2/trunk/src/Plugin.php

    r3478358 r3478438  
    7171        add_action( 'wp_ajax_request_shipments', array( $ajax, 'request_shipments' ) );
    7272        add_action( 'wp_ajax_request_states', array( $ajax, 'request_states' ) );
     73        add_action( 'wp_ajax_wooss_reset_plugin', array( $ajax, 'reset_plugin' ) );
    7374    }
    7475
  • sendbox-shipping/tags/5.5.2/trunk/wooss.php

    r3478390 r3478438  
    44 * Plugin URI:        https://sendbox.co/
    55 * Description:       WooCommerce shipping integration with Sendbox — ship from your store to anywhere in the world.
    6  * Version:           5.5.1
     6 * Version:           5.5.2
    77 * Author:            Sendbox
    88 * Author URI:        https://sendbox.co/
     
    2323}
    2424
    25 define( 'WOOSS_VERSION', '5.5.1' );
     25define( 'WOOSS_VERSION', '5.5.2' );
    2626define( 'WOOSS_PLUGIN_FILE', __FILE__ );
    2727define( 'WOOSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • sendbox-shipping/tags/5.5.2/wooss.php

    r3478390 r3478438  
    44 * Plugin URI:        https://sendbox.co/
    55 * Description:       WooCommerce shipping integration with Sendbox — ship from your store to anywhere in the world.
    6  * Version:           5.5.1
     6 * Version:           5.5.2
    77 * Author:            Sendbox
    88 * Author URI:        https://sendbox.co/
     
    2323}
    2424
    25 define( 'WOOSS_VERSION', '5.5.1' );
     25define( 'WOOSS_VERSION', '5.5.2' );
    2626define( 'WOOSS_PLUGIN_FILE', __FILE__ );
    2727define( 'WOOSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
  • sendbox-shipping/trunk/README.txt

    r3478390 r3478438  
    55Requires at least: 6.0
    66Tested up to: 6.9
    7 Stable tag: 5.5.1
     7Stable tag: 5.5.2
    88Requires PHP: 7.4
    99License: GPLv2 or later
  • sendbox-shipping/trunk/assets/js/admin-settings.js

    r3478358 r3478438  
    115115        }
    116116
     117        // Reset plugin button
     118        var resetBtn = document.querySelector(".wooss-reset-plugin");
     119        if (resetBtn) {
     120            resetBtn.addEventListener("click", function (e) {
     121                e.preventDefault();
     122
     123                if (!confirm("Are you sure? This will delete all Sendbox Shipping settings and disconnect your account.")) {
     124                    return;
     125                }
     126
     127                resetBtn.disabled = true;
     128                resetBtn.textContent = "Resetting...";
     129
     130                var formData = new FormData();
     131                formData.append("action", "wooss_reset_plugin");
     132                formData.append("security", wooss_ajax.nonce);
     133
     134                fetch(wooss_ajax.ajax_url, { method: "POST", body: formData })
     135                    .then(function (res) { return res.json(); })
     136                    .then(function (response) {
     137                        if (response.success) {
     138                            showSuccess("Plugin reset. Reloading...");
     139                            setTimeout(function () { window.location.reload(); }, 2000);
     140                        } else {
     141                            var msg = response.data && response.data.message ? response.data.message : "Reset failed.";
     142                            showError(msg);
     143                            resetBtn.disabled = false;
     144                            resetBtn.textContent = "Reset Plugin";
     145                        }
     146                    })
     147                    .catch(function () {
     148                        showError("Network error. Please try again.");
     149                        resetBtn.disabled = false;
     150                        resetBtn.textContent = "Reset Plugin";
     151                    });
     152            });
     153        }
     154
    117155        function showError(msg) {
    118156            var el = document.querySelector(".wooss-errors-message");
  • sendbox-shipping/trunk/src/Admin/Ajax.php

    r3478358 r3478438  
    212212    }
    213213
     214    public function reset_plugin() {
     215        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
     216
     217        if ( ! current_user_can( 'manage_woocommerce' ) ) {
     218            wp_send_json_error( array( 'message' => __( 'Permission denied.', 'wooss' ) ), 403 );
     219        }
     220
     221        delete_option( 'sendbox_data' );
     222        delete_option( 'wooss_connection_status' );
     223        delete_option( 'wooss_db_version' );
     224        Cache::flush_all();
     225
     226        wp_send_json_success( array( 'message' => __( 'Plugin data has been reset. Reloading...', 'wooss' ) ) );
     227    }
     228
    214229    public function request_states() {
    215230        check_ajax_referer( 'wooss-ajax-nonce', 'security' );
  • sendbox-shipping/trunk/src/Admin/SettingsPage.php

    r3478358 r3478438  
    153153                    <?php esc_html_e( 'Sync changes', 'wooss' ); ?>
    154154                </button>
     155                <button type="button" class="button wooss-reset-plugin" style="margin-left:10px;color:#d63638;">
     156                    <?php esc_html_e( 'Reset Plugin', 'wooss' ); ?>
     157                </button>
    155158            </div>
    156159            <span class="wooss-errors-message"></span>
  • sendbox-shipping/trunk/src/Plugin.php

    r3478358 r3478438  
    7171        add_action( 'wp_ajax_request_shipments', array( $ajax, 'request_shipments' ) );
    7272        add_action( 'wp_ajax_request_states', array( $ajax, 'request_states' ) );
     73        add_action( 'wp_ajax_wooss_reset_plugin', array( $ajax, 'reset_plugin' ) );
    7374    }
    7475
  • sendbox-shipping/trunk/wooss.php

    r3478390 r3478438  
    44 * Plugin URI:        https://sendbox.co/
    55 * Description:       WooCommerce shipping integration with Sendbox — ship from your store to anywhere in the world.
    6  * Version:           5.5.1
     6 * Version:           5.5.2
    77 * Author:            Sendbox
    88 * Author URI:        https://sendbox.co/
     
    2323}
    2424
    25 define( 'WOOSS_VERSION', '5.5.1' );
     25define( 'WOOSS_VERSION', '5.5.2' );
    2626define( 'WOOSS_PLUGIN_FILE', __FILE__ );
    2727define( 'WOOSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset for help on using the changeset viewer.