| @@ -1,7 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || exit; | |
| 3 | - | |
| 4 | 2 | if ( ! function_exists( 'sellkit_update_option' ) ) { |
| 5 | 3 | /** |
| 6 | 4 | * Update option from options storage. |
| 7 | 5 | * |
| @@ -72,24 +70,8 @@ | ||
| 72 | 70 | return $value; |
| 73 | 71 | } |
| 74 | 72 | } |
| 75 | 73 | |
| 76 | -if ( ! function_exists( 'sellkit_decode_entity_title' ) ) { | |
| 77 | - /** | |
| 78 | - * Decode HTML entities in titles for JSON/React (fixes literal – etc. in chart headers). | |
| 79 | - * | |
| 80 | - * @param string $title Title string. | |
| 81 | - * @return string | |
| 82 | - */ | |
| 83 | - function sellkit_decode_entity_title( $title ) { | |
| 84 | - if ( ! is_string( $title ) || '' === $title ) { | |
| 85 | - return $title; | |
| 86 | - } | |
| 87 | - | |
| 88 | - return html_entity_decode( $title, ENT_QUOTES | ENT_HTML5, 'UTF-8' ); | |
| 89 | - } | |
| 90 | -} | |
| 91 | - | |
| 92 | 74 | /** |
| 93 | 75 | * Delete option from options storage. |
| 94 | 76 | * |
| 95 | 77 | * @param string $option Option name. |
| @@ -189,39 +171,6 @@ | ||
| 189 | 171 | } |
| 190 | 172 | |
| 191 | 173 | end( $array ); |
| 192 | 174 | return key( $array ); |
| 193 | - } | |
| 194 | -} | |
| 195 | - | |
| 196 | -add_action( 'woocommerce_removed_coupon', 'sellkit_set_cookie_after_auto_apply_coupon_removed', 10, 1 ); | |
| 197 | - | |
| 198 | -/** | |
| 199 | - * Create cookie for deleted auto apply coupon. | |
| 200 | - * | |
| 201 | - * @param string $coupon_code coupon code. | |
| 202 | - */ | |
| 203 | -function sellkit_set_cookie_after_auto_apply_coupon_removed( $coupon_code ) { | |
| 204 | - $cookie_value = null; | |
| 205 | - $parsed_url = wp_parse_url( site_url() ); | |
| 206 | - $domain = $parsed_url['host']; | |
| 207 | - | |
| 208 | - if ( isset( $_COOKIE['sellkit_rejected_coupon'] ) ) { | |
| 209 | - $cookie_value = sanitize_text_field( wp_unslash( $_COOKIE['sellkit_rejected_coupon'] ) ); | |
| 210 | - } | |
| 211 | - | |
| 212 | - $cookie_value = $cookie_value . ',' . $coupon_code; | |
| 213 | - setcookie( 'sellkit_rejected_coupon', $cookie_value, time() + 600, '/', $domain ); | |
| 214 | -} | |
| 215 | - | |
| 216 | -add_action( 'woocommerce_checkout_order_processed', 'sellkit_remove_rejected_auto_apply_coupon_cookie' ); | |
| 217 | - | |
| 218 | -/** | |
| 219 | - * Remove cookie after make an order. | |
| 220 | - */ | |
| 221 | -function sellkit_remove_rejected_auto_apply_coupon_cookie() { | |
| 222 | - if ( isset( $_COOKIE['sellkit_rejected_coupon'] ) ) { | |
| 223 | - $parsed_url = wp_parse_url( site_url() ); | |
| 224 | - $domain = $parsed_url['host']; | |
| 225 | - setcookie( 'sellkit_rejected_coupon', '', time() - 600, '/', $domain ); | |
| 226 | 175 | } |
| 227 | 176 | } |