Enhanced Ecommerce Google Analytics Plugin for WooCommerce - Version 4.8.0

Version Description

  • 20/06/2022 =
  • New:- Add the New Feature "Performance Max Campaigns" so From the plugin itself users can create a Pmax campaign within a few clicks to promote products across Google Search, Shopping, YouTube, Gmail, and the Display Network. He can also check the Campaign-wise performance report which gives visibility of Clicks, Cost, Conversion, and Sales of respective Campaigns.
Download this release

Release Info

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

Code changes from version 4.7.5 to 4.8.0

admin/class-conversios-admin.php CHANGED
@@ -63,10 +63,14 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
63
  wp_enqueue_style('conversios-slick-css');
64
  wp_register_style('conversios-daterangepicker-css', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/css/daterangepicker.css') );
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,7 +90,12 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
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
  }
@@ -132,6 +141,14 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
132
  'conversios-google-ads',
133
  array($this, 'showPage')
134
  );
 
 
 
 
 
 
 
 
135
  add_submenu_page(
136
  'conversios',
137
  esc_html__('Account Settings', 'conversios'),
@@ -203,6 +220,23 @@ if ( ! class_exists( 'Conversios_Admin' ) ) {
203
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/google-ads.php');
204
  new GoogleAds();
205
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  public function conversios_google_shopping_feed() {
207
  include(ENHANCAD_PLUGIN_DIR . 'includes/setup/help-html.php');
208
  include(ENHANCAD_PLUGIN_DIR . 'includes/setup/google-shopping-feed.php');
63
  wp_enqueue_style('conversios-slick-css');
64
  wp_register_style('conversios-daterangepicker-css', esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/css/daterangepicker.css') );
65
  wp_enqueue_style('conversios-daterangepicker-css');
66
+ }else if(sanitize_text_field($_GET['page']) == "conversios-pmax"){
67
+ wp_register_style('tvc-bootstrap-datepicker-css', esc_url_raw(ENHANCAD_PLUGIN_URL. '/includes/setup/plugins/datepicker/bootstrap-datepicker.min.css'));
68
+ wp_enqueue_style('tvc-bootstrap-datepicker-css');
69
  }
70
  //all conversios page css
71
  wp_enqueue_style('conversios-style-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/style.css'), array(), esc_attr($this->version), 'all' );
72
  wp_enqueue_style('conversios-responsive-css', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/css/responsive.css'), array(), esc_attr($this->version), 'all');
73
+
74
  }
75
  }
76
 
90
  wp_enqueue_script( 'conversios-moment-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/moment.min.js') );
91
  wp_enqueue_script( 'conversios-daterangepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/daterangepicker.js') );
92
 
93
+ wp_enqueue_script( 'conversios-custom-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/tvc-ee-custom.js'), array( 'jquery' ), esc_attr($this->version), false );
94
+ }else if(sanitize_text_field($_GET['page']) == "conversios-pmax"){
95
+ //wp_enqueue_script( 'conversios-chart-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/chart.js') );
96
+ wp_enqueue_script( 'conversios-pmax-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/admin/js/pmax-custom.js'), array( 'jquery' ), esc_attr($this->version), false );
97
+ wp_register_script('tvc-bootstrap-datepicker-js', esc_url_raw(ENHANCAD_PLUGIN_URL . '/includes/setup/plugins/datepicker/bootstrap-datepicker.min.js'));
98
+ wp_enqueue_script('tvc-bootstrap-datepicker-js');
99
  }
100
  }
101
  }
141
  'conversios-google-ads',
142
  array($this, 'showPage')
143
  );
144
+ add_submenu_page(
145
+ 'conversios',
146
+ esc_html__('Performance Max', 'conversios'),
147
+ esc_html__('Performance Max', 'conversios'),
148
+ 'manage_options',
149
+ 'conversios-pmax',
150
+ array($this, 'showPage')
151
+ );
152
  add_submenu_page(
153
  'conversios',
154
  esc_html__('Account Settings', 'conversios'),
220
  require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/google-ads.php');
221
  new GoogleAds();
222
  }
223
+ public function conversios_pmax(){
224
+ $action_tab = (isset($_GET['tab']))?sanitize_text_field($_GET['tab']):"";
225
+ if($action_tab!=""){
226
+ $this->$action_tab();
227
+ }else{
228
+ require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/pmax.php');
229
+ new TVC_PMax();
230
+ }
231
+ }
232
+ public function pmax_add(){
233
+ require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/pmax-add.php');
234
+ new TVC_PMaxAdd();
235
+ }
236
+ public function pmax_edit(){
237
+ require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/pmax-edit.php');
238
+ new TVC_PMaxEdit();
239
+ }
240
  public function conversios_google_shopping_feed() {
241
  include(ENHANCAD_PLUGIN_DIR . 'includes/setup/help-html.php');
242
  include(ENHANCAD_PLUGIN_DIR . 'includes/setup/google-shopping-feed.php');
admin/class-enhanced-ecommerce-google-analytics-admin.php CHANGED
@@ -102,6 +102,15 @@ class Enhanced_Ecommerce_Google_Analytics_Admin extends TVC_Admin_Helper {
102
  </div>';
103
  }
104
  }
 
 
 
 
 
 
 
 
 
105
  ?>
106
  <script>
107
  var tvc_ajax_url = '<?php echo esc_url_raw(admin_url( 'admin-ajax.php' )); ?>';
102
  </div>';
103
  }
104
  }
105
+
106
+ if(isset($ee_additional_data['dismissed_ee_adimin_notic_f']) && $ee_additional_data['dismissed_ee_adimin_notic_f'] == 1){
107
+ }else if(( isset($ee_additional_data['dismissed_ee_adimin_notic_f']) && $ee_additional_data['dismissed_ee_adimin_notic_f'] == 1) || $fb_pixel_id != ""){
108
+ $gm_id = isset($ee_settings['gm_id'])?$ee_settings['gm_id']:"";
109
+ if($gm_id != ""){
110
+ echo '<div class="notice notice-info is-dismissible" data-id="ee_adimin_notic_f"><p style="line-height: 28px; margin-left: 5px; display: inline-block;">'. esc_html__("Grow your business with Performance Max campaigns. you can create a campaign through our plugin with just a few clicks, and promote products across Google Platform,","conversios").' <a href="'.esc_url_raw('admin.php?page=conversios-pmax').'"><b><u>'. esc_html__(" Try now.","conversios").'</u></b></a></p>
111
+ </div>';
112
+ }
113
+ }
114
  ?>
115
  <script>
116
  var tvc_ajax_url = '<?php echo esc_url_raw(admin_url( 'admin-ajax.php' )); ?>';
admin/css/style.css CHANGED
@@ -117,7 +117,7 @@ select#tvc_conversion_tracking_type{
117
  75%{opacity: 1; margin-top: -20%;}
118
  100%{opacity: 0;margin-top: 40%;}
119
  }
120
- #tvc_onboarding_popup_box.tvc_popup_box_close{
121
  display: none;
122
  animation: tvc_popup_box_close 0.5s;
123
  -webkit-animation: tvc_popup_box_close 0.5s;
@@ -318,7 +318,8 @@ button:disabled,button[disabled], button:disabled:hover,button[disabled]:hover{b
318
  animation: gradient 15s ease infinite;
319
  min-width: 30px;
320
  }
