Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.5.8

Version Description

  • 10/01/2022 =

  • In this release, we have optimise the code and upgrade the plugin security.

Download this release

Release Info

Developer Tatvic
Plugin Icon 128x128 Enhanced Ecommerce Google Analytics Plugin for WooCommerce
Version 4.5.8
Comparing to
See all releases

Code changes from version 4.5.7 to 4.5.8

admin/class-conversios-admin.php CHANGED
@@ -27,9 +27,8 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
27
  protected $version;
28
  public function __construct() {
29
  $this->version = PLUGIN_TVC_VERSION;
30
- $this->includes();
31
- $this->url = $this->get_onboarding_page_url();
32
- /* $this->pro_plan_site = $this->get_pro_plan_site();*/
33
  $this->google_detail = $this->get_ee_options_data();
34
  add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
35
  add_action('admin_init',array($this, 'init'));
@@ -66,8 +65,8 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
66
  wp_enqueue_style('conversios-daterangepicker-css');
67
  }
68
  //all conversios page css
69
- wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all' );
70
- wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), $this->version, 'all');
71
  }
72
  }
73
 
@@ -87,7 +86,7 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
87
  wp_enqueue_script( 'conversios-moment-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/moment.min.js') );
88
  wp_enqueue_script( 'conversios-daterangepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/daterangepicker.js') );
89
 
90
- wp_enqueue_script( 'tvc-ee-custom-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/tvc-ee-custom.js'), array( 'jquery' ), $this->version, false );
91
  }
92
  }
93
  }
27
  protected $version;
28
  public function __construct() {
29
  $this->version = PLUGIN_TVC_VERSION;
30
+ $this->includes();
31
+ $this->url = $this->get_onboarding_page_url(); // use in setting page
 
32
  $this->google_detail = $this->get_ee_options_data();
33
  add_action( 'admin_menu', array( $this, 'add_admin_pages' ) );
34
  add_action('admin_init',array($this, 'init'));
65
  wp_enqueue_style('conversios-daterangepicker-css');
66
  }
67
  //all conversios page css
68
+ wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), esc_attr($this->version), 'all' );
69
+ wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), esc_attr($this->version), 'all');
70
  }
71
  }
72
 
86
  wp_enqueue_script( 'conversios-moment-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/moment.min.js') );
87
  wp_enqueue_script( 'conversios-daterangepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/daterangepicker.js') );
88
 
89
+ wp_enqueue_script( 'tvc-ee-custom-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/tvc-ee-custom.js'), array( 'jquery' ), esc_attr($this->version), false );
90
  }
91
  }
92
  }
admin/class-conversios-onboarding.php CHANGED
@@ -35,7 +35,6 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
35
  /**
36
  * check last login for check RefreshToken
37
  */
38
- //print_r($ee_additional_data); exit;
39
  if(isset($ee_additional_data['ee_last_login']) && $ee_additional_data['ee_last_login'] != ""){
40
  $this->last_login = $ee_additional_data['ee_last_login'];
41
  $current = current_time( 'timestamp' );
@@ -75,14 +74,14 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
75
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
76
  foreach ($contData as $key => $value) {
77
  $selected = ($value->code == $user_country) ? "selected='selected'" : "";
78
- $data .= "<option value=" . esc_attr($value->code) . " " . $selected . " >" . esc_attr($value->name) . "</option>";
79
  }
80
  $data .= "</select>";
81
  } else {
82
  $data = "<select id='selectCountry' name='country' class='form-control slect2bx'>";
83
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
84
  foreach ($contData as $key => $value) {
85
- $data .= "<option value=" . esc_attr($value->code) . ">" . esc_attr($value->name) . "</option>";
86
  }
87
  $data .= "</select>";
88
  }
@@ -116,8 +115,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
116
  $this->TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
117
 
118
  $this->is_refresh_token_expire = false;
119
- }
120
- //$this->tvc_data = json_encode($this->tvc_data);
121
  }
122
 
123
  if($this->subscriptionId != ""){
@@ -126,8 +124,8 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
126
  if( property_exists($google_detail, "data") && $google_detail->data != "" ){
127
  $googleDetail = $google_detail->data;
128
  $this->tvc_data['subscription_id'] = $googleDetail->id;
129
- $this->tvc_data['access_token'] = base64_encode($googleDetail->access_token);
130
- $this->tvc_data['refresh_token'] = base64_encode($googleDetail->refresh_token);
131
  $this->plan_id = $googleDetail->plan_id;
132
  $login_customer_id = $googleDetail->customer_id;
133
  $tracking_option = $googleDetail->tracking_option;
@@ -145,7 +143,6 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
145
  $complete_step["step-3"] = 1;
146
  }
147
  }
148
-
149
  }
150
  }
151
  }
@@ -271,7 +268,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
271
  </label>
272
  <div id="UA" class="slctunivr-filed">
273
  <div class="tvc-dropdown">
274
- <div class="tvc-dropdown-header" id="ua_web_property_id_option_val" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
275
  echo esc_attr($googleDetail->property_id);
276
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
277
  <div class="tvc-dropdown-content" id="ua_web_property_id_option">
@@ -284,14 +281,14 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
284
  </div>
285
  <div class="cstmrdobtn-item">
286
  <label for="gglanytc">
287
- <input type="radio" <?php echo $this->is_checked($tracking_option, "GA4"); ?> name="analytic_tag_type" id="gglanytc" value="GA4">
288
  <span class="checkmark"></span>
289
  <?php esc_html_e("Google Analytics 4","conversios"); ?>
290
  </label>
291
  <div id="GA4" class="slctunivr-filed">
292
 
293
  <div class="tvc-dropdown">
294
- <div class="tvc-dropdown-header" id="ga4_web_measurement_id_option_val" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
295
  <?php if($googleDetail->measurement_id){
296
  echo esc_attr($googleDetail->measurement_id);
297
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
@@ -306,7 +303,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
306
  </div>
307
  <div class="cstmrdobtn-item">
308
  <label for="both">
309
- <input type="radio" <?php echo $this->is_checked($tracking_option, "BOTH"); ?> name="analytic_tag_type" id="both" value="BOTH">
310
  <span class="checkmark"></span>
311
  <?php esc_html_e("Both","conversios"); ?>
312
  </label>
@@ -314,7 +311,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
314
  <div class="botslectbxitem">
315
 
316
  <div class="tvc-dropdown">
317
- <div class="tvc-dropdown-header" id="both_ua_web_property_id_option_val" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
318
  echo esc_attr($googleDetail->property_id);
319
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
320
  <div class="tvc-dropdown-content" id="both_ua_web_property_id_option">
@@ -327,7 +324,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
327
  <div class="botslectbxitem">
328
 
329
  <div class="tvc-dropdown">
330
- <div class="tvc-dropdown-header" id="both_ga4_web_measurement_id_option_val" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
331
  <?php if($googleDetail->measurement_id){
332
  echo esc_attr($googleDetail->measurement_id);
333
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
@@ -392,7 +389,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
392
  <option value=''><?php esc_html_e("Select Google Ads Account","conversios"); ?></option>
393
  </select>
394
  </div>
395
- <div class="orwrp">or</div>
396
  <div class="creatnewwrp">
397
  <button type="button" class="cretnewbtn newggladsbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
398
  </div>
@@ -404,8 +401,8 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
404
  <p><?php esc_html_e("Your Google Ads Account has been created","conversios"); ?> <strong>(<b><span id="new_google_ads_id"></span></b>).</strong></p>
405
  <h5><?php esc_html_e("Steps to claim your Google Ads Account:","conversios"); ?></h5>
406
  <ol>
407
- <li><?php esc_html_e("Accept invitation mail from Google Ads sent to your email address","conversios"); ?> <em><?php echo (isset($this->tvc_data['g_mail']))?$this->tvc_data['g_mail']:""; ?></em></li>
408
- <li><?php esc_html_e("Log into your Google Ads account and set up your <em>billing preferences</em>","conversios"); ?></li>
409
  </ol>
410
  </div>
411
  </div>
@@ -490,7 +487,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
490
  <option value=''><?php esc_html_e("Select Google Merchant Center","conversios"); ?></option>
491
  </select>
492
  </div>
493
- <div class="orwrp">or</div>
494
  <div class="creatnewwrp">
495
  <button type="button" class="cretnewbtn newmrchntbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
496
  </div>
@@ -506,11 +503,11 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
506
  <input type="hidden" id="plan_id" name="plan_id" value="<?php echo esc_attr($this->plan_id); ?>">
507
  <input type="hidden" id="conversios_onboarding_nonce" name="conversios_onboarding_nonce" value="<?php echo wp_create_nonce( 'conversios_onboarding_nonce' ); ?>">
508
 
509
- <input type="hidden" id="ga_view_id" name="ga_view_id" value="<?php echo esc_attr(get_option('ee_ga_view_id')); ?>">
510
  </form>
511
  </div>
512
  <div class="stepnotewrp">
513
- <?php esc_html_e('If you are in the European Economic Area or Switzerland your Merchant Center account must be associated with a Comparison Shopping Service (CSS). Please find more information at <a href="">Google Merchant Center Help</a> website. If you create a new Merchant Center account through this application, it will be associated with Google Shopping, Google’s CSS, by default. You can change the CSS associated with your account at any time. Please find more information about our CSS Partners <a href="">here</a>. Once you have set up your Merchant Center account you can use our onboarding tool regardless of which CSS you use.','conversios'); ?>
514
  </div>
515
  </div>
516
  </div>
@@ -729,11 +726,11 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
729
  * onboarding page javascript
730
  */
731
  public function page_script(){
732
- $j_tvc_data = json_encode($this->tvc_data);
733
  ?>
734
  <script>
735
- let tvc_data = <?php echo $j_tvc_data; ?>;
736
- var tvc_ajax_url = '<?php echo admin_url( 'admin-ajax.php' ); ?>';
 
737
  let subscription_id ="<?php echo esc_attr($this->subscriptionId); ?>";
738
  let plan_id ="<?php echo esc_attr($this->plan_id); ?>";
739
  let app_id ="<?php echo esc_attr($this->app_id); ?>";
@@ -752,8 +749,7 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
752
  const systemZoom = width / window.screen.availWidth;
753
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
754
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
755
- /*window.open('<?php echo $this->connect_url; ?>','newwindow', config=`height=670,width=670,top=100,left=${left},toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=no`);*/
756
- var url ='<?php echo $this->connect_url; ?>';
757
  url = url.replace(/&amp;/g, '&');
758
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
759
  width=${w / systemZoom},
@@ -1003,12 +999,12 @@ if ( ! class_exists( 'Conversios_Onboarding' ) ) {
1003
  if(isset($_GET['page']) && sanitize_text_field($_GET['page']) == "conversios_onboarding"){
1004
  wp_register_style('conversios-select2-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/select2.css'));
1005
  wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all');
1006
- wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), $this->version, 'all');
1007
  wp_enqueue_style('conversios-select2-css');
1008
 
1009
  wp_register_script('conversios-select2-js', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/js/select2.min.js') );
1010
  wp_enqueue_script('conversios-select2-js');
1011
- wp_enqueue_script( 'conversios-onboarding-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/onboarding-custom.js') , array( 'jquery' ), $this->version, false );
1012
  }
1013
  }
1014
  /**
35
  /**
36
  * check last login for check RefreshToken
37
  */
 
38
  if(isset($ee_additional_data['ee_last_login']) && $ee_additional_data['ee_last_login'] != ""){
39
  $this->last_login = $ee_additional_data['ee_last_login'];
40
  $current = current_time( 'timestamp' );
74
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
75
  foreach ($contData as $key => $value) {
76
  $selected = ($value->code == $user_country) ? "selected='selected'" : "";
77
+ $data .= "<option value=" . esc_attr($value->code) . " " . esc_attr($selected) . " >" . esc_attr($value->name) . "</option>";
78
  }
79
  $data .= "</select>";
80
  } else {
81
  $data = "<select id='selectCountry' name='country' class='form-control slect2bx'>";
82
  $data .= "<option value=''>".esc_html__("Please select country","conversios")."</option>";
83
  foreach ($contData as $key => $value) {
84
+ $data .= "<option value=" . esc_attr($value->code) . ">" . esc_attr($value->name) . "</option>";
85
  }
86
  $data .= "</select>";
87
  }
115
  $this->TVC_Admin_Helper->set_ee_additional_data($ee_additional_data);
116
 
117
  $this->is_refresh_token_expire = false;
118
+ }
 
119
  }
120
 
121
  if($this->subscriptionId != ""){
124
  if( property_exists($google_detail, "data") && $google_detail->data != "" ){
125
  $googleDetail = $google_detail->data;
126
  $this->tvc_data['subscription_id'] = $googleDetail->id;
127
+ $this->tvc_data['access_token'] = base64_encode(sanitize_text_field($googleDetail->access_token));
128
+ $this->tvc_data['refresh_token'] = base64_encode(sanitize_text_field($googleDetail->refresh_token));
129
  $this->plan_id = $googleDetail->plan_id;
130
  $login_customer_id = $googleDetail->customer_id;
131
  $tracking_option = $googleDetail->tracking_option;
143
  $complete_step["step-3"] = 1;
144
  }
145
  }
 
146
  }
147
  }
148
  }
268
  </label>
269
  <div id="UA" class="slctunivr-filed">
270
  <div class="tvc-dropdown">
271
+ <div class="tvc-dropdown-header" id="ua_web_property_id_option_val" data-profileid="" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
272
  echo esc_attr($googleDetail->property_id);
273
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
274
  <div class="tvc-dropdown-content" id="ua_web_property_id_option">
281
  </div>
282
  <div class="cstmrdobtn-item">
283
  <label for="gglanytc">
