Changeset 2872067
- Timestamp:
- 02/28/2023 06:28:21 AM (3 years ago)
- File:
-
- 1 edited
-
webmaxycdp/trunk/includes/class-webmaxycdp.php (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
webmaxycdp/trunk/includes/class-webmaxycdp.php
r2872055 r2872067 1 1 <?php 2 2 global $wp; 3 if ( !session_id()) {4 session_start();3 if (!session_id()) { 4 session_start(); 5 5 } 6 6 /** 7 * The file that defines the core plugin class8 *9 * A class definition that includes attributes and functions used across both the10 * public-facing side of the site and the admin area.11 *12 * @link https://www.webmaxy.co13 * @since 1.0.014 *15 * @package WebMaxyCDP16 * @subpackage WebMaxyCDP/includes17 */7 * The file that defines the core plugin class 8 * 9 * A class definition that includes attributes and functions used across both the 10 * public-facing side of the site and the admin area. 11 * 12 * @link https://www.webmaxy.co 13 * @since 1.0.0 14 * 15 * @package WebMaxyCDP 16 * @subpackage WebMaxyCDP/includes 17 */ 18 18 19 19 /** 20 * The core plugin class. 21 * 22 * This is used to define internationalization, admin-specific hooks, and 23 * public-facing site hooks. 24 * 25 * Also maintains the unique identifier of this plugin as well as the current 26 * version of the plugin. 27 * 28 * @since 1.0.0 29 * @package WebMaxyCDP 30 * @subpackage WebMaxyCDP/includes 31 * @author WebMaxy 32 */ 33 34 class WebMaxyCDP { 35 36 /** 37 * The loader that's responsible for maintaining and registering all hooks that power 20 * The core plugin class. 21 * 22 * This is used to define internationalization, admin-specific hooks, and 23 * public-facing site hooks. 24 * 25 * Also maintains the unique identifier of this plugin as well as the current 26 * version of the plugin. 27 * 28 * @since 1.0.0 29 * @package WebMaxyCDP 30 * @subpackage WebMaxyCDP/includes 31 * @author WebMaxy 32 */ 33 34 class WebMaxyCDP 35 { 36 37 /** 38 * The loader that's responsible for maintaining and registering all hooks that power 38 39 * the plugin. 39 40 * … … 72 73 * @since 1.0.0 73 74 */ 74 public function __construct() { 75 if ( defined( 'WebMaxyCDP_VERSION' ) ) { 75 public function __construct() 76 { 77 if (defined('WebMaxyCDP_VERSION')) { 76 78 $this->version = WebMaxyCDP_VERSION; 77 79 } else { … … 85 87 $this->define_public_hooks(); 86 88 $this->enqueue_script(); 87 88 } 89 90 public function is_chained_product( $cart_item_properties ){91 92 if ( class_exists( 'WC_Chained_Products' ) && ! empty( $cart_item_properties['chained_item_of'] )) {89 } 90 91 public function is_chained_product($cart_item_properties) 92 { 93 94 if (class_exists('WC_Chained_Products') && !empty($cart_item_properties['chained_item_of'])) { 93 95 return true; 94 96 } 95 97 return false; 96 98 } 97 99 98 100 public function wbmxa_build_add_to_cart_data($added_product, $quantity, $cart) 99 101 { … … 114 116 } 115 117 116 117 function wbmxa_track_request($customer_identify, $data,$event,$action) 118 { 119 120 $client_id= get_option( 'webmaxy_client_id' ); 121 $secret_id= get_option( 'webmaxy_secret_id' ); 122 if(empty($client_id) && empty($secret_id)){ 123 return; 124 } 125 $code=base64_encode($client_id.":".$secret_id); 126 if ( ! $code ) { return; } 127 $atc_data = array( 128 'token' => $code, 129 'event_type' => $event, 130 'customer_properties' => $customer_identify, 131 'properties' => $data 132 ); 133 $base64_encoded = base64_encode(json_encode($atc_data)); 134 $url = "https://performanceapi.webmaxy.co/api/woocommerce/$action?data=" . $base64_encoded .'&admin='.is_admin(); 135 $response = wp_remote_get($url); 136 if($event == 'SESSION' || $event == 'LOGIN' || $event == 'PLACE_ORDER' || $event == 'USER_REGISTER' ){ 137 $response=wp_remote_retrieve_body( $response ); 138 $response=json_decode($response); 139 if(!empty($response)){ 140 if(isset( $response->us)){ 141 setcookie('__wbmxa_ckid', $response->ck, time()+31556926,"/"); 142 unset($_SESSION['__wbmxa_usid']); 143 $_SESSION['__wbmxa_usid']=sanitize_text_field( $response->us); 144 } 118 119 function wbmxa_track_request($customer_identify, $data, $event, $action) 120 { 121 122 $client_id = get_option('webmaxy_client_id'); 123 $secret_id = get_option('webmaxy_secret_id'); 124 if (empty($client_id) && empty($secret_id)) { 125 return; 126 } 127 $code = base64_encode($client_id . ":" . $secret_id); 128 if (!$code) { 129 return; 130 } 131 $atc_data = array( 132 'token' => $code, 133 'event_type' => $event, 134 'customer_properties' => $customer_identify, 135 'properties' => $data 136 ); 137 $base64_encoded = base64_encode(json_encode($atc_data)); 138 $url = "https://performanceapi.webmaxy.co/api/woocommerce/$action?data=" . $base64_encoded . '&admin=' . is_admin(); 139 $response = wp_remote_get($url); 140 if ($event == 'SESSION' || $event == 'LOGIN' || $event == 'PLACE_ORDER' || $event == 'USER_REGISTER') { 141 $response = wp_remote_retrieve_body($response); 142 $response = json_decode($response); 143 if (!empty($response)) { 144 if (isset($response->us)) { 145 setcookie('__wbmxa_ckid', $response->ck, time() + 31556926, "/"); 146 unset($_SESSION['__wbmxa_usid']); 147 $_SESSION['__wbmxa_usid'] = sanitize_text_field($response->us); 148 } 149 } 150 return true; 145 151 } 146 152 return true; 147 } 148 return true; 149 150 151 } 152 153 function customer_list($request) { 154 $code=$request['code']; 155 $code = base64_decode( $code ); 156 $arr = explode( ':', $code ); 157 if ( count( $arr ) < 2 ) { 158 return false; 159 } 160 $client_id = $arr[ 0 ]; 161 $secret_id = $arr[ 1 ]; 162 if($client_id != get_option( 'webmaxy_client_id' ) || $secret_id != get_option( 'webmaxy_secret_id' )){ 163 return false; 164 165 } 166 $DBRecord = array(); 167 $args = array( 168 'paged' => $request['page'], 169 'number'=>1000 170 ); 171 $users = get_users( $args ); 172 $i=0; 173 foreach ( $users as $user ) 174 { 175 $DBRecord[$i]['WPId'] = $user->ID; 176 $DBRecord[$i]['first_name'] = $user->first_name; 177 $DBRecord[$i]['last_name'] = $user->last_name; 178 $DBRecord[$i]['email'] = $user->user_email; 179 $i++; 180 } 181 $data=array( 182 "count"=>count_users(), 183 "users"=>$DBRecord 184 ); 185 $response = new WP_REST_Response($data); 186 $response->set_status(200); 187 return $response; 188 } 189 190 private function enqueue_script() { 191 add_action( 'wp_head', array($this, 'my_getcookie') ); 192 add_action( 'template_redirect', array($this, 'pageLoaded')); 153 } 154 155 function customer_list($request) 156 { 157 $code = $request['code']; 158 $code = base64_decode($code); 159 $arr = explode(':', $code); 160 if (count($arr) < 2) { 161 return false; 162 } 163 $client_id = $arr[0]; 164 $secret_id = $arr[1]; 165 if ($client_id != get_option('webmaxy_client_id') || $secret_id != get_option('webmaxy_secret_id')) { 166 return false; 167 } 168 $DBRecord = array(); 169 $args = array( 170 'paged' => $request['page'], 171 'number' => 1000 172 ); 173 $users = get_users($args); 174 $i = 0; 175 foreach ($users as $user) { 176 $DBRecord[$i]['WPId'] = $user->ID; 177 $DBRecord[$i]['first_name'] = $user->first_name; 178 $DBRecord[$i]['last_name'] = $user->last_name; 179 $DBRecord[$i]['email'] = $user->user_email; 180 $i++; 181 } 182 $data = array( 183 "count" => count_users(), 184 "users" => $DBRecord 185 ); 186 $response = new WP_REST_Response($data); 187 $response->set_status(200); 188 return $response; 189 } 190 191 private function enqueue_script() 192 { 193 add_action('wp_head', array($this, 'my_getcookie')); 194 add_action('template_redirect', array($this, 'pageLoaded')); 193 195 add_action('wp_login', array($this, 'wmxA_login_event'), 10, 2); 194 add_action( 'user_register', array($this, 'user_register'), 10, 2);196 add_action('user_register', array($this, 'user_register'), 10, 2); 195 197 add_action('wp_logout', array($this, 'wmxA_logout_event'), 10, 1); 196 add_action( 'woocommerce_add_to_cart', array($this, 'wmxA_added_to_cart_event'),25,3);197 198 add_action('woocommerce_checkout_order_processed', array($this, 'wmxA_checkout_order_event'), 10, 1);199 add_action('woocommerce_order_status_cancelled', array($this, 'wmxA_cancel_order_event'), 21, 1);198 add_action('woocommerce_add_to_cart', array($this, 'wmxA_added_to_cart_event'), 25, 3); 199 200 add_action('woocommerce_checkout_order_processed', array($this, 'wmxA_checkout_order_event'), 10, 1); 201 add_action('woocommerce_order_status_cancelled', array($this, 'wmxA_cancel_order_event'), 21, 1); 200 202 // add_action('woocommerce_order_status_changed', 'wmxA_order_status_event', 10, 1); 201 203 add_action('woocommerce_order_status_changed', array($this, 'wmxA_order_status_event'), 10, 1); 202 add_action( 'woocommerce_update_product',array($this, 'wmxA_price_change_event') ,10, 1);203 add_action( 'updated_post_meta', array($this, 'mp_sync_on_product_save'), 10, 4);204 add_action('wp_footer', array($this, 'wpb_hook_javascript_footer'), 10, 1);204 add_action('woocommerce_update_product', array($this, 'wmxA_price_change_event'), 10, 1); 205 add_action('updated_post_meta', array($this, 'mp_sync_on_product_save'), 10, 4); 206 add_action('wp_footer', array($this, 'wpb_hook_javascript_footer'), 10, 1); 205 207 206 208 add_action('rest_api_init', function () { 207 register_rest_route( 'api/v1', 'users',array(208 'methods' => 'GET',209 'callback' => array($this, 'customer_list'),210 ));211 212 register_rest_route( 'api/v1', 'orders',array(209 register_rest_route('api/v1', 'users', array( 210 'methods' => 'GET', 211 'callback' => array($this, 'customer_list'), 212 )); 213 214 register_rest_route('api/v1', 'orders', array( 213 215 'methods' => 'GET', 214 216 'callback' => array($this, 'getAllOrders'), 215 217 )); 216 register_rest_route( 'api/v1', 'categories',array(218 register_rest_route('api/v1', 'categories', array( 217 219 'methods' => 'GET', 218 220 'callback' => array($this, 'getALLCategory'), 219 221 )); 220 register_rest_route( 'api/v1', 'order-details',array(222 register_rest_route('api/v1', 'order-details', array( 221 223 'methods' => 'GET', 222 224 'callback' => array($this, 'getOrderDetails'), 223 225 )); 224 226 225 register_rest_route( 'api/v1', 'login-status',array(227 register_rest_route('api/v1', 'login-status', array( 226 228 'methods' => 'GET', 227 229 'callback' => array($this, 'checkUserStatus'), 228 230 )); 229 230 231 232 }); 233 234 } 235 236 public function user_register($user_id,$user_data){ 237 238 $data=array( 239 "ck"=>sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "" )), 240 "us"=>sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "" )), 241 "email"=>$user_data['user_email'], 231 }); 232 } 233 234 public function user_register($user_id, $user_data) 235 { 236 237 $data = array( 238 "ck" => sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")), 239 "us" => sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")), 240 "email" => $user_data['user_email'], 242 241 ); 243 244 $this->wbmxa_track_request(1, $data,"USER_REGISTER",'actions');245 246 } 247 248 public function checkUserStatus(){249 $isUserLogged =false;250 if ( isset($_SESSION['__wbmxa_loginid'])) {251 $isUserLogged = true;252 }242 243 $this->wbmxa_track_request(1, $data, "USER_REGISTER", 'actions'); 244 } 245 246 public function checkUserStatus() 247 { 248 $isUserLogged = false; 249 if (isset($_SESSION['__wbmxa_loginid'])) { 250 $isUserLogged = true; 251 } 253 252 $data = [ 254 253 'loggedin' => $isUserLogged, 255 254 ]; 256 wp_send_json_success( $data);257 } 258 259 public function getALLCategory($request) {260 $code=$request['code'];261 $code = base64_decode( $code );262 $arr = explode( ':', $code);263 if ( count( $arr ) < 2 ) { 264 return false; 265 } 266 $client_id = $arr[ 0 ]; 267 $secret_id = $arr[ 1];268 if($client_id != get_option( 'webmaxy_client_id' ) || $secret_id != get_option( 'webmaxy_secret_id' )){269 return array(get_option( 'webmaxy_client_id' ), $client_id ,get_option( 'webmaxy_secret_id' ),$secret_id);270 271 } 272 $categories =[];255 wp_send_json_success($data); 256 } 257 258 public function getALLCategory($request) 259 { 260 $code = $request['code']; 261 $code = base64_decode($code); 262 $arr = explode(':', $code); 263 if (count($arr) < 2) { 264 return false; 265 } 266 $client_id = $arr[0]; 267 $secret_id = $arr[1]; 268 if ($client_id != get_option('webmaxy_client_id') || $secret_id != get_option('webmaxy_secret_id')) { 269 return array(get_option('webmaxy_client_id'), $client_id, get_option('webmaxy_secret_id'), $secret_id); 270 } 271 $categories = []; 273 272 $args = array( 274 273 'hierarchical' => 1, … … 276 275 'hide_empty' => 0, 277 276 'taxonomy' => 'product_cat', 278 "orderby"=>'parent', 279 'order'=>"ASC" 280 ); 281 $categories = get_categories($args); 282 foreach ($categories as $key => $sc) { 283 $sc->link = get_term_link( $sc->slug, $sc->taxonomy ); 284 $arr = explode("/",$sc->link); 285 $cat_name=""; 286 if(count($arr)>0){ 287 $is_p_cate_pass=false; 288 foreach ($arr as $key => $value) { 289 if($is_p_cate_pass){ 290 if(!empty($value)){ 291 if($cat_name==""){ 292 $cat_name=$value; 293 }else{ 294 $cat_name.=" > " .$value; 277 "orderby" => 'parent', 278 'order' => "ASC" 279 ); 280 $categories = get_categories($args); 281 foreach ($categories as $key => $sc) { 282 $sc->link = get_term_link($sc->slug, $sc->taxonomy); 283 $arr = explode("/", $sc->link); 284 $cat_name = ""; 285 if (count($arr) > 0) { 286 $is_p_cate_pass = false; 287 foreach ($arr as $key => $value) { 288 if ($is_p_cate_pass) { 289 if (!empty($value)) { 290 if ($cat_name == "") { 291 $cat_name = $value; 292 } else { 293 $cat_name .= " > " . $value; 294 } 295 295 } 296 296 } 297 if ($value == "product-category") { 298 $is_p_cate_pass = true; 299 } 297 300 } 298 if($value=="product-category"){ 299 $is_p_cate_pass=true; 300 } 301 } 302 } 303 $sc->cat_name=$cat_name; 304 } 305 return $categories ; 301 } 302 $sc->cat_name = $cat_name; 303 } 304 return $categories; 306 305 } 307 306 … … 310 309 { 311 310 $is_admin = is_admin(); 312 if ( $is_admin ) { 313 $order = wc_get_order( $order_id ); 314 if (empty($order) ) { return; } 315 $items = $order->get_items(); 316 $dataset=[]; 317 foreach ( $items as $key => $item ){ 318 $product = $item->get_product(); 319 if ( $product ) { 320 $obj=array( 311 if ($is_admin) { 312 $order = wc_get_order($order_id); 313 if (empty($order)) { 314 return; 315 } 316 $items = $order->get_items(); 317 $dataset = []; 318 foreach ($items as $key => $item) { 319 $product = $item->get_product(); 320 if ($product) { 321 $obj = array( 321 322 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 322 323 'AddedItemPrice' => (float) $product->get_price(), … … 328 329 'AddedItemSKU' => (string) $product->get_sku(), 329 330 'AddedItemURL' => (string) $product->get_permalink() 330 );331 $dataset[] = $obj;332 }333 }334 $data['ck']=sanitize_text_field($_COOKIE['__wbmxa_ckid']);335 $data['us']=sanitize_text_field($_SESSION['__wbmxa_usid']);336 $data['order_id']=$order_id;337 $data['items']=$dataset;338 $data['status']=$order->get_status();339 $data['currency']=$order->get_currency();340 $data['total']=$order->get_total();341 $this->wbmxa_track_request(1,$data,'ORDER_STATUS_CHANGED','actions');342 }343 } 344 345 346 public function getAllOrders($request){ 347 348 $code=$request['code']; 349 $code = base64_decode( $code );350 $arr = explode( ':', $code);351 if ( count( $arr ) < 2 ) { 352 return false; 353 } 354 $client_id = $arr[ 0 ]; 355 $secret_id = $arr[ 1];356 if($client_id != get_option( 'webmaxy_client_id' ) || $secret_id != get_option( 'webmaxy_secret_id' )){357 return array(get_option( 'webmaxy_client_id' ), $client_id ,get_option( 'webmaxy_secret_id' ),$secret_id);358 331 ); 332 $dataset[] = $obj; 333 } 334 } 335 $data['ck'] = sanitize_text_field($_COOKIE['__wbmxa_ckid']); 336 $data['us'] = sanitize_text_field($_SESSION['__wbmxa_usid']); 337 $data['order_id'] = $order_id; 338 $data['items'] = $dataset; 339 $data['status'] = $order->get_status(); 340 $data['currency'] = $order->get_currency(); 341 $data['total'] = $order->get_total(); 342 $this->wbmxa_track_request(1, $data, 'ORDER_STATUS_CHANGED', 'actions'); 343 } 344 } 345 346 347 public function getAllOrders($request) 348 { 349 350 $code = $request['code']; 351 $code = base64_decode($code); 352 $arr = explode(':', $code); 353 if (count($arr) < 2) { 354 return false; 355 } 356 $client_id = $arr[0]; 357 $secret_id = $arr[1]; 358 if ($client_id != get_option('webmaxy_client_id') || $secret_id != get_option('webmaxy_secret_id')) { 359 return array(get_option('webmaxy_client_id'), $client_id, get_option('webmaxy_secret_id'), $secret_id); 359 360 } 360 361 $DBRecord = array(); 361 362 $args = array( 362 'paged' =>$request['page'],363 'numberposts' =>1000363 'paged' => $request['page'], 364 'numberposts' => 1000 364 365 ); 365 $orders = wc_get_orders( $args); 366 $i=0; 367 foreach ( $orders as $order ) 368 { 369 $items=[]; 370 $order = wc_get_order( $order->id ); 371 foreach ( $order->get_items() as $item_key => $item_values ) { 366 $orders = wc_get_orders($args); 367 $i = 0; 368 foreach ($orders as $order) { 369 $items = []; 370 $order = wc_get_order($order->id); 371 foreach ($order->get_items() as $item_key => $item_values) { 372 372 $product = $item_values->get_product(); 373 if ( $product) {374 $product_data =$product->get_data();375 $obj =array(376 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())),377 'AddedItemPrice' => (float) $product->get_price(),378 'AddedItemQuantity' => $item_values->get_quantity(),379 'subtotal' => $item_values->get_subtotal(),380 'total' => $item_values->get_total(),381 'id' => (int)$product->get_id(),382 'title' => (string) $product->get_name(),383 'AddedItemSKU' => (string) $product->get_sku(),384 'AddedItemURL' => (string) $product->get_permalink(),385 'categories' => $product_data['category_ids'],386 'attributes' => $product_data['attributes']373 if ($product) { 374 $product_data = $product->get_data(); 375 $obj = array( 376 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 377 'AddedItemPrice' => (float) $product->get_price(), 378 'AddedItemQuantity' => $item_values->get_quantity(), 379 'subtotal' => $item_values->get_subtotal(), 380 'total' => $item_values->get_total(), 381 'id' => (int)$product->get_id(), 382 'title' => (string) $product->get_name(), 383 'AddedItemSKU' => (string) $product->get_sku(), 384 'AddedItemURL' => (string) $product->get_permalink(), 385 'categories' => $product_data['category_ids'], 386 'attributes' => $product_data['attributes'] 387 387 ); 388 $items[] = $obj;388 $items[] = $obj; 389 389 } 390 390 } 391 $DBRecord[$i]['coupons']= $order->get_coupon_codes();392 $DBRecord[$i]['order']= $order->get_data();393 $DBRecord[$i]['items']= $items;394 $i++;395 } 396 $statuss =["completed","processing","on-hold","pending","cancelled","refunded","failed"];397 $count =0;391 $DBRecord[$i]['coupons'] = $order->get_coupon_codes(); 392 $DBRecord[$i]['order'] = $order->get_data(); 393 $DBRecord[$i]['items'] = $items; 394 $i++; 395 } 396 $statuss = ["completed", "processing", "on-hold", "pending", "cancelled", "refunded", "failed"]; 397 $count = 0; 398 398 foreach ($statuss as $key => $value) { 399 $count = $count + wc_orders_count( $value );400 } 401 $data =array("count"=>$count,"orders"=>$DBRecord);399 $count = $count + wc_orders_count($value); 400 } 401 $data = array("count" => $count, "orders" => $DBRecord); 402 402 $response = new WP_REST_Response($data); 403 403 $response->set_status(200); 404 404 return $response; 405 }406 407 408 409 function mp_sync_on_product_save( $meta_id, $post_id, $meta_key, $meta_value ) {410 if ( $meta_key == '_edit_lock' ) { // we've been editing the post411 if ( get_post_type( $post_id ) == 'product' ) {412 $product = wc_get_product( $post_id );413 if(!empty($product )){414 $_SESSION['__wbmxa_price'] = $product->get_sale_price();415 }405 } 406 407 408 409 function mp_sync_on_product_save($meta_id, $post_id, $meta_key, $meta_value) 410 { 411 if ($meta_key == '_edit_lock') { // we've been editing the post 412 if (get_post_type($post_id) == 'product') { 413 $product = wc_get_product($post_id); 414 if (!empty($product)) { 415 $_SESSION['__wbmxa_price'] = $product->get_sale_price(); 416 416 } 417 417 } 418 418 } 419 420 421 function wmxA_price_change_event( $product_id ) { 422 $product = wc_get_product( $product_id ); 423 if(!empty($product )){ 424 425 if($_SESSION['__wbmxa_price'] > $product->get_sale_price()){ 426 $data=array( 427 "id"=>$product->get_id(), 428 "price"=>$product->get_sale_price(), 429 "title"=>$product->get_title(), 419 } 420 421 422 function wmxA_price_change_event($product_id) 423 { 424 $product = wc_get_product($product_id); 425 if (!empty($product)) { 426 427 if ($_SESSION['__wbmxa_price'] > $product->get_sale_price()) { 428 $data = array( 429 "id" => $product->get_id(), 430 "price" => $product->get_sale_price(), 431 "title" => $product->get_title(), 430 432 ); 431 432 $this->wbmxa_track_request(1,$data,"PRICE_DROPPED",'actions'); 433 } 434 } 435 } 436 437 public function my_getcookie(){ 438 $client_id= get_option( 'webmaxy_client_id' ); 439 $secret_id= get_option( 'webmaxy_secret_id' ); 440 if(empty($client_id) && empty($secret_id)){ 433 434 $this->wbmxa_track_request(1, $data, "PRICE_DROPPED", 'actions'); 435 } 436 } 437 } 438 439 public function my_getcookie() 440 { 441 $client_id = get_option('webmaxy_client_id'); 442 $secret_id = get_option('webmaxy_secret_id'); 443 if (empty($client_id) && empty($secret_id)) { 441 444 return; 442 445 } 443 $code =base64_encode($client_id.":".$secret_id);446 $code = base64_encode($client_id . ":" . $secret_id); 444 447 $is_admin = is_admin(); 445 448 446 if ( $is_admin) {449 if ($is_admin) { 447 450 return; 448 451 } … … 453 456 } 454 457 $_SESSION['discard_after'] = $now + 900; 455 456 } 457 458 function wpb_hook_javascript_footer(){459 if (isset($_SESSION['__wbmxa_usid'])){460 $client_id = get_option( 'webmaxy_client_id');461 $secret_id = get_option( 'webmaxy_secret_id');462 if (empty($client_id) && empty($secret_id)){458 } 459 460 function wpb_hook_javascript_footer() 461 { 462 if (isset($_SESSION['__wbmxa_usid'])) { 463 $client_id = get_option('webmaxy_client_id'); 464 $secret_id = get_option('webmaxy_secret_id'); 465 if (empty($client_id) && empty($secret_id)) { 463 466 return; 464 467 } 465 $code =base64_encode($client_id.":".$secret_id);468 $code = base64_encode($client_id . ":" . $secret_id); 466 469 $is_admin = is_admin(); 467 470 468 if ( $is_admin) {471 if ($is_admin) { 469 472 return; 470 473 } 471 $us =$_SESSION['__wbmxa_usid'];474 $us = $_SESSION['__wbmxa_usid']; 472 475 ?> 473 <script>474 var ifrm = document.createElement("iframe");475 ifrm.id="webmaxyloyaltyId"476 ifrm.setAttribute("src", "https://loyalty.webmaxy.ai/loyalty/rewards?code=<?php echo $code;?>&us=<?php echo $us;?>");477 ifrm.style = "z-index:9999999;position: fixed;border: none;border-radius: 20px;bottom: 20px;right: 11px;min-width: 340px; min-height: 600px;";478 document.body.appendChild(ifrm);479 document.getElementById('webmaxyloyaltyId').onload=function(){480 window.addEventListener("message", (event) => {481 if (event.origin !== "https://loyalty.webmaxy.ai")482 return;483 if(event.data==="DO_SIGN_UP_OR_LOGIN"){476 <script> 477 var ifrm = document.createElement("iframe"); 478 ifrm.id = "webmaxyloyaltyId" 479 ifrm.setAttribute("src", "https://loyalty.webmaxy.ai/loyalty/rewards?code=<?php echo $code; ?>&us=<?php echo $us; ?>"); 480 ifrm.style = "z-index:9999999;position: fixed;border: none;border-radius: 20px;bottom: 20px;right: 11px;min-width: 450px; min-height: 600px;display:none;"; 481 document.body.appendChild(ifrm); 482 document.getElementById('webmaxyloyaltyId').onload = function() { 483 window.addEventListener("message", (event) => { 484 if (event.origin !== "https://loyalty.webmaxy.ai") 485 return; 486 if (event.data === "DO_SIGN_UP_OR_LOGIN") { 484 487 window.location.assign("my-account") 485 }486 if (event.data==="DO_REFRESH_WEBMAXY"){488 } 489 if (event.data === "DO_REFRESH_WEBMAXY") { 487 490 var iframe = document.getElementById('webmaxyloyaltyId'); 488 491 iframe.src = iframe.src; 489 492 } 493 if (event.data === "CLOSE_LOYALTY_PANEL") { 494 var iframe = document.getElementById('webmaxyloyaltyId'); 495 iframe.style = "z-index:9999999;position: fixed;border: none;border-radius: 20px;bottom: 20px;right: 11px;min-width: 100px; min-height: 100px;display:block;" 496 } 497 if (event.data === "OPEN_LOYALTY_PANEL") { 498 var iframe = document.getElementById('webmaxyloyaltyId'); 499 iframe.style = "z-index:9999999;position: fixed;border: none;border-radius: 20px;bottom: 20px;right: 11px;min-width: 450px; min-height: 600px;display:block;"; 500 } 501 502 490 503 }, false); 491 }; 492 493 494 495 </script> 496 <?php 497 } 498 499 } 504 }; 505 </script> 506 <?php 507 } 508 } 500 509 // referral device landing_page 501 public function pageLoaded() { 502 510 public function pageLoaded() 511 { 512 503 513 $is_admin = is_admin(); 504 514 505 if ( $is_admin) {515 if ($is_admin) { 506 516 return false; 507 517 } … … 509 519 session_start(); 510 520 } 511 $device ="DESKTOP";512 if (wp_is_mobile()){513 $device ="MOBILE";514 } 515 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'){516 $url = "https://"; 517 } else {521 $device = "DESKTOP"; 522 if (wp_is_mobile()) { 523 $device = "MOBILE"; 524 } 525 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { 526 $url = "https://"; 527 } else { 518 528 $url = "http://"; 519 529 } 520 $url .=sanitize_text_field( $_SERVER['HTTP_HOST']);521 $url .= sanitize_text_field($_SERVER['REQUEST_URI']);522 523 524 525 if ( is_wc_endpoint_url( 'order-received' ) && !empty( $_GET[ 'key' ] )) {526 $order_id = wc_get_order_id_by_order_key( $_GET[ 'key' ]);527 $order = wc_get_order( $order_id);530 $url .= sanitize_text_field($_SERVER['HTTP_HOST']); 531 $url .= sanitize_text_field($_SERVER['REQUEST_URI']); 532 533 534 535 if (is_wc_endpoint_url('order-received') && !empty($_GET['key'])) { 536 $order_id = wc_get_order_id_by_order_key($_GET['key']); 537 $order = wc_get_order($order_id); 528 538 // echo ("<script>setTimeout(function(){wmxattr.conversion(".$order->get_total().",'".$order->get_currency()."');},1000);</script>"); 529 539 } 530 $referra_url =sanitize_text_field(isset($_GET['referer']) ? $_GET['referer'] : ($_SERVER['HTTP_REFERER'] !=null ? $_SERVER['HTTP_REFERER'] : null));531 $reff =$this->getDomain($referra_url);532 $utm_medium =sanitize_text_field((isset($_GET['utm_medium']) ? $_GET['utm_medium'] : ""));533 $utm_source =sanitize_text_field((isset($_GET['utm_source']) ? $_GET['utm_source'] : ""));534 $data =array(535 "ck" =>sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")),536 "us" =>sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")),537 "referral" =>$reff,538 "utm_source" =>$utm_source,539 "utm_medium" =>$utm_medium,540 "referra_url" =>$referra_url,541 "device" =>$device,542 "landing_page" =>$url540 $referra_url = sanitize_text_field(isset($_GET['referer']) ? $_GET['referer'] : ($_SERVER['HTTP_REFERER'] != null ? $_SERVER['HTTP_REFERER'] : null)); 541 $reff = $this->getDomain($referra_url); 542 $utm_medium = sanitize_text_field((isset($_GET['utm_medium']) ? $_GET['utm_medium'] : "")); 543 $utm_source = sanitize_text_field((isset($_GET['utm_source']) ? $_GET['utm_source'] : "")); 544 $data = array( 545 "ck" => sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")), 546 "us" => sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")), 547 "referral" => $reff, 548 "utm_source" => $utm_source, 549 "utm_medium" => $utm_medium, 550 "referra_url" => $referra_url, 551 "device" => $device, 552 "landing_page" => $url 543 553 ); 544 $this->wbmxa_track_request(1, $data,"SESSION",'session');545 546 547 if ( 548 ! is_singular() &&549 ! is_page() &&550 ! is_single() &&551 ! is_archive() &&552 !is_home() &&553 ! is_front_page()554 $this->wbmxa_track_request(1, $data, "SESSION", 'session'); 555 556 557 if ( 558 !is_singular() && 559 !is_page() && 560 !is_single() && 561 !is_archive() && 562 !is_home() && 563 !is_front_page() 554 564 ) { 555 return false; 556 } 557 558 if(isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) 559 { 560 if(is_checkout()){ 561 if(count(WC()->cart->get_cart() )>0){ 562 $dataset=[]; 563 foreach ( WC()->cart->get_cart() as $cart_item ) { 565 return false; 566 } 567 568 if (isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) { 569 if (is_checkout()) { 570 if (count(WC()->cart->get_cart()) > 0) { 571 $dataset = []; 572 foreach (WC()->cart->get_cart() as $cart_item) { 564 573 $product = sanitize_text_field($cart_item['data']); 565 574 $quantity = sanitize_text_field($cart_item['quantity']); 566 if (!empty($product)){567 $dataset[] =$this->wbmxa_build_add_to_cart_data($product,$quantity,WC()->cart);575 if (!empty($product)) { 576 $dataset[] = $this->wbmxa_build_add_to_cart_data($product, $quantity, WC()->cart); 568 577 } 569 578 } 570 $data =array(571 "ck" =>sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")),572 "us" =>sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")),573 "data" =>$dataset574 ); 575 $this->wbmxa_track_request(1, $data,"REACHED_CHECKOUT",'actions');579 $data = array( 580 "ck" => sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")), 581 "us" => sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")), 582 "data" => $dataset 583 ); 584 $this->wbmxa_track_request(1, $data, "REACHED_CHECKOUT", 'actions'); 576 585 } 577 } else if( is_product()){578 $data =array(579 "ck" =>sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")),580 "us" =>sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")),581 "url" =>$url,582 "is_product" =>1,583 "id" =>wc_get_product()->get_id(),584 "title" =>wc_get_product()->get_title(),585 "price" =>wc_get_product()->get_sale_price(),586 } else if (is_product()) { 587 $data = array( 588 "ck" => sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")), 589 "us" => sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")), 590 "url" => $url, 591 "is_product" => 1, 592 "id" => wc_get_product()->get_id(), 593 "title" => wc_get_product()->get_title(), 594 "price" => wc_get_product()->get_sale_price(), 586 595 ); 587 $this->wbmxa_track_request(1, $data,"VIEW",'actions');588 } else{589 $data =array(590 "ck" =>sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")),591 "us" =>sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")),592 "url" =>$url,593 "is_product" =>0596 $this->wbmxa_track_request(1, $data, "VIEW", 'actions'); 597 } else { 598 $data = array( 599 "ck" => sanitize_text_field((isset($_COOKIE['__wbmxa_ckid']) ? $_COOKIE['__wbmxa_ckid'] : "")), 600 "us" => sanitize_text_field((isset($_SESSION['__wbmxa_usid']) ? $_SESSION['__wbmxa_usid'] : "")), 601 "url" => $url, 602 "is_product" => 0 594 603 ); 595 $this->wbmxa_track_request(1, $data,"VIEW",'actions');596 } 597 604 $this->wbmxa_track_request(1, $data, "VIEW", 'actions'); 605 } 606 598 607 return false; 599 608 } 600 } 601 602 private function getHostName($url) { 603 $pieces = parse_url($url); 604 $domain = isset($pieces['host']) ? $pieces['host'] : ''; 605 if(preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)){ 606 $dos=explode('.',$regs['domain']); 607 return strtoupper($dos[0]); 608 }else{ 609 return "DIRECT"; 610 } 611 } 612 private function getDomain($path) { 613 if ($path == null ) { 614 return 'DIRECT'; 615 } 616 return $this->getHostName($path); 617 } 618 619 public function wmxA_login_event( $user_login, $user ) { 620 $data=array( 621 "email"=>$user->user_email, 622 "name"=>$user->user_login, 623 "ck"=>sanitize_text_field((!isset($_COOKIE['__wbmxa_ckid']) ? "" : $_COOKIE['__wbmxa_ckid'])), 624 "us"=>sanitize_text_field((!isset($_SESSION['__wbmxa_usid']) ? "" : $_SESSION['__wbmxa_usid'])), 609 } 610 611 private function getHostName($url) 612 { 613 $pieces = parse_url($url); 614 $domain = isset($pieces['host']) ? $pieces['host'] : ''; 615 if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) { 616 $dos = explode('.', $regs['domain']); 617 return strtoupper($dos[0]); 618 } else { 619 return "DIRECT"; 620 } 621 } 622 private function getDomain($path) 623 { 624 if ($path == null) { 625 return 'DIRECT'; 626 } 627 return $this->getHostName($path); 628 } 629 630 public function wmxA_login_event($user_login, $user) 631 { 632 $data = array( 633 "email" => $user->user_email, 634 "name" => $user->user_login, 635 "ck" => sanitize_text_field((!isset($_COOKIE['__wbmxa_ckid']) ? "" : $_COOKIE['__wbmxa_ckid'])), 636 "us" => sanitize_text_field((!isset($_SESSION['__wbmxa_usid']) ? "" : $_SESSION['__wbmxa_usid'])), 625 637 ); 626 $this->wbmxa_track_request(1, $data,"LOGIN",'login');638 $this->wbmxa_track_request(1, $data, "LOGIN", 'login'); 627 639 } 628 640 629 641 // REACHED_CHECKOUT 630 public static function wmxA_logout_event( $user_logout_id ) { 642 public static function wmxA_logout_event($user_logout_id) 643 { 631 644 // your code 632 645 unset($_SESSION['__wbmxa_loginid']); 633 646 } 634 647 635 648 public function wmxA_added_to_cart_event($cart_item_key, $product_id, $quantity) 636 649 { 637 638 if(isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) 639 { 640 $added_product = wc_get_product( $product_id ); 641 if ( ! $added_product instanceof WC_Product ) { return; } 642 $data=$this->wbmxa_build_add_to_cart_data($added_product,$quantity,WC()->cart); 643 $data['ck']=sanitize_text_field($_COOKIE['__wbmxa_ckid']); 644 $data['us']=sanitize_text_field($_SESSION['__wbmxa_usid']); 645 $this->wbmxa_track_request(1,$data,'ATC','actions'); 650 651 if (isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) { 652 $added_product = wc_get_product($product_id); 653 if (!$added_product instanceof WC_Product) { 654 return; 655 } 656 $data = $this->wbmxa_build_add_to_cart_data($added_product, $quantity, WC()->cart); 657 $data['ck'] = sanitize_text_field($_COOKIE['__wbmxa_ckid']); 658 $data['us'] = sanitize_text_field($_SESSION['__wbmxa_usid']); 659 $this->wbmxa_track_request(1, $data, 'ATC', 'actions'); 646 660 } 647 661 } … … 650 664 { 651 665 652 if(isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) 653 { 654 $order = wc_get_order( $order_id ); 655 if (empty($order) ) { return; } 656 666 if (isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) { 667 $order = wc_get_order($order_id); 668 if (empty($order)) { 669 return; 670 } 671 657 672 // $order = new WC_Order( $order_id ); 658 673 $items = $order->get_items(); 659 $dataset =[];660 foreach ( $items as $key => $item ){674 $dataset = []; 675 foreach ($items as $key => $item) { 661 676 $product = $item->get_product(); 662 if ( $product) {663 $product_data =$product->get_data();664 $obj =array(665 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())),666 'AddedItemPrice' => (float) $product->get_price(),667 'AddedItemQuantity' => $item->get_quantity(),668 'subtotal' => $item->get_subtotal(),669 'total' => $item->get_total(),670 'id' => (int)$product->get_id(),671 'title' => (string) $product->get_name(),672 'AddedItemSKU' => (string) $product->get_sku(),673 'AddedItemURL' => (string) $product->get_permalink(),674 'categories' => $product_data['category_ids'],675 'attributes' => $product_data['attributes']677 if ($product) { 678 $product_data = $product->get_data(); 679 $obj = array( 680 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 681 'AddedItemPrice' => (float) $product->get_price(), 682 'AddedItemQuantity' => $item->get_quantity(), 683 'subtotal' => $item->get_subtotal(), 684 'total' => $item->get_total(), 685 'id' => (int)$product->get_id(), 686 'title' => (string) $product->get_name(), 687 'AddedItemSKU' => (string) $product->get_sku(), 688 'AddedItemURL' => (string) $product->get_permalink(), 689 'categories' => $product_data['category_ids'], 690 'attributes' => $product_data['attributes'] 676 691 ); 677 $dataset[] =$obj;678 }679 } 680 $data['ck'] =sanitize_text_field($_COOKIE['__wbmxa_ckid']);681 $data['us'] =sanitize_text_field($_SESSION['__wbmxa_usid']);682 $data['order_id'] =$order_id;683 $data['items'] =$dataset;684 $data['currency'] =$order->get_currency();685 $data['total'] =$order->get_total();692 $dataset[] = $obj; 693 } 694 } 695 $data['ck'] = sanitize_text_field($_COOKIE['__wbmxa_ckid']); 696 $data['us'] = sanitize_text_field($_SESSION['__wbmxa_usid']); 697 $data['order_id'] = $order_id; 698 $data['items'] = $dataset; 699 $data['currency'] = $order->get_currency(); 700 $data['total'] = $order->get_total(); 686 701 $order_data = $order->get_data(); 687 $data['user'] =$order_data['billing'];688 $data['coupons'] =$order->get_coupon_codes();689 $this->wbmxa_track_request(1, $data,'PLACE_ORDER','actions');690 702 $data['user'] = $order_data['billing']; 703 $data['coupons'] = $order->get_coupon_codes(); 704 $this->wbmxa_track_request(1, $data, 'PLACE_ORDER', 'actions'); 705 691 706 // sleep(2); 692 707 } 693 708 } 694 709 695 710 696 711 public function wmxA_cancel_order_event($order_id) 697 712 { 698 713 699 if(isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) 700 { 701 $order = wc_get_order( $order_id ); 702 if (empty($order) ) { return; } 703 714 if (isset($_COOKIE['__wbmxa_ckid']) && isset($_SESSION['__wbmxa_usid'])) { 715 $order = wc_get_order($order_id); 716 if (empty($order)) { 717 return; 718 } 719 704 720 // $order = new WC_Order( $order_id ); 705 721 $items = $order->get_items(); 706 $dataset =[];707 foreach ( $items as $key => $item ){722 $dataset = []; 723 foreach ($items as $key => $item) { 708 724 $product = $item->get_product(); 709 if ( $product) {710 $obj =array(711 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())),712 'AddedItemPrice' => (float) $product->get_price(),713 'AddedItemQuantity' => $item->get_quantity(),714 'subtotal' => $item->get_subtotal(),715 'total' => $item->get_total(),716 'id' => (int)$product->get_id(),717 'title' => (string) $product->get_name(),718 'AddedItemSKU' => (string) $product->get_sku(),719 'AddedItemURL' => (string) $product->get_permalink()725 if ($product) { 726 $obj = array( 727 'AddedItemImageURL' => (string) wp_get_attachment_url(get_post_thumbnail_id($product->get_id())), 728 'AddedItemPrice' => (float) $product->get_price(), 729 'AddedItemQuantity' => $item->get_quantity(), 730 'subtotal' => $item->get_subtotal(), 731 'total' => $item->get_total(), 732 'id' => (int)$product->get_id(), 733 'title' => (string) $product->get_name(), 734 'AddedItemSKU' => (string) $product->get_sku(), 735 'AddedItemURL' => (string) $product->get_permalink() 720 736 ); 721 $dataset[] =$obj;722 }723 } 724 $data['ck'] =sanitize_text_field($_COOKIE['__wbmxa_ckid']);725 $data['us'] =sanitize_text_field($_SESSION['__wbmxa_usid']);726 $data['order_id'] =$order_id;727 $data['items'] =$dataset;728 $data['currency'] =$order->get_currency();729 $data['total'] =$order->get_total();730 $this->wbmxa_track_request(1, $data,'CANCEL_ORDER','actions');731 } 732 } 733 734 735 736 737 $dataset[] = $obj; 738 } 739 } 740 $data['ck'] = sanitize_text_field($_COOKIE['__wbmxa_ckid']); 741 $data['us'] = sanitize_text_field($_SESSION['__wbmxa_usid']); 742 $data['order_id'] = $order_id; 743 $data['items'] = $dataset; 744 $data['currency'] = $order->get_currency(); 745 $data['total'] = $order->get_total(); 746 $this->wbmxa_track_request(1, $data, 'CANCEL_ORDER', 'actions'); 747 } 748 } 749 750 751 752 737 753 738 754 /** … … 752 768 * @access private 753 769 */ 754 private function load_dependencies() { 770 private function load_dependencies() 771 { 755 772 756 773 /** … … 758 775 * core plugin. 759 776 */ 760 require_once plugin_dir_path( dirname( __FILE__ )) . 'includes/class-webmaxycdp-loader.php';777 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-webmaxycdp-loader.php'; 761 778 762 779 /** … … 764 781 * of the plugin. 765 782 */ 766 require_once plugin_dir_path( dirname( __FILE__ )) . 'includes/class-webmaxycdp-i18n.php';783 require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-webmaxycdp-i18n.php'; 767 784 768 785 /** 769 786 * The class responsible for defining all actions that occur in the admin area. 770 787 */ 771 require_once plugin_dir_path( dirname( __FILE__ )) . 'admin/class-webmaxycdp-admin.php';788 require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-webmaxycdp-admin.php'; 772 789 773 790 /** … … 775 792 * side of the site. 776 793 */ 777 require_once plugin_dir_path( dirname( __FILE__ )) . 'public/class-webmaxycdp-public.php';794 require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-webmaxycdp-public.php'; 778 795 779 796 $this->loader = new WebMaxyCDP_Loader(); 780 781 797 } 782 798 … … 790 806 * @access private 791 807 */ 792 private function set_locale() { 808 private function set_locale() 809 { 793 810 794 811 $plugin_i18n = new WebMaxyCDP_i18n(); 795 812 796 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 797 813 $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); 798 814 } 799 815 … … 805 821 * @access private 806 822 */ 807 private function define_admin_hooks() { 808 809 $plugin_admin = new WebMaxyCDP_Admin( $this->get_plugin_name(), $this->get_version() ); 823 private function define_admin_hooks() 824 { 825 826 $plugin_admin = new WebMaxyCDP_Admin($this->get_plugin_name(), $this->get_version()); 810 827 811 828 // $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); … … 821 838 * @access private 822 839 */ 823 private function define_public_hooks() { 824 825 $plugin_public = new WebMaxyCDP_Public( $this->get_plugin_name(), $this->get_version() ); 840 private function define_public_hooks() 841 { 842 843 $plugin_public = new WebMaxyCDP_Public($this->get_plugin_name(), $this->get_version()); 826 844 827 845 // $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); 828 846 // $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); 829 847 830 } 831 832 /** 833 * Run the loader to execute all of the hooks with WordPress. 834 * 835 * @since 1.0.0 836 */ 837 838 public function run() { 839 $this->loader->run(); 840 } 841 842 /** 843 * The name of the plugin used to uniquely identify it within the context of 844 * WordPress and to define internationalization functionality. 845 * 846 * @since 1.0.0 847 * @return string The name of the plugin. 848 */ 849 850 public function get_plugin_name() { 851 return $this->plugin_name; 852 } 853 854 /** 855 * The reference to the class that orchestrates the hooks with the plugin. 856 * 857 * @since 1.0.0 858 * @return WebMaxyCDP_Loader Orchestrates the hooks of the plugin. 859 */ 860 861 public function get_loader() { 862 return $this->loader; 863 } 864 865 /** 866 * Retrieve the version number of the plugin. 867 * 868 * @since 1.0.0 869 * @return string The version number of the plugin. 870 */ 871 872 public function get_version() { 873 return $this->version; 874 } 875 848 } 849 850 /** 851 * Run the loader to execute all of the hooks with WordPress. 852 * 853 * @since 1.0.0 854 */ 855 856 public function run() 857 { 858 $this->loader->run(); 859 } 860 861 /** 862 * The name of the plugin used to uniquely identify it within the context of 863 * WordPress and to define internationalization functionality. 864 * 865 * @since 1.0.0 866 * @return string The name of the plugin. 867 */ 868 869 public function get_plugin_name() 870 { 871 return $this->plugin_name; 872 } 873 874 /** 875 * The reference to the class that orchestrates the hooks with the plugin. 876 * 877 * @since 1.0.0 878 * @return WebMaxyCDP_Loader Orchestrates the hooks of the plugin. 879 */ 880 881 public function get_loader() 882 { 883 return $this->loader; 884 } 885 886 /** 887 * Retrieve the version number of the plugin. 888 * 889 * @since 1.0.0 890 * @return string The version number of the plugin. 891 */ 892 893 public function get_version() 894 { 895 return $this->version; 896 } 876 897 }
Note: See TracChangeset
for help on using the changeset viewer.