321
- .dashbrdpage-wrap .is_loading{
 
322
  background: rgba(255,255,255,0.65) url('../images/ajax-loader.gif') no-repeat 50% 50%;
323
  -webkit-transition: background-color 0;
324
  transition: background-color 0;
@@ -952,7 +953,7 @@ background: linear-gradient(360deg, #F8F8F8 0%, rgba(248, 248, 248, 0.8) 41.15%,
952
  .blueupgrdbtn:hover{background-color: #1e1e1e;}
953
  .chartarea img{width: 100%;}
954
  .whiteroundedbx{background-color: #ffffff; border-radius: 6px;}
955
- .dshreport-sec{padding: 30px 20px 5px;}
956
  .dsh-reprttop{display: flex; flex-wrap: wrap;}
957
  .dshrprttp-left, .dshrprttp-right{flex: 1; padding: 0 15px;}
958
  .dshrprttp-left{display: flex; align-items: center; flex-wrap: wrap;}
@@ -1172,4 +1173,195 @@ button:disabled,button[disabled], button:disabled:hover,button[disabled]:hover{b
1172
  min-width: 330px;
1173
  }
1174
  table .tracking-trigger td{ padding: 0 0 0.5rem 1rem;}
1175
- #ee_plugin_form input[type="text"], #ee_plugin_form input[type="number"]{ min-width: 285px; height: 32px; margin-bottom: 5px;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  75%{opacity: 1; margin-top: -20%;}
118
  100%{opacity: 0;margin-top: 40%;}
119
  }
120
+ #tvc_onboarding_popup_box.tvc_popup_box_close, .tvc_popup_box_close{
121
  display: none;
122
  animation: tvc_popup_box_close 0.5s;
123
  -webkit-animation: tvc_popup_box_close 0.5s;
318
  animation: gradient 15s ease infinite;
319
  min-width: 30px;
320
  }
321
+ #add_loading{height: 50px;}
322
+ .dashbrdpage-wrap .is_loading, .pmax-campaign .is_loading{
323
  background: rgba(255,255,255,0.65) url('../images/ajax-loader.gif') no-repeat 50% 50%;
324
  -webkit-transition: background-color 0;
325
  transition: background-color 0;
953
  .blueupgrdbtn:hover{background-color: #1e1e1e;}
954
  .chartarea img{width: 100%;}
955
  .whiteroundedbx{background-color: #ffffff; border-radius: 6px;}
956
+ .dshreport-sec{padding: 30px 20px 5px; overflow: hidden;}
957
  .dsh-reprttop{display: flex; flex-wrap: wrap;}
958
  .dshrprttp-left, .dshrprttp-right{flex: 1; padding: 0 15px;}
959
  .dshrprttp-left{display: flex; align-items: center; flex-wrap: wrap;}
1173
  min-width: 330px;
1174
  }
1175
  table .tracking-trigger td{ padding: 0 0 0.5rem 1rem;}
1176
+ #ee_plugin_form input[type="text"], #ee_plugin_form input[type="number"]{ min-width: 285px; height: 32px; margin-bottom: 5px;}
1177
+ /**********PMax CSS ************/
1178
+ .search-box { background: url('../images/search-icon.png');
1179
+ background-repeat: no-repeat;
1180
+ background-position: 13px center;
1181
+ padding: 5px 4px 5px 40px !important;}
1182
+ button.btn-search {
1183
+ border: 2px solid #0137FC;
1184
+ padding: 12px;
1185
+ text-transform: uppercase;
1186
+ background: #fff;
1187
+ }
1188
+ .date-range { background: url('../images/calendar-icon.png');
1189
+ background-repeat: no-repeat;
1190
+ background-position: 13px center;
1191
+ padding: 9px 4px 9px 40px !important;}
1192
+
1193
+ .btn-campaign {
1194
+ padding: 10px;
1195
+ }
1196
+ .campaign-list-tbl {
1197
+ border: 1px solid #E9E9E9;
1198
+ }
1199
+ /* Pmax add campaign */
1200
+ .section-addcampaign h3, .section-Campaignlisting {
1201
+ margin-top: 10px;
1202
+ }
1203
+ .tabs{
1204
+ width:100%;
1205
+ height:auto;
1206
+ margin:0 auto;
1207
+ }
1208
+
1209
+ /* tab list item */
1210
+ .tabs .tabs-list{
1211
+ list-style:none;
1212
+ margin:0px;
1213
+ padding:0px;
1214
+ }
1215
+ .tabs .tabs-list li{
1216
+ float: left;
1217
+ margin: 0px;
1218
+ margin-right: 0px;
1219
+ padding: 15px 38px;
1220
+ text-align: center;
1221
+ background-color: #fff;
1222
+ border-radius: 0px;
1223
+ border-bottom: 2px solid #ddd;
1224
+ border-right: 0px;
1225
+ border-top: 0px;
1226
+ border-left: 0px;
1227
+ box-shadow: 0px 1px 12px rgb(0 0 0 / 6%);
1228
+ }
1229
+ .tabs .tabs-list li:hover{
1230
+ cursor:pointer;
1231
+ }
1232
+ .tabs .tabs-list li a{
1233
+ text-decoration: none;
1234
+ color: #515151;
1235
+ font-weight: 500;
1236
+ }
1237
+
1238
+ /* Tab content section */
1239
+ .tabs .tab{
1240
+ display:none;
1241
+ width:96%;
1242
+ min-height:250px;
1243
+ height:auto;
1244
+ border-radius:3px;
1245
+ padding:20px 15px;
1246
+ background-color:#FFF;
1247
+ color:darkslategray;
1248
+ clear:both;
1249
+ }
1250
+ .tabs .tab h3{
1251
+ letter-spacing:1px;
1252
+ font-weight:normal;
1253
+ padding:5px;
1254
+ }
1255
+ .tabs .tab p{
1256
+ line-height:20px;
1257
+ letter-spacing: 1px;
1258
+ }
1259
+
1260
+ /* When active state */
1261
+ .active{
1262
+ display:block !important;
1263
+ }
1264
+ .tabs .tabs-list li.active{
1265
+ background-color: #002BFC;
1266
+ border-bottom: 2px solid #002BFC;
1267
+ }
1268
+ .tabs .tabs-list li.active a{
1269
+ color:#fff;
1270
+ }
1271
+ /* Campaign Form stylem */
1272
+ .campform-row label {
1273
+ margin-bottom: 0.5rem;
1274
+ font-weight: bold;
1275
+ }
1276
+ .add-pmax-campaign .campform-row input.fromfiled, .add-pmax-campaign select, .add-pmax-campaign form img {
1277
+ display: block;
1278
+ }
1279
+ .form-row-grp.campform-row {
1280
+ display: flex;
1281
+ flex-wrap: wrap;
1282
+ }
1283
+ .form-col-8 {
1284
+ width: 27%;
1285
+ }
1286
+ .form-col-4 {
1287
+ width: 10.666667%;
1288
+ margin-right: 15px;
1289
+ }
1290
+ button.btn-fade-blue {
1291
+ background-color: #F1F4FB;
1292
+ border-radius: 6px;
1293
+ border: none;
1294
+ padding: 9px 15px;
1295
+ color: #002BFC;
1296
+ font-size: 13px;
1297
+ min-width: 154px;
1298
+ text-align: center;
1299
+ height: 40px;
1300
+ display: inline-flex;
1301
+ align-items: center;
1302
+ justify-content: center;
1303
+ line-height: 24px;
1304
+ }
1305
+ .btn-fade-blue img {
1306
+ margin-right: 10px;
1307
+ }
1308
+ p.label {
1309
+ margin-bottom: 5px;
1310
+ }
1311
+ .score-line {width: 258px;position: absolute;left: 21%;font-size: 10px;}
1312
+ .form-row .radio {
1313
+ margin-right: 10px;
1314
+ }
1315
+ .radio-label {
1316
+ margin-right: 10px;
1317
+ }
1318
+ .campform-row .slect2bx {
1319
+ border-radius: 4px;
1320
+ border-color: #b4b9be;
1321
+ }
1322
+ button.btn-withborder {
1323
+ border: 1px solid #757575;
1324
+ background: #fff;
1325
+ border-radius: 6px;
1326
+ padding: 9px 15px;
1327
+ font-size: 16px;
1328
+ font-weight: 400;
1329
+ min-width: 154px;
1330
+ text-align: center;
1331
+ height: 42px;
1332
+ display: inline-flex;
1333
+ align-items: center;
1334
+ justify-content: center;
1335
+ line-height: 24px;
1336
+ color: #757575;
1337
+ }
1338
+ .campfooterbtn {padding: 0 0px 10px;}
1339
+ .assetformwrp {width: 70%; float: left;}t
1340
+ .assetsection {width: 30%; float: left;}
1341
+ img.img-upload {
1342
+ display: inline-block;
1343
+ margin-right: 10px;
1344
+ }
1345
+ .note {font-size: 10px;margin-bottom: 5px;}
1346
+ .img-icon {display: inline-block;position: absolute;margin-left: 10px;}
1347
+
1348
+ /* Pmax Edit */
1349
+ .campaign-edit .assetformwrp, .campaign-edit .assetsection {
1350
+ margin-top: 40px;
1351
+ }
1352
+ .form-edit input.fromfiled {display: inline;}
1353
+ .edit-icon {width: 35px;}
1354
+ .page_no_sec{margin: 10px;}
1355
+ #tvc_pmax_popup_box.tvc_popup_box {
1356
+ overflow: hidden;
1357
+ z-index: 9999;
1358
+ display: block;
1359
+ position: relative;
1360
+ float: left;
1361
+ }
1362
+ .add-pmax-campaign .mb1{margin-bottom: 5px;}
1363
+ .add-pmax-campaign .remove-row{margin: 14px; cursor: pointer;}
1364
+ .pmax-campaign .fromfiled{max-width: 350px;}
1365
+ .pmax-campaign .cmp_urls .fromfiled{max-width: 500px;}
1366
+ .pmax-campaign .cmp_urls .form-col-8 {width: 45%;}
1367
+ /*.pmax-campaign .fromfiled.smtext{max-width: 200px;}*/
admin/helper/class-pmax-helper.php ADDED
@@ -0,0 +1,551 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The admin-specific functionality of the plugin.
4
+ *
5
+ * @link
6
+ * @since 1.0.0
7
+ *
8
+ * Woo Order Reports
9
+ */
10
+
11
+ if(!defined('ABSPATH')){
12
+ exit; // Exit if accessed directly
13
+ }
14
+ if(!class_exists('Conversios_PMax_Helper')){
15
+ class Conversios_PMax_Helper{
16
+ protected $ShoppingApi;
17
+ protected $TVC_Admin_Helper;
18
+ protected $CustomApi;
19
+ protected $apiDomain;
20
+ protected $token;
21
+ public function __construct(){
22
+ $this->req_int();
23
+ $this->apiDomain = TVC_API_CALL_URL;
24
+ $this->token = 'MTIzNA==';
25
+ $this->TVC_Admin_Helper = new TVC_Admin_Helper();
26
+ $this->CustomApi = new CustomApi();
27
+ //$this->ShoppingApi = new ShoppingApi();
28
+ //add_action('wp_ajax_get_google_ads_reports_chart', array($this,'get_google_ads_reports_chart') );
29
+ add_action('wp_ajax_get_pmax_campaign_list', array($this,'get_pmax_campaign_list') );
30
+ add_action('wp_ajax_create_pmax_campaign', array($this,'create_pmax_campaign') );
31
+ add_action('wp_ajax_edit_pmax_campaign', array($this,'edit_pmax_campaign') );
32
+ }
33
+
34
+ public function req_int(){
35
+ if (!class_exists('CustomApi')) {
36
+ require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/CustomApi.php');
37
+ }
38
+ if (!class_exists('ShoppingApi')) {
39
+ //require_once(ENHANCAD_PLUGIN_DIR . 'includes/setup/ShoppingApi.php');
40
+ }
41
+ }
42
+ protected function admin_safe_ajax_call( $nonce, $registered_nonce_name ) {
43
+ // only return results when the user is an admin with manage options
44
+ if ( is_admin() && wp_verify_nonce($nonce,$registered_nonce_name) ) {
45
+ return true;
46
+ } else {
47
+ return false;
48
+ }
49
+ }
50
+ public function get_pmax_campaign_list(){
51
+ $nonce = (isset($_POST['conversios_nonce']))?sanitize_text_field($_POST['conversios_nonce']):"";
52
+ $return = array();
53
+ if($this->admin_safe_ajax_call($nonce, 'conversios_nonce')){
54
+ /*$start_date = str_replace(' ', '',(isset($_POST['start_date']))?sanitize_text_field($_POST['start_date']):"");
55
+ if($start_date != ""){
56
+ $date = DateTime::createFromFormat('d-m-Y', $start_date);
57
+ $start_date = $date->format('Y-m-d');
58
+ }
59
+
60
+ $end_date = str_replace(' ', '',(isset($_POST['end_date']))?sanitize_text_field($_POST['end_date']):"");
61
+ if($end_date != ""){
62
+ $date = DateTime::createFromFormat('d-m-Y', $end_date);
63
+ $end_date = $date->format('Y-m-d');
64
+ }
65
+ $start_date = sanitize_text_field($start_date);
66
+ $end_date = sanitize_text_field($end_date);*/
67
+ $customer_id =(isset($_POST['google_ads_id']))?sanitize_text_field($_POST['google_ads_id']):"";
68
+ $page_size =(isset($_POST['page_size']))?sanitize_text_field($_POST['page_size']):"10";
69
+ $page_token =(isset($_POST['page_token']))?sanitize_text_field($_POST['page_token']):"";
70
+ $page =(isset($_POST['page']))?sanitize_text_field($_POST['page']):"";
71
+ if($customer_id != ""){
72
+ $api_rs = $this->campaign_pmax_list($customer_id, $page_size, $page_token, $page);
73
+ if (isset($api_rs->error) && $api_rs->error == '') {
74
+ if(isset($api_rs->data) && $api_rs->data != ""){
75
+ $return = array('error'=>false, 'data'=>$api_rs->data);
76
+ }
77
+ }else{
78
+ $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
79
+ $return = array('error'=>true,'errors'=>$errormsg, 'status' => $api_rs->status);
80
+ }
81
+ }
82
+ }else{
83
+ $return = array('error'=>true,'errors'=>esc_html__("Admin security nonce is not verified.","conversios"));
84
+ }
85
+ echo json_encode($return);
86
+ wp_die();
87
+ }
88
+ public function create_pmax_campaign(){
89
+ $nonce = (isset($_POST['conversios_nonce']))?sanitize_text_field($_POST['conversios_nonce']):"";
90
+ $return = array();
91
+ if($this->admin_safe_ajax_call($nonce, 'conversios_nonce')){
92
+ $data = isset($_POST['tvc_data'])?$_POST['tvc_data']:"";
93
+ $site_key = isset($_POST['site_key'])?$_POST['site_key']:"";
94
+ $site_url = isset($_POST['site_url'])?$_POST['site_url']:"";
95
+ $urls = array();
96
+ if(!empty($site_url)){
97
+ foreach($site_url as $key => $val){
98
+ if(isset($site_key[$key]) && $site_key[$key] && $val){
99
+ $urls[]=array("key"=>sanitize_text_field($site_key[$key]), "value" => sanitize_text_field($val));
100
+ }
101
+ }
102
+ }
103
+ //print_r($site_key);
104
+ //print_r($site_url);
105
+ parse_str($data, $form_array);
106
+ if(!empty($form_array)){
107
+ foreach ($form_array as $key => $value) {
108
+ $form_array[$key] = sanitize_text_field($value);
109
+ }
110
+ }
111
+ unset($form_array["site_key"]);
112
+ unset($form_array["site_url"]);
113
+ if($form_array["target_roas"] != ""){
114
+ $form_array["target_roas"] = $form_array["target_roas"]/100;
115
+ }else{
116
+ unset($form_array["target_roas"]);
117
+ }
118
+ if(!empty($urls)){
119
+ $form_array["urls"] = $urls;
120
+ }
121
+ $require_fields = array("customer_id","merchant_id","campaign_name","budget","target_country");
122
+ foreach($require_fields as $val){
123
+ if(isset($form_array[$val]) && $form_array[$val] ==""){
124
+ $return = array('error'=>true, 'message'=>esc_html__(str_replace("_"," ",$val)." is required field.","conversios"));
125
+ }
126
+ }
127
+ if(!empty($return)){
128
+ echo json_encode($return);
129
+ wp_die();
130
+ }else if(isset($form_array["customer_id"]) ){
131
+ $api_rs = $this->create_pmax_campaign_callapi($form_array);
132
+ if (isset($api_rs->error) && $api_rs->error == '') {
133
+ //print_r($api_rs->data);
134
+ if(isset($api_rs->data->results[0]->resourceName) && $api_rs->data != ""){
135
+ $resource_name = $api_rs->data->results[0]->resourceName;
136
+ $return = array('error'=>false, 'message'=> "Campaign Created Successfully with resource name - ".$resource_name);
137
+ }else if(isset($api_rs->data)){
138
+ $return = array('error'=>false, 'data' => $api_rs->data);
139
+ }
140
+ }else{
141
+ $errormsg = "";
142
+ if(!is_array($api_rs->errors) && is_string($api_rs->errors)){
143
+ $errormsg = $api_rs->errors;
144
+ }else{
145
+ $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
146
+ }
147
+ $return = array('error'=>true, 'message'=>$errormsg, 'status' => $api_rs->status);
148
+ }
149
+ }
150
+ }else{
151
+ $return = array('error'=>true, 'message' => esc_html__("Admin security nonce is not verified.","conversios"));
152
+ }
153
+ echo json_encode($return);
154
+ wp_die();
155
+ }
156
+ public function edit_pmax_campaign(){
157
+ $nonce = (isset($_POST['conversios_nonce']))?sanitize_text_field($_POST['conversios_nonce']):"";
158
+ $return = array();
159
+ if($this->admin_safe_ajax_call($nonce, 'conversios_nonce')){
160
+ $data = isset($_POST['tvc_data'])?$_POST['tvc_data']:"";
161
+ $site_key = isset($_POST['site_key'])?$_POST['site_key']:"";
162
+ $site_url = isset($_POST['site_url'])?$_POST['site_url']:"";
163
+ $urls = array();
164
+ if(!empty($site_url)){
165
+ foreach($site_url as $key => $val){
166
+ if(isset($site_key[$key]) && $site_key[$key] && $val){
167
+ $urls[]=array("key"=>sanitize_text_field($site_key[$key]), "value" => sanitize_text_field($val));
168
+ }
169
+ }
170
+ }
171
+ //print_r($site_key);
172
+ //print_r($site_url);
173
+ parse_str($data, $form_array);
174
+ if(!empty($form_array)){
175
+ foreach ($form_array as $key => $value) {
176
+ $form_array[$key] = sanitize_text_field($value);
177
+ }
178
+ }
179
+ unset($form_array["site_key"]);
180
+ unset($form_array["site_url"]);
181
+ $form_array["target_roas"] = $form_array["target_roas"]/100;
182
+ $form_array["urls"] = $urls;
183
+ $require_fields = array("customer_id","merchant_id","campaign_name","budget","target_country","campaign_budget_resource_name","resource_name");
184
+ foreach($require_fields as $val){
185
+ if(isset($form_array[$val]) && $form_array[$val] ==""){
186
+ $return = array('error'=>true, 'message'=>esc_html__(str_replace("_"," ",$val)." is required field.","conversios"));
187
+ }
188
+ }
189
+ if(!empty($return)){
190
+ echo json_encode($return);
191
+ wp_die();
192
+ }else if(isset($form_array["customer_id"]) ){
193
+ $api_rs = "";
194
+ if($form_array["status"] == "REMOVED"){
195
+ $api_rs = $this->delete_pmax_campaign_callapi( array("customer_id"=>$form_array["customer_id"], "resource_name"=>$form_array["resource_name"]) );
196
+ }else{
197
+ $api_rs = $this->edit_pmax_campaign_callapi($form_array);
198
+ }
199
+ if (isset($api_rs->error) && $api_rs->error == '') {
200
+ //print_r($api_rs->data);
201
+ if(isset($api_rs->data->results[0]->resourceName) && $api_rs->data != ""){
202
+ $resource_name = $api_rs->data->results[0]->resourceName;
203
+ if($form_array["status"] == "REMOVED"){
204
+ $return = array('error'=>false, 'message'=> "Campaign Removed Successfully with resource name - ".$resource_name);
205
+ }else{
206
+ $return = array('error'=>false, 'message'=> "Campaign Edit Successfully with resource name - ".$resource_name);
207
+ }
208
+ }else if(isset($api_rs->data)){
209
+ $return = array('error'=>false, 'data' => $api_rs->data);
210
+ }
211
+ }else{
212
+ $errormsg = "";
213
+ if(!is_array($api_rs->errors) && is_string($api_rs->errors)){
214
+ $errormsg = $api_rs->errors;
215
+ }else{
216
+ $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
217
+ }
218
+ $return = array('error'=>true, 'message'=>$errormsg, 'status' => $api_rs->status);
219
+ }
220
+ }
221
+ }else{
222
+ $return = array('error'=>true, 'message' => esc_html__("Admin security nonce is not verified.","conversios"));
223
+ }
224
+ echo json_encode($return);
225
+ wp_die();
226
+ }
227
+ /*public function get_google_ads_reports_chart(){
228
+ $nonce = (isset($_POST['conversios_nonce']))?sanitize_text_field($_POST['conversios_nonce']):"";
229
+ if($this->admin_safe_ajax_call($nonce, 'conversios_nonce')){
230
+ $start_date = str_replace(' ', '',(isset($_POST['start_date']))?sanitize_text_field($_POST['start_date']):"");
231
+ if($start_date != ""){
232
+ $date = DateTime::createFromFormat('d-m-Y', $start_date);
233
+ $start_date = $date->format('Y-m-d');
234
+ }
235
+ $start_date == (false !==strtotime( $start_date ))?date('Y-m-d', strtotime($start_date)):date( 'Y-m-d', strtotime( '-1 month' ));
236
+
237
+ $end_date = str_replace(' ', '',(isset($_POST['end_date']))?sanitize_text_field($_POST['end_date']):"");
238
+ if($end_date != ""){
239
+ $date = DateTime::createFromFormat('d-m-Y', $end_date);
240
+ $end_date = $date->format('Y-m-d');
241
+ }
242
+ $end_date == (false !==strtotime( $end_date ))?date('Y-m-d', strtotime($end_date)):date( 'Y-m-d', strtotime( 'now' ));
243
+ $start_date = sanitize_text_field($start_date);
244
+ $end_date = sanitize_text_field($end_date);
245
+ $api_rs = $this->ShoppingApi->accountPerformance_for_dashboard( $start_date, $end_date );
246
+ if (isset($api_rs->error) && $api_rs->error == '') {
247
+ if(isset($api_rs->data) && $api_rs->data != ""){
248
+ $return = array('error'=>false, 'data'=>$api_rs->data);
249
+ }
250
+ }else{
251
+ $errormsg= isset($api_rs->errors[0])?$api_rs->errors[0]:"";
252
+ $return = array('error'=>true,'errors'=>$errormsg, 'status' => $api_rs->status);
253
+ }
254
+ }else{
255
+ $return = array('error'=>true,'errors'=>esc_html__("Admin security nonce is not verified.","conversios"));
256
+ }
257
+ echo json_encode($return);
258
+ wp_die();
259
+ }*/
260
+
261
+ /*API CALL*/
262
+ public function campaign_pmax_detail($customer_id, $campaign_id) {
263
+ try {
264
+ $url = $this->apiDomain . '/pmax/detail';
265
+ $data = [
266
+ 'customer_id' => $customer_id,
267
+ 'campaign_id' => $campaign_id,
268
+ 'access_token' => $this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() )
269
+ ];
270
+ $header = array(
271
+ "Authorization: Bearer $this->token",
272
+ "Content-Type" => "application/json"
273
+ );
274
+ $args = array(
275
+ 'timeout' => 10000,
276
+ 'headers' =>$header,
277
+ 'method' => 'POST',
278
+ 'body' => wp_json_encode($data)
279
+ );
280
+ // Send remote request
281
+ $request = wp_remote_post(esc_url_raw($url), $args);
282
+
283
+ // Retrieve information
284
+ $response_code = wp_remote_retrieve_response_code($request);
285
+ $response_message = wp_remote_retrieve_response_message($request);
286
+ $result = json_decode(wp_remote_retrieve_body($request));
287
+ $return = new \stdClass();
288
+ // print_r($result);
289
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
290
+ $return->data = (isset($result->data))?$result->data:"";
291
+ $return->error = false;
292
+ return $return;
293
+ }else{
294
+ $return->error = true;
295
+ $return->data = (isset($result->data))?$result->data:"";
296
+ $return->errors = $result->errors;
297
+ $return->status = $response_code;
298
+ return $return;
299
+ }
300
+
301
+ } catch (Exception $e) {
302
+ return $e->getMessage();
303
+ }
304
+ }
305
+ public function campaign_pmax_list($customer_id, $page_size, $page_token, $page) {
306
+ try {
307
+ $url = $this->apiDomain . '/pmax/list';
308
+ $data = [
309
+ 'customer_id' => $customer_id,
310
+ 'page_size' => $page_size,
311
+ 'page_token' => $page_token,
312
+ 'access_token' => $this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() )
313
+ ];
314
+ $header = array(
315
+ "Authorization: Bearer $this->token",
316
+ "Content-Type" => "application/json"
317
+ );
318
+ $args = array(
319
+ 'timeout' => 10000,
320
+ 'headers' =>$header,
321
+ 'method' => 'POST',
322
+ 'body' => wp_json_encode($data)
323
+ );
324
+ //print_r($args);
325
+ // Send remote request
326
+ $request = wp_remote_post(esc_url_raw($url), $args);
327
+
328
+ // Retrieve information
329
+ $response_code = wp_remote_retrieve_response_code($request);
330
+ $response_message = wp_remote_retrieve_response_message($request);
331
+ $result = json_decode(wp_remote_retrieve_body($request));
332
+ $return = new \stdClass();
333
+ // print_r($result);
334
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
335
+ $return->data = (isset($result->data))?$result->data:"";
336
+ $return->error = false;
337
+ return $return;
338
+ }else{
339
+ $return->error = true;
340
+ $return->data = (isset($result->data))?$result->data:"";
341
+ $return->errors = $result->errors;
342
+ $return->status = $response_code;
343
+ return $return;
344
+ }
345
+
346
+ } catch (Exception $e) {
347
+ return $e->getMessage();
348
+ }
349
+ }
350
+
351
+ public function create_pmax_campaign_callapi($post_data) {
352
+ try {
353
+ $url = $this->apiDomain . '/pmax/create';
354
+ $post_data["access_token"] =$this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() );
355
+ // print_r($post_data);
356
+ $header = array(
357
+ "Authorization: Bearer $this->token",
358
+ "Content-Type" => "application/json"
359
+ );
360
+ $args = array(
361
+ 'timeout' => 10000,
362
+ 'headers' =>$header,
363
+ 'method' => 'POST',
364
+ 'body' => wp_json_encode($post_data)
365
+ );
366
+ //print_r($args);
367
+ // Send remote request
368
+ $request = wp_remote_post(esc_url_raw($url), $args);
369
+
370
+ // Retrieve information
371
+ $response_code = wp_remote_retrieve_response_code($request);
372
+ $response_message = wp_remote_retrieve_response_message($request);
373
+ $result = json_decode(wp_remote_retrieve_body($request));
374
+ $return = new \stdClass();
375
+ // print_r($result);
376
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
377
+ $return->data = (isset($result->data))?$result->data:"";
378
+ $return->error = false;
379
+ //print_r($return);
380
+ return $return;
381
+ }else{
382
+ $return->error = true;
383
+ $return->data = (isset($result->data))?$result->data:"";
384
+ $result->errors = (array)$result->errors;
385
+ if(!empty($result->errors) ){
386
+ if(count($result->errors) != count($result->errors, COUNT_RECURSIVE)){
387
+ $return->errors = implode(" & ",array_map(function($a) {return implode("~",$a);},$result->errors));
388
+ }else{
389
+ $return->errors = implode(" ",$result->errors);
390
+ }
391
+ }else{
392
+ $return->errors = $result->errors;
393
+ }
394
+ $return->status = $response_code;
395
+ return $return;
396
+ }
397
+
398
+ } catch (Exception $e) {
399
+ return $e->getMessage();
400
+ }
401
+ }
402
+
403
+ public function edit_pmax_campaign_callapi($post_data) {
404
+ try {
405
+ $url = $this->apiDomain . '/pmax/update';
406
+ $post_data["access_token"] =$this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() );
407
+ // print_r($post_data);
408
+ $header = array(
409
+ "Authorization: Bearer $this->token",
410
+ "Content-Type" => "application/json"
411
+ );
412
+ $args = array(
413
+ 'timeout' => 10000,
414
+ 'headers' =>$header,
415
+ 'method' => 'POST',
416
+ 'body' => wp_json_encode($post_data)
417
+ );
418
+ //print_r($args);
419
+ // Send remote request
420
+ $request = wp_remote_post(esc_url_raw($url), $args);
421
+
422
+ // Retrieve information
423
+ $response_code = wp_remote_retrieve_response_code($request);
424
+ $response_message = wp_remote_retrieve_response_message($request);
425
+ $result = json_decode(wp_remote_retrieve_body($request));
426
+ $return = new \stdClass();
427
+ // print_r($result);
428
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
429
+ $return->data = (isset($result->data))?$result->data:"";
430
+ $return->error = false;
431
+ //print_r($return);
432
+ return $return;
433
+ }else{
434
+ $return->error = true;
435
+ $return->data = (isset($result->data))?$result->data:"";
436
+ $result->errors = (array)$result->errors;
437
+ if(!empty($result->errors) ){
438
+ if(count($result->errors) != count($result->errors, COUNT_RECURSIVE)){
439
+ $return->errors = implode(" & ",array_map(function($a) {return implode("~",$a);},$result->errors));
440
+ }else{
441
+ $return->errors = implode(" ",$result->errors);
442
+ }
443
+ }else{
444
+ $return->errors = $result->errors;
445
+ }
446
+ $return->status = $response_code;
447
+ return $return;
448
+ }
449
+
450
+ } catch (Exception $e) {
451
+ return $e->getMessage();
452
+ }
453
+ }
454
+
455
+ public function delete_pmax_campaign_callapi($post_data) {
456
+ try {
457
+ $url = $this->apiDomain . '/pmax/delete';
458
+ $post_data["access_token"] =$this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() );
459
+ $header = array(
460
+ "Authorization: Bearer $this->token",
461
+ "Content-Type" => "application/json"
462
+ );
463
+ $args = array(
464
+ 'timeout' => 10000,
465
+ 'headers' =>$header,
466
+ 'method' => 'POST',
467
+ 'body' => wp_json_encode($post_data)
468
+ );
469
+ // Send remote request
470
+ $request = wp_remote_post(esc_url_raw($url), $args);
471
+
472
+ // Retrieve information
473
+ $response_code = wp_remote_retrieve_response_code($request);
474
+ $response_message = wp_remote_retrieve_response_message($request);
475
+ $result = json_decode(wp_remote_retrieve_body($request));
476
+ $return = new \stdClass();
477
+ //print_r($result);
478
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
479
+ $return->data = (isset($result->data))?$result->data:"";
480
+ $return->error = false;
481
+ //print_r($return);
482
+ return $return;
483
+ }else{
484
+ $return->error = true;
485
+ $return->data = (isset($result->data))?$result->data:"";
486
+ $result->errors = (array)$result->errors;
487
+ if(!empty($result->errors) ){
488
+ if(count($result->errors) != count($result->errors, COUNT_RECURSIVE)){
489
+ $return->errors = implode(" & ",array_map(function($a) {return implode("~",$a);},$result->errors));
490
+ }else{
491
+ $return->errors = implode(" ",$result->errors);
492
+ }
493
+ }else{
494
+ $return->errors = $result->errors;
495
+ }
496
+ $return->status = $response_code;
497
+ return $return;
498
+ }
499
+
500
+ } catch (Exception $e) {
501
+ return $e->getMessage();
502
+ }
503
+ }
504
+
505
+ public function get_campaign_currency_code($customer_id) {
506
+ try {
507
+ $url = $this->apiDomain . '/pmax/currency-code';
508
+ $data = [
509
+ 'customer_id' => $customer_id,
510
+ 'access_token' => $this->CustomApi->generateAccessToken( $this->CustomApi->get_tvc_access_token(), $this->CustomApi->get_tvc_refresh_token() )
511
+ ];
512
+ $header = array(
513
+ "Authorization: Bearer $this->token",
514
+ "Content-Type" => "application/json"
515
+ );
516
+ $args = array(
517
+ 'timeout' => 10000,
518
+ 'headers' =>$header,
519
+ 'method' => 'POST',
520
+ 'body' => wp_json_encode($data)
521
+ );
522
+ //print_r($args);
523
+ // Send remote request
524
+ $request = wp_remote_post(esc_url_raw($url), $args);
525
+
526
+ // Retrieve information
527
+ $response_code = wp_remote_retrieve_response_code($request);
528
+ $response_message = wp_remote_retrieve_response_message($request);
529
+ $result = json_decode(wp_remote_retrieve_body($request));
530
+ $return = new \stdClass();
531
+ // print_r($result);
532
+ if( isset($result->error) && isset($result->data) && $result->error == '' ) {
533
+ $return->data = (isset($result->data))?$result->data:"";
534
+ $return->error = false;
535
+ return $return;
536
+ }else{
537
+ $return->error = true;
538
+ $return->data = (isset($result->data))?$result->data:"";
539
+ $return->errors = (isset($result->errors))?$result->errors:"";
540
+ $return->status = $response_code;
541
+ return $return;
542
+ }
543
+
544
+ } catch (Exception $e) {
545
+ return $e->getMessage();
546
+ }
547
+ }
548
+
549
+ }
550
+ }
551
+ new Conversios_PMax_Helper();
admin/js/pmax-custom.js ADDED
@@ -0,0 +1,563 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $=jQuery;
2
+
3
+ jQuery(function() {
4
+ var tvc_time_out="";
5
+ var conversion_funnel_chart = "";
6
+ var conversion_bar_chart = "";
7
+ var checkout_funnel_chart = "";
8
+ var checkout_bar_chart = "";
9
+ });
10
+ var chart_ids = {};
11
+ var tvc_helper = {
12
+ add_message:function(type, msg, is_close = true){
13
+ let tvc_popup_box = document.getElementById('tvc_pmax_popup_box');
14
+ tvc_popup_box.classList.remove("tvc_popup_box_close");
15
+ tvc_popup_box.classList.add("tvc_popup_box");
16
+ if(type == "success"){
17
+ document.getElementById('tvc_pmax_popup_box').innerHTML ="<div class='alert tvc-alert-success'>"+msg+"</div>";
18
+ }else if(type == "error"){
19
+ document.getElementById('tvc_pmax_popup_box').innerHTML ="<div class='alert tvc-alert-error'>"+msg+"</div>";
20
+ }else if(type == "warning"){
21
+ document.getElementById('tvc_pmax_popup_box').innerHTML ="<div class='alert tvc-alert-warning'>"+msg+"</div>";
22
+ }
23
+ if(is_close){
24
+ tvc_time_out = setTimeout(function(){ //tvc_popup_box.style.display = "none";
25
+ tvc_popup_box.classList.add("tvc_popup_box_close");
26
+ tvc_popup_box.classList.remove("tvc_popup_box");
27
+ }, 8000);
28
+ }
29
+ },
30
+ tvc_alert:function(msg_type=null, msg_subject=null, msg, auto_close=false, tvc_time=7000){
31
+ document.getElementById('tvc_msg_title').innerHTML ="";
32
+ document.getElementById('tvc_msg_content').innerHTML ="";
33
+ document.getElementById('tvc_msg_icon').innerHTML ="";
34
+
35
+ if(msg != ""){
36
+ let tvc_popup_box = document.getElementById('tvc_popup_box');
37
+ tvc_popup_box.classList.remove("tvc_popup_box_close");
38
+ tvc_popup_box.classList.add("tvc_popup_box");
39
+
40
+ //tvc_popup_box.style.display = "block";
41
+ document.getElementById('tvc_msg_title').innerHTML =this.tvc_subject_title(msg_type, msg_subject);
42
+ document.getElementById('tvc_msg_content').innerHTML =msg;
43
+ if(msg_type=="success"){
44
+ document.getElementById('tvc_msg_icon').innerHTML ='<i class="fas fa-check-circle fa-3x tvc-success"></i>';
45
+ }else{
46
+ document.getElementById('tvc_msg_icon').innerHTML ='<i class="fas fa-exclamation-circle fa-3x"></i>';
47
+ }
48
+ if(auto_close == true){
49
+ setTimeout(function(){ //tvc_popup_box.style.display = "none";
50
+ tvc_popup_box.classList.add("tvc_popup_box_close");
51
+ tvc_popup_box.classList.remove("tvc_popup_box");
52
+ }
53
+ , tvc_time);
54
+ }
55
+ }
56
+ },
57
+ tvc_subject_title:function(msg_type=null, msg_subject=null){
58
+ if(msg_subject == null || msg_subject ==""){
59
+ if(msg_type=="success" ){
60
+ return '<span class="tvc-success">Success!!</span>';
61
+ }else{
62
+ return '<span class="tvc-error">Oops!</span>';
63
+ }
64
+ }else{
65
+ if(msg_type=="success" ){
66
+ return '<span class="tvc-success">'+msg_subject+'</span>';
67
+ }else{
68
+ return '<span>'+msg_subject+'</span>';
69
+ }
70
+ }
71
+ },
72
+ tvc_close_msg:function(){
73
+ let tvc_popup_box = document.getElementById('tvc_popup_box');
74
+ tvc_popup_box.classList.add("tvc_popup_box_close");
75
+ tvc_popup_box.classList.remove("tvc_popup_box");
76
+ //tvc_popup_box.style.display = "none";
77
+ },
78
+ loaderSection:function(isShow) {
79
+ if (isShow){
80
+ jQuery('#feed-spinner').show();
81
+ }else{
82
+ jQuery('#feed-spinner').hide();
83
+ }
84
+ },
85
+ get_call_ajax_request:function(post_data){
86
+ //console.log(post_data);
87
+ //post_data.plan_id
88
+ this.cleare_data();
89
+ this.add_loader();
90
+ this.google_ads_pmax_call_api(post_data);
91
+ },
92
+ google_ads_pmax_call_api:function(post_data){
93
+ // Shopping and Google Ads Performance
94
+ //post_data['action']='get_google_ads_reports_chart';
95
+ var v_this = this;
96
+ /*$.ajax({
97
+ type: "POST",
98
+ dataType: "json",
99
+ url: tvc_ajax_url,
100
+ data: post_data,
101
+ success: function (response) {
102
+ console.log(response);
103
+ if(response.error == false){
104
+ if(Object.keys(response.data).length > 0){
105
+ v_this.set_google_ads_reports_chart_value(response.data, post_data);
106
+ }
107
+ }else{
108
+ if(response.status == "423" || response.status == "400"){
109
+ v_this.tvc_alert("error","", "If Google Ads Performance Data is not generated please make sure your Google Ads account should link with our MCC account");
110
+ }else{
111
+ v_this.tvc_alert("error", "", response?.errors);
112
+ }
113
+ }
114
+ v_this.remove_loader_for_analytics_reports();
115
+ }
116
+ });*/
117
+ //Compaign Performance List
118
+ post_data['action']='get_pmax_campaign_list';
119
+ var v_this = this;
120
+ jQuery.ajax({
121
+ type: "POST",
122
+ dataType: "json",
123
+ url: tvc_ajax_url,
124
+ data: post_data,
125
+ success: function (response) {
126
+ console.log(response);
127
+ if(response.error == false){
128
+ if(response.data.hasOwnProperty('results') && Object.keys(response.data.results).length > 0){
129
+ v_this.set_google_ads_reports_campaign_performance_value(response.data.results, post_data);
130
+ }else{
131
+ v_this.set_google_ads_reports_campaign_performance_value("", post_data);
132
+ }
133
+ }else{
134
+ if(response.errors != ""){
135
+ //v_this.tvc_alert("error","",response.errors);
136
+ }
137
+ }
138
+ var page_token = post_data['page_token'];
139
+ var page = post_data['page'];
140
+ jQuery("#page_no").html(page);
141
+ //console.log("page"+page+ response.data.nextPageToken);
142
+ var pre_token = jQuery(".pgnextbtn").attr("data-token");
143
+ //console.log("pre_token"+pre_token);
144
+ if(page > 2){
145
+ jQuery(".pgprevbtn").attr("data-token",pre_token);
146
+ jQuery(".pgprevbtn").prop("disabled", false);
147
+ }else if(page == 2){
148
+ jQuery(".pgprevbtn").attr("data-token","");
149
+ jQuery(".pgprevbtn").prop("disabled", false);
150
+ }else if(page == 1){
151
+ jQuery(".pgprevbtn").attr("data-token","");
152
+ jQuery(".pgprevbtn").prop("disabled", true);
153
+ jQuery(".pgnextbtn").prop("disabled", false);
154
+ }
155
+ if(response.data.nextPageToken != "" && response.data.nextPageToken != undefined){
156
+ jQuery(".pgnextbtn").attr("data-token",response.data.nextPageToken);
157
+ }else{
158
+ jQuery(".pgnextbtn").attr("data-token","");
159
+ jQuery(".pgnextbtn").prop("disabled", true);
160
+ }
161
+ v_this.remove_loader_for_analytics_reports();
162
+ }
163
+ });
164
+ },
165
+ set_google_ads_reports_campaign_performance_value:function(data, post_data){
166
+ //if(data.hasOwnProperty('data')){
167
+ //var p_p_r = data.product_performance_report.products;
168
+ //console.log(p_p_r);
169
+ var table_row = '';
170
+ var table_row_last = '';
171
+ var product_revenue_per = 0;
172
+ var status = "";
173
+ var daily_budget = "";
174
+ var cost_micros = "";
175
+ var v_this = this;
176
+ var currency_symbol = post_data['currency_symbol'];
177
+ if(data != undefined && Object.keys(data).length > 0){
178
+ var i=0;
179
+ jQuery.each(data, function (propKey, propValue) {
180
+ //console.log(propValue);
181
+ //if(i<5){
182
+ //table_row = ''; table_row_last = '';
183
+ status = (propValue.campaign.status== "ENABLED")?'Enabled':'Paused';
184
+ daily_budget = parseInt(propValue.campaignBudget.amountMicros/1000000).toFixed(2);
185
+ if( parseInt(daily_budget) < 0 || daily_budget == "undefined" ){
186
+ daily_budget = "";
187
+ }
188
+ cost_micros = (propValue.metrics.costMicros/1000000).toFixed(2);
189
+ if(status == 'Enabled'){
190
+ table_row += '<tr><td class="prdnm-cell">'+propValue.campaign.name+'</td>';
191
+ table_row += '<td>'+v_this.numberWithCommas(daily_budget)+'</td>';
192
+ table_row += '<td>'+status+'</td>';
193
+ table_row += '<td>'+propValue.metrics.clicks+'</td>';
194
+ table_row += '<td>'+v_this.numberWithCommas(cost_micros)+'</td>';
195
+ table_row += '<td>'+v_this.numberWithCommas(propValue.metrics.conversions.toFixed(2))+'</td>';
196
+ table_row += '<td>'+v_this.numberWithCommas(propValue.metrics.conversionsValue.toFixed(2))+'</td><td><a href="admin.php?page=conversios-pmax&tab=pmax_edit&id='+propValue.campaign.id+'">Edit Campaign</a></td></tr>';
197
+ }else{
198
+ table_row_last += '<tr><td class="prdnm-cell">'+propValue.campaign.name+'</td>';
199
+ table_row_last += '<td>'+daily_budget+'</td>';
200
+ table_row_last += '<td>'+status+'</td>';
201
+ table_row_last += '<td>'+propValue.metrics.clicks+'</td>';
202
+ table_row_last += '<td>'+v_this.numberWithCommas(cost_micros)+'</td>';
203
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue.metrics.conversions.toFixed(2))+'</td>';
204
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue.metrics.conversionsValue.toFixed(2))+'</td><td><a href="admin.php?page=conversios-pmax&tab=pmax_edit&id='+propValue.campaign.id+'">Edit Campaign</a></td></tr>';
205
+ }
206
+ i = i+1;
207
+ //}
208
+ });
209
+ jQuery("#campaign_pmax_list table tbody").append(table_row);
210
+ jQuery("#campaign_pmax_list table tbody").append(table_row_last);
211
+ }else{
212
+ jQuery("#campaign_pmax_list table tbody").append("<tr><td colspan='7'>Data not available</td></tr>");
213
+ }
214
+ //}
215
+ },
216
+ set_google_ads_reports_chart_value:function(data, post_data){
217
+ var v_this = this;
218
+ var s_1_div_id ={
219
+ 'daily_clicks':{
220
+ 'id':'dailyClicks',
221
+ 'type':'number',
222
+ 'is_chart':true,
223
+ 'chart_type':'line',
224
+ 'chart_value_field_id':'clicks',
225
+ 'chart_title':'Clicks',
226
+ 'chart_id':'dailyClicks'
227
+ },'daily_cost':{
228
+ 'id':'dailyCost',
229
+ 'type':'currency',
230
+ 'is_chart':true,
231
+ 'chart_type':'line',
232
+ 'chart_value_field_id':'costs',
233
+ 'chart_title':'Cost',
234
+ 'chart_id':'dailyCost'
235
+ },'daily_conversions':{
236
+ 'id':'dailyConversions',
237
+ 'type':'number',
238
+ 'is_chart':true,
239
+ 'chart_type':'line',
240
+ 'chart_value_field_id':'conversions',
241
+ 'chart_title':'Conversions',
242
+ 'chart_id':'dailyConversions'
243
+ },'daily_sales':{
244
+ 'id':'dailySales',
245
+ 'type':'number',
246
+ 'is_chart':true,
247
+ 'chart_type':'line',
248
+ 'chart_value_field_id':'sales',
249
+ 'chart_title':'Sales',
250
+ 'chart_id':'dailySales'
251
+ }
252
+ };
253
+ if(Object.keys(s_1_div_id).length > 0){
254
+ var labels_key = "";
255
+ if(data.hasOwnProperty('graph_type')){
256
+ labels_key = data['graph_type'];
257
+ }
258
+ jQuery.each(s_1_div_id, function (propKey, propValue) {
259
+ if(data.hasOwnProperty(propValue['id'])){
260
+ if(propValue['chart_id']!= undefined && propValue['is_chart'] != undefined && propValue['chart_type'] != undefined){
261
+ var chart_id = propValue['chart_id'];
262
+ var field_id = propValue['chart_value_field_id'];
263
+ var chart_title = propValue['chart_title'];
264
+ //console.log(propValue['chart_type']+"call"+chart_id);
265
+ if(propValue['chart_type'] == 'line'){
266
+ v_this.drow_google_ads_chart(chart_id, data[propValue['id']], field_id, chart_title, labels_key);
267
+ }
268
+ }
269
+ }
270
+ });
271
+ }
272
+
273
+ },
274
+ drow_google_ads_chart:function(chart_id, alldata, field_key, d_label, labels_key){
275
+ var chart_data = alldata;
276
+ var ctx = document.getElementById(chart_id).getContext('2d');
277
+ var gradientFill = ctx.createLinearGradient(0, 0, 0, 500);
278
+ if(chart_id == 'dailyClicks'){
279
+ gradientFill.addColorStop(0.4, 'rgba(153, 170, 255, 0.9)');
280
+ gradientFill.addColorStop(0.85, 'rgba(255, 255, 255, 0.7)');
281
+ }else if(chart_id =='dailyCost'){
282
+ gradientFill.addColorStop(0.4, 'rgba(110, 245, 197, 0.9)');
283
+ gradientFill.addColorStop(0.85, 'rgba(255, 255, 255, 0.7)');
284
+ }else if(chart_id =='dailyConversions'){
285
+ gradientFill.addColorStop(0.4, 'rgba(255, 229, 139, 0.9)');
286
+ gradientFill.addColorStop(0.85, 'rgba(255, 255, 255, 0.7)');
287
+ }else if(chart_id =='dailySales'){
288
+ gradientFill.addColorStop(0.4, 'rgba(107, 232, 255, 0.9)');
289
+ gradientFill.addColorStop(0.85, 'rgba(255, 255, 255, 0.75)');
290
+ }
291
+ const labels = [];
292
+ const chart_val = [];
293
+ var t_labels = "";
294
+
295
+ //var d_backgroundColors = ['#FF6384','#22CFCF','#0ea50b','#FF9F40','#FFCD56']
296
+ jQuery.each(chart_data, function (key, value) {
297
+ if(labels_key != "" && value.hasOwnProperty(labels_key)){
298
+ t_labels =value[labels_key];
299
+ }else{
300
+ t_labels = value['date'];
301
+ }
302
+ labels.push(t_labels.toString());
303
+ //chart_val.push(value[field_key]);
304
+ chart_val.push(((value[field_key]!=null)?value[field_key]:0));
305
+ });
306
+ //console.log(alldata);
307
+ //console.log(field_key);
308
+ //console.log(chart_val);
309
+ const data = {
310
+ labels: labels,
311
+ datasets: [
312
+ {
313
+ data: chart_val,
314
+ borderColor: '#002BFC',
315
+ pointBorderColor: '#002BFC',
316
+ pointBackgroundColor: '#fff',
317
+ pointBorderWidth: 1,
318
+ pointRadius: 2,
319
+ fill: true,
320
+ backgroundColor: gradientFill,
321
+ borderWidth: 1
322
+ }
323
+ ]
324
+ };
325
+ const config = {
326
+ type: 'line',
327
+ data: data,
328
+ options: {
329
+ animation: {
330
+ easing: "easeInOutBack"
331
+ },
332
+ plugins:{
333
+ legend:false
334
+ },
335
+ responsive: true,
336
+ scales: {
337
+ y:{
338
+ fontColor: "#ffffff",
339
+ fontStyle: "normal",
340
+ beginAtZero: true,
341
+ maxTicksLimit: 5,
342
+ padding: 30,
343
+ grid:{
344
+ borderWidth:0,
345
+ },
346
+ ticks: {
347
+ stepSize: 1000,
348
+ callback: function(value) {
349
+ var ranges = [
350
+ { divider: 1e6, suffix: 'M' },
351
+ { divider: 1e3, suffix: 'k' }
352
+ ];
353
+ function formatNumber(n) {
354
+ for (var i = 0; i < ranges.length; i++) {
355
+ if (n >= ranges[i].divider) {
356
+ return (n / ranges[i].divider).toString() + ranges[i].suffix;
357
+ }
358
+ }
359
+ return n;
360
+ }
361
+ return '' + formatNumber(value);
362
+ }
363
+ }
364
+ },
365
+ x:{
366
+ padding: 10,
367
+ fontColor: "#ffffff",
368
+ fontStyle: "normal",
369
+ grid: {
370
+ display:false
371
+ }
372
+ }
373
+ }
374
+ }
375
+ };
376
+ chart_ids[chart_id] = new Chart(ctx,config);
377
+ },
378
+ google_analytics_reports_call_api:function(post_data){
379
+ var v_this = this;
380
+ var g_mail = post_data.g_mail;
381
+ jQuery.ajax({
382
+ type: "POST",
383
+ dataType: "json",
384
+ url: tvc_ajax_url,
385
+ data: post_data,
386
+ success: function (response) {
387
+ console.log(response);
388
+ if(response.error == false){
389
+ if(Object.keys(response.data).length > 0){
390
+ v_this.set_google_analytics_reports_value(response.data, post_data);
391
+ }
392
+ }else if(response.error == true && response.errors != undefined){
393
+ const errors = response.errors;
394
+ if(response.errors == "access_token_error"){
395
+ if(g_mail != ""){
396
+ v_this.tvc_alert("error","","It seems the token to access your Google Analytics account is expired. Sign in with "+g_mail+" again to reactivate the token. <span class='google_connect_url'>Click here..</span>");
397
+ }else{
398
+ v_this.tvc_alert("error","","It seems the token to access your Google Analytics account is expired. Sign in with the connected email again to reactivate the token. <span class='google_connect_url'>Click here..</span>");
399
+ }
400
+ }else{
401
+ v_this.tvc_alert("error","Error",errors);
402
+ }
403
+ }else{
404
+ v_this.tvc_alert("error","Error","Analytics report data not fetched");
405
+ }
406
+ v_this.remove_loader_for_analytics_reports();
407
+ }
408
+ });
409
+ },
410
+ display_field_val:function(div_id, field, field_val, field_type, currency_code, plugin_url){
411
+ if(field_type == "currency"){
412
+ if(Math.floor(field_val) != field_val){
413
+ field_val = parseFloat(field_val).toFixed(2);
414
+ }
415
+ var currency = this.get_currency_symbols(currency_code);
416
+ jQuery(div_id).html(currency +''+field_val);
417
+ }else if(field_type == "rate"){
418
+ field_val = parseFloat(field_val).toFixed(2);
419
+ var img = "";
420
+ if(plugin_url != "" && plugin_url != undefined){
421
+ img = '<img src="'+plugin_url+'/admin/images/red-down.png">';
422
+ if(field_val >0){
423
+ img = '<img src="'+plugin_url+'/admin/images/green-up.png">';
424
+ }
425
+ }
426
+ jQuery(div_id).html(img+field_val+'%');
427
+ }else {
428
+ if(Math.floor(field_val) != field_val){
429
+ field_val = parseFloat(field_val).toFixed(2);
430
+ }
431
+
432
+ jQuery(div_id).html(field_val);
433
+ }
434
+
435
+ },
436
+ remove_loader_for_analytics_reports:function(){
437
+ var reg_section = this.get_sections_list();
438
+ if(Object.keys(reg_section).length > 0){
439
+ jQuery.each(reg_section, function (propKey, propValue) {
440
+ if(propValue.hasOwnProperty('main-class') && propValue.hasOwnProperty('loading-type')){
441
+ if(propValue['loading-type'] == 'bgcolor'){
442
+ //jQuery("."+propValue['main-class']).addClass("is_loading");
443
+ if(Object.keys(propValue['ajax_fields']).length > 0){
444
+ jQuery.each(propValue['ajax_fields'], function (propKey, propValue) {
445
+ jQuery("."+propValue['class']).removeClass("loading-bg-effect");
446
+ });
447
+ }
448
+ }else if(propValue['loading-type'] == 'gif'){
449
+ jQuery("."+propValue['main-class']).removeClass("is_loading");
450
+ }
451
+
452
+ }
453
+ });
454
+ }
455
+ },
456
+ cleare_data:function(){
457
+ var v_this = this;
458
+ jQuery("#campaign_pmax_list table tbody").html("");
459
+ var canvas = document.getElementById('ecomfunchart');
460
+ if( canvas != null){
461
+ var is_blank = this.is_canvas_blank(canvas);
462
+ if(!is_blank){
463
+ conversion_bar_chart.destroy();
464
+ //const canvas = document.getElementById('ecomfunchart');
465
+ //canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
466
+ }
467
+ }
468
+ canvas = document.getElementById('ecomcheckoutfunchart');
469
+ if(canvas != null){
470
+ var is_blank = this.is_canvas_blank(canvas);
471
+ if(!is_blank){
472
+ checkout_bar_chart.destroy();
473
+ }
474
+ }
475
+
476
+ if(Object.keys(chart_ids).length > 0){
477
+ jQuery.each(chart_ids, function (propKey, propValue) {
478
+ var canvas = document.getElementById(propKey);
479
+ if( canvas != null){
480
+ var is_blank = v_this.is_canvas_blank(canvas);
481
+ //console.log(propValue+"-"+canvas+"-"+is_blank);
482
+ if(!is_blank){
483
+ chart_ids[propKey].destroy();
484
+ }
485
+ }
486
+ });
487
+ }
488
+ },
489
+ add_loader:function(){
490
+ var reg_section = this.get_sections_list();
491
+ if(Object.keys(reg_section).length > 0){
492
+ jQuery.each(reg_section, function (propKey, propValue) {
493
+ if(propValue.hasOwnProperty('main-class') && propValue.hasOwnProperty('loading-type')){
494
+ if(propValue['loading-type'] == 'bgcolor'){
495
+ //jQuery("."+propValue['main-class']).addClass("is_loading");
496
+ if(Object.keys(propValue['ajax_fields']).length > 0){
497
+ jQuery.each(propValue['ajax_fields'], function (propKey, propValue) {
498
+ jQuery("."+propValue['class']).addClass("loading-bg-effect");
499
+ });
500
+ }
501
+ }else if(propValue['loading-type'] == 'gif'){
502
+ jQuery("."+propValue['main-class']).addClass("is_loading");
503
+ }
504
+
505
+ }
506
+ });
507
+ }
508
+ },
509
+ get_sections_list:function(){
510
+ return {
511
+ 'dashboard_summary':{
512
+ 'loading-type':'bgcolor',
513
+ 'main-class':'dashsmry-item',
514
+ 'sub-clsass':'dashsmrybx',
515
+ 'ajax_fields':{
516
+ 'field_1':{
517
+ 'class':'dash-smry-title'
518
+ },'field_2':{
519
+ 'class':'dash-smry-value'
520
+ },'field_3':{
521
+ 'class':'dash-smry-compare-val'
522
+ },'field_4':{
523
+ 'class':'dshsmryprdtxt'
524
+ }
525
+ }
526
+ },'campaign_pmax_list':{
527
+ 'loading-type':'gif',
528
+ 'main-class':'campaign_pmax_list',
529
+ }
530
+ };
531
+ },numberWithCommas:function(x) {
532
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
533
+ },get_currency_symbols:function(code){
534
+ var currency_symbols = {
535
+ 'USD': '$', // US Dollar
536
+ 'EUR': '€', // Euro
537
+ 'CRC': '₡', // Costa Rican Colón
538
+ 'GBP': '£', // British Pound Sterling
539
+ 'ILS': '₪', // Israeli New Sheqel
540
+ 'INR': '₹', // Indian Rupee
541
+ 'JPY': '¥', // Japanese Yen
542
+ 'KRW': '₩', // South Korean Won
543
+ 'NGN': '₦', // Nigerian Naira
544
+ 'PHP': '₱', // Philippine Peso
545
+ 'PLN': 'zł', // Polish Zloty
546
+ 'PYG': '₲', // Paraguayan Guarani
547
+ 'THB': '฿', // Thai Baht
548
+ 'UAH': '₴', // Ukrainian Hryvnia
549
+ 'VND': '₫', // Vietnamese Dong
550
+ };
551
+ if(currency_symbols[code]!==undefined) {
552
+ return currency_symbols[code];
553
+ }else{
554
+ return code;
555
+ }
556
+ },is_canvas_blank:function (canvas) {
557
+ const context = canvas.getContext('2d');
558
+ const pixelBuffer = new Uint32Array(
559
+ context.getImageData(0, 0, canvas.width, canvas.height).data.buffer
560
+ );
561
+ return !pixelBuffer.some(color => color !== 0);
562
+ }
563
+ };
admin/js/tvc-ee-custom.js CHANGED
@@ -127,6 +127,7 @@ var tvc_helper = {
127
  var table_row_last = '';
128
  var product_revenue_per = 0;
129
  var status = "";
 
130
  if(data != undefined && Object.keys(data).length > 0){
131
  var i=0;
132
  $.each(data, function (propKey, propValue) {
@@ -135,20 +136,20 @@ var tvc_helper = {
135
  status = (propValue['active'] == 1)?'active':'deactivate';
136
  if(status == 'active'){
137
  table_row += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
138
- table_row += '<td>'+propValue['dailyBudget']+'</td>';
139
  table_row += '<td>'+status+'</td>';
140
  table_row += '<td>'+propValue['clicks']+'</td>';
141
- table_row += '<td>'+propValue['cost']+'</td>';
142
- table_row += '<td>'+propValue['conversions']+'</td>';
143
- table_row += '<td>'+propValue['sales']+'</td></tr>';
144
  }else{
145
  table_row_last += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
146
- table_row_last += '<td>'+propValue['dailyBudget']+'</td>';
147
  table_row_last += '<td>'+status+'</td>';
148
  table_row_last += '<td>'+propValue['clicks']+'</td>';
149
- table_row_last += '<td>'+propValue['cost']+'</td>';
150
- table_row_last += '<td>'+propValue['conversions']+'</td>';
151
- table_row_last += '<td>'+propValue['sales']+'</td></tr>';
152
  }
153
  i = i+1;
154
  }
@@ -787,7 +788,7 @@ var tvc_helper = {
787
  field_val = parseFloat(field_val).toFixed(2);
788
  }
789
  var currency = this.get_currency_symbols(currency_code);
790
- jQuery(div_id).html(currency +''+field_val);
791
  }else if(field_type == "rate"){
792
  field_val = parseFloat(field_val).toFixed(2);
793
  var img = "";
@@ -802,8 +803,7 @@ var tvc_helper = {
802
  if(Math.floor(field_val) != field_val){
803
  field_val = parseFloat(field_val).toFixed(2);
804
  }
805
-
806
- jQuery(div_id).html(field_val);
807
  }
808
 
809
  },
@@ -958,5 +958,7 @@ var tvc_helper = {
958
  context.getImageData(0, 0, canvas.width, canvas.height).data.buffer
959
  );
960
  return !pixelBuffer.some(color => color !== 0);
 
 
961
  }
962
  };
127
  var table_row_last = '';
128
  var product_revenue_per = 0;
129
  var status = "";
130
+ var v_this = this;
131
  if(data != undefined && Object.keys(data).length > 0){
132
  var i=0;
133
  $.each(data, function (propKey, propValue) {
136
  status = (propValue['active'] == 1)?'active':'deactivate';
137
  if(status == 'active'){
138
  table_row += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
139
+ table_row += '<td>'+v_this.numberWithCommas(propValue['dailyBudget'].toFixed(2))+'</td>';
140
  table_row += '<td>'+status+'</td>';
141
  table_row += '<td>'+propValue['clicks']+'</td>';
142
+ table_row += '<td>'+v_this.numberWithCommas(propValue['cost'].toFixed(2))+'</td>';
143
+ table_row += '<td>'+v_this.numberWithCommas(propValue['conversions'].toFixed(2))+'</td>';
144
+ table_row += '<td>'+v_this.numberWithCommas(propValue['sales'].toFixed(2))+'</td></tr>';
145
  }else{
146
  table_row_last += '<tr><td class="prdnm-cell">'+propValue['compaignName']+'</td>';
147
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue['dailyBudget'].toFixed(2))+'</td>';
148
  table_row_last += '<td>'+status+'</td>';
149
  table_row_last += '<td>'+propValue['clicks']+'</td>';
150
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue['cost'].toFixed(2))+'</td>';
151
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue['conversions'].toFixed(2))+'</td>';
152
+ table_row_last += '<td>'+v_this.numberWithCommas(propValue['sales'].toFixed(2))+'</td></tr>';
153
  }
154
  i = i+1;
155
  }