284
+ <input type="radio" <?php echo esc_attr($this->is_checked($tracking_option, "GA4")); ?> name="analytic_tag_type" id="gglanytc" value="GA4">
285
  <span class="checkmark"></span>
286
  <?php esc_html_e("Google Analytics 4","conversios"); ?>
287
  </label>
288
  <div id="GA4" class="slctunivr-filed">
289
 
290
  <div class="tvc-dropdown">
291
+ <div class="tvc-dropdown-header" id="ga4_web_measurement_id_option_val" data-name="" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
292
  <?php if($googleDetail->measurement_id){
293
  echo esc_attr($googleDetail->measurement_id);
294
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
303
  </div>
304
  <div class="cstmrdobtn-item">
305
  <label for="both">
306
+ <input type="radio" <?php echo esc_attr($this->is_checked($tracking_option, "BOTH")); ?> name="analytic_tag_type" id="both" value="BOTH">
307
  <span class="checkmark"></span>
308
  <?php esc_html_e("Both","conversios"); ?>
309
  </label>
311
  <div class="botslectbxitem">
312
 
313
  <div class="tvc-dropdown">
314
+ <div class="tvc-dropdown-header" id="both_ua_web_property_id_option_val" data-profileid="" data-accountid="<?php if($googleDetail->ua_analytic_account_id){ echo esc_attr($googleDetail->ua_analytic_account_id); } ?>" data-val="<?php if($googleDetail->property_id){ echo esc_attr($googleDetail->property_id); } ?>"><?php if($googleDetail->property_id){
315
  echo esc_attr($googleDetail->property_id);
316
  }else{?><?php esc_html_e("Select Property Id","conversios"); ?><?php } ?></div>
317
  <div class="tvc-dropdown-content" id="both_ua_web_property_id_option">
324
  <div class="botslectbxitem">
325
 
326
  <div class="tvc-dropdown">
327
+ <div class="tvc-dropdown-header" id="both_ga4_web_measurement_id_option_val" data-name="" data-accountid="<?php if($googleDetail->ga4_analytic_account_id){ echo esc_attr($googleDetail->ga4_analytic_account_id); } ?>" data-val="<?php if($googleDetail->measurement_id){ echo esc_attr($googleDetail->measurement_id); } ?>">
328
  <?php if($googleDetail->measurement_id){
329
  echo esc_attr($googleDetail->measurement_id);
330
  }else{?><?php esc_html_e("Select Measurement Id","conversios"); ?>
389
  <option value=''><?php esc_html_e("Select Google Ads Account","conversios"); ?></option>
390
  </select>
391
  </div>
392
+ <div class="orwrp"><?php esc_html_e("or","conversios"); ?></div>
393
  <div class="creatnewwrp">
394
  <button type="button" class="cretnewbtn newggladsbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
395
  </div>
401
  <p><?php esc_html_e("Your Google Ads Account has been created","conversios"); ?> <strong>(<b><span id="new_google_ads_id"></span></b>).</strong></p>
402
  <h5><?php esc_html_e("Steps to claim your Google Ads Account:","conversios"); ?></h5>
403
  <ol>
404
+ <li><?php esc_html_e("Accept invitation mail from Google Ads sent to your email address","conversios"); ?> <em><?php echo (isset($this->tvc_data['g_mail']))?esc_attr($this->tvc_data['g_mail']):""; ?></em></li>
405
+ <li><?php esc_html_e("Log into your Google Ads account and set up your billing preferences","conversios"); ?></li>
406
  </ol>
407
  </div>
408
  </div>
487
  <option value=''><?php esc_html_e("Select Google Merchant Center","conversios"); ?></option>
488
  </select>
489
  </div>
490
+ <div class="orwrp"><?php esc_html_e("or","conversios"); ?></div>
491
  <div class="creatnewwrp">
492
  <button type="button" class="cretnewbtn newmrchntbtn"><span class="plusicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png'); ?>" alt="" /></span> <?php esc_html_e("Create New","conversios"); ?></button>
493
  </div>
503
  <input type="hidden" id="plan_id" name="plan_id" value="<?php echo esc_attr($this->plan_id); ?>">
504
  <input type="hidden" id="conversios_onboarding_nonce" name="conversios_onboarding_nonce" value="<?php echo wp_create_nonce( 'conversios_onboarding_nonce' ); ?>">
505
 
506
+ <input type="hidden" id="ga_view_id" name="ga_view_id" value="">
507
  </form>
508
  </div>
509
  <div class="stepnotewrp">
510
+ <?php esc_html_e('If you are in the European Economic Area or Switzerland your Merchant Center account must be associated with a Comparison Shopping Service (CSS). Please find more information at <a href="#">Google Merchant Center Help</a> website. If you create a new Merchant Center account through this application, it will be associated with Google Shopping, Google’s CSS, by default. You can change the CSS associated with your account at any time. Please find more information about our CSS Partners <a href="">here</a>. Once you have set up your Merchant Center account you can use our onboarding tool regardless of which CSS you use.','conversios'); ?>
511
  </div>
512
  </div>
513
  </div>
726
  * onboarding page javascript
727
  */
728
  public function page_script(){
 
729
  ?>
730
  <script>
731
+
732
+ var tvc_data = "<?php echo esc_js(wp_json_encode($this->tvc_data)); ?>";
733
+ var tvc_ajax_url = '<?php echo esc_url_raw(admin_url( 'admin-ajax.php' )); ?>';
734
  let subscription_id ="<?php echo esc_attr($this->subscriptionId); ?>";
735
  let plan_id ="<?php echo esc_attr($this->plan_id); ?>";
736
  let app_id ="<?php echo esc_attr($this->app_id); ?>";
749
  const systemZoom = width / window.screen.availWidth;
750
  const left = (width - w) / 2 / systemZoom + dualScreenLeft;
751
  const top = (height - h) / 2 / systemZoom + dualScreenTop;
752
+ var url ='<?php echo esc_url_raw($this->connect_url); ?>';
 
753
  url = url.replace(/&amp;/g, '&');
754
  const newWindow = window.open(url, "newwindow", config= `scrollbars=yes,
755
  width=${w / systemZoom},
999
  if(isset($_GET['page']) && sanitize_text_field($_GET['page']) == "conversios_onboarding"){
1000
  wp_register_style('conversios-select2-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/select2.css'));
1001
  wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), $this->version, 'all');
1002
+ wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), esc_attr($this->version), 'all');
1003
  wp_enqueue_style('conversios-select2-css');
1004
 
1005
  wp_register_script('conversios-select2-js', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/js/select2.min.js') );
1006
  wp_enqueue_script('conversios-select2-js');
1007
+ wp_enqueue_script( 'conversios-onboarding-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/onboarding-custom.js') , array( 'jquery' ), esc_attr($this->version), false );
1008
  }
1009
  }
1010
  /**
admin/class-enhanced-ecommerce-google-analytics-admin.php CHANGED
@@ -46,14 +46,11 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
46
  public function __construct($plugin_name, $version) {
47
  $this->plugin_name = $plugin_name;
48
  $this->version = $version;
49
- $this->url = $this->get_onboarding_page_url();
50
- $this->site_url = "admin.php?page=conversios";
51
- $this->pro_plan_site = $this->get_pro_plan_site();
52
  $this->google_detail = $this->get_ee_options_data();
53
  }
54
  public function tvc_admin_notice(){
55
  // add fixed message notification
56
- $this->add_tvc_fixed_nofification();
57
  $ee_additional_data = $this->get_ee_additional_data();
58
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_a']) && $ee_additional_data['dismissed_ee_adimin_notic_a'] == 1){
59
  }else{
@@ -65,16 +62,16 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
65
  }
66
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_b']) && $ee_additional_data['dismissed_ee_adimin_notic_b'] == 1){
67
  }else{
68
- $google_detail = $this->get_ee_options_data();
69
- if(isset($google_detail['setting']) && $google_detail['setting']){
70
- $googleDetail = $google_detail['setting'];
71
- if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id =="" && $this->subscriptionId != "" ){
72
- echo '<div class="notice notice-info is-dismissible" data-id="ee_adimin_notic_b">
73
- <p>'. esc_html__("Leverage the power of Google Shopping to reach out millions of shoppers across Google. Automate entire Google Shopping and get eligible for free listing when user searches on Google for products similar to your eCommerce business.","conversios").' <a href="'.esc_url_raw('admin.php?page=conversios').'"><b><u>'. esc_html__("Automate now","conversios").'</u></b></a></p>
74
- </div>';
75
-
76
- }
77
- }
78
  }
79
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_c']) && $ee_additional_data['dismissed_ee_adimin_notic_c'] == 1){
80
  }else{
@@ -114,8 +111,7 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
114
  if ($screen->id == 'toplevel_page_conversios' || (isset($_GET['page']) && strpos(sanitize_text_field($_GET['page']), 'conversios') !== false) ) {
115
  if(sanitize_text_field($_GET['page']) == "conversios_onboarding"){
116
  return;
117
- }
118
-
119
  if(is_rtl()){
120
  wp_register_style('plugin-bootstrap', esc_url_raw(ENHANCAD_PLUGIN_URL . '/includes/setup/plugins/bootstrap/css/bootstrap.rtl.min.css') );
121
  }else{
46
  public function __construct($plugin_name, $version) {
47
  $this->plugin_name = $plugin_name;
48
  $this->version = $version;
 
 
 
49
  $this->google_detail = $this->get_ee_options_data();
50
  }
51
  public function tvc_admin_notice(){
52
  // add fixed message notification
53
+ //$this->add_tvc_fixed_nofification();
54
  $ee_additional_data = $this->get_ee_additional_data();
55
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_a']) && $ee_additional_data['dismissed_ee_adimin_notic_a'] == 1){
56
  }else{
62
  }
63
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_b']) && $ee_additional_data['dismissed_ee_adimin_notic_b'] == 1){
64
  }else{
65
+ $google_detail = $this->get_ee_options_data();
66
+ if(isset($google_detail['setting']) && $google_detail['setting']){
67
+ $googleDetail = $google_detail['setting'];
68
+ if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id =="" && $this->subscriptionId != "" ){
69
+ echo '<div class="notice notice-info is-dismissible" data-id="ee_adimin_notic_b">
70
+ <p>'. esc_html__("Leverage the power of Google Shopping to reach out millions of shoppers across Google. Automate entire Google Shopping and get eligible for free listing when user searches on Google for products similar to your eCommerce business.","conversios").' <a href="'.esc_url_raw('admin.php?page=conversios').'"><b><u>'. esc_html__("Automate now","conversios").'</u></b></a></p>
71
+ </div>';
72
+
73
+ }
74
+ }
75
  }
76
  if(isset($ee_additional_data['dismissed_ee_adimin_notic_c']) && $ee_additional_data['dismissed_ee_adimin_notic_c'] == 1){
77
  }else{
111
  if ($screen->id == 'toplevel_page_conversios' || (isset($_GET['page']) && strpos(sanitize_text_field($_GET['page']), 'conversios') !== false) ) {
112
  if(sanitize_text_field($_GET['page']) == "conversios_onboarding"){
113
  return;
114
+ }
 
115
  if(is_rtl()){
116
  wp_register_style('plugin-bootstrap', esc_url_raw(ENHANCAD_PLUGIN_URL . '/includes/setup/plugins/bootstrap/css/bootstrap.rtl.min.css') );
117
  }else{
admin/class-survey.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
  if ( ! class_exists( 'TVC_Survey' ) ) {
3
  class TVC_Survey {
4
- public $api_url = TVC_API_CALL_URL.'/customersurvey';
5
  public $name;
6
  public $plugin;
7
  protected $TVC_Admin_DB_Helper;
@@ -25,7 +24,7 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
25
  $url = network_site_url( '/' );
26
  $is_local_url = false;
27
  // Trim it up
28
- $url = esc_url(strtolower( trim( $url ) ) );
29
  if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
30
  $url = 'http://' . $url;
31
  }
@@ -126,11 +125,6 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
126
  plugin_name: 'ee-woocommerce'
127
  }
128
  add_survey(data);
129
- /*var submitSurvey = $.post('<?php echo $this->api_url; ?>', data);
130
- submitSurvey.always(function() {
131
- $(".ee-survey-modal").hide(100);
132
- location.href = $deactivateLink.attr('href');
133
- });*/
134
  });
135
  // Exit key closes survey when open.
136
  $(document).keyup(function(event) {
@@ -272,7 +266,7 @@ if ( ! class_exists( 'TVC_Survey' ) ) {
272
  ),
273
  );
274
  ?>
275
- <div class="ee-survey-modal" id="ee-survey-<?php echo $this->plugin; ?>">
276
  <div class="ee-survey-wrap">
277
  <form class="ee-survey" method="post">
278
  <span class="ee-survey-title"><span class="dashicons dashicons-admin-customizer"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'conversios' ); ?></span>
1
  <?php
2
  if ( ! class_exists( 'TVC_Survey' ) ) {
3
  class TVC_Survey {
 
4
  public $name;
5
  public $plugin;
6
  protected $TVC_Admin_DB_Helper;
24
  $url = network_site_url( '/' );
25
  $is_local_url = false;
26
  // Trim it up
27
+ $url = esc_url_raw(strtolower( trim( $url ) ) );
28
  if ( false === strpos( $url, 'http://' ) && false === strpos( $url, 'https://' ) ) {
29
  $url = 'http://' . $url;
30
  }
125
  plugin_name: 'ee-woocommerce'
126
  }
127
  add_survey(data);
 
 
 
 
 
128
  });
129
  // Exit key closes survey when open.
130
  $(document).keyup(function(event) {
266
  ),
267
  );
268
  ?>
269
+ <div class="ee-survey-modal" id="ee-survey-<?php echo esc_attr($this->plugin); ?>">
270
  <div class="ee-survey-wrap">
271
  <form class="ee-survey" method="post">
272
  <span class="ee-survey-title"><span class="dashicons dashicons-admin-customizer"></span><?php echo ' ' . esc_html__( 'Quick Feedback', 'conversios' ); ?></span>
admin/class-tvc-admin-auto-product-sync-helper.php CHANGED
@@ -172,10 +172,10 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
172
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
173
 
174
  $product = array(
175
- 'offer_id'=>esc_attr($postvalue->w_product_id),
176
  'channel'=>'online',
177
- 'link'=>get_permalink($postvalue->w_product_id),
178
- 'google_product_category'=>esc_attr($postvalue->g_cat_id)
179
  );
180
 
181
  $temp_product=array();
@@ -184,14 +184,14 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
184
  foreach ($fixed_att_select_list as $fixed_key) {
185
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
186
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
187
- $temp_product[$fixed_key]['price']['value'] = $formArray[$fixed_key];
188
- $temp_product[$fixed_key]['price']['currency'] = $tvc_currency;
189
- $temp_product[$fixed_key]['country'] = $formArray['target_country'];
190
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
191
- $temp_product['taxes']['rate'] = $formArray[$fixed_key];
192
- $temp_product['taxes']['country'] = $formArray['target_country'];
193
  }else if( $formArray[$fixed_key] != ""){
194
- $temp_product[$fixed_key] = $formArray[$fixed_key];
195
  }
196
  }
197
  unset($formArray[$fixed_key]);
@@ -211,7 +211,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
211
  unset($product['customAttributes']);
212
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
213
  $formArray_val = $formArray['title'];
214
- $product['title'] = (isset($postObj->$formArray_val))?$postObj->$formArray_val:get_the_title($postvalue->w_product_id);
215
  $tvc_temp_desc_key = $formArray['description'];
216
  $product['description'] = ( $variation_description != "")?$variation_description:$postObj->$tvc_temp_desc_key;
217
  $product['offer_id'] = esc_attr($variation_id);
@@ -222,7 +222,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
222
  $product['productTypes'] = $productTypes;
223
  }
224
  $image_id = $variation->get_image_id();
225
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
226
  if(isset($variation_attributes) && !empty($variation_attributes) ){
227
  foreach($variation_attributes as $va_key => $va_value ){
228
  $va_key = str_replace("_", " ", $va_key);
@@ -251,7 +251,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
251
  unset($product[$key]);
252
  }
253
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
254
- $product[$key]['currency'] = $tvc_currency;
255
  }else{
256
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
257
  }
@@ -264,7 +264,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
264
  unset($product[$key]);
265
  }
266
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
267
- $product[$key]['currency'] = $tvc_currency;
268
  }
269
  }else if($key == 'availability'){
270
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -272,24 +272,24 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
272
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
273
  $stock_status = $postmeta_var->$value;
274
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
275
- $product[$key] = $stock_status;
276
  }else{
277
  $stock_status = $postmeta_var->_stock_status;
278
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
279
- $product[$key] = $stock_status;
280
  }
281
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
282
- $product[$key] = $postmeta_var->$value;
283
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
284
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
285
  if($yith_product_brand != ""){
286
- $product[$key] = $yith_product_brand;
287
  }
288
  }
289
  }
290
  $item = [
291
- 'merchant_id' => esc_attr($merchantId),
292
- 'batch_id' => ++$batchId,
293
  'method' => 'insert',
294
  'product' => $product
295
  ];
@@ -297,9 +297,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
297
  }
298
  }
299
 
300
- }else if( !empty($prd) ){ // for somple product
301
  $image_id = $prd->get_image_id();
302
- $product['image_link'] = wp_get_attachment_image_url($image_id, 'full');
303
  $productTypes = $this->get_product_category($postvalue->w_product_id);
304
  if(!empty($productTypes)){
305
  $product['productTypes'] = $productTypes;
@@ -316,7 +316,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
316
  $product[$key]['value'] = $postObj->_sale_price;
317
  }
318
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
319
- $product[$key]['currency'] = $tvc_currency;
320
  }else{
321
  $skipProducts[$postObj->ID] = $postObj;
322
  }
@@ -327,7 +327,7 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
327
  $product[$key]['value'] = $postObj->_sale_price;
328
  }
329
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
330
- $product[$key]['currency'] = $tvc_currency;
331
  }
332
  }else if($key == 'availability'){
333
  $tvc_find = array("instock","outofstock","onbackorder");
@@ -335,25 +335,24 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
335
  if(isset($postObj->$value) && $postObj->$value != ""){
336
  $stock_status = $postObj->$value;
337
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
338
- $product[$key] = $stock_status;
339
  }else{
340
  $stock_status = $postObj->_stock_status;
341
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
342
- $product[$key] = $stock_status;
343
  }
344
  }else if(isset($postObj->$value) && $postObj->$value != ""){
345
- //echo $key."==".$postObj->$value."<br>";
346
  $product[$key] = $postObj->$value;
347
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
348
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
349
  if($yith_product_brand != ""){
350
- $product[$key] = $yith_product_brand;
351
  }
352
  }
353
  }
354
  $item = [
355
- 'merchant_id' => esc_attr($merchantId),
356
- 'batch_id' => ++$batchId,
357
  'method' => 'insert',
358
  'product' => $product
359
  ];
@@ -368,12 +367,12 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
368
  //$count = 0;
369
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
370
  if( $product_count > 0 ){
371
- $tvc_currency = esc_attr($this->TVC_Admin_Helper->get_woo_currency());
372
- $merchantId = esc_attr($this->TVC_Admin_Helper->get_merchantId());
373
- $customerId = esc_attr($this->TVC_Admin_Helper->get_currentCustomerId());
374
- $accountId = esc_attr($this->TVC_Admin_Helper->get_main_merchantId());
375
- $subscriptionId = esc_attr($this->TVC_Admin_Helper->get_subscriptionId());
376
- $last_sync_product_id =esc_attr(( $last_sync_product_id > 0)?$last_sync_product_id:0);
377
  global $wpdb;
378
  $tablename = $wpdb->prefix .'ee_product_sync_data';
379
  $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".esc_sql($this->batch_size);
@@ -384,9 +383,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
384
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
385
  // call product sync API
386
  $data = [
387
- 'merchant_id' => esc_attr($accountId),
388
- 'account_id' => esc_attr($merchantId),
389
- 'subscription_id' => esc_attr($subscriptionId),
390
  'entries' => $p_map_attribute['items']
391
  ];
392
  $url = $this->apiDomain.'/products/batch';
@@ -488,9 +487,9 @@ if ( ! class_exists( 'TVC_Admin_Auto_Product_sync_Helper' ) ) {
488
 
489
  $data = [
490
  "grant_type" => 'refresh_token',
491
- "client_id" => esc_attr($clientId),
492
- 'client_secret' => esc_attr($clientSecret),
493
- 'refresh_token' => esc_attr($refresh_token),
494
  ];
495
  $args = array(
496
  'headers' =>$header,
172
  $postObj = (object) array_merge((array) get_post($postvalue->w_product_id), (array) $postmeta);
173
 
174
  $product = array(
175
+ 'offer_id'=>sanitize_text_field($postvalue->w_product_id),
176
  'channel'=>'online',
177
+ 'link'=> esc_url_raw(get_permalink($postvalue->w_product_id)),
178
+ 'google_product_category'=>sanitize_text_field($postvalue->g_cat_id)
179
  );
180
 
181
  $temp_product=array();
184
  foreach ($fixed_att_select_list as $fixed_key) {
185
  if(isset($formArray[$fixed_key]) && $formArray[$fixed_key] != "" ){
186
  if($fixed_key == "shipping" && $formArray[$fixed_key] != ""){
187
+ $temp_product[$fixed_key]['price']['value'] = sanitize_text_field($formArray[$fixed_key]);
188
+ $temp_product[$fixed_key]['price']['currency'] = sanitize_text_field($tvc_currency);
189
+ $temp_product[$fixed_key]['country'] = sanitize_text_field($formArray['target_country']);
190
  }else if($fixed_key == "tax" && $formArray[$fixed_key] != ""){
191
+ $temp_product['taxes']['rate'] = sanitize_text_field($formArray[$fixed_key]);
192
+ $temp_product['taxes']['country'] = sanitize_text_field($formArray['target_country']);
193
  }else if( $formArray[$fixed_key] != ""){
194
+ $temp_product[$fixed_key] = sanitize_text_field($formArray[$fixed_key]);
195
  }
196
  }
197
  unset($formArray[$fixed_key]);
211
  unset($product['customAttributes']);
212
  $postmeta_var = (object)$this->TVC_Admin_Helper->tvc_get_post_meta($variation_id);
213
  $formArray_val = $formArray['title'];
214
+ $product['title'] = (isset($postObj->$formArray_val))?sanitize_text_field($postObj->$formArray_val):get_the_title($postvalue->w_product_id);
215
  $tvc_temp_desc_key = $formArray['description'];
216
  $product['description'] = ( $variation_description != "")?$variation_description:$postObj->$tvc_temp_desc_key;
217
  $product['offer_id'] = esc_attr($variation_id);
222
  $product['productTypes'] = $productTypes;
223
  }
224
  $image_id = $variation->get_image_id();
225
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
226
  if(isset($variation_attributes) && !empty($variation_attributes) ){
227
  foreach($variation_attributes as $va_key => $va_value ){
228
  $va_key = str_replace("_", " ", $va_key);
251
  unset($product[$key]);
252
  }
253
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
254
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
255
  }else{
256
  $skipProducts[$postmeta_var->ID] = $postmeta_var;
257
  }
264
  unset($product[$key]);
265
  }
266
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
267
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
268
  }
269
  }else if($key == 'availability'){
270
  $tvc_find = array("instock","outofstock","onbackorder");
272
  if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
273
  $stock_status = $postmeta_var->$value;
274
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
275
+ $product[$key] = sanitize_text_field($stock_status);
276
  }else{
277
  $stock_status = $postmeta_var->_stock_status;
278
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
279
+ $product[$key] = sanitize_text_field($stock_status);
280
  }
281
  }else if(isset($postmeta_var->$value) && $postmeta_var->$value != ""){
282
+ $product[$key] = sanitize_text_field($postmeta_var->$value);
283
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
284
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
285
  if($yith_product_brand != ""){
286
+ $product[$key] = sanitize_text_field($yith_product_brand);
287
  }
288
  }
289
  }
290
  $item = [
291
+ 'merchant_id' => sanitize_text_field($merchantId),
292
+ 'batch_id' => sanitize_text_field(++$batchId),
293
  'method' => 'insert',
294
  'product' => $product
295
  ];
297
  }
298
  }
299
 
300
+ }else if( !empty($prd) ){ // for simple product
301
  $image_id = $prd->get_image_id();
302
+ $product['image_link'] = esc_url_raw(wp_get_attachment_image_url($image_id, 'full'));
303
  $productTypes = $this->get_product_category($postvalue->w_product_id);
304
  if(!empty($productTypes)){
305
  $product['productTypes'] = $productTypes;
316
  $product[$key]['value'] = $postObj->_sale_price;
317
  }
318
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
319
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
320
  }else{
321
  $skipProducts[$postObj->ID] = $postObj;
322
  }
327
  $product[$key]['value'] = $postObj->_sale_price;
328
  }
329
  if(isset($product[$key]['value']) && $product[$key]['value'] >0){
330
+ $product[$key]['currency'] = sanitize_text_field($tvc_currency);
331
  }
332
  }else if($key == 'availability'){
333
  $tvc_find = array("instock","outofstock","onbackorder");
335
  if(isset($postObj->$value) && $postObj->$value != ""){
336
  $stock_status = $postObj->$value;
337
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
338
+ $product[$key] = sanitize_text_field($stock_status);
339
  }else{
340
  $stock_status = $postObj->_stock_status;
341
  $stock_status = str_replace($tvc_find,$tvc_replace,$stock_status);
342
+ $product[$key] = sanitize_text_field($stock_status);
343
  }
344
  }else if(isset($postObj->$value) && $postObj->$value != ""){
 
345
  $product[$key] = $postObj->$value;
346
  }else if(in_array($key, array("brand")) ){ //list of cutom option added
347
  $yith_product_brand = $this->TVC_Admin_Helper->add_additional_option_val_in_map_product_attribute($key, $postvalue->w_product_id);
348
  if($yith_product_brand != ""){
349
+ $product[$key] = sanitize_text_field($yith_product_brand);
350
  }
351
  }
352
  }
353
  $item = [
354
+ 'merchant_id' => sanitize_text_field($merchantId),
355
+ 'batch_id' => sanitize_text_field(++$batchId),
356
  'method' => 'insert',
357
  'product' => $product
358
  ];
367
  //$count = 0;
368
  $pre_last_sync_product_id = sanitize_text_field($last_sync_product_id);
369
  if( $product_count > 0 ){
370
+ $tvc_currency = sanitize_text_field($this->TVC_Admin_Helper->get_woo_currency());
371
+ $merchantId = sanitize_text_field($this->TVC_Admin_Helper->get_merchantId());
372
+ $customerId = sanitize_text_field($this->TVC_Admin_Helper->get_currentCustomerId());
373
+ $accountId = sanitize_text_field($this->TVC_Admin_Helper->get_main_merchantId());
374
+ $subscriptionId = sanitize_text_field($this->TVC_Admin_Helper->get_subscriptionId());
375
+ $last_sync_product_id =sanitize_text_field(( $last_sync_product_id > 0)?$last_sync_product_id:0);
376
  global $wpdb;
377
  $tablename = $wpdb->prefix .'ee_product_sync_data';
378
  $sql = "select * from ".esc_sql($tablename)." where id > ".esc_sql($last_sync_product_id)." LIMIT ".esc_sql($this->batch_size);
383
  if(!empty($p_map_attribute) && isset($p_map_attribute['items']) && !empty($p_map_attribute['items'])){
384
  // call product sync API
385
  $data = [
386
+ 'merchant_id' => sanitize_text_field($accountId),
387
+ 'account_id' => sanitize_text_field($merchantId),
388
+ 'subscription_id' => sanitize_text_field($subscriptionId),
389
  'entries' => $p_map_attribute['items']
390
  ];
391
  $url = $this->apiDomain.'/products/batch';
487
 
488
  $data = [
489
  "grant_type" => 'refresh_token',
490
+ "client_id" => sanitize_text_field($clientId),
491
+ 'client_secret' => sanitize_text_field($clientSecret),
492
+ 'refresh_token' => sanitize_text_field($refresh_token),
493
  ];
494
  $args = array(
495
  'headers' =>$header,
admin/class-tvc-admin-helper.php CHANGED
@@ -23,6 +23,8 @@ Class TVC_Admin_Helper{
23
  $this->includes();
24
  $this->customApiObj = new CustomApi();
25
  $this->TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
 
 
26
  }
27
 
28
  public function includes() {
@@ -31,7 +33,72 @@ Class TVC_Admin_Helper{
31
  }
32
  if (!class_exists('ShoppingApi')) {
33
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/ShoppingApi.php');
34
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  /*
37
  * verstion auto updated
@@ -50,14 +117,14 @@ Class TVC_Admin_Helper{
50
  $tablename = $wpdb->prefix ."ee_product_sync_call";
51
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
52
  new TVC_Admin_Auto_Product_sync_Helper();
53
- update_option("ee_auto_update_id", sanitize_option("ee_auto_update_id", $new_ee_auto_update_id) );
54
  }
55
  if($ee_auto_update_id == "tvc_4.5.1"){
56
  //tvc_4.5.1
57
  $this->update_subscription_details_api_to_db();
58
  }
59
  }else{
60
- update_option("ee_auto_update_id", sanitize_option("ee_auto_update_id", $old_ee_auto_update_id) );
61
  }
62
  }
63
  /*
@@ -98,8 +165,8 @@ Class TVC_Admin_Helper{
98
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
99
  if(property_exists($google_detail,"error") && $google_detail->error == false){
100
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
101
- $google_detail->data->access_token = base64_encode($google_detail->data->access_token);
102
- $google_detail->data->refresh_token = base64_encode($google_detail->data->refresh_token);
103
  $googleDetail = $google_detail->data;
104
  }
105
  }
@@ -118,8 +185,8 @@ Class TVC_Admin_Helper{
118
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
119
  if(property_exists($google_detail,"error") && $google_detail->error == false){
120
  if(property_exists($google_detail,"data") && $google_detail->data != "") {
121
- $google_detail->data->access_token = base64_encode($google_detail->data->access_token);
122
- $google_detail->data->refresh_token = base64_encode($google_detail->data->refresh_token);
123
  $googleDetail = $google_detail->data;
124
  }
125
  }else{
@@ -130,15 +197,6 @@ Class TVC_Admin_Helper{
130
  $syncProductList = [];
131
  $campaigns_list = [];
132
  if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id != ""){
133
- /*$syncProduct_list_res = $this->customApiObj->getSyncProductList(['merchant_id' => $this->get_merchantId()]);
134
- if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
135
- if (isset($syncProduct_list_res->data->statistics)) {
136
- $syncProductStat = $syncProduct_list_res->data->statistics;
137
- }
138
- if (isset($syncProduct_list_res->data->products)) {
139
- $syncProductList = $syncProduct_list_res->data->products;
140
- }
141
- }*/
142
  if($is_import_gmc_products){
143
  $this->import_gmc_products_sync_in_db();
144
  }
@@ -151,7 +209,7 @@ Class TVC_Admin_Helper{
151
  }
152
  $syncProductStat["total"] = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_products_sync_list');
153
  }else{
154
- $syncProductStat = array("total" =>0, "approved" => 0, "disapproved" => 0, "pending" => 0 );
155
  }
156
  if(isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != ""){
157
  $this->update_remarketing_snippets();
@@ -163,7 +221,7 @@ Class TVC_Admin_Helper{
163
  }
164
  }
165
  }
166
-
167
  $this->set_ee_options_data(array("setting" => $googleDetail, "prod_sync_status" => (object) $syncProductStat, "campaigns_list"=>$campaigns_list, "sync_time"=>current_time( 'timestamp' )));
168
  return array("error"=>false, "message"=>esc_html__("Details updated successfully.","conversios"));
169
  }
@@ -176,12 +234,12 @@ Class TVC_Admin_Helper{
176
  $rs = $this->customApiObj->get_remarketing_snippets($customer_id);
177
  $remarketing_snippets=array();
178
  if(property_exists($rs,"error") && $rs->error == false){
179
- if(property_exists($rs,"data") && $rs->data != "") {
180
  $remarketing_snippets["snippets"]=base64_encode($rs->data->snippets);
181
  $remarketing_snippets["id"]=$rs->data->id;
182
  }
183
  }
184
- update_option("ee_remarketing_snippets", serialize(sanitize_option("ee_remarketing_snippets", $remarketing_snippets) ));
185
  }
186
  }
187
  /*
@@ -207,16 +265,14 @@ Class TVC_Admin_Helper{
207
  foreach ($con_array as $key => $con_value) {
208
  $con_val_array = explode(":", $con_value);
209
  if(in_array("send_to", $con_val_array)){
210
- update_option("ee_conversio_send_to", sanitize_option("ee_conversio_send_to", $con_val_array[1]) );
211
  break 2;
212
  }
213
  }
214
  }
215
  }
216
  }
217
- }
218
-
219
-
220
  }
221
  }
222
  /*
@@ -231,13 +287,11 @@ Class TVC_Admin_Helper{
231
  if(!empty($last_row) && isset($last_row['gmc_id']) && $last_row['gmc_id'] != $merchant_id){
232
  global $wpdb;
233
  $tablename = $wpdb->prefix ."ee_products_sync_list";
234
- //$wpdb->query("DROP TABLE IF EXISTS ".$tablename);
235
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
236
  $tablename = $wpdb->prefix ."ee_product_sync_data";
237
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
238
  $tablename = $wpdb->prefix ."ee_product_sync_call";
239
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
240
- //new TVC_Admin_Auto_Product_sync_Helper();
241
  }else if( $next_page_token =="" ){
242
  global $wpdb;
243
  $tablename = $wpdb->prefix ."ee_products_sync_list";
@@ -246,7 +300,7 @@ Class TVC_Admin_Helper{
246
  if( $merchant_id != "" ){
247
  $args = array( 'merchant_id' => $merchant_id );
248
  if($next_page_token != ""){
249
- $args["pageToken"] = $next_page_token;
250
  }
251
  $syncProduct_list_res = $this->customApiObj->getSyncProductList($args);
252
  if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
@@ -261,11 +315,11 @@ Class TVC_Admin_Helper{
261
  }
262
  $t_data = array(
263
  'gmc_id' => esc_sql($merchant_id),
264
- 'name'=> esc_sql($value->name),
265
- 'product_id'=> esc_sql($value->productId),
266
- 'google_status'=> esc_sql($googleStatus),
267
- 'image_link'=> esc_sql($value->imageLink),
268
- 'issues'=>json_encode($value->issues)
269
  );
270
  $where ="product_id = '".esc_sql($value->productId)."'";
271
  $row_count = $this->TVC_Admin_DB_Helper->tvc_check_row('ee_products_sync_list', $where);
@@ -298,13 +352,13 @@ Class TVC_Admin_Helper{
298
  * set API data in DB
299
  */
300
  public function set_ee_options_data($ee_options_data){
301
- update_option("ee_api_data", serialize(sanitize_option("ee_api_data", $ee_options_data) ));
302
  }
303
  /*
304
  * set additional data in DB
305
  */
306
  public function set_ee_additional_data($ee_additional_data){
307
- update_option("ee_additional_data", serialize(sanitize_option("ee_additional_data",$ee_additional_data) ));
308
  }
309
  /*
310
  * get additional data from DB
@@ -319,7 +373,7 @@ Class TVC_Admin_Helper{
319
  }
320
 
321
  public function save_ee_options_settings($settings){
322
- update_option("ee_options", serialize(sanitize_option("ee_options", $settings) ));
323
  }
324
  /*
325
  * get plugin setting data from DB
@@ -400,7 +454,7 @@ Class TVC_Admin_Helper{
400
  return $this->store_data;
401
  }else{
402
  return $this->store_data = array(
403
- "subscription_id"=>$this->get_subscriptionId(),
404
  "user_domain" => $this->get_connect_actual_link(),
405
  "currency_code" => $this->get_woo_currency(),
406
  "timezone_string" => $this->get_time_zone(),
@@ -444,7 +498,7 @@ Class TVC_Admin_Helper{
444
  return $this->woo_currency;
445
  }else{
446
  $this->woo_currency = get_option('woocommerce_currency');
447
- return $this->woo_currency;
448
  }
449
  }
450
 
@@ -494,7 +548,7 @@ Class TVC_Admin_Helper{
494
  public function add_spinner_html(){
495
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
496
  echo '<div class="feed-spinner" id="feed-spinner" style="display:none;">
497
- <img id="img-spinner" src="' . esc_url($spinner_gif) . '" alt="Loading" />
498
  </div>';
499
  }
500
 
@@ -572,10 +626,8 @@ Class TVC_Admin_Helper{
572
  }
573
 
574
  public function add_additional_option_val_in_map_product_attribute($key, $product_id){
575
- //echo $key."__".$product_id;
576
  if($key != "" && $product_id != ""){
577
  if($key == "brand"){
578
- //echo $key."__".$product_id;
579
  $is_plugin='yith-woocommerce-brands-add-on/init.php';
580
  $is_plugin_premium='yith-woocommerce-brands-add-on-premium/init.php';
581
  if(is_plugin_active($is_plugin) || is_plugin_active($is_plugin_premium)){
@@ -607,158 +659,6 @@ Class TVC_Admin_Helper{
607
  }
608
 
609
  /* end from input*/
610
- public function check_setting_status(){
611
- if(!empty($this->setting_status)){
612
- return $this->setting_status;
613
- }else{
614
- $google_detail = $this->get_ee_options_data();
615
- $setting_status = array();
616
- if(isset($google_detail['setting'])){
617
- $googleDetail = $google_detail['setting'];
618
- //for google analytic
619
- if(isset($googleDetail->tracking_option) && isset($googleDetail->measurement_id) && isset($googleDetail->property_id) && $googleDetail->tracking_option == "BOTH" ){
620
- if($googleDetail->property_id != "" && $googleDetail->measurement_id != ""){
621
- $setting_status['google_analytic']= true;
622
- $setting_status['google_analytic_msg']= "";
623
- }else if($googleDetail->property_id == "" ){
624
- $setting_status['google_analytic']= false;
625
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
626
- }else if($googleDetail->measurement_id == "" ){
627
- $setting_status['google_analytic']= false;
628
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
629
- }
630
- }else if(isset($googleDetail->tracking_option) && isset($googleDetail->measurement_id) && $googleDetail->tracking_option == "GA4"){
631
- if( $googleDetail->measurement_id != ""){
632
- $setting_status['google_analytic']= true;
633
- $setting_status['google_analytic_msg']= "";
634
- }else{
635
- $setting_status['google_analytic']= false;
636
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
637
- }
638
- }else if(isset($googleDetail->tracking_option) && isset($googleDetail->property_id) && $googleDetail->tracking_option == "UA" ){
639
- if($googleDetail->property_id != ""){
640
- $setting_status['google_analytic']= true;
641
- $setting_status['google_analytic_msg']= "";
642
- }else{
643
- $setting_status['google_analytic']= false;
644
- $setting_status['google_analytic_msg']= "There is a configuration issue in your Google Analytics account set up <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
645
- }
646
- }else{
647
- $setting_status['google_analytic']= false;
648
- $setting_status['google_analytic_msg']= "";
649
- }
650
- // for google shopping
651
- if(property_exists($googleDetail,"google_merchant_center_id") && property_exists($googleDetail,"google_ads_id") ){
652
- //main tab
653
- if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != ""){
654
- $setting_status['google_shopping']= true;
655
- $setting_status['google_shopping_msg']= "";
656
- }else if($googleDetail->google_merchant_center_id == ""){
657
- $setting_status['google_shopping']= false;
658
- $setting_status['google_shopping_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
659
- }else if($googleDetail->google_ads_id == ""){
660
- $setting_status['google_shopping']= false;
661
- $setting_status['google_shopping_msg']= "Link your Google Ads with Merchant center to start running shopping campaigns <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
662
- }
663
- }else{
664
- $setting_status['google_shopping']= false;
665
- $setting_status['google_shopping_msg']= "";
666
- }
667
-
668
- //google_ads_id
669
- if(property_exists($googleDetail,"google_ads_id") && property_exists($googleDetail,"google_merchant_center_id") ){
670
- if( $googleDetail->google_ads_id != "" && $googleDetail->google_merchant_center_id != ""){
671
- $setting_status['google_ads']= true;
672
- $setting_status['google_ads_msg']= "";
673
- }else if($googleDetail->google_merchant_center_id == ""){
674
- $setting_status['google_ads']= false;
675
- $setting_status['google_ads_msg']= "Link your Google Ads with Merchant center to start running shopping campaigns <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
676
- }else if($googleDetail->google_ads_id == ""){
677
- $setting_status['google_ads']= false;
678
- $setting_status['google_ads_msg']= "Configure Google Ads account to reach to millions of interested shoppers <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
679
- }
680
- }else{
681
- $setting_status['google_ads']= false;
682
- $setting_status['google_ads_msg']= "";
683
- }
684
- }
685
- $this->setting_status = $setting_status;
686
- return $setting_status;
687
- }
688
- }
689
- public function check_setting_status_sub_tabs(){
690
- $google_detail = $this->get_ee_options_data();
691
- $setting_status = array();
692
- if(isset($google_detail['setting'])){
693
- $googleDetail = $google_detail['setting'];
694
- //sub tab shopping config
695
- if(property_exists($googleDetail,"google_merchant_center_id") && property_exists($googleDetail,"is_site_verified") && property_exists($googleDetail,"is_domain_claim") && property_exists($googleDetail,"google_ads_id")){
696
- if( $googleDetail->google_merchant_center_id != "" && $googleDetail->google_ads_id != "" && $googleDetail->is_site_verified == 1 && $googleDetail->is_domain_claim == 1 ){
697
- $setting_status['google_shopping_conf']= true;
698
- $setting_status['google_shopping_conf_msg']= esc_html__("Google Shopping Configuration Success.","conversios");
699
- }else if($googleDetail->google_merchant_center_id == "" || $googleDetail->google_ads_id == "" ){
700
- $setting_status['google_shopping_conf']= false;
701
- $setting_status['google_shopping_conf_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
702
- }else if($googleDetail->is_site_verified ==0 && $googleDetail->is_domain_claim ==0 ){
703
- $setting_status['google_shopping_conf']= false;
704
- $setting_status['google_shopping_conf_msg']= esc_html__("Site verification and domain claim for your merchant center account failed.","conversios");
705
- }else if($googleDetail->is_site_verified ==0 ){
706
- $setting_status['google_shopping_conf']= false;
707
- $setting_status['google_shopping_conf_msg']= esc_html__("Site verification and domain claim for your merchant center account failed.","conversios");
708
- }
709
- }else{
710
- $setting_status['google_shopping_conf']= false;
711
- $missing="";
712
- }
713
- //sub tab product sync
714
- $syncProductList = [];
715
- $syncProductStat = [];
716
- if(property_exists($googleDetail,"google_merchant_center_id") && $googleDetail->google_merchant_center_id != ''){
717
- if(isset($google_detail['prod_sync_status']) && $google_detail['prod_sync_status']){
718
- $syncProductStat = $google_detail['prod_sync_status'];
719
- $sync_product_total = (!empty($syncProductStat)) ? $syncProductStat->total : "0";
720
- $sync_product_approved = (!empty($syncProductStat)) ? $syncProductStat->approved : "0";
721
- $sync_product_disapproved = (!empty($syncProductStat)) ? $syncProductStat->disapproved : "0";
722
- $sync_product_pending = (!empty($syncProductStat)) ? $syncProductStat->pending : "0";
723
-
724
- if($sync_product_total > 1 && $sync_product_approved > 1 && $sync_product_disapproved < 1){
725
- $setting_status['google_shopping_p_sync']= true;
726
- $setting_status['google_shopping_p_sync_msg']= esc_html__("Google Shopping product sync is a success.","conversios");
727
- }else if($sync_product_total < 1){
728
- $setting_status['google_shopping_p_sync']= false;
729
- $setting_status['google_shopping_p_sync_msg']= esc_html__("Sync your product data into Merchant center and get eligible for free listing across Google.","conversios");
730
- }else if($sync_product_disapproved > 0){
731
- $setting_status['google_shopping_p_sync']= false;
732
- $setting_status['google_shopping_p_sync_msg']= esc_html__("There seems to be some problem with your product data. Rectify the issues by selecting right attributes.","conversios");
733
- }
734
- }
735
- }else{
736
- $setting_status['google_shopping_p_sync']= false;
737
- $setting_status['google_shopping_p_sync_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
738
- }
739
-
740
- //sub tab product Campaigns
741
- if(property_exists($googleDetail,"google_merchant_center_id") && $googleDetail->google_merchant_center_id != ''){
742
- if(isset($google_detail['campaigns_list']) && $google_detail['campaigns_list']){
743
- $campaigns_list = $google_detail['campaigns_list'];
744
- $totalCampaigns = count($campaigns_list);
745
- if($totalCampaigns < 1){
746
- $setting_status['google_shopping_p_campaigns']= false;
747
- $setting_status['google_shopping_p_campaigns_msg']= esc_html__("Reach out to customers based on their past site behavior by running start shopping campaign.","conversios");
748
- }else{
749
- $setting_status['google_shopping_p_campaigns']= true;
750
- }
751
- }else{
752
- $setting_status['google_shopping_p_campaigns']= false;
753
- $setting_status['google_shopping_p_campaigns_msg']= esc_html__("Reach out to customers based on their past site behavior by running start shopping campaign.","conversios");
754
- }
755
- }else{
756
- $setting_status['google_shopping_p_campaigns']= false;
757
- $setting_status['google_shopping_p_campaigns_msg']= "Connect your merchant center account and make your products available to shoppers across Google <a href='".esc_url($this->get_onboarding_page_url())."'>click here</a>.";
758
- }
759
- }
760
- return $setting_status;
761
- }
762
 
763
  public function is_current_tab_in($tabs){
764
  if(isset($_GET['tab']) && is_array($tabs) && in_array(sanitize_text_field($_GET['tab']), $tabs)){
@@ -823,11 +723,11 @@ Class TVC_Admin_Helper{
823
  <div class="errormsgtopbx claimalert">
824
  <div class="errmscntbx">
825
  <div class="errmsglft">
826
- <span class="errmsgicon"><img src="<?php echo esc_url(ENHANCAD_PLUGIN_URL.'/admin/images/error-white-icon.png'); ?>" alt="error" /></span>
827
  </div>
828
  <div class="erralertrigt">
829
- <h6><?php echo $title; ?></h6>
830
- <p><?php echo $message; ?> <a href="javascript:void(0)" id="call_both_verification" onclick="call_tvc_site_verified_and_domain_claim('<?php echo $call_js_function_args; ?>');">Click here</a> <?php esc_html_e("to verify and claim the domain.","conversios"); ?></p>
831
  </div>
832
  </div>
833
  </div>
@@ -898,10 +798,10 @@ Class TVC_Admin_Helper{
898
  }else if(property_exists($googleDetail,"is_domain_claim") && $googleDetail->is_domain_claim == '0'){
899
  //'website_url' => $googleDetail->site_url,
900
  $postData = [
901
- 'merchant_id' => $googleDetail->merchant_id,
902
- 'website_url' => get_site_url(),
903
- 'subscription_id' => $googleDetail->id,
904
- 'account_id' => $googleDetail->google_merchant_center_id
905
  ];
906
  $claimWebsite = $this->customApiObj->claimWebsite($postData);
907
  if(isset($claimWebsite->error) && !empty($claimWebsite->errors)){
@@ -925,10 +825,10 @@ Class TVC_Admin_Helper{
925
  if(property_exists($googleDetail,"is_site_verified") && $googleDetail->is_site_verified == '0'){
926
  //'website_url' => $googleDetail->site_url,
927
  $postData = [
928
- 'merchant_id' => $googleDetail->merchant_id,
929
  'website_url' => get_site_url(),
930
- 'subscription_id' => $googleDetail->id,
931
- 'account_id' => $googleDetail->google_merchant_center_id
932
  ];
933
  $postData['method']="file";
934
  $siteVerificationToken = $this->customApiObj->siteVerificationToken($postData);
@@ -954,19 +854,19 @@ Class TVC_Admin_Helper{
954
  if(isset($siteVerificationToken_tag->data->token) && $siteVerificationToken_tag->data->token){
955
  $ee_additional_data = $this->get_ee_additional_data();
956
  $ee_additional_data['add_site_varification_tag']=1;
957
- $ee_additional_data['site_varification_tag_val']=base64_encode($siteVerificationToken_tag->data->token);
958
 
959
  $this->set_ee_additional_data($ee_additional_data);
960
  sleep(1);
961
  $siteVerification_tag = $this->customApiObj->siteVerification($postData);
962
  if(isset($siteVerification_tag->error) && !empty($siteVerification_tag->errors)){
963
- return array('error'=>true, 'msg'=>$siteVerification_tag->errors[0]);
964
  }else{
965
  $this->update_subscription_details_api_to_db();
966
  return array('error'=>false, 'msg'=>esc_html__("Site verification successfully.","conversios"));
967
  }
968
  }else{
969
- return array('error'=>true, 'msg'=>$siteVerificationToken_tag->errors[0]);
970
  }
971
  // one more try
972
  }else{
@@ -998,7 +898,7 @@ Class TVC_Admin_Helper{
998
  }
999
 
1000
  public function get_auto_sync_batch_size(){
1001
- return "200";
1002
  }
1003
 
1004
  public function get_last_auto_sync_product_info(){
@@ -1019,7 +919,7 @@ Class TVC_Admin_Helper{
1019
 
1020
  public function getTableColumns($table) {
1021
  global $wpdb;
1022
- $tablename = $wpdb->prefix .$table;
1023
  return $wpdb->get_results("SELECT column_name as field FROM information_schema.columns WHERE table_name = '$table'");
1024
  }
1025
 
@@ -1032,12 +932,12 @@ Class TVC_Admin_Helper{
1032
  }
1033
  /* message notification */
1034
  public function set_ee_msg_nofification_list($ee_msg_list){
1035
- update_option("ee_msg_nofifications", serialize(sanitize_option("ee_msg_nofifications", $ee_msg_list) ));
1036
  }
1037
  public function get_ee_msg_nofification_list(){
1038
  return unserialize(get_option('ee_msg_nofifications'));
1039
  }
1040
- public function add_ee_msg_nofification($key, $html, $title = null, $link = null, $link_title = null, $overwrite= false, $link_type = "internal"){
1041
  $ee_msg_list = $this->get_ee_msg_nofification_list();
1042
  if((!isset($ee_msg_list[$key]) && $html !="") ||($overwrite == true && isset($ee_msg_list[$key]) && $html !="")){
1043
  $msg = array();
@@ -1061,9 +961,7 @@ Class TVC_Admin_Helper{
1061
 
1062
  public function add_tvc_fixed_nofification(){
1063
  $nofifications = [];
1064
- /*
1065
- * add fixed notification
1066
- */
1067
  $nofifications["tvc_f_notif_1"] = array(
1068
  "tittle"=>esc_html__("Congratulations..!! You are one step closer.","conversios"),
1069
  "html"=>esc_html__("Thanks for installing the new avatar of Enhanced Ecommerce for WooCommerce plugin. Explore the full potential of Google Analytics, Google Ads and Google shopping by setting up all your Google accounts and take data driven decisions to scale your eCommerce business faster.", "conversios")
@@ -1075,9 +973,7 @@ Class TVC_Admin_Helper{
1075
  "link_title"=>esc_html__("Share Feedback", "conversios"),
1076
  "link_type"=>"external"
1077
  );
1078
- /*
1079
- * add payment notification
1080
- */
1081
  $google_detail = $this->get_ee_options_data();
1082
  if(isset($google_detail['setting'])){
1083
  $googleDetail = $google_detail['setting'];
@@ -1096,12 +992,7 @@ Class TVC_Admin_Helper{
1096
  );
1097
  }
1098
  $diffrent_day = floor(( $current - $subscription_expiry_time)/(60*60*24)-1);
1099
- /*if($diffrent_day == 5 ){
1100
- $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
1101
- "tittle"=>"Your plan expired.",
1102
- "html"=>"Your subscription plan has been expiring in some time."
1103
- );
1104
- }*/
1105
  if($diffrent_day == 6 ){
1106
  $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
1107
  "tittle"=>"Plan Expired..!!",
@@ -1111,9 +1002,7 @@ Class TVC_Admin_Helper{
1111
  }
1112
 
1113
  }
1114
- /*
1115
- * add notifications
1116
- */
1117
  if(!empty($nofifications)){
1118
  foreach ($nofifications as $key => $value){
1119
  if(isset($value["html"]) && $value["html"] != ""){
@@ -1124,7 +1013,7 @@ Class TVC_Admin_Helper{
1124
  }
1125
  }
1126
  }
1127
- }
1128
 
1129
  public function active_licence($licence_key, $subscription_id){
1130
  if($licence_key != ""){
23
  $this->includes();
24
  $this->customApiObj = new CustomApi();
25
  $this->TVC_Admin_DB_Helper = new TVC_Admin_DB_Helper();
26
+ add_action('init',array($this, 'init'));
27
+
28
  }
29
 
30
  public function includes() {
33
  }
34
  if (!class_exists('ShoppingApi')) {
35
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/ShoppingApi.php');
36
+ }
37
+ }
38
+
39
+ public function init(){
40
+ add_filter('sanitize_option_ee_auto_update_id', array($this, 'sanitize_option_ee_general'), 10, 2);
41
+ add_filter('sanitize_option_ee_remarketing_snippets', array($this, 'sanitize_option_ee_general'), 10, 2);
42
+ add_filter('sanitize_option_ee_conversio_send_to', array($this, 'sanitize_option_ee_general'), 10, 2);
43
+ add_filter('sanitize_option_ee_api_data', array($this, 'sanitize_option_ee_general'), 10, 2);
44
+ add_filter('sanitize_option_ee_additional_data', array($this, 'sanitize_option_ee_general'), 10, 2);
45
+ add_filter('sanitize_option_ee_options', array($this, 'sanitize_option_ee_general'), 10, 2);
46
+ add_filter('sanitize_option_ee_msg_nofifications', array($this, 'sanitize_option_ee_general'), 10, 2);
47
+ add_filter('sanitize_option_google_ads_conversion_tracking', array($this, 'sanitize_option_ee_general'), 10, 2);
48
+ add_filter('sanitize_option_ads_tracking_id', array($this, 'sanitize_option_ee_general'), 10, 2);
49
+ add_filter('sanitize_option_ads_ert', array($this, 'sanitize_option_ee_general'), 10, 2);
50
+ add_filter('sanitize_option_ads_edrt', array($this, 'sanitize_option_ee_general'), 10, 2);
51
+ add_filter('sanitize_option_ee_customer_gmail', array($this, 'sanitize_option_ee_email'), 10, 2);
52
+ add_filter('sanitize_option_ee_prod_mapped_cats', array($this, 'sanitize_option_ee_general'), 10, 2);
53
+ add_filter('sanitize_option_ee_prod_mapped_attrs', array($this, 'sanitize_option_ee_general'), 10, 2);
54
+
55
+ add_filter( 'sanitize_post_meta__tracked', array($this, 'sanitize_meta_ee_number'));
56
+ }
57
+
58
+ public function sanitize_meta_ee_number($value){
59
+ $value = (int) $value;
60
+ if ( empty( $value ) ) {
61
+ $value = 1;
62
+ }
63
+ if ( $value < -1 ) {
64
+ $value = abs( $value );
65
+ }
66
+ return $value;
67
+ }
68
+
69
+ public function sanitize_option_ee_email($value, $option){
70
+ global $wpdb;
71
+ $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
72
+ if ( is_wp_error( $value ) ) {
73
+ $error = $value->get_error_message();
74
+ } else {
75
+ $value = sanitize_email( $value );
76
+ if ( ! is_email( $value ) ) {
77
+ $error = esc_html__( 'The email address entered did not appear to be a valid email address. Please enter a valid email address.' );
78
+ }
79
+ }
80
+ if ( ! empty( $error ) ) {
81
+ $value = get_option( $option );
82
+ if ( function_exists( 'add_settings_error' ) ) {
83
+ add_settings_error( $option, "invalid_{$option}", $error );
84
+ }
85
+ }
86
+ return $value;
87
+ }
88
+
89
+ public function sanitize_option_ee_general($value, $option){
90
+ global $wpdb;
91
+ $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
92
+ if ( is_wp_error( $value ) ) {
93
+ $error = $value->get_error_message();
94
+ }
95
+ if ( ! empty( $error ) ) {
96
+ $value = get_option( $option );
97
+ if ( function_exists( 'add_settings_error' ) ) {
98
+ add_settings_error( $option, "invalid_{$option}", $error );
99
+ }
100
+ }
101
+ return $value;
102
  }
103
  /*
104
  * verstion auto updated
117
  $tablename = $wpdb->prefix ."ee_product_sync_call";
118
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
119
  new TVC_Admin_Auto_Product_sync_Helper();
120
+ update_option("ee_auto_update_id", $new_ee_auto_update_id );
121
  }
122
  if($ee_auto_update_id == "tvc_4.5.1"){
123
  //tvc_4.5.1
124
  $this->update_subscription_details_api_to_db();
125
  }
126
  }else{
127
+ update_option("ee_auto_update_id", $old_ee_auto_update_id );
128
  }
129
  }
130
  /*
165
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
166
  if(property_exists($google_detail,"error") && $google_detail->error == false){
167
  if(property_exists($google_detail,"data") && $google_detail->data != ""){
168
+ $google_detail->data->access_token = base64_encode(sanitize_text_field($google_detail->data->access_token));
169
+ $google_detail->data->refresh_token = base64_encode(sanitize_text_field($google_detail->data->refresh_token));
170
  $googleDetail = $google_detail->data;
171
  }
172
  }
185
  $google_detail = $this->customApiObj->getGoogleAnalyticDetail();
186
  if(property_exists($google_detail,"error") && $google_detail->error == false){
187
  if(property_exists($google_detail,"data") && $google_detail->data != "") {
188
+ $google_detail->data->access_token = base64_encode(sanitize_text_field($google_detail->data->access_token));
189
+ $google_detail->data->refresh_token = base64_encode(sanitize_text_field($google_detail->data->refresh_token));
190
  $googleDetail = $google_detail->data;
191
  }
192
  }else{
197
  $syncProductList = [];
198
  $campaigns_list = [];
199
  if(isset($googleDetail->google_merchant_center_id) && $googleDetail->google_merchant_center_id != ""){
 
 
 
 
 
 
 
 
 
200
  if($is_import_gmc_products){
201
  $this->import_gmc_products_sync_in_db();
202
  }
209
  }
210
  $syncProductStat["total"] = $this->TVC_Admin_DB_Helper->tvc_row_count('ee_products_sync_list');
211
  }else{
212
+ $syncProductStat = array("total" =>0, "approved" => 0, "disapproved" => 0, "pending" => 0 );
213
  }
214
  if(isset($googleDetail->google_ads_id) && $googleDetail->google_ads_id != ""){
215
  $this->update_remarketing_snippets();
221
  }
222
  }
223
  }
224
+
225
  $this->set_ee_options_data(array("setting" => $googleDetail, "prod_sync_status" => (object) $syncProductStat, "campaigns_list"=>$campaigns_list, "sync_time"=>current_time( 'timestamp' )));
226
  return array("error"=>false, "message"=>esc_html__("Details updated successfully.","conversios"));
227
  }
234
  $rs = $this->customApiObj->get_remarketing_snippets($customer_id);
235
  $remarketing_snippets=array();
236
  if(property_exists($rs,"error") && $rs->error == false){
237
+ if(property_exists($rs,"data") && $rs->data != "" && isset($remarketing_snippets["snippets"])) {
238
  $remarketing_snippets["snippets"]=base64_encode($rs->data->snippets);
239
  $remarketing_snippets["id"]=$rs->data->id;
240
  }
241
  }
242
+ update_option("ee_remarketing_snippets", serialize( $remarketing_snippets ));
243
  }
244
  }
245
  /*
265
  foreach ($con_array as $key => $con_value) {
266
  $con_val_array = explode(":", $con_value);
267
  if(in_array("send_to", $con_val_array)){
268
+ update_option("ee_conversio_send_to", $con_val_array[1] );
269
  break 2;
270
  }
271
  }
272
  }
273
  }
274
  }
275
+ }
 
 
276
  }
277
  }
278
  /*
287
  if(!empty($last_row) && isset($last_row['gmc_id']) && $last_row['gmc_id'] != $merchant_id){
288
  global $wpdb;
289
  $tablename = $wpdb->prefix ."ee_products_sync_list";
 
290
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
291
  $tablename = $wpdb->prefix ."ee_product_sync_data";
292
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
293
  $tablename = $wpdb->prefix ."ee_product_sync_call";
294
  $this->TVC_Admin_DB_Helper->tvc_safe_truncate_table($tablename);
 
295
  }else if( $next_page_token =="" ){
296
  global $wpdb;
297
  $tablename = $wpdb->prefix ."ee_products_sync_list";
300
  if( $merchant_id != "" ){
301
  $args = array( 'merchant_id' => $merchant_id );
302
  if($next_page_token != ""){
303
+ $args["pageToken"] = sanitize_text_field($next_page_token);
304
  }
305
  $syncProduct_list_res = $this->customApiObj->getSyncProductList($args);
306
  if(isset($syncProduct_list_res->data) && isset($syncProduct_list_res->status) && $syncProduct_list_res->status == 200){
315
  }
316
  $t_data = array(
317
  'gmc_id' => esc_sql($merchant_id),
318
+ 'name' => esc_sql($value->name),
319
+ 'product_id' => esc_sql($value->productId),
320
+ 'google_status' => esc_sql($googleStatus),
321
+ 'image_link' => esc_sql($value->imageLink),
322
+ 'issues' => json_encode($value->issues)
323
  );
324
  $where ="product_id = '".esc_sql($value->productId)."'";
325
  $row_count = $this->TVC_Admin_DB_Helper->tvc_check_row('ee_products_sync_list', $where);
352
  * set API data in DB
353
  */
354
  public function set_ee_options_data($ee_options_data){
355
+ update_option("ee_api_data", serialize( $ee_options_data ));
356
  }
357
  /*
358
  * set additional data in DB
359
  */
360
  public function set_ee_additional_data($ee_additional_data){
361
+ update_option("ee_additional_data", serialize($ee_additional_data));
362
  }
363
  /*
364
  * get additional data from DB
373
  }
374
 
375
  public function save_ee_options_settings($settings){
376
+ update_option("ee_options", serialize( $settings) );
377
  }
378
  /*
379
  * get plugin setting data from DB
454
  return $this->store_data;
455
  }else{
456
  return $this->store_data = array(
457
+ "subscription_id"=> $this->get_subscriptionId(),
458
  "user_domain" => $this->get_connect_actual_link(),
459
  "currency_code" => $this->get_woo_currency(),
460
  "timezone_string" => $this->get_time_zone(),
498
  return $this->woo_currency;
499
  }else{
500
  $this->woo_currency = get_option('woocommerce_currency');
501
+ return $this->woo_currency;
502
  }
503
  }
504
 
548
  public function add_spinner_html(){
549
  $spinner_gif = ENHANCAD_PLUGIN_URL . '/admin/images/ajax-loader.gif';
550
  echo '<div class="feed-spinner" id="feed-spinner" style="display:none;">
551
+ <img id="img-spinner" src="' . esc_url_raw($spinner_gif) . '" alt="Loading" />
552
  </div>';
553
  }
554
 
626
  }
627
 
628
  public function add_additional_option_val_in_map_product_attribute($key, $product_id){
 
629
  if($key != "" && $product_id != ""){
630
  if($key == "brand"){
 
631
  $is_plugin='yith-woocommerce-brands-add-on/init.php';
632
  $is_plugin_premium='yith-woocommerce-brands-add-on-premium/init.php';
633
  if(is_plugin_active($is_plugin) || is_plugin_active($is_plugin_premium)){
659
  }
660
 
661
  /* end from input*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
662
 
663
  public function is_current_tab_in($tabs){
664
  if(isset($_GET['tab']) && is_array($tabs) && in_array(sanitize_text_field($_GET['tab']), $tabs)){
723
  <div class="errormsgtopbx claimalert">
724
  <div class="errmscntbx">
725
  <div class="errmsglft">
726
+ <span class="errmsgicon"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/error-white-icon.png'); ?>" alt="error" /></span>
727
  </div>
728
  <div class="erralertrigt">
729
+ <h6><?php echo esc_attr($title); ?></h6>
730
+ <p><?php echo esc_attr($message); ?> <a href="javascript:void(0)" id="call_both_verification" onclick="call_tvc_site_verified_and_domain_claim('<?php echo esc_attr($call_js_function_args); ?>');"><?php esc_html_e("Click here","conversios"); ?></a> <?php esc_html_e("to verify and claim the domain.","conversios"); ?></p>
731
  </div>
732
  </div>
733
  </div>
798
  }else if(property_exists($googleDetail,"is_domain_claim") && $googleDetail->is_domain_claim == '0'){
799
  //'website_url' => $googleDetail->site_url,
800
  $postData = [
801
+ 'merchant_id' => sanitize_text_field($googleDetail->merchant_id),
802
+ 'website_url' => get_site_url(),
803
+ 'subscription_id' => sanitize_text_field($googleDetail->id),
804
+ 'account_id' => sanitize_text_field($googleDetail->google_merchant_center_id)
805
  ];
806
  $claimWebsite = $this->customApiObj->claimWebsite($postData);
807
  if(isset($claimWebsite->error) && !empty($claimWebsite->errors)){
825
  if(property_exists($googleDetail,"is_site_verified") && $googleDetail->is_site_verified == '0'){
826
  //'website_url' => $googleDetail->site_url,
827
  $postData = [
828
+ 'merchant_id' => sanitize_text_field($googleDetail->merchant_id),
829
  'website_url' => get_site_url(),
830
+ 'subscription_id' => sanitize_text_field($googleDetail->id),
831
+ 'account_id' => sanitize_text_field($googleDetail->google_merchant_center_id)
832
  ];
833
  $postData['method']="file";
834
  $siteVerificationToken = $this->customApiObj->siteVerificationToken($postData);
854
  if(isset($siteVerificationToken_tag->data->token) && $siteVerificationToken_tag->data->token){
855
  $ee_additional_data = $this->get_ee_additional_data();
856
  $ee_additional_data['add_site_varification_tag']=1;
857
+ $ee_additional_data['site_varification_tag_val']=base64_encode(sanitize_text_field($siteVerificationToken_tag->data->token));
858
 
859
  $this->set_ee_additional_data($ee_additional_data);
860
  sleep(1);
861
  $siteVerification_tag = $this->customApiObj->siteVerification($postData);
862
  if(isset($siteVerification_tag->error) && !empty($siteVerification_tag->errors)){
863
+ return array('error'=>true, 'msg'=>esc_html($siteVerification_tag->errors[0]));
864
  }else{
865
  $this->update_subscription_details_api_to_db();
866
  return array('error'=>false, 'msg'=>esc_html__("Site verification successfully.","conversios"));
867
  }
868
  }else{
869
+ return array('error'=>true, 'msg'=> esc_html($siteVerificationToken_tag->errors[0]));
870
  }
871
  // one more try
872
  }else{
898
  }
899
 
900
  public function get_auto_sync_batch_size(){
901
+ return "100";
902
  }
903
 
904
  public function get_last_auto_sync_product_info(){
919
 
920
  public function getTableColumns($table) {
921
  global $wpdb;
922
+ $tablename = $wpdb->prefix .esc_sql($table);
923
  return $wpdb->get_results("SELECT column_name as field FROM information_schema.columns WHERE table_name = '$table'");
924
  }
925
 
932
  }
933
  /* message notification */
934
  public function set_ee_msg_nofification_list($ee_msg_list){
935
+ update_option("ee_msg_nofifications", serialize( $ee_msg_list ));
936
  }
937
  public function get_ee_msg_nofification_list(){
938
  return unserialize(get_option('ee_msg_nofifications'));
939
  }
940
+ /*public function add_ee_msg_nofification($key, $html, $title = null, $link = null, $link_title = null, $overwrite= false, $link_type = "internal"){
941
  $ee_msg_list = $this->get_ee_msg_nofification_list();
942
  if((!isset($ee_msg_list[$key]) && $html !="") ||($overwrite == true && isset($ee_msg_list[$key]) && $html !="")){
943
  $msg = array();
961
 
962
  public function add_tvc_fixed_nofification(){
963
  $nofifications = [];
964
+
 
 
965
  $nofifications["tvc_f_notif_1"] = array(
966
  "tittle"=>esc_html__("Congratulations..!! You are one step closer.","conversios"),
967
  "html"=>esc_html__("Thanks for installing the new avatar of Enhanced Ecommerce for WooCommerce plugin. Explore the full potential of Google Analytics, Google Ads and Google shopping by setting up all your Google accounts and take data driven decisions to scale your eCommerce business faster.", "conversios")
973
  "link_title"=>esc_html__("Share Feedback", "conversios"),
974
  "link_type"=>"external"
975
  );
976
+
 
 
977
  $google_detail = $this->get_ee_options_data();
978
  if(isset($google_detail['setting'])){
979
  $googleDetail = $google_detail['setting'];
992
  );
993
  }
994
  $diffrent_day = floor(( $current - $subscription_expiry_time)/(60*60*24)-1);
995
+
 
 
 
 
 
996
  if($diffrent_day == 6 ){
997
  $nofifications["tvc_expired_plan_not_".date("YYYY_m_d",$current)] = array(
998
  "tittle"=>"Plan Expired..!!",
1002
  }
1003
 
1004
  }
1005
+
 
 
1006
  if(!empty($nofifications)){
1007
  foreach ($nofifications as $key => $value){
1008
  if(isset($value["html"]) && $value["html"] != ""){
1013
  }
1014
  }
1015
  }
1016
+ } */
1017
 
1018
  public function active_licence($licence_key, $subscription_id){
1019
  if($licence_key != ""){
admin/helper/class-onboarding-helper.php CHANGED
@@ -62,7 +62,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
62
  public function get_analytics_web_properties(){
63
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
64
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
65
- $tvc_data = (object)$_POST['tvc_data'];
 
66
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
67
  echo json_encode($api_obj->getAnalyticsWebProperties($_POST));
68
  wp_die();
@@ -78,7 +79,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
78
  public function save_analytics_data(){
79
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
80
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
81
- $tvc_data = (object)$_POST['tvc_data'];
 
82
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
83
  /*sendingblue*/
84
  $data = array();
@@ -103,7 +105,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
103
  public function list_googl_ads_account(){
104
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
105
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
106
- $tvc_data = (object)$_POST['tvc_data'];
 
107
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
108
  echo json_encode($api_obj->getGoogleAdsAccountList($_POST));
109
  wp_die();
@@ -118,7 +121,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
118
  public function create_google_ads_account(){
119
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
120
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
121
- $tvc_data = (object)$_POST['tvc_data'];
 
122
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
123
  echo json_encode($api_obj->createGoogleAdsAccount($_POST));
124
  wp_die();
@@ -134,7 +138,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
134
  public function save_google_ads_data(){
135
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
136
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
137
- $tvc_data = (object)$_POST['tvc_data'];
 
138
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
139
  /*sendingblue*/
140
  $data = array();
@@ -159,7 +164,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
159
  public function link_analytic_to_ads_account(){
160
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
161
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
162
- $tvc_data = (object)$_POST['tvc_data'];
 
163
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
164
  echo json_encode($api_obj->linkAnalyticToAdsAccount($_POST));
165
  wp_die();
@@ -175,7 +181,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
175
  public function list_google_merchant_account(){
176
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
177
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
178
- $tvc_data = (object)$_POST['tvc_data'];
 
179
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
180
  echo json_encode($api_obj->listMerchantCenterAccount($_POST));
181
  wp_die();
@@ -190,7 +197,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
190
  public function create_google_merchant_center_account(){
191
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
192
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
193
- $tvc_data = (object)$_POST['tvc_data'];
 
194
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
195
  echo json_encode($api_obj->createMerchantAccount($_POST));
196
  wp_die();
@@ -206,7 +214,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
206
  public function save_merchant_data(){
207
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
208
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
209
- $tvc_data = (object)$_POST['tvc_data'];
 
210
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
211
  /*sendingblue*/
212
  $data = array();
@@ -230,7 +239,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
230
  public function get_conversion_list(){
231
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
232
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
233
- $tvc_data = (object)$_POST['tvc_data'];
 
234
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
235
  unset($_POST['tvc_data']);
236
  unset($_POST['conversios_onboarding_nonce']);
@@ -248,7 +258,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
248
  public function link_google_ads_to_merchant_center(){
249
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
250
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
251
- $tvc_data = (object)$_POST['tvc_data'];
 
252
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
253
  echo json_encode($api_obj->linkGoogleAdsToMerchantCenter($_POST));
254
  wp_die();
@@ -263,9 +274,10 @@ if(!class_exists('Conversios_Onboarding_Helper')):
263
  public function get_subscription_details(){
264
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
265
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
266
- $tvc_data = (object)$_POST['tvc_data'];
 
267
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
268
- echo json_encode($api_obj->getSubscriptionDetails($_POST['tvc_data'], sanitize_text_field($_POST['subscription_id']) ));
269
  wp_die();
270
  }else{
271
  echo esc_html__("Admin security nonce is not verified.","conversios");
@@ -279,7 +291,8 @@ if(!class_exists('Conversios_Onboarding_Helper')):
279
  public function update_setup_time_to_subscription(){
280
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
281
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
282
- $tvc_data = (object)$_POST['tvc_data'];
 
283
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
284
  $return_url = $this->save_wp_setting_from_subscription_api($api_obj, $tvc_data, sanitize_text_field($_POST['subscription_id']) );
285
  $return_rs = $api_obj->updateSetupTimeToSubscription($_POST);
@@ -341,10 +354,10 @@ if(!class_exists('Conversios_Onboarding_Helper')):
341
  $settings['ga_PrivacyPolicy'] = 'on';
342
  $settings['google-analytic'] = '';
343
  //update option in wordpress local database
344
- update_option('google_ads_conversion_tracking', sanitize_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking));
345
- update_option('ads_tracking_id', sanitize_option('ads_tracking_id', $googleDetail->google_ads_id));
346
- update_option('ads_ert', sanitize_option('ads_ert', $googleDetail->remarketing_tags));
347
- update_option('ads_edrt', sanitize_option('ads_edrt', $googleDetail->dynamic_remarketing_tags));
348
 
349
  $TVC_Admin_Helper->save_ee_options_settings($settings);
350
  /*
@@ -360,10 +373,7 @@ if(!class_exists('Conversios_Onboarding_Helper')):
360
  * save gmail and view ID in WP DB
361
  */
362
  if(property_exists($tvc_data,"g_mail") && sanitize_email($tvc_data->g_mail)){
363
- update_option('ee_customer_gmail', sanitize_option('ee_customer_gmail', $tvc_data->g_mail));
364
- }
365
- if(isset($_POST['ga_view_id']) && sanitize_text_field($_POST['ga_view_id'])){
366
- update_option('ee_ga_view_id', sanitize_text_field($_POST['ga_view_id']));
367
  }
368
  $return_url = "admin.php?page=conversios-google-shopping-feed&tab=gaa_config_page";
369
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
@@ -527,7 +537,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
527
  $tvc_data = (object)$tvc_data;
528
  $access_token = sanitize_text_field(base64_decode($this->access_token));
529
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
530
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken: $access_token");
531
  $data = [
532
  'subscription_id' => sanitize_text_field($subscription_id),//$this->subscription_id,
533
  'domain' => sanitize_text_field($tvc_data->user_domain)
@@ -535,7 +545,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
535
  $args = array(
536
  'headers' =>$header,
537
  'method' => 'POST',
538
- 'body' => $data
539
  );
540
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
541
 
@@ -616,7 +626,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
616
  'Content-Type' => 'application/json',
617
  'RefreshToken' => $refresh_token
618
  ),
619
- 'body' => wp_json_encode($data)
620
  );
621
  $request = wp_remote_post(esc_url_raw($url), $args);
622
 
@@ -648,14 +658,14 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
648
  public function listMerchantCenterAccount() {
649
  try {
650
  $url = $this->apiDomain . '/gmc/user-merchant-center/list';
651
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
652
  $data = [
653
  'access_token' => sanitize_text_field(base64_decode($this->access_token)),
654
  ];
655
  $args = array(
656
  'headers' =>$header,
657
  'method' => 'POST',
658
- 'body' => $data
659
  );
660
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
661
  $return = new \stdClass();
@@ -677,21 +687,25 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
677
 
678
  public function createGoogleAdsAccount($postData) {
679
  try {
680
- $tvc_data = (object)$postData['tvc_data'];
 
 
681
  $url = $this->apiDomain . '/adwords/create-ads-account';
682
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
683
  $data = [
684
  'email' => sanitize_email($tvc_data->g_mail),
685
  'currency' => sanitize_text_field($tvc_data->currency_code),
686
  'time_zone' => sanitize_text_field($tvc_data->timezone_string), //'Asia/Kolkata',
687
  'domain' => sanitize_text_field($tvc_data->user_domain)
688
  ];
 
689
  $args = array(
690
  'headers' =>$header,
691
  'method' => 'POST',
692
- 'body' => $data
693
  );
694
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
695
  $return = new \stdClass();
696
  if($result->status == 200){
697
  $return->status = $result->status;
@@ -700,7 +714,8 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
700
  return $return;
701
  }else{
702
  $return->error = true;
703
- $return->data = $result->data;
 
704
  $return->status = $result->status;
705
  return $return;
706
  }
@@ -711,9 +726,12 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
711
  public function createMerchantAccount($postData) {
712
  try {
713
  $url = $this->apiDomain . '/gmc/create';
714
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
 
 
 
715
  $data = [
716
- 'merchant_id' => $this->merchantId, //'256922349',
717
  'name' => sanitize_text_field($postData['store_name']),
718
  'website_url' => esc_url_raw(sanitize_text_field($postData['website_url'])),
719
  'customer_id' => sanitize_text_field($postData['customer_id']),
@@ -734,12 +752,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
734
  $args = array(
735
  'headers' =>$header,
736
  'method' => 'POST',
737
- 'body' => $data
738
- );
739
- $args = array(
740
- 'headers' =>$header,
741
- 'method' => 'POST',
742
- 'body' => $data
743
  );
744
  $args['timeout']= "1000";
745
  $request = wp_remote_post(esc_url_raw($url), $args);
@@ -766,7 +779,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
766
  public function saveAnalyticsData($postData = array()) {
767
  try {
768
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
769
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
770
  $data = array(
771
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
772
  'tracking_option' => sanitize_text_field((isset($postData['tracking_option']))?$postData['tracking_option'] : ''),
@@ -784,7 +797,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
784
  $args = array(
785
  'headers' =>$header,
786
  'method' => 'POST',
787
- 'body' => $data
788
  );
789
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
790
  $return = new \stdClass();
@@ -807,7 +820,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
807
  public function saveGoogleAdsData($postData = array()){
808
  try {
809
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
810
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
811
  $data = [
812
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
813
  'google_ads_id' => sanitize_text_field((isset($postData['google_ads_id']))? $postData['google_ads_id'] : ''),
@@ -819,7 +832,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
819
  $args = array(
820
  'headers' =>$header,
821
  'method' => 'POST',
822
- 'body' => $data
823
  );
824
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
825
  $return = new \stdClass();
@@ -842,7 +855,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
842
  public function saveMechantData($postData = array()) {
843
  try {
844
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
845
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
846
  $data = [
847
  'merchant_id' => sanitize_text_field(($postData['merchant_id'] == 'NewMerchant') ? $this->merchantId: $postData['merchant_id']),
848
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
@@ -853,7 +866,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
853
  $args = array(
854
  'headers' =>$header,
855
  'method' => 'POST',
856
- 'body' => $data
857
  );
858
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
859
  $return = new \stdClass();
@@ -878,7 +891,6 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
878
  $url = $this->apiDomain . '/google-analytics/link-ads-to-analytics';
879
  $access_token = sanitize_text_field(base64_decode($this->access_token));
880
  $refresh_token = sanitize_text_field(base64_decode($this->refresh_token));
881
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken:$access_token", "RefreshToken:$refresh_token");
882
  if ($postData['type'] == "UA") {
883
  $data = [
884
  'type' => sanitize_text_field($postData['type']),
@@ -897,22 +909,36 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
897
  'web_property' => sanitize_text_field($postData['web_property']),
898
  ];
899
  }
 
900
  $args = array(
901
- 'headers' =>$header,
 
 
 
 
 
 
902
  'method' => 'POST',
903
- 'body' => $data
904
  );
905
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
906
  $return = new \stdClass();
907
- if($result->status == 200){
908
- $return->status = $result->status;
909
  $return->data = $result->data;
910
  $return->error = false;
911
  return $return;
912
  }else{
913
  $return->error = true;
914
- $return->data = $result->data;
915
- $return->status = $result->status;
 
916
  return $return;
917
  }
918
  } catch (Exception $e) {
@@ -923,28 +949,39 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
923
  try {
924
  $url = $this->apiDomain . '/adwords/link-ads-to-merchant-center';
925
  $access_token = sanitize_text_field(base64_decode($this->access_token));
926
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json", "AccessToken:$access_token");
927
  $data = [
928
  'merchant_id' => sanitize_text_field(($postData['merchant_id']) == 'NewMerchant' ? $this->merchantId: $postData['merchant_id']),
929
  'account_id' => sanitize_text_field($postData['account_id']),
930
  'adwords_id' => sanitize_text_field($postData['adwords_id'])
931
  ];
932
  $args = array(
933
- 'headers' =>$header,
934
- 'method' => 'POST',
935
- 'body' => $data
 
 
 
 
936
  );
937
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
 
938
  $return = new \stdClass();
939
- if($result->status == 200){
940
- $return->status = $result->status;
941
  $return->data = $result->data;
942
  $return->error = false;
943
  return $return;
944
  }else{
945
  $return->error = true;
946
- $return->data = $result->data;
947
- $return->status = $result->status;
 
948
  return $return;
949
  }
950
 
@@ -955,27 +992,37 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
955
  public function updateSetupTimeToSubscription($postData) {
956
  try {
957
  $url = $this->apiDomain . '/customer-subscriptions/update-setup-time';
958
- $this->header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
959
  $data = [
960
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
961
  'setup_end_time' => date('Y-m-d H:i:s')
962
  ];
963
  $args = array(
964
- 'headers' =>$header,
965
- 'method' => 'POST',
966
- 'body' => $data
 
 
 
967
  );
968
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
 
 
 
969
  $return = new \stdClass();
970
- if($result->status == 200){
971
- $return->status = $result->status;
972
  $return->data = $result->data;
973
  $return->error = false;
974
  return $return;
975
  }else{
976
  $return->error = true;
977
- $return->data = $result->data;
978
- $return->status = $result->status;
 
979
  return $return;
980
  }
981
 
@@ -984,22 +1031,34 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
984
  }
985
  }
986
 
987
- public function getConversionList($data) {
988
  try {
 
 
 
 
 
989
  $url = $this->apiDomain . '/google-ads/conversion-list';
990
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
 
 
 
991
  $args = array(
992
  'headers' =>$header,
993
  'method' => 'POST',
994
- 'body' => $data
995
  );
996
- $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
 
 
 
 
997
  $return = new \stdClass();
998
- if($result->status == 200){
999
- $return->status = $result->status;
1000
- $return->data =$result->data;
1001
  $return->error = false;
1002
- if(isset($result->data) && count($result->data) > 0){
1003
  $return->message = esc_html__("Google Ads conversion tracking setting success.","conversios");
1004
  }else{
1005
  $response = $this->createConversion($data);
@@ -1015,8 +1074,9 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1015
  return $return;
1016
  }else{
1017
  $return->error = true;
1018
- $return->data = $result->data;
1019
- $return->status = $result->status;
 
1020
  return $return;
1021
  }
1022
  } catch (Exception $e) {
@@ -1027,7 +1087,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1027
  public function createConversion($postData) {
1028
  try {
1029
  $url = $this->apiDomain . '/google-ads/create-conversion';
1030
- $header = array("Authorization: Bearer MTIzNA==", "content-type: application/json");
1031
  $data = [
1032
  'customer_id' => sanitize_text_field((isset($postData['customer_id']))?$postData['customer_id'] : ''),
1033
  'name' => "Order Conversion"
@@ -1035,7 +1095,7 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1035
  $args = array(
1036
  'headers' =>$header,
1037
  'method' => 'POST',
1038
- 'body' => $data
1039
  );
1040
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
1041
  $return = new \stdClass();
@@ -1072,8 +1132,8 @@ if(!class_exists('Conversios_Onboarding_ApiCall') ){
1072
  $data = [
1073
  "grant_type" => 'refresh_token',
1074
  "client_id" => sanitize_text_field($clientId),
1075
- 'client_secret' => $clientSecret,
1076
- 'refresh_token' => $refresh_token,
1077
  ];
1078
  $args = array(
1079
  'headers' =>$header,
62
  public function get_analytics_web_properties(){
63
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
64
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
65
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
66
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
67
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
68
  echo json_encode($api_obj->getAnalyticsWebProperties($_POST));
69
  wp_die();
79
  public function save_analytics_data(){
80
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
81
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
82
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
83
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
84
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
85
  /*sendingblue*/
86
  $data = array();
105
  public function list_googl_ads_account(){
106
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
107
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
108
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
109
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
110
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
111
  echo json_encode($api_obj->getGoogleAdsAccountList($_POST));
112
  wp_die();
121
  public function create_google_ads_account(){
122
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
123
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
124
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
125
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
126
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
127
  echo json_encode($api_obj->createGoogleAdsAccount($_POST));
128
  wp_die();
138
  public function save_google_ads_data(){
139
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
140
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
141
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
142
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
143
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
144
  /*sendingblue*/
145
  $data = array();
164
  public function link_analytic_to_ads_account(){
165
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
166
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
167
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
168
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
169
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
170
  echo json_encode($api_obj->linkAnalyticToAdsAccount($_POST));
171
  wp_die();
181
  public function list_google_merchant_account(){
182
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
183
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
184
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
185
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
186
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
187
  echo json_encode($api_obj->listMerchantCenterAccount($_POST));
188
  wp_die();
197
  public function create_google_merchant_center_account(){
198
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
199
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
200
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
201
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
202
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
203
  echo json_encode($api_obj->createMerchantAccount($_POST));
204
  wp_die();
214
  public function save_merchant_data(){
215
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
216
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
217
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
218
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
219
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
220
  /*sendingblue*/
221
  $data = array();
239
  public function get_conversion_list(){
240
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
241
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
242
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
243
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
244
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
245
  unset($_POST['tvc_data']);
246
  unset($_POST['conversios_onboarding_nonce']);
258
  public function link_google_ads_to_merchant_center(){
259
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
260
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
261
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
262
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
263
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
264
  echo json_encode($api_obj->linkGoogleAdsToMerchantCenter($_POST));
265
  wp_die();
274
  public function get_subscription_details(){
275
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
276
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
277
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
278
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
279
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
280
+ echo json_encode($api_obj->getSubscriptionDetails($tvc_data, sanitize_text_field($_POST['subscription_id']) ));
281
  wp_die();
282
  }else{
283
  echo esc_html__("Admin security nonce is not verified.","conversios");
291
  public function update_setup_time_to_subscription(){
292
  $nonce = (isset($_POST['conversios_onboarding_nonce']))?sanitize_text_field($_POST['conversios_onboarding_nonce']):"";
293
  if($this->admin_safe_ajax_call($nonce, 'conversios_onboarding_nonce')){
294
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
295
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
296
  $api_obj = new Conversios_Onboarding_ApiCall(sanitize_text_field($tvc_data->access_token), sanitize_text_field($tvc_data->refresh_token));
297
  $return_url = $this->save_wp_setting_from_subscription_api($api_obj, $tvc_data, sanitize_text_field($_POST['subscription_id']) );
298
  $return_rs = $api_obj->updateSetupTimeToSubscription($_POST);
354
  $settings['ga_PrivacyPolicy'] = 'on';
355
  $settings['google-analytic'] = '';
356
  //update option in wordpress local database
357
+ update_option('google_ads_conversion_tracking', $googleDetail->google_ads_conversion_tracking);
358
+ update_option('ads_tracking_id', $googleDetail->google_ads_id);
359
+ update_option('ads_ert', $googleDetail->remarketing_tags);
360
+ update_option('ads_edrt', $googleDetail->dynamic_remarketing_tags);
361
 
362
  $TVC_Admin_Helper->save_ee_options_settings($settings);
363
  /*
373
  * save gmail and view ID in WP DB
374
  */
375
  if(property_exists($tvc_data,"g_mail") && sanitize_email($tvc_data->g_mail)){
376
+ update_option('ee_customer_gmail', $tvc_data->g_mail);
 
 
 
377
  }
378
  $return_url = "admin.php?page=conversios-google-shopping-feed&tab=gaa_config_page";
379
  if(isset($googleDetail->google_merchant_center_id) || isset($googleDetail->google_ads_id) ){
537
  $tvc_data = (object)$tvc_data;
538
  $access_token = sanitize_text_field(base64_decode($this->access_token));
539
  $url = $this->apiDomain . '/customer-subscriptions/subscription-detail';
540
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json", "AccessToken: $access_token");
541
  $data = [
542
  'subscription_id' => sanitize_text_field($subscription_id),//$this->subscription_id,
543
  'domain' => sanitize_text_field($tvc_data->user_domain)
545
  $args = array(
546
  'headers' =>$header,
547
  'method' => 'POST',
548
+ 'body' => wp_json_encode($data)
549
  );
550
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
551
 
626
  'Content-Type' => 'application/json',
627
  'RefreshToken' => $refresh_token
628
  ),
629
+ 'body' => ""
630
  );
631
  $request = wp_remote_post(esc_url_raw($url), $args);
632
 
658
  public function listMerchantCenterAccount() {
659
  try {
660
  $url = $this->apiDomain . '/gmc/user-merchant-center/list';
661
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
662
  $data = [
663
  'access_token' => sanitize_text_field(base64_decode($this->access_token)),
664
  ];
665
  $args = array(
666
  'headers' =>$header,
667
  'method' => 'POST',
668
+ 'body' => wp_json_encode($data)
669
  );
670
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
671
  $return = new \stdClass();
687
 
688
  public function createGoogleAdsAccount($postData) {
689
  try {
690
+ //$tvc_data = (object)$postData['tvc_data'];
691
+ $data = isset($_POST['tvc_data'])?sanitize_text_field($_POST['tvc_data']):"";
692
+ $tvc_data = json_decode(str_replace("&quot;", "\"", $data));
693
  $url = $this->apiDomain . '/adwords/create-ads-account';
694
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
695
  $data = [
696
  'email' => sanitize_email($tvc_data->g_mail),
697
  'currency' => sanitize_text_field($tvc_data->currency_code),
698
  'time_zone' => sanitize_text_field($tvc_data->timezone_string), //'Asia/Kolkata',
699
  'domain' => sanitize_text_field($tvc_data->user_domain)
700
  ];
701
+ //print_r( $data );
702
  $args = array(
703
  'headers' =>$header,
704
  'method' => 'POST',
705
+ 'body' => wp_json_encode($data)
706
  );
707
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
708
+ //print_r($result);
709
  $return = new \stdClass();
710
  if($result->status == 200){
711
  $return->status = $result->status;
714
  return $return;
715
  }else{
716
  $return->error = true;
717
+ $return->error = $result->errors;
718
+ //$return->data = $result->data;
719
  $return->status = $result->status;
720
  return $return;
721
  }
726
  public function createMerchantAccount($postData) {
727
  try {
728
  $url = $this->apiDomain . '/gmc/create';
729
+ $header = array(
730
+ "Authorization: Bearer MTIzNA==",
731
+ "Content-Type" => "application/json"
732
+ );
733
  $data = [
734
+ 'merchant_id' => sanitize_text_field($this->merchantId), //'256922349',
735
  'name' => sanitize_text_field($postData['store_name']),
736
  'website_url' => esc_url_raw(sanitize_text_field($postData['website_url'])),
737
  'customer_id' => sanitize_text_field($postData['customer_id']),
752
  $args = array(
753
  'headers' =>$header,
754
  'method' => 'POST',
755
+ 'body' => wp_json_encode($data)
 
 
 
 
 
756
  );
757
  $args['timeout']= "1000";
758
  $request = wp_remote_post(esc_url_raw($url), $args);
779
  public function saveAnalyticsData($postData = array()) {
780
  try {
781
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
782
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
783
  $data = array(
784
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
785
  'tracking_option' => sanitize_text_field((isset($postData['tracking_option']))?$postData['tracking_option'] : ''),
797
  $args = array(
798
  'headers' =>$header,
799
  'method' => 'POST',
800
+ 'body' => wp_json_encode($data)
801
  );
802
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
803
  $return = new \stdClass();
820
  public function saveGoogleAdsData($postData = array()){
821
  try {
822
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
823
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
824
  $data = [
825
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
826
  'google_ads_id' => sanitize_text_field((isset($postData['google_ads_id']))? $postData['google_ads_id'] : ''),
832
  $args = array(
833
  'headers' =>$header,
834
  'method' => 'POST',
835
+ 'body' => wp_json_encode($data)
836
  );
837
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
838
  $return = new \stdClass();
855
  public function saveMechantData($postData = array()) {
856
  try {
857
  $url = $this->apiDomain . '/customer-subscriptions/update-detail';
858
+ $header = array("Authorization: Bearer MTIzNA==", "Content-Type" => "application/json");
859
  $data = [
860
  'merchant_id' => sanitize_text_field(($postData['merchant_id'] == 'NewMerchant') ? $this->merchantId: $postData['merchant_id']),
861
  'subscription_id' => sanitize_text_field((isset($postData['subscription_id']))?$postData['subscription_id'] : ''),
866
  $args = array(
867
  'headers' =>$header,
868
  'method' => 'POST',
869
+ 'body' => wp_json_encode($data)
870
  );
871
  $result = $this->tc_wp_remot_call_post(esc_url_raw($url), $args);
872
  $return = new \stdClass();
891
  $url = $this->apiDomain . '/google-analytics/link-ads-to-analytics';
892
  $access_token = sanitize_text_field(base64_decode($this->access_token));
893
  $refresh_token = sanitize_text_field(base64_decode($this->refresh_token));
 
894
  if ($postData['type'] == "UA") {
895
  $data = [
896
  'type' => sanitize_text_field($postData['type']),
909
  'web_property' => sanitize_text_field($postData['web_property']),
910
  ];
911
  }
912
+
913
  $args = array(
914
+ 'timeout' => 10000,
915
+ 'headers' => array(
916
+ 'Authorization' => "Bearer $this->token",
917
+ 'Content-Type' => 'application/json',
918
+ 'AccessToken' => $access_token,
919
+ 'RefreshToken' => $refresh_token
920
+ ),
921
  'method' => 'POST',
922
+ 'body' => wp_json_encode($data)