Plugin Directory

Changeset 3412135


Ignore:
Timestamp:
12/05/2025 11:36:46 AM (4 months ago)
Author:
uxheart
Message:

Update to version 1.1.4

Location:
simple-empty-cart/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-empty-cart/trunk/readme.txt

    r3201798 r3412135  
    33Tags: woocommerce, cart, empty
    44Requires at least: 5.0
    5 Tested up to: 6.7.1
     5Tested up to: 6.9
    66Requires PHP: 7.0
    7 Stable tag: 1.1.3
     7Stable tag: 1.1.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3232
    3333== Changelog ==
     34
     35= 1.1.4 =
     36* Performance improvement: Scope empty-cart handler to front-end only and harden settings sanitization to avoid unnecessary cart/session bootstraps and notices.
    3437
    3538= 1.1.3 =
  • simple-empty-cart/trunk/simpe-empty-cart.php

    r3201798 r3412135  
    33Plugin Name: Simple Empty Cart
    44Description: Remove all items from the cart page with a single click - No bloat & Zero Impact code 🚀
    5 Version: 1.1.3
     5Version: 1.1.4
    66Author: UX Heart
    77Author URI: http://uxheart.com
     
    9999add_action( 'admin_init', 'uxh_sec_register_settings' );
    100100
    101 // Sanitize settings
    102101function uxh_sec_sanitize_settings( $input ) {
    103102    $new_input = array();
    104     foreach ($input as $key => $value) {
    105         $new_input[$key] = isset($value) ? absint($value) : '';
     103    if ( ! is_array( $input ) ) {
     104        return $new_input;
     105    }
     106    foreach ( $input as $key => $value ) {
     107        $new_input[ $key ] = isset( $value ) ? absint( $value ) : '';
    106108    }
    107109    return $new_input;
     
    151153// Handle the empty cart button click
    152154function uxh_sec_empty_cart() {
    153     if ( isset( $_POST['uxh_sec_empty_cart'] ) && isset( $_POST['uxh_sec_empty_cart_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uxh_sec_empty_cart_nonce'] ) ), 'uxh_sec_empty_cart_action' ) ) {
     155    if ( is_admin() || wp_doing_ajax() ) {
     156        return;
     157    }
     158    if ( ! isset( $_POST['uxh_sec_empty_cart'] ) || ! isset( $_POST['uxh_sec_empty_cart_nonce'] ) ) {
     159        return;
     160    }
     161    if ( ! function_exists( 'WC' ) || ! WC()->cart ) {
     162        return;
     163    }
     164    if ( wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['uxh_sec_empty_cart_nonce'] ) ), 'uxh_sec_empty_cart_action' ) ) {
    154165        WC()->cart->empty_cart();
    155166    }
    156167}
    157 add_action( 'init', 'uxh_sec_empty_cart' );
     168add_action( 'template_redirect', 'uxh_sec_empty_cart' );
    158169?>
Note: See TracChangeset for help on using the changeset viewer.