788
  field_val = parseFloat(field_val).toFixed(2);
789
  }
790
  var currency = this.get_currency_symbols(currency_code);
791
+ jQuery(div_id).html(currency +''+this.numberWithCommas(field_val));
792
  }else if(field_type == "rate"){
793
  field_val = parseFloat(field_val).toFixed(2);
794
  var img = "";
803
  if(Math.floor(field_val) != field_val){
804
  field_val = parseFloat(field_val).toFixed(2);
805
  }
806
+ jQuery(div_id).html(this.numberWithCommas(field_val));
 
807
  }
808
 
809
  },
958
  context.getImageData(0, 0, canvas.width, canvas.height).data.buffer
959
  );
960
  return !pixelBuffer.some(color => color !== 0);
961
+ },numberWithCommas:function(x) {
962
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
963
  }
964
  };
admin/partials/class-conversios-header.php CHANGED
@@ -137,6 +137,10 @@ if ( ! class_exists( 'Conversios_Header' ) ) {
137
  ),
138
  'conversios-google-shopping-feed'=>array('title'=>esc_html__('Google Shopping','conversios')),
139
  'conversios-google-ads'=>array('title'=>esc_html__('Google Ads','conversios')),
 
 
 
 
140
  'conversios-google-analytics'=>array('title'=>esc_html__('Account Settings','conversios')),
