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 | ![]() |
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 +35 -1
- admin/class-enhanced-ecommerce-google-analytics-admin.php +9 -0
- admin/css/style.css +196 -4
- admin/helper/class-pmax-helper.php +551 -0
- admin/js/pmax-custom.js +563 -0
- admin/js/tvc-ee-custom.js +13 -11
- admin/partials/class-conversios-header.php +4 -0
- admin/partials/general-fields.php +13 -7
- enhanced-ecommerce-google-analytics.php +2 -2
- includes/class-enhanced-ecommerce-google-analytics.php +1 -0
- includes/setup/ShoppingApi.php +7 -0
- includes/setup/account.php +1 -1
- includes/setup/pmax-add.php +348 -0
- includes/setup/pmax-edit.php +406 -0
- includes/setup/pmax.php +203 -0
- public/class-enhanced-ecommerce-google-analytics-public-pro.php +17 -3
- readme.txt +5 -2
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( '
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
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 |