Changeset 3412135
- Timestamp:
- 12/05/2025 11:36:46 AM (4 months ago)
- Location:
- simple-empty-cart/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
simpe-empty-cart.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-empty-cart/trunk/readme.txt
r3201798 r3412135 3 3 Tags: woocommerce, cart, empty 4 4 Requires at least: 5.0 5 Tested up to: 6. 7.15 Tested up to: 6.9 6 6 Requires PHP: 7.0 7 Stable tag: 1.1. 37 Stable tag: 1.1.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 32 32 33 33 == 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. 34 37 35 38 = 1.1.3 = -
simple-empty-cart/trunk/simpe-empty-cart.php
r3201798 r3412135 3 3 Plugin Name: Simple Empty Cart 4 4 Description: Remove all items from the cart page with a single click - No bloat & Zero Impact code 🚀 5 Version: 1.1. 35 Version: 1.1.4 6 6 Author: UX Heart 7 7 Author URI: http://uxheart.com … … 99 99 add_action( 'admin_init', 'uxh_sec_register_settings' ); 100 100 101 // Sanitize settings102 101 function uxh_sec_sanitize_settings( $input ) { 103 102 $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 ) : ''; 106 108 } 107 109 return $new_input; … … 151 153 // Handle the empty cart button click 152 154 function 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' ) ) { 154 165 WC()->cart->empty_cart(); 155 166 } 156 167 } 157 add_action( ' init', 'uxh_sec_empty_cart' );168 add_action( 'template_redirect', 'uxh_sec_empty_cart' ); 158 169 ?>
Note: See TracChangeset
for help on using the changeset viewer.