PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.6.5
ShopBuilder – WooCommerce Builder For Elementor v2.6.5
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Modules / WishList / Wishlist.php

Wishlist.php in ShopBuilder – WooCommerce Builder For Elementor 2.6.5, at app/Modules/WishList/Wishlist.php

79 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RadiusTheme\SB\Modules\WishList;
4
5 use RadiusTheme\SB\Helpers\Fns;
6 use RadiusTheme\SB\Models\ExtraSettings;
7 use RadiusTheme\SB\Traits\SingletonTrait;
8
9 // Do not allow directly accessing this file.
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit( 'This script cannot be accessed directly.' );
12 }
13
14 final class Wishlist {
15
16 const KEY = 'rtsb_wishlist';
17
18 private $wishlist_db_key = 'rtsb_wishlist_db_version';
19
20 private $wishlist_db_version = '1.0.0';
21
22 /**
23 * @var array
24 */
25 public $settings = [];
26
27 /**
28 * SingleTon
29 */
30 use SingletonTrait;
31
32 private function __construct() {
33
34 if ( ! ExtraSettings::instance()->get_option( $this->wishlist_db_key, get_option( $this->wishlist_db_key, false ) ) ) {
35 add_action( 'wp_loaded', [ $this, 'activate' ] );
36 ExtraSettings::instance()->set_option( $this->wishlist_db_key, $this->wishlist_db_version );
37 }
38
39 // if ( ! get_option( $this->wishlist_db_key, '' ) ) {
40 // add_action( 'wp_loaded', [ $this, 'activate' ] );
41 // update_option( $this->wishlist_db_key, $this->wishlist_db_version );
42 // }
43
44 new WishlistRouteV1();
45
46 WishlistFrontEnd::instance();
47
48 if ( is_user_logged_in() ) {
49 $cookie_name = WishlistFns::instance()->get_cookie_name();
50
51 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
52 if ( isset( $_COOKIE[ $cookie_name ] ) && is_array( json_decode( wp_unslash( $_COOKIE[ $cookie_name ] ), true ) ) ) {
53 $ids = WishlistFns::instance()->get_wishlist_ids();
54 $product_ids = [];
55 foreach ( $ids as $pid ) {
56 $product_ids[ $pid ] = $pid;
57 }
58 WishlistFns::instance()->update_user_wishlist_ids( $product_ids );
59 setcookie( self::KEY, '', time() - 3600, '/' );
60 }
61 }
62
63 if ( is_admin() ) {
64 WishlistAdmin::instance();
65 }
66
67 do_action( 'rtsb/module/wishlist/loaded' );
68 }
69
70 /**
71 * Do stuff upon plugin activation
72 *
73 * @return void
74 */
75 public function activate() {
76 ( new WishlistInstaller() )->run();
77 }
78 }
79