| @@ -7,12 +7,8 @@ | ||
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | // Exit if accessed directly |
| 10 | 10 | |
| 11 | -if (! function_exists('is_plugin_active')) { | |
| 12 | - include_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 13 | -} | |
| 14 | - | |
| 15 | 11 | final class WishlistCompare { |
| 16 | 12 | public function __construct() { |
| 17 | 13 | add_action('wp_ajax_usk_add_to_wishlist', [$this, 'usk_add_to_wishlist']); |
| 18 | 14 | add_action('wp_ajax_nopriv_usk_add_to_wishlist', [$this, 'usk_add_to_wishlist']); |
| @@ -80,14 +76,14 @@ | ||
| 80 | 76 | unset($wishlist[$key]); |
| 81 | 77 | } else { |
| 82 | 78 | // Only gate additions. A removal just drops an id the visitor already |
| 83 | 79 | // holds, so it must keep working even if the product was since unpublished. |
| 84 | - if (! usk_is_public_product($product_id)) { | |
| 80 | + if (! ultimate_store_kit_is_public_product($product_id)) { | |
| 85 | 81 | $response['message'] = __('Invalid product!', 'ultimate-store-kit'); |
| 86 | 82 | wp_send_json($response); |
| 87 | 83 | } |
| 88 | 84 | |
| 89 | - if ($wishlistCounter >= usk_get_list_item_limit()) { | |
| 85 | + if ($wishlistCounter >= ultimate_store_kit_get_list_item_limit()) { | |
| 90 | 86 | $response['message'] = __('Wishlist is full!', 'ultimate-store-kit'); |
| 91 | 87 | wp_send_json($response); |
| 92 | 88 | } |
| 93 | 89 | |
| @@ -197,21 +193,21 @@ | ||
| 197 | 193 | } |
| 198 | 194 | |
| 199 | 195 | $product_id = absint($_POST['product_id']); |
| 200 | 196 | |
| 201 | - if (! usk_is_public_product($product_id)) { | |
| 197 | + if (! ultimate_store_kit_is_public_product($product_id)) { | |
| 202 | 198 | $response['message'] = __('Invalid product!', 'ultimate-store-kit'); |
| 203 | 199 | wp_send_json($response); |
| 204 | 200 | } |
| 205 | 201 | |
| 206 | 202 | $user_id = get_current_user_id(); |
| 207 | - $compare_products = usk_get_compare_products($user_id); | |
| 203 | + $compare_products = ultimate_store_kit_get_compare_products($user_id); | |
| 208 | 204 | |
| 209 | 205 | if (! is_array($compare_products)) { |
| 210 | 206 | $compare_products = []; |
| 211 | 207 | } |
| 212 | 208 | |
| 213 | - if (count($compare_products) >= usk_get_list_item_limit() && ! in_array($product_id, $compare_products)) { | |
| 209 | + if (count($compare_products) >= ultimate_store_kit_get_list_item_limit() && ! in_array($product_id, $compare_products)) { | |
| 214 | 210 | $response['message'] = __('Compare list is full!', 'ultimate-store-kit'); |
| 215 | 211 | wp_send_json($response); |
| 216 | 212 | } |
| 217 | 213 | |
| @@ -254,9 +250,9 @@ | ||
| 254 | 250 | wp_send_json($response); |
| 255 | 251 | } |
| 256 | 252 | $product_id = absint($_POST['product_id']); |
| 257 | 253 | $user_id = get_current_user_id(); |
| 258 | - $compare_products = usk_get_compare_products($user_id); | |
| 254 | + $compare_products = ultimate_store_kit_get_compare_products($user_id); | |
| 259 | 255 | |
| 260 | 256 | //add remove from compare products |
| 261 | 257 | if (($key = array_search($product_id, $compare_products)) !== false) { |
| 262 | 258 | $response['action'] = 'removed'; |
| @@ -263,9 +259,9 @@ | ||
| 263 | 259 | unset($compare_products[$key]); |
| 264 | 260 | } |
| 265 | 261 | |
| 266 | 262 | // Reindex: unset() leaves a gap, and a gapped array json_encodes to an |
| 267 | - // object, which breaks the cookie read back in usk_get_compare_products(). | |
| 263 | + // object, which breaks the cookie read back in ultimate_store_kit_get_compare_products(). | |
| 268 | 264 | $compare_products = array_values(array_unique($compare_products)); |
| 269 | 265 | |
| 270 | 266 | // update compare_products |
| 271 | 267 | $this->ultimate_store_kit_set_compare_products($compare_products, $user_id); |