141
  );
142
  }
137
  ),
138
  'conversios-google-shopping-feed'=>array('title'=>esc_html__('Google Shopping','conversios')),
139
  'conversios-google-ads'=>array('title'=>esc_html__('Google Ads','conversios')),
140
+ 'conversios-pmax'=>array('title'=>esc_html__('Performance Max','conversios'),
141
+ 'icon'=>esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/conversios-google-ads-menu.png"),
142
+ 'acitve_icon'=>esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/active-conversios-google-ads-menu.png")
143
+ ),
144
  'conversios-google-analytics'=>array('title'=>esc_html__('Account Settings','conversios')),
145
  );
146
  }
admin/partials/general-fields.php CHANGED
@@ -162,7 +162,7 @@ if(isset($google_detail['setting'])){
162
  <table class="table">
163
  <tbody>
164
  <tr>
165
- <th width="150px">
166
  <label class="align-middle" for="tracking_code"><?php esc_html_e("Tracking Code","conversios"); ?></label>
167
  </th>
168
  <td>
@@ -191,12 +191,13 @@ if(isset($google_detail['setting'])){
191
  </tr>
192
  <tr>
193
  <th>
194
- <label class="align-middle" for= "ga_CG" ><?php esc_html_e("Content Grouping","conversios"); ?></label>
195
  </th>
196
  <td>
197
  <label class = "align-middle">
198
- <?php $ga_CG = !empty($data['ga_CG']) ? 'checked' : ''; ?>
199
- <input type="checkbox" name="ga_CG" id="ga_CG" <?php echo esc_attr($ga_CG);?> >
 
200
  <label class="custom-control-label" for="ga_CG"><?php esc_html_e("Add Code to enable content grouping","conversios"); ?> <i>(Optional)</i></label>
201
  <p class="description" style="text-align: justify;"><?php esc_html_e("Content grouping helps you group your web pages (content). To use this feature create Content Grouping in your GA as instructed in the","conversios"); ?> <a href="<?php echo esc_url_raw("https://conversios.io/help-center/Installation-Manual.pdf"); ?>" target="_blank"><?php esc_html_e("Installation Doc","conversios"); ?></a>.</p>
202
  </label>
@@ -204,10 +205,15 @@ if(isset($google_detail['setting'])){
204
  </tr>
205
  <tr>
206
  <th>
207
- <label class="align-middle" for= "ga_optimize" ><?php esc_html_e("Google Optimize","conversios"); ?></label>
208
  </th>
209
  <td>
210
- <input style="margin-top:10px;" type="text" size="30" name="ga_optimize_id" id="ga_optimize_id" value = "<?php echo !empty($data['ga_optimize_id']) ? esc_attr($data['ga_optimize_id']) : '';?>" placeholder="<?php esc_html_e("Google Optimize ID","conversios"); ?>">
 
 
 
 
 
211
  <i style="cursor: help;" class="fas fa-question-circle" id="ga_optimize_id" title="Enter a valid google optimize container ID."></i>
212
  </td>
213
  </tr>
@@ -384,7 +390,7 @@ jQuery(document).ready(function () {
384
  action: "tvc_call_active_licence",
385
  licence_key:licence_key
386
  };
387
- $.ajax({
388
  type: "POST",
389
  dataType: "json",
390
  url: tvc_ajax_url,
162
  <table class="table">
163
  <tbody>
164
  <tr>
165
+ <th width="155px">
166
  <label class="align-middle" for="tracking_code"><?php esc_html_e("Tracking Code","conversios"); ?></label>
167
  </th>
168
  <td>
191
  </tr>
192
  <tr>
193
  <th>
194
+ <label class="align-middle" for= "ga_CG" ><?php esc_html_e("Content Grouping","conversios"); ?> <span class="tvc-pro"> (PRO)</span></label>
195
  </th>
196
  <td>
197
  <label class = "align-middle">
198
+ <?php $ga_CG = (!empty($data['ga_CG'])) ? 'checked' : '';
199
+ if($plan_id==1){ $ga_CG ="";}?>
200
+ <input type="checkbox" name="ga_CG" id="ga_CG" <?php if($plan_id==1){?> onclick="return false;"<?php } ?> <?php echo esc_attr($ga_CG);?> >
201
  <label class="custom-control-label" for="ga_CG"><?php esc_html_e("Add Code to enable content grouping","conversios"); ?> <i>(Optional)</i></label>
202
  <p class="description" style="text-align: justify;"><?php esc_html_e("Content grouping helps you group your web pages (content). To use this feature create Content Grouping in your GA as instructed in the","conversios"); ?> <a href="<?php echo esc_url_raw("https://conversios.io/help-center/Installation-Manual.pdf"); ?>" target="_blank"><?php esc_html_e("Installation Doc","conversios"); ?></a>.</p>
203
  </label>
205
  </tr>
206
  <tr>
207
  <th>
208
+ <label class="align-middle" for= "ga_optimize" ><?php esc_html_e("Google Optimize","conversios"); ?> <span class="tvc-pro"> (PRO)</span></label>
209
  </th>
210
  <td>
211
+ <?php
212
+ if($plan_id==1){?>
213
+ <input type="text" name="ga_optimize_id" id="ga_optimize_id" value = "<?php echo !empty($data['ga_optimize_id']) ? esc_attr($data['ga_optimize_id']) : '';?>" placeholder="<?php esc_html_e("Google Optimize ID","conversios"); ?>" disabled>
214
+ <?php }else{ ?>
215
+ <input type="text" name="ga_optimize_id" id="ga_optimize_id" value = "<?php echo !empty($data['ga_optimize_id']) ? esc_attr($data['ga_optimize_id']) : '';?>" placeholder="<?php esc_html_e("Google Optimize ID","conversios"); ?>">
216
+ <?php } ?>
217
  <i style="cursor: help;" class="fas fa-question-circle" id="ga_optimize_id" title="Enter a valid google optimize container ID."></i>
218
  </td>
219
  </tr>
390
  action: "tvc_call_active_licence",
391
  licence_key:licence_key
392
  };
393
+ jQuery.ajax({
394
  type: "POST",
395
  dataType: "json",
396
  url: tvc_ajax_url,
enhanced-ecommerce-google-analytics.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
- * Version: 4.7.5
19
  * Author: Conversios
20
  * Author URI: conversios.io
21
  * License: GPL-2.0+
@@ -37,7 +37,7 @@ if ( ! defined( 'WPINC' ) ) {
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
- define( 'PLUGIN_TVC_VERSION', '4.7.5' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
15
  * Plugin Name: Conversios.io - Google Analytics and Google Shopping plugin for WooCommerce
16
  * Plugin URI: https://www.tatvic.com/tatvic-labs/woocommerce-extension/
17
  * Description: Automates eCommerce tracking in Google Analytics, dynamic remarkting in Google Ads, and provides complete Google Shopping features.
18
+ * Version: 4.8.0
19
  * Author: Conversios
20
  * Author URI: conversios.io
21
  * License: GPL-2.0+
37
  * Start at version 1.0.0 and use SemVer - https://semver.org
38
  * Rename this for your plugin and update it as you release new versions.
39
  */
40
+ define( 'PLUGIN_TVC_VERSION', '4.8.0' );
41
  $fullName = plugin_basename( __FILE__ );
42
  $dir = str_replace('/enhanced-ecommerce-google-analytics.php','',$fullName);
43
  if ( ! defined( 'ENHANCAD_PLUGIN_NAME' ) ) {
includes/class-enhanced-ecommerce-google-analytics.php CHANGED
@@ -128,6 +128,7 @@ class Enhanced_Ecommerce_Google_Analytics {
128
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-onboarding.php';
129
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-onboarding-helper.php';
130
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-dashboard-helper.php';
 
131
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-admin.php';
132
  /**
133
  * End New conversios UI file list
128
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-onboarding.php';
129
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-onboarding-helper.php';
130
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-dashboard-helper.php';
131
+ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/helper/class-pmax-helper.php';
132
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-conversios-admin.php';
133
  /**
134
  * End New conversios UI file list
includes/setup/ShoppingApi.php CHANGED
@@ -69,6 +69,7 @@ class ShoppingApi {
69
  ];
70
 
71
  $args = array(
 
72
  'headers' => array(
73
  'Authorization' => "Bearer $this->token",
74
  'Content-Type' => 'application/json'
@@ -119,6 +120,7 @@ class ShoppingApi {
119
  'to_date' => sanitize_text_field($to_date)
120
  ];
121
  $args = array(
 
122
  'headers' => array(
123
  'Authorization' => "Bearer $this->token",
124
  'Content-Type' => 'application/json'
@@ -173,6 +175,7 @@ class ShoppingApi {
173
  "Content-Type" => "application/json"
174
  );
175
  $args = array(
 
176
  'headers' =>$header,
177
  'method' => 'POST',
178
  'body' => wp_json_encode($data)
@@ -222,6 +225,7 @@ class ShoppingApi {
222
  "Content-Type" => "application/json"
223
  );
224
  $args = array(
 
225
  'headers' =>$header,
226
  'method' => 'POST',
227
  'body' => wp_json_encode($data)
@@ -270,6 +274,7 @@ class ShoppingApi {
270
  ];
271
 
272
  $args = array(
 
273
  'headers' => array(
274
  'Authorization' => "Bearer $this->token",
275
  'Content-Type' => 'application/json'
@@ -477,6 +482,7 @@ class ShoppingApi {
477
  ];
478
 
479
  $args = array(
 
480
  'headers' =>$header,
481
  'method' => 'POST',
482
  'body' => wp_json_encode($data)
@@ -527,6 +533,7 @@ class ShoppingApi {
527
  ];
528
 
529
  $args = array(
 
530
  'headers' =>$header,
531
  'method' => 'PATCH',
532
  'body' => wp_json_encode($data)
69
  ];
70
 
71
  $args = array(
72
+ 'timeout' => 10000,
73
  'headers' => array(
74
  'Authorization' => "Bearer $this->token",
75
  'Content-Type' => 'application/json'
120
  'to_date' => sanitize_text_field($to_date)
121
  ];
122
  $args = array(
123
+ 'timeout' => 10000,
124
  'headers' => array(
125
  'Authorization' => "Bearer $this->token",
126
  'Content-Type' => 'application/json'
175
  "Content-Type" => "application/json"
176
  );
177
  $args = array(
178
+ 'timeout' => 10000,
179
  'headers' =>$header,
180
  'method' => 'POST',
181
  'body' => wp_json_encode($data)
225
  "Content-Type" => "application/json"
226
  );
227
  $args = array(
228
+ 'timeout' => 10000,
229
  'headers' =>$header,
230
  'method' => 'POST',
231
  'body' => wp_json_encode($data)
274
  ];
275
 
276
  $args = array(
277
+ 'timeout' => 10000,
278
  'headers' => array(
279
  'Authorization' => "Bearer $this->token",
280
  'Content-Type' => 'application/json'
482
  ];
483
 
484
  $args = array(
485
+ 'timeout' => 10000,
486
  'headers' =>$header,
487
  'method' => 'POST',
488
  'body' => wp_json_encode($data)
533
  ];
534
 
535
  $args = array(
536
+ 'timeout' => 10000,
537
  'headers' =>$header,
538
  'method' => 'PATCH',
539
  'body' => wp_json_encode($data)
includes/setup/account.php CHANGED
@@ -133,7 +133,7 @@ jQuery(document).ready(function () {
133
  action: "tvc_call_active_licence",
134
  licence_key:licence_key
135
  };
136
- $.ajax({
137
  type: "POST",
138
  dataType: "json",
139
  url: tvc_ajax_url,
133
  action: "tvc_call_active_licence",
134
  licence_key:licence_key
135
  };
136
+ jQuery.ajax({
137
  type: "POST",
138
  dataType: "json",
139
  url: tvc_ajax_url,
includes/setup/pmax-add.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TVC_PMaxAdd {
3
+ protected $TVC_Admin_Helper="";
4
+ protected $subscriptionId = "";
5
+ //protected $google_detail;
6
+ protected $site_url;
7
+ protected $google_ads_id;
8
+ protected $currency_code;
9
+ protected $currency_symbol;
10
+ protected $merchant_id;
11
+ public function __construct() {
12
+ $this->includes();
13
+ $this->site_url = "admin.php?page=conversios-pmax";
14
+ $this->TVC_Admin_Helper = new TVC_Admin_Helper();
15
+ $this->PMax_Helper = new Conversios_PMax_Helper();
16
+ $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
17
+ $this->merchant_id = $this->TVC_Admin_Helper->get_merchantId();
18
+ //$this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
19
+ $this->subscription_data = $this->TVC_Admin_Helper->get_user_subscription_data();
20
+ if(isset($this->subscription_data->google_ads_id) && $this->subscription_data->google_ads_id != ""){
21
+ $this->google_ads_id = $this->subscription_data->google_ads_id;
22
+ }
23
+ $currency_code_rs = $this->PMax_Helper->get_campaign_currency_code($this->google_ads_id);
24
+ if(isset($currency_code_rs->data->currencyCode)){
25
+ $this->currency_code = $currency_code_rs->data->currencyCode;
26
+ }
27
+ $this->currency_symbol = $this->TVC_Admin_Helper->get_currency_symbols($this->currency_code);
28
+ if($this->google_ads_id){
29
+ $this->load_html();
30
+ }
31
+ }
32
+ public function includes() {
33
+ if (!class_exists('Conversios_PMax_Helper')) {
34
+ require_once(ENHANCAD_PLUGIN_DIR . 'admin/helper/class-pmax-helper.php');
35
+ }
36
+ }
37
+
38
+ public function load_html(){
39
+ do_action('conversios_start_html_'.sanitize_text_field($_GET['page']));
40
+ $this->current_html();
41
+ $this->current_js();
42
+ do_action('conversios_end_html_'.sanitize_text_field($_GET['page']));
43
+ }
44
+
45
+ public function country_dropdown($selected_code = '', $is_disabled = false) {
46
+ $getCountris = file_get_contents(__DIR__ . "/json/countries.json");
47
+ $contData = json_decode($getCountris);
48
+ $wooCountry = $this->TVC_Admin_Helper->get_woo_country();
49
+ $is_disabled = ($is_disabled) ? "style=pointer-events:none;background:#f2f2f2;" : "";
50
+ $data = '<select name="target_country" id="target_country" class="slect2bx fromfiled" '.esc_attr($is_disabled).'>';
51
+ foreach ($contData as $key => $value) {
52
+ $selected = ($value->code == $wooCountry) ? "selected='selected'" : "";
53
+ $data .= "<option value=" . esc_attr($value->code) . " " . esc_attr($selected) . " >" . esc_attr($value->name) . "</option>";
54
+ }
55
+ $data .= "</select>";
56
+ return $data;
57
+ }
58
+
59
+ public function current_html() {
60
+ //REMOVED, PAUSED, ENABLED
61
+ ?>
62
+ <div class="pmax-campaign add-pmax-campaign">
63
+ <div class="mt24 whiteroundedbx dshreport-sec">
64
+ <h3><?php esc_html_e("Performance Max campaign","conversios"); ?></h3>
65
+ <a href="<?php echo esc_url_raw($this->site_url); ?>" class="btn-withborder"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/icon/left-angle-arrow.svg"); ?>"alt="back"/> <?php esc_html_e("Back to List","conversios"); ?></a>
66
+ <div class="tabs">
67
+ <?php /*<ul class="tabs-list">
68
+ <li class="active"><a href="#tab1">Campaign Details</a></li>
69
+ <li ><a href="#tab2">Link the Assets</a></li>
70
+ </ul> */ ?>
71
+ <div id="tab1" class="tab active">
72
+ <div class="campaignformwrp">
73
+ <form id="add-pmax-campaign-form" method="post">
74
+ <div class="form-row campform-row">
75
+ <label><?php esc_html_e("Campaign Name *","conversios"); ?></label>
76
+ <input type="text" class="fromfiled" name ="campaign_name" id="campaign_name" placeholder="<?php esc_html_e("Enter Campaign Name","conversios"); ?>" required>
77
+ </div>
78
+ <div class="form-row campform-row">
79
+ <label><?php esc_html_e("Daily Budget","conversios"); ?> (<spn class="ga_currency_symbols"><?php echo esc_attr($this->currency_symbol); ?></spn>) *</label>
80
+ <input type="number" class="fromfiled" name="budget" id="budget" placeholder="<?php esc_html_e("Enter your budget","conversios"); ?>" maxlength="120" required>
81
+ </div>
82
+ <div class="form-row campform-row">
83
+ <label><?php esc_html_e("Country *","conversios"); ?></label>
84
+ <?php echo $this->country_dropdown();?>
85
+ </div>
86
+ <div class="form-row-grp campform-row cmp_urls">
87
+ <div class="form-col-4 mb1">
88
+ <label><?php esc_html_e("Site URL Key","conversios"); ?></label>
89
+ <input type="text" class="fromfiled" name="site_key[]" placeholder="<?php esc_html_e("Key","conversios"); ?>" maxlength="100" onblur="this.value=removeSpaces(this.value);">
90
+ </div>
91
+ <div class="form-col-8 mb1">
92
+ <label><?php esc_html_e("Site URL Value","conversios"); ?></label>
93
+ <input type="text" class="fromfiled" name="site_url[]" placeholder="<?php esc_html_e("Site URL","conversios"); ?>">
94
+ </div>
95
+ </div>
96
+
97
+ <div id="more_cmp_urls"></div>
98
+ <div class="form-row campform-row">
99
+ <button type="button" id="add_more_cmp_urls" class="btn-fade-blue">
100
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
101
+ <?php esc_html_e("Add Site URLs","conversios"); ?></button>
102
+ </div>
103
+ <div class="form-row campform-row">
104
+ <label><?php esc_html_e("Target ROAS (%)","conversios"); ?></label>
105
+ <small>Formula: Conversion value ÷ ad spend x 100% = target ROAS percentage</small>
106
+ <input type="number" name="target_roas" class="fromfiled smtext" placeholder="<?php esc_html_e("Add Number","conversios"); ?>">
107
+ </div>
108
+ <div class="form-row campform-row">
109
+ <label><?php esc_html_e("FINAL URL Suffix","conversios"); ?></label>
110
+ <input type="text" name="final_url_suffix" class="fromfiled smtext" placeholder="<?php esc_html_e("Add Suffix","conversios"); ?>">
111
+ </div>
112
+ <div class="form-row campform-row">
113
+ <label><?php esc_html_e("Start Date","conversios"); ?></label>
114
+ <input type="text" name="start_date" id="start_date" class="fromfiled smtext datepicker">
115
+ </div>
116
+ <div class="form-row campform-row">
117
+ <label><?php esc_html_e("End Date","conversios"); ?></label>
118
+ <input type="text" name="end_date" id="end_date" class="fromfiled smtext datepicker">
119
+ </div>
120
+ <p class="label"><b>Status</b></p>
121
+ <div class="form-row form-row-grp campform-row">
122
+ <input type="radio" checked="checked" class="radio" value="ENABLED" name="status" id="cmp_active">
123
+ <label class="radio-label" for="cmp_active"><?php esc_html_e("Enable","conversios"); ?></label>
124
+ <input type="radio" class="radio" value="PAUSED" name="status" id="cmp_inactive">
125
+ <label class="radio-label" for="cmp_inactive"><?php esc_html_e("Pause","conversios"); ?></label>
126
+ </div>
127
+ <div class="campfooterbtn">
128
+ <input type="hidden" name="customer_id" value="<?php echo esc_attr($this->google_ads_id); ?>">
129
+ <input type="hidden" name="merchant_id" value="<?php echo esc_attr($this->merchant_id); ?>">
130
+ <button type="submit" class="ppblubtn cretemrchntbtn"><?php esc_html_e("Save","conversios"); ?></button>
131
+ </div>
132
+ </form>
133
+ <div class="alert-message" id="tvc_pmax_popup_box"></div>
134
+ <div id="add_loading"></div>
135
+ </div>
136
+
137
+ <a href="<?php echo esc_url_raw($this->site_url); ?>" class="btn-withborder"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/icon/left-angle-arrow.svg"); ?>"alt="back"/> <?php esc_html_e("Back to List","conversios"); ?></a>
138
+ </div>
139
+ <?php /*<div id="tab2" class="tab">
140
+ <h3>Link the Assets</h3>
141
+ <div class="assetformwrp">
142
+ <form action="#">
143
+ <div class="form-row campform-row">
144
+ <label>Headline* </label>
145
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
146
+ <p class="note">Required three headlines and Add up to 5 headlines</p>
147
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 1*">
148
+ <p class="score-line" style="float: right;">0/30</p>
149
+ </div>
150
+ <div class="form-row campform-row">
151
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 2*">
152
+ <p class="score-line" style="float: right;">0/30</p>
153
+ </div>
154
+ <div class="form-row campform-row">
155
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 3*">
156
+ <p class="score-line" style="float: right;">0/30</p>
157
+ </div>
158
+ <div class="form-row campform-row">
159
+ <button type="button" class="btn-fade-blue">
160
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
161
+ Add Headline</button>
162
+ </div>
163
+ <div class="form-row campform-row">
164
+ <label>Long Headline*</label>
165
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
166
+ <p class="note">Min 1 Required</p>
167
+ <input type="text" class="fromfiled" value="" placeholder="Add Long Headline*">
168
+ <p class="score-line" style="float: right;">0/30</p>
169
+ </div>
170
+ <div class="form-row campform-row">
171
+ <button type="button" class="btn-fade-blue">
172
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
173
+ Add Long Headline</button>
174
+ </div>
175
+ <div class="form-row campform-row">
176
+ <label>Description*</label>
177
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
178
+ <p class="note">Min. 2 descriptions required, maximum up to 60-90 character</p>
179
+ <input type="text" class="fromfiled" value="" placeholder="Add Description 1*">
180
+ <p class="score-line" style="float: right;">0/30</p>
181
+ </div>
182
+ <div class="form-row campform-row">
183
+ <input type="text" class="fromfiled" value="" placeholder="Add Description 2*">
184
+ <p class="score-line" style="float: right;">0/30</p>
185
+ </div>
186
+ <div class="form-row campform-row">
187
+ <button type="button" class="btn-fade-blue">
188
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
189
+ Add Description</button>
190
+ </div>
191
+ <div class="form-row campform-row">
192
+ <label>Buisness Name*</label>
193
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
194
+ <input type="text" class="fromfiled" value="" placeholder="Add your buisness name">
195
+ <p class="score-line" style="float: right;">0/30</p>
196
+ </div>
197
+ </form>
198
+ <div class="campfooterbtn">
199
+ <button type="button" class="btn-withborder">Previous
200
+ </button>
201
+ <button type="button" class="ppblubtn cretemrchntbtn">Submit
202
+ </button>
203
+ </div>
204
+ </div>
205
+ <div class="assetsection">
206
+ <form action="#">
207
+ <p class="label" style="display: inline-block;"><b>Images</b></p>
208
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
209
+ <p class="note">Min 2 Images required</p>
210
+ <div class="form-row campform-row">
211
+ <button type="button" class="btn-fade-blue">
212
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
213
+ Add Images</button>
214
+ </div>
215
+ <div class="form-row campform-row">
216
+ <label>Square Image* (1:1)</label>
217
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/square-image.png');?>">
218
+ </div>
219
+ <p class="label"><b>Landscape Image* (1.91:1)</b></p>
220
+ <div class="form-row campform-row">
221
+ <img class="img-upload" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/landscape-image.png');?>">
222
+ <img class="img-upload" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/landscape-image.png');?>">
223
+ </div>
224
+ <p class="label" style="display: inline-block;"><b>Logo* </b></p>
225
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
226
+ <p class="note"> min 1 logo require</p>
227
+ <div class="form-row campform-row">
228
+ <button type="button" class="btn-fade-blue">
229
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
230
+ Add Logo</button>
231
+ </div>
232
+ <div class="form-row campform-row">
233
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/square-image.png');?>">
234
+ </div>
235
+ <div class="form-row campform-row">
236
+ <label>Videos</label>
237
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
238
+ <input type="text" class="fromfiled" value="" placeholder="Add Video URL*">
239
+ </div>
240
+ <div class="form-row campform-row">
241
+ <button type="button" class="btn-fade-blue">
242
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
243
+ Add Video</button>
244
+ </div>
245
+ </form>
246
+ </div>
247
+ </div>*/ ?>
248
+
249
+ </div>
250
+ </div>
251
+ </div>
252
+ <?php /*
253
+ <script>
254
+ $(document).ready(function(){
255
+ $(".tabs-list li a").click(function(e){
256
+ e.preventDefault();
257
+ });
258
+
259
+ $(".tabs-list li").click(function(){
260
+ var tabid = $(this).find("a").attr("href");
261
+ $(".tabs-list li,.tabs div.tab").removeClass("active"); // removing active class from tab and tab content
262
+ $(".tab").hide(); // hiding open tab
263
+ $(tabid).show(); // show tab
264
+ $(this).addClass("active"); // adding active class to clicked tab
265
+
266
+ });
267
+ });
268
+ </script>*/ ?>
269
+ <?php
270
+ }
271
+ /**
272
+ * Page custom js code
273
+ *
274
+ * @since 4.1.4
275
+ */
276
+ public function current_js(){
277
+ /*ga_currency :'<?php echo esc_attr($this->ga_currency); ?>',*/
278
+ ?>
279
+ <script>
280
+ function removeSpaces(string) {
281
+ return string.split(' ').join('');
282
+ }
283
+ jQuery( document ).ready(function() {
284
+ jQuery(".datepicker").datepicker({
285
+ todayHighlight: true,
286
+ autoclose: true,
287
+ defaultViewDate: new Date(),
288
+ startDate: new Date(),
289
+ format: "yyyy-mm-dd"
290
+ });
291
+ jQuery(document).on('click','.remove-row', function(event){
292
+ event.preventDefault();
293
+ jQuery(this).parent().remove();
294
+ });
295
+ jQuery(document).on('click','#add_more_cmp_urls', function(event){
296
+ event.preventDefault();
297
+ //let parent_id = document.querySelector('#cmp_urls');
298
+ var html = '<div class="form-row-grp campform-row add-more-url"><div class="form-col-4 mb1"><input type="text" class="fromfiled" name="site_key[]" placeholder="Key" maxlength="100" onblur="this.value=removeSpaces(this.value);"></div><div class="form-col-8 mb1"><input type="text" class="fromfiled" name="site_url[]" placeholder="Site URL"></div><span class="form-col-1 remove-row">X</span></div>';
299
+ jQuery("#more_cmp_urls").append(html);
300
+ });
301
+ jQuery(document).on('submit','#add-pmax-campaign-form', function(event){
302
+ event.preventDefault();
303
+ var site_key = $("input[name='site_key\\[\\]']").map(function(){return $(this).val();}).get();
304
+ var site_url = $("input[name='site_url\\[\\]']").map(function(){return $(this).val();}).get();
305
+ //console.log(site_key);
306
+ //console.log(site_url);
307
+ // code
308
+ var fdata = jQuery(this).serialize();
309
+ //console.log(fdata);
310
+ var post_data = {
311
+ action:'create_pmax_campaign',
312
+ tvc_data:fdata,
313
+ site_key:site_key,
314
+ site_url:site_url,
315
+ conversios_nonce:'<?php echo wp_create_nonce( 'conversios_nonce' ); ?>'
316
+ };
317
+ jQuery(':input[type="submit"]').prop('disabled', true);
318
+ jQuery("#add_loading").addClass("is_loading");
319
+ jQuery.ajax({
320
+ type: "POST",
321
+ dataType: "json",
322
+ url: tvc_ajax_url,
323
+ data: post_data,
324
+ success: function (response) {
325
+ jQuery(':input[type="submit"]').prop('disabled', false);
326
+ jQuery("#add_loading").removeClass("is_loading");
327
+ console.log(response);
328
+ //tvc_helper.add_message("success", "this is test", false);
329
+ if(response.error == false){
330
+ tvc_helper.add_message("success",response.message);
331
+ setTimeout(function(){
332
+ window.location = '<?php echo esc_url_raw($this->site_url); ?>';
333
+ });
334
+ }else{
335
+ if(response.errors != ""){
336
+ tvc_helper.add_message("error",response.message);
337
+ }
338
+ }
339
+ }
340
+ });// ajax
341
+ });
342
+
343
+ });
344
+ </script>
345
+ <?php
346
+ }
347
+ }
348
+ ?>
includes/setup/pmax-edit.php ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TVC_PMaxEdit {
3
+ protected $TVC_Admin_Helper="";
4
+ protected $subscriptionId = "";
5
+ //protected $google_detail;
6
+ protected $site_url;
7
+ protected $google_ads_id;
8
+ protected $currency_code;
9
+ protected $currency_symbol;
10
+ protected $merchant_id;
11
+ protected $campaign;
12
+ protected $campaign_budget;
13
+ protected $campaign_id;
14
+ public function __construct() {
15
+ $this->includes();
16
+ $this->site_url = "admin.php?page=conversios-pmax";
17
+ $this->TVC_Admin_Helper = new TVC_Admin_Helper();
18
+ $this->PMax_Helper = new Conversios_PMax_Helper();
19
+ $this->subscriptionId = $this->TVC_Admin_Helper->get_subscriptionId();
20
+ $this->merchant_id = $this->TVC_Admin_Helper->get_merchantId();
21
+ //$this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
22
+ $this->subscription_data = $this->TVC_Admin_Helper->get_user_subscription_data();
23
+ if(isset($this->subscription_data->google_ads_id) && $this->subscription_data->google_ads_id != ""){
24
+ $this->google_ads_id = $this->subscription_data->google_ads_id;
25
+ }
26
+ $this->campaign_id = (isset($_GET['id']))?sanitize_text_field($_GET['id']):"";
27
+ if($this->campaign_id && $this->google_ads_id){
28
+ $rs = $this->PMax_Helper->campaign_pmax_detail($this->google_ads_id, $this->campaign_id);
29
+ if(isset($rs->data->campaign)){
30
+ $this->campaign = $rs->data->campaign;
31
+ }
32
+ if(isset($rs->data->campaign_budget)){
33
+ $this->campaign_budget = $rs->data->campaign_budget;
34
+ }
35
+ }else{
36
+ wp_redirect("admin.php?page=conversios-pmax");
37
+ exit;
38
+ }
39
+
40
+ $currency_code_rs = $this->PMax_Helper->get_campaign_currency_code($this->google_ads_id);
41
+ if(isset($currency_code_rs->data->currencyCode)){
42
+ $this->currency_code = $currency_code_rs->data->currencyCode;
43
+ }
44
+ $this->currency_symbol = $this->TVC_Admin_Helper->get_currency_symbols($this->currency_code);
45
+ if($this->google_ads_id){
46
+ $this->load_html();
47
+ }
48
+ }
49
+ public function includes() {
50
+ if (!class_exists('Conversios_PMax_Helper')) {
51
+ require_once(ENHANCAD_PLUGIN_DIR . 'admin/helper/class-pmax-helper.php');
52
+ }
53
+ }
54
+
55
+ public function load_html(){
56
+ do_action('conversios_start_html_'.sanitize_text_field($_GET['page']));
57
+ $this->current_html();
58
+ $this->current_js();
59
+ do_action('conversios_end_html_'.sanitize_text_field($_GET['page']));
60
+ }
61
+
62
+ public function object_value($obj, $key){
63
+ if(!empty($obj) && $key && isset($obj->$key)){
64
+ return $obj->$key;
65
+ }
66
+ }
67
+
68
+ public function country_dropdown($selected_code = '', $is_disabled = false) {
69
+ $getCountris = file_get_contents(__DIR__ . "/json/countries.json");
70
+ $contData = json_decode($getCountris);
71
+ if($selected_code ==""){
72
+ $selected_code = $this->TVC_Admin_Helper->get_woo_country();
73
+ }
74
+ $is_disabled = ($is_disabled) ? "style=pointer-events:none;background:#f2f2f2;" : "";
75
+ $data = '<select name="target_country" id="target_country" class="slect2bx fromfiled" '.esc_attr($is_disabled).'>';
76
+ foreach ($contData as $key => $value) {
77
+ $selected = ($value->code == $selected_code) ? "selected='selected'" : "";
78
+ $data .= "<option value=" . esc_attr($value->code) . " " . esc_attr($selected) . " >" . esc_attr($value->name) . "</option>";
79
+ }
80
+ $data .= "</select>";
81
+ return $data;
82
+ }
83
+
84
+ public function current_html() {
85
+ //REMOVED, PAUSED, ENABLED
86
+ //print_r($this->campaign_budget);
87
+ $sale_country = isset($this->campaign->shoppingSetting->salesCountry)?$this->campaign->shoppingSetting->salesCountry:"";
88
+ $budget_micro = isset($this->campaign_budget->amountMicros)?$this->campaign_budget->amountMicros:"";
89
+ if($budget_micro > 0){
90
+ $budget = $budget_micro / 1000000;
91
+ }
92
+ ?>
93
+ <div class="pmax-campaign add-pmax-campaign">
94
+ <div class="mt24 whiteroundedbx dshreport-sec">
95
+ <h3><?php esc_html_e("Edit Performance Max campaign","conversios"); ?></h3>
96
+ <a href="<?php echo esc_url_raw($this->site_url); ?>" class="btn-withborder"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/icon/left-angle-arrow.svg"); ?>"alt="back"/> <?php esc_html_e("Back to List","conversios"); ?></a>
97
+ <div class="tabs">
98
+ <?php /*<ul class="tabs-list">
99
+ <li class="active"><a href="#tab1">Campaign Details</a></li>
100
+ <li ><a href="#tab2">Link the Assets</a></li>
101
+ </ul> */ ?>
102
+ <div id="tab1" class="tab active">
103
+ <div class="campaignformwrp">
104
+ <form id="edit-pmax-campaign-form" method="post">
105
+ <div class="form-row campform-row">
106
+ <label><?php esc_html_e("Campaign Name *","conversios"); ?></label>
107
+ <input type="text" class="fromfiled" name ="campaign_name" id="campaign_name" value="<?php echo esc_attr($this->object_value($this->campaign, "name")); ?>" placeholder="<?php esc_html_e("Enter Campaign Name","conversios"); ?>" required>
108
+ </div>
109
+ <div class="form-row campform-row">
110
+ <label><?php esc_html_e("Daily Budget","conversios"); ?> (<spn class="ga_currency_symbols"><?php echo esc_attr($this->currency_symbol); ?></spn>) *</label>
111
+ <input type="number" class="fromfiled" name="budget" id="budget" value="<?php echo esc_attr($budget); ?>" placeholder="<?php esc_html_e("Enter your budget","conversios"); ?>" maxlength="120" required>
112
+ </div>
113
+ <div class="form-row campform-row">
114
+ <label><?php esc_html_e("Country *","conversios"); ?></label>
115
+ <?php echo $this->country_dropdown($sale_country, true);?>
116
+ </div>
117
+ <?php if(!empty($this->campaign->urlCustomParameters)){
118
+ $i = 1;
119
+ foreach($this->campaign->urlCustomParameters as $val){
120
+ ?>
121
+ <div class="form-row-grp campform-row cmp_urls">
122
+ <div class="form-col-4 mb1">
123
+ <?php if($i ==1){?><label><?php esc_html_e("Site URL Key","conversios"); ?></label><?php } ?>
124
+ <input type="text" class="fromfiled" name="site_key[]" value="<?php echo esc_attr($this->object_value($val, "key")); ?>" placeholder="<?php esc_html_e("Key","conversios"); ?>" maxlength="100" onblur="this.value=removeSpaces(this.value);">
125
+ </div>
126
+ <div class="form-col-8 mb1">
127
+ <?php if($i ==1){?><label><?php esc_html_e("Site URL Value","conversios"); ?></label><?php } ?>
128
+ <input type="text" class="fromfiled" name="site_url[]" value="<?php echo esc_attr($this->object_value($val, "value")); ?>" placeholder="<?php esc_html_e("Site URL","conversios"); ?>">
129
+ </div>
130
+ <?php if($i !=1){?><span class="form-col-1 remove-row">X</span><?php } ?>
131
+ </div>
132
+ <?php
133
+ $i++;
134
+ }
135
+ }else{?>
136
+ <div class="form-row-grp campform-row cmp_urls">
137
+ <div class="form-col-4 mb1">
138
+ <label><?php esc_html_e("Site URL Key","conversios"); ?></label>
139
+ <input type="text" class="fromfiled" name="site_key[]" placeholder="<?php esc_html_e("Key","conversios"); ?>" maxlength="100" onblur="this.value=removeSpaces(this.value);">
140
+ </div>
141
+ <div class="form-col-8 mb1">
142
+ <label><?php esc_html_e("Site URL Value","conversios"); ?></label>
143
+ <input type="text" class="fromfiled" name="site_url[]" placeholder="<?php esc_html_e("Site URL","conversios"); ?>">
144
+ </div>
145
+ </div>
146
+ <?php }?>
147
+ <div id="more_cmp_urls"></div>
148
+ <div class="form-row campform-row">
149
+ <button type="button" id="add_more_cmp_urls" class="btn-fade-blue">
150
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
151
+ <?php esc_html_e("Add Site URLs","conversios"); ?></button>
152
+ </div>
153
+ <div class="form-row campform-row">
154
+ <?php
155
+ $maximizeconversionvalue = isset($this->campaign->maximizeConversionValue)?$this->campaign->maximizeConversionValue:"";
156
+ $target_roas = $this->object_value($maximizeconversionvalue, "targetRoas")*100; ?>
157
+ <label><?php esc_html_e("Target ROAS (%)","conversios"); ?></label>
158
+ <small>Formula: Conversion value ÷ ad spend x 100% = target ROAS percentage</small>
159
+ <input type="number" name="target_roas" value="<?php echo esc_attr($target_roas); ?>" class="fromfiled smtext" placeholder="<?php esc_html_e("Add Number","conversios"); ?>">
160
+ </div>
161
+ <div class="form-row campform-row">
162
+ <label><?php esc_html_e("FINAL URL Suffix","conversios"); ?></label>
163
+ <input type="text" name="final_url_suffix" value="<?php echo esc_attr($this->object_value($this->campaign, "finalUrlSuffix")); ?>" class="fromfiled smtext" placeholder="<?php esc_html_e("Add Suffix","conversios"); ?>">
164
+ </div>
165
+ <div class="form-row campform-row">
166
+ <label><?php esc_html_e("Start Date","conversios"); ?></label>
167
+ <input type="text" name="start_date" id="start_date" value="<?php echo esc_attr($this->object_value($this->campaign, "startDate")); ?>" class="fromfiled smtext datepicker">
168
+ </div>
169
+ <div class="form-row campform-row">
170
+ <label><?php esc_html_e("End Date","conversios"); ?></label>
171
+ <input type="text" name="end_date" id="end_date" value="<?php echo esc_attr($this->object_value($this->campaign, "endDate")); ?>" class="fromfiled smtext datepicker">
172
+ </div>
173
+ <p class="label"><b>Status</b></p>
174
+ <div class="form-row form-row-grp campform-row">
175
+ <input type="radio" <?php echo ($this->campaign->status == "ENABLED")?'checked="checked"':''; ?> class="radio" value="ENABLED" name="status" id="cmp_active">
176
+ <label class="radio-label" for="cmp_active"><?php esc_html_e("Enable","conversios"); ?></label>
177
+ <input type="radio" <?php echo ($this->campaign->status == "PAUSED")?'checked="checked"':''; ?> class="radio" value="PAUSED" name="status" id="cmp_inactive">
178
+ <label class="radio-label" for="cmp_inactive"><?php esc_html_e("Pause","conversios"); ?></label>
179
+ <input type="radio" <?php echo ($this->campaign->status == "REMOVED")?'checked="checked"':''; ?> class="radio" value="REMOVED" name="status" id="cmp_removed">
180
+ <label class="radio-label" for="cmp_removed"><?php esc_html_e("Remove","conversios"); ?></label>
181
+ </div>
182
+ <div class="campfooterbtn">
183
+ <input type="hidden" name="customer_id" value="<?php echo esc_attr($this->google_ads_id); ?>">
184
+ <input type="hidden" name="merchant_id" value="<?php echo esc_attr($this->merchant_id); ?>">
185
+ <input type="hidden" name="campaign_id" value="<?php echo esc_attr($this->campaign_id); ?>">
186
+ <input type="hidden" name="resource_name" value="<?php echo esc_attr($this->campaign->resourceName); ?>">
187
+ <input type="hidden" name="campaign_budget_resource_name" value="<?php echo esc_attr($this->campaign->campaignBudget); ?>">
188
+ <button type="submit" class="ppblubtn cretemrchntbtn"><?php esc_html_e("Save","conversios"); ?></button>
189
+ </div>
190
+ </form>
191
+ <div class="alert-message" id="tvc_pmax_popup_box"></div>
192
+ <div id="add_loading"></div>
193
+ </div>
194
+
195
+ <a href="<?php echo esc_url_raw($this->site_url); ?>" class="btn-withborder"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL."/admin/images/icon/left-angle-arrow.svg"); ?>"alt="back"/> <?php esc_html_e("Back to List","conversios"); ?></a>
196
+ </div>
197
+ <?php /*<div id="tab2" class="tab">
198
+ <h3>Link the Assets</h3>
199
+ <div class="assetformwrp">
200
+ <form action="#">
201
+ <div class="form-row campform-row">
202
+ <label>Headline* </label>
203
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
204
+ <p class="note">Required three headlines and Add up to 5 headlines</p>
205
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 1*">
206
+ <p class="score-line" style="float: right;">0/30</p>
207
+ </div>
208
+ <div class="form-row campform-row">
209
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 2*">
210
+ <p class="score-line" style="float: right;">0/30</p>
211
+ </div>
212
+ <div class="form-row campform-row">
213
+ <input type="text" class="fromfiled" value="" placeholder="Add Headline 3*">
214
+ <p class="score-line" style="float: right;">0/30</p>
215
+ </div>
216
+ <div class="form-row campform-row">
217
+ <button type="button" class="btn-fade-blue">
218
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
219
+ Add Headline</button>
220
+ </div>
221
+ <div class="form-row campform-row">
222
+ <label>Long Headline*</label>
223
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
224
+ <p class="note">Min 1 Required</p>
225
+ <input type="text" class="fromfiled" value="" placeholder="Add Long Headline*">
226
+ <p class="score-line" style="float: right;">0/30</p>
227
+ </div>
228
+ <div class="form-row campform-row">
229
+ <button type="button" class="btn-fade-blue">
230
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
231
+ Add Long Headline</button>
232
+ </div>
233
+ <div class="form-row campform-row">
234
+ <label>Description*</label>
235
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
236
+ <p class="note">Min. 2 descriptions required, maximum up to 60-90 character</p>
237
+ <input type="text" class="fromfiled" value="" placeholder="Add Description 1*">
238
+ <p class="score-line" style="float: right;">0/30</p>
239
+ </div>
240
+ <div class="form-row campform-row">
241
+ <input type="text" class="fromfiled" value="" placeholder="Add Description 2*">
242
+ <p class="score-line" style="float: right;">0/30</p>
243
+ </div>
244
+ <div class="form-row campform-row">
245
+ <button type="button" class="btn-fade-blue">
246
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
247
+ Add Description</button>
248
+ </div>
249
+ <div class="form-row campform-row">
250
+ <label>Buisness Name*</label>
251
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
252
+ <input type="text" class="fromfiled" value="" placeholder="Add your buisness name">
253
+ <p class="score-line" style="float: right;">0/30</p>
254
+ </div>
255
+ </form>
256
+ <div class="campfooterbtn">
257
+ <button type="button" class="btn-withborder">Previous
258
+ </button>
259
+ <button type="button" class="ppblubtn cretemrchntbtn">Submit
260
+ </button>
261
+ </div>
262
+ </div>
263
+ <div class="assetsection">
264
+ <form action="#">
265
+ <p class="label" style="display: inline-block;"><b>Images</b></p>
266
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
267
+ <p class="note">Min 2 Images required</p>
268
+ <div class="form-row campform-row">
269
+ <button type="button" class="btn-fade-blue">
270
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
271
+ Add Images</button>
272
+ </div>
273
+ <div class="form-row campform-row">
274
+ <label>Square Image* (1:1)</label>
275
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/square-image.png');?>">
276
+ </div>
277
+ <p class="label"><b>Landscape Image* (1.91:1)</b></p>
278
+ <div class="form-row campform-row">
279
+ <img class="img-upload" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/landscape-image.png');?>">
280
+ <img class="img-upload" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/landscape-image.png');?>">
281
+ </div>
282
+ <p class="label" style="display: inline-block;"><b>Logo* </b></p>
283
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
284
+ <p class="note"> min 1 logo require</p>
285
+ <div class="form-row campform-row">
286
+ <button type="button" class="btn-fade-blue">
287
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
288
+ Add Logo</button>
289
+ </div>
290
+ <div class="form-row campform-row">
291
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/square-image.png');?>">
292
+ </div>
293
+ <div class="form-row campform-row">
294
+ <label>Videos</label>
295
+ <img class="img-icon" src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon-help.png');?>" alt="">
296
+ <input type="text" class="fromfiled" value="" placeholder="Add Video URL*">
297
+ </div>
298
+ <div class="form-row campform-row">
299
+ <button type="button" class="btn-fade-blue">
300
+ <img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/blue-plus.png');?>" alt="">
301
+ Add Video</button>
302
+ </div>
303
+ </form>
304
+ </div>
305
+ </div>*/ ?>
306
+
307
+ </div>
308
+ </div>
309
+ </div>
310
+ <?php /*
311
+ <script>
312
+ $(document).ready(function(){
313
+ $(".tabs-list li a").click(function(e){
314
+ e.preventDefault();
315
+ });
316
+
317
+ $(".tabs-list li").click(function(){
318
+ var tabid = $(this).find("a").attr("href");
319
+ $(".tabs-list li,.tabs div.tab").removeClass("active"); // removing active class from tab and tab content
320
+ $(".tab").hide(); // hiding open tab
321
+ $(tabid).show(); // show tab
322
+ $(this).addClass("active"); // adding active class to clicked tab
323
+
324
+ });
325
+ });
326
+ </script>*/ ?>
327
+ <?php
328
+ }
329
+ /**
330
+ * Page custom js code
331
+ *
332
+ * @since 4.1.4
333
+ */
334
+ public function current_js(){
335
+ /*ga_currency :'<?php echo esc_attr($this->ga_currency); ?>',*/
336
+ ?>
337
+ <script>
338
+ function removeSpaces(string) {
339
+ return string.split(' ').join('');
340
+ }
341
+ jQuery( document ).ready(function() {
342
+ jQuery(".datepicker").datepicker({
343
+ todayHighlight: true,
344
+ autoclose: true,
345
+ defaultViewDate: new Date(),
346
+ startDate: new Date(),
347
+ format: "yyyy-mm-dd"
348
+ });
349
+ jQuery(document).on('click','.remove-row', function(event){
350
+ event.preventDefault();
351
+ jQuery(this).parent().remove();
352
+ });
353
+ jQuery(document).on('click','#add_more_cmp_urls', function(event){
354
+ event.preventDefault();
355
+ //let parent_id = document.querySelector('#cmp_urls');
356
+ var html = '<div class="form-row-grp campform-row add-more-url"><div class="form-col-4 mb1"><input type="text" class="fromfiled" name="site_key[]" placeholder="Key" maxlength="100" onblur="this.value=removeSpaces(this.value);"></div><div class="form-col-8 mb1"><input type="text" class="fromfiled" name="site_url[]" placeholder="Site URL"></div><span class="form-col-1 remove-row">X</span></div>';
357
+ jQuery("#more_cmp_urls").append(html);
358
+ });
359
+ jQuery(document).on('submit','#edit-pmax-campaign-form', function(event){
360
+ event.preventDefault();
361
+ var site_key = $("input[name='site_key\\[\\]']").map(function(){return $(this).val();}).get();
362
+ var site_url = $("input[name='site_url\\[\\]']").map(function(){return $(this).val();}).get();
363
+ //console.log(site_key);
364
+ //console.log(site_url);
365
+ // code
366
+ var fdata = jQuery(this).serialize();
367
+ //console.log(fdata);
368
+ var post_data = {
369
+ action:'edit_pmax_campaign',
370
+ tvc_data:fdata,
371
+ site_key:site_key,
372
+ site_url:site_url,
373
+ conversios_nonce:'<?php echo wp_create_nonce( 'conversios_nonce' ); ?>'
374
+ };
375
+ jQuery("#add_loading").addClass("is_loading");
376
+ jQuery(':input[type="submit"]').prop('disabled', true);
377
+ jQuery.ajax({
378
+ type: "POST",
379
+ dataType: "json",
380
+ url: tvc_ajax_url,
381
+ data: post_data,
382
+ success: function (response) {
383
+ jQuery(':input[type="submit"]').prop('disabled', false);
384
+ jQuery("#add_loading").removeClass("is_loading");
385
+ console.log(response);
386
+ //tvc_helper.add_message("success", "this is test", false);
387
+ if(response.error == false){
388
+ tvc_helper.add_message("success",response.message);
389
+ setTimeout(function(){
390
+ //window.location = '<?php echo esc_url_raw($this->site_url); ?>';
391
+ });
392
+ }else{
393
+ if(response.errors != ""){
394
+ tvc_helper.add_message("error",response.message);
395
+ }
396
+ }
397
+ }
398
+ });// ajax
399
+ });
400
+
401
+ });
402
+ </script>
403
+ <?php
404
+ }
405
+ }
406
+ ?>
includes/setup/pmax.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class TVC_PMax {
3
+ protected $TVC_Admin_Helper;
4
+ protected $PMax_Helper;
5
+ protected $subscription_id;
6
+ //protected $google_detail;
7
+ protected $site_url;
8
+ protected $plan_id;
9
+ protected $google_ads_id;
10
+ protected $currency_code;
11
+ protected $currency_symbol;
12
+ public function __construct() {
13
+ $this->includes();
14
+ $this->TVC_Admin_Helper = new TVC_Admin_Helper();
15
+ $this->PMax_Helper = new Conversios_PMax_Helper();
16
+ $this->subscription_id = $this->TVC_Admin_Helper->get_subscriptionId();
17
+ //$this->google_detail = $this->TVC_Admin_Helper->get_ee_options_data();
18
+ $this->subscription_data = $this->TVC_Admin_Helper->get_user_subscription_data();
19
+ $this->site_url = "admin.php?page=conversios-pmax&tab=";
20
+
21
+ $this->subscription_data = $this->TVC_Admin_Helper->get_user_subscription_data();
22
+ if(isset($this->subscription_data->plan_id) && !in_array($this->subscription_data->plan_id, array("1"))){
23
+ $this->plan_id = $this->subscription_data->plan_id;
24
+ }
25
+ if(isset($this->subscription_data->google_ads_id) && $this->subscription_data->google_ads_id != ""){
26
+ $this->google_ads_id = $this->subscription_data->google_ads_id;
27
+ }
28
+ $currency_code_rs = $this->PMax_Helper->get_campaign_currency_code($this->google_ads_id);
29
+ if(isset($currency_code_rs->data->currencyCode)){
30
+ $this->currency_code = $currency_code_rs->data->currencyCode;
31
+ }
32
+ $this->currency_symbol = $this->TVC_Admin_Helper->get_currency_symbols($this->currency_code);
33
+ if($this->google_ads_id){
34
+ $this->load_html();
35
+ }else{
36
+ $this->current_connect_google_ads_html();
37
+ }
38
+ }
39
+
40
+ public function includes() {
41
+ if (!class_exists('Conversios_PMax_Helper')) {
42
+ require_once(ENHANCAD_PLUGIN_DIR . 'admin/helper/class-pmax-helper.php');
43
+ }
44
+ }
45
+
46
+ public function load_html(){
47
+ do_action('conversios_start_html_'.sanitize_text_field($_GET['page']));
48
+ $this->current_html();
49
+ $this->current_js();
50
+ do_action('conversios_end_html_'.sanitize_text_field($_GET['page']));
51
+ }
52
+ public function current_connect_google_ads_html() {
53
+ ?>
54
+ <div class="section-campaignlisting dashbrdpage-wrap">
55
+ <div class="mt24 whiteroundedbx dshreport-sec" style="box-shadow: 0px 4px 10px rgb(0 0 0 / 25%);">
56
+ <div class="row dsh-reprttop">
57
+ <div class="dshrprttp-left">
58
+ <h3><?php esc_html_e("Performance Max campaigns","conversios"); ?></h3>
59
+ <?php /*<h4 style="margin-bottom: 15px;"><strong>Campaign Performance</strong></h4>*/ ?>
60
+ </div>
61
+ </div>
62
+ <div class="google-account-analytics">
63
+ <div class="row mb-3">
64
+ <div class="col-6 col-md-6 col-lg-6">
65
+ <h2 class="ga-title"><?php esc_html_e("Connected Google Ads account:","conversios"); ?></h2>
66
+ </div>
67
+ <div class="col-6 col-md-6 col-lg-6 text-right">
68
+ <div class="acc-num">
69
+ <p class="ga-text">
70
+ <span><a href="<?php echo esc_url_raw($this->TVC_Admin_Helper->get_onboarding_page_url()); ?>" class="text-underline"><?php echo esc_html__('Get started','conversios'); ?></a></span>
71
+ </p>
72
+ <p class="ga-text text-right"><a href="<?php echo esc_url_raw($this->TVC_Admin_Helper->get_onboarding_page_url()); ?>" class="text-underline"><img src="<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/icon/add.svg'); ?>" alt="connect account"/></a></p>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
77
+
78
+
79
+ </div>
80
+ </div>
81
+ <?php
82
+ }
83
+ public function current_html() {
84
+ $icon = esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/calendar-icon.png');
85
+ $icon_caret = esc_url_raw(ENHANCAD_PLUGIN_URL.'/admin/images/caret-down.png');
86
+ ?>
87
+ <div class="section-campaignlisting dashbrdpage-wrap">
88
+ <div class="mt24 whiteroundedbx dshreport-sec" style="box-shadow: 0px 4px 10px rgb(0 0 0 / 25%);">
89
+ <div class="row dsh-reprttop">
90
+ <div class="dshrprttp-left">
91
+ <h3><?php esc_html_e("Performance Max campaigns","conversios"); ?></h3>
92
+ <?php /*<h4 style="margin-bottom: 15px;"><strong>Campaign Performance</strong></h4>*/ ?>
93
+ </div>
94
+ <div class="search-container">
95
+ <a class="feedback_btn btn-campaign" href="<?php echo esc_url_raw($this->site_url.'pmax_add'); ?>"><?php esc_html_e("Create a New Campaign","conversios"); ?></a>
96
+ </div>
97
+ </div>
98
+ <div class="dashtablewrp campaign_pmax_list" id="campaign_pmax_list">
99
+ <table class="dshreporttble mbl-table campaign-list-tbl">
100
+ <thead>
101
+ <tr>
102
+ <th class="prdnm-cell"><?php esc_html_e("Campaign","conversios"); ?></th>
103
+ <th><?php esc_html_e("Daily Budget ","conversios"); ?>(<spn class="ga_currency_symbols"><?php echo esc_attr($this->currency_symbol); ?></spn>)</th>
104
+ <th><?php esc_html_e("Status","conversios"); ?></th>
105
+ <th><?php esc_html_e("Clicks","conversios"); ?></th>
106
+ <th><?php esc_html_e("Cost ","conversios"); ?>(<spn class="ga_currency_symbols"><?php echo esc_attr($this->currency_symbol); ?></spn>)</th>
107
+ <th><?php esc_html_e("Conversions ","conversios"); ?></th>
108
+ <th><?php esc_html_e("Sales","conversios"); ?></th>
109
+ <th><?php esc_html_e("Action","conversios"); ?></th>
110
+ </tr>
111
+ </thead>
112
+ <tbody></tbody>
113
+ </table>
114
+ <div class="syncprofooter">
115
+ <div class="properpage">
116
+ <?php esc_html_e("Items per page:","conversios"); ?>
117
+ <select class="properselect" name="page_size" id="page_size" style="display: inline-table;">
118
+ <option value="5">5</option>
119
+ <option value="10">10</option>
120
+ <option value="20">20</option>
121
+ <option value="50">50</option>
122
+ </select>
123
+ </div>
124
+
125
+ <div class="syncpropagination">
126
+ <div class="page_no_sec">
127
+ <?php esc_html_e("Page","conversios"); ?> <span id="page_no">1</span>
128
+ </div>
129
+ <ul>
130
+ <li class="prevli"><button data-token="" class="paginitem pgprevbtn" disabled><?php esc_html_e("Prev","conversios"); ?></button></li>
131
+ <li class="nextli"><button data-token="" data-token="" class="paginitem pgnextbtn"><?php esc_html_e("Next","conversios"); ?></button></li>
132
+ </ul>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ <!-- daterage script -->
139
+ <?php
140
+ }
141
+ /**
142
+ * Page custom js code
143
+ *
144
+ * @since 4.1.4
145
+ */
146
+ public function current_js(){
147
+ /*ga_currency :'<?php echo esc_attr($this->ga_currency); ?>',*/
148
+ ?>
149
+ <script>
150
+ var page = 1;
151
+ var page_token = "";
152
+ var page_size = jQuery('#page_size').val();
153
+ var plan_id = '<?php echo esc_attr($this->plan_id); ?>';
154
+ var currency_symbol = '<?php echo esc_attr($this->currency_symbol); ?>';
155
+ function get_page(page_size, page_token, page){
156
+ var data = {
157
+ action:'get_pmax_campaign_list',
158
+ subscription_id:'<?php echo esc_attr($this->subscription_id); ?>',
159
+ plan_id:plan_id,
160
+ plugin_url:'<?php echo esc_url_raw(ENHANCAD_PLUGIN_URL); ?>',
161
+ page_size: page_size,
162
+ page_token: page_token,
163
+ page:page,
164
+ currency_symbol:currency_symbol,
165
+ //start_date :jQuery.trim(start_date.replace(/\//g,"-")),
166
+ //end_date :jQuery.trim(end_date.replace(/\//g,"-")),
167
+ //g_mail:g_mail,
168
+ google_ads_id:'<?php echo esc_attr($this->google_ads_id); ?>',
169
+ conversios_nonce:'<?php echo wp_create_nonce( 'conversios_nonce' ); ?>'
170
+ };
171
+ // Call API
172
+ tvc_helper.get_call_ajax_request(data);
173
+ }
174
+
175
+ jQuery( document ).ready(function() {
176
+ get_page(page_size, page_token, page);
177
+
178
+ jQuery("#page_size").on( "change", function() {
179
+ page_size = jQuery('#page_size').val();
180
+ page_token = "";
181
+ page =1;
182
+ get_page(page_size, page_token, page);
183
+ });
184
+
185
+ jQuery(".pgprevbtn").on( "click", function(event) {
186
+ event.preventDefault();
187
+ page--;
188
+ page_token = jQuery(this).attr("data-token");
189
+ get_page(page_size, page_token, page);
190
+ })
191
+ jQuery(".pgnextbtn").on( "click", function(event) {
192
+ event.preventDefault();
193
+ page++;
194
+ page_token = jQuery(this).attr("data-token");
195
+ get_page(page_size, page_token, page);
196
+ })
197
+
198
+ });
199
+ </script>
200
+ <?php
201
+ }
202
+ }
203
+ ?>
public/class-enhanced-ecommerce-google-analytics-public-pro.php CHANGED
@@ -492,6 +492,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
492
  function gtag(){dataLayer.push(arguments);}
493
  gtag("js", new Date());
494
  gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
 
495
  "custom_map": {
496
  "dimension1": "user_id",
497
  "dimension3": "user_type",
@@ -524,6 +525,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
524
  function gtag(){dataLayer.push(arguments);}
525
  gtag("js", new Date());
526
  gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
 
527
  "custom_map": {
528
  "dimension1": "user_id",
529
  "dimension3": "user_type",
@@ -555,6 +557,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
555
  function gtag(){dataLayer.push(arguments);}
556
  gtag("js", new Date());
557
  gtag("config", "<?php echo esc_js($this->ga_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
 
558
  "custom_map": {
559
  "dimension1": "user_id",
560
  "dimension3": "user_type",
@@ -579,12 +582,23 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
579
  </script>
580
  <?php
581
  }
582
- if($this->ga_CG){?>
583
  <script>
584
  gtag('set', {'content_group': '<?php echo esc_js($this->add_page_type());?>'});
585
  </script>
586
- <?php }
587
  //add remarketing snippets
 
 
 
 
 
 
 
 
 
 
 
588
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
589
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
590
  echo html_entity_decode(str_replace("&#039;", "'", esc_html($this->remarketing_snippets)) );
@@ -595,7 +609,7 @@ class Enhanced_Ecommerce_Google_Analytics_Public {
595
  echo html_entity_decode(str_replace("&#039;", "'",esc_html($googleDetail->google_ads_snippets)) );
596
  }
597
  }
598
- }
599
 
600
  /*facebook pixel*/
601
  if($this->fb_pixel_id != ""){
492
  function gtag(){dataLayer.push(arguments);}
493
  gtag("js", new Date());
494
  gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
495
+ <?php if($this->ga_CG){ echo "'content_group': '".esc_js($this->add_page_type())."', 'content_group5': '".esc_js($this->add_page_type())."',"; }?>
496
  "custom_map": {
497
  "dimension1": "user_id",
498
  "dimension3": "user_type",
525
  function gtag(){dataLayer.push(arguments);}
526
  gtag("js", new Date());
527
  gtag("config", "<?php echo esc_js($this->gm_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
528
+ <?php if($this->ga_CG){ echo "'content_group': '".esc_js($this->add_page_type())."',"; }?>
529
  "custom_map": {
530
  "dimension1": "user_id",
531
  "dimension3": "user_type",
557
  function gtag(){dataLayer.push(arguments);}
558
  gtag("js", new Date());
559
  gtag("config", "<?php echo esc_js($this->ga_id); ?>",{<?php echo $ga_ip_anonymization; ?> "cookie_domain":"<?php echo esc_js($this->ga_Dname); ?>",
560
+ <?php if($this->ga_CG){ echo "'content_group5': '".esc_js($this->add_page_type())."',"; }?>
561
  "custom_map": {
562
  "dimension1": "user_id",
563
  "dimension3": "user_type",
582
  </script>
583
  <?php
584
  }
585
+ /*if($this->ga_CG){?>
586
  <script>
587
  gtag('set', {'content_group': '<?php echo esc_js($this->add_page_type());?>'});
588
  </script>
589
+ <?php } */
590
  //add remarketing snippets
591
+ ?>
592
+ <script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_js($this->remarketing_snippet_id); ?>">
593
+ </script>
594
+ <script>
595
+ window.dataLayer = window.dataLayer || [];
596
+ function gtag(){dataLayer.push(arguments);}
597
+ gtag('js', new Date());
598
+ gtag('config','<?php echo esc_js($this->remarketing_snippet_id); ?>', {'allow_enhanced_conversions':true});
599
+ </script>
600
+ <?php
601
+ /* old code
602
  if($this->ads_tracking_id && ($this->ads_ert || $this->ads_edrt)){
603
  if(!empty($this->remarketing_snippets) && $this->remarketing_snippets){
604
  echo html_entity_decode(str_replace("&#039;", "'", esc_html($this->remarketing_snippets)) );
609
  echo html_entity_decode(str_replace("&#039;", "'",esc_html($googleDetail->google_ads_snippets)) );
610
  }
611
  }
612
+ }*/
613
 
614
  /*facebook pixel*/
615
  if($this->fb_pixel_id != ""){
readme.txt CHANGED
@@ -8,8 +8,8 @@ Author: Conversios
8
  Requires at least: 3.5.0
9
  Tested up to: 6.0
10
  Requires PHP: 5.6 or Higher
11
- Stable tag: 4.7.5
12
- Version: 4.7.5
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
@@ -405,6 +405,9 @@ You can resolve the duplication of data by removing the manually implemented GA
405
 
406
 
407
  == Changelog ==
 
 
 
408
  = 4.7.5 - 07/06/2022 =
409
  * NEW: (PRO) Add the New features "Content Grouping" for Google Analytics tracking & "Google Optimize tracking".
410
 
8
  Requires at least: 3.5.0
9
  Tested up to: 6.0
10
  Requires PHP: 5.6 or Higher
11
+ Stable tag: 4.8.0
12
+ Version: 4.8.0
13
  License: GPLv3
14
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
15
 
405
 
406
 
407
  == Changelog ==
408
+ = 4.8.0 - 20/06/2022 =
409
+ * New:- Add the New Feature "Performance Max Campaigns" so From the plugin itself users can create a Pmax campaign within a few clicks to promote products across Google Search, Shopping, YouTube, Gmail, and the Display Network. He can also check the Campaign-wise performance report which gives visibility of Clicks, Cost, Conversion, and Sales of respective Campaigns.
410
+
411
  = 4.7.5 - 07/06/2022 =
412
  * NEW: (PRO) Add the New features "Content Grouping" for Google Analytics tracking & "Google Optimize tracking".
413