Skip to content

Commit 54eb91f

Browse files
committed
Merge branch 'release/2.0.3'
v2.0.3
2 parents 5f59323 + 00182f0 commit 54eb91f

10 files changed

Lines changed: 1355 additions & 940 deletions

File tree

assets/css/style.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,56 @@ PLEASE DO NOT MODIFY*/
326326
visibility: visible;
327327
opacity: 1;
328328
}
329+
.wcct-notice-wrap {
330+
overflow: hidden;
331+
padding: 22px 15px;
332+
}
333+
.wcct-message-icon {
334+
width: 10%;
335+
float: left;
336+
}
337+
.wcct-message-icon img {
338+
height: 50px;
339+
}
340+
.wcct-message-content {
341+
width: 70%;
342+
float: left;
343+
margin-top: 20px;
344+
}
345+
.wcct-message-content p {
346+
font-size: 16px;
347+
padding: 0;
348+
margin: 0;
349+
}
350+
.wcct-message-action {
351+
width: 16.5%;
352+
float: right;
353+
text-align: center;
354+
margin-right: 1.2%;
355+
}
356+
#wcct_remote_notice {
357+
display: none;
358+
}
359+
#wcct-install-happ-addons {
360+
background: #5c41d2 !important;
361+
border-color: #5c41d2 !important;
362+
box-shadow: 0 1px 0 #5c41d2;
363+
color: #fff;
364+
text-decoration: none;
365+
text-shadow: 0 -1px 1px #5c41d2, 1px 0 1px #5c41d2, 0 1px 1px #5c41d2, -1px 0 1px #5c41d2;
366+
height: inherit;
367+
padding: 4px 20px;
368+
display: flex;
369+
align-items: center;
370+
}
371+
#wcct-install-happ-addons i {
372+
margin-right: 7px;
373+
}
374+
#wcct-install-happ-addons:hover {
375+
background: #150654 !important;
376+
border-color: #150654 !important;
377+
box-shadow: 0 1px 0 #150654;
378+
color: #fff;
379+
text-decoration: none;
380+
text-shadow: 0 -1px 1px #150654, 1px 0 1px #150654, 0 1px 1px #150654, -1px 0 1px #150654;
381+
}

assets/images/happy-addons.png

9.77 KB
Loading

assets/js/admin.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,27 @@
8888
$( tooltipText ).text( newText );
8989
} );
9090

91+
// Install and activate happy addons
92+
$( '#wcct-install-happ-addons' ).on( 'click', function( e ) {
93+
e.preventDefault();
94+
var loader = $( '#wcct-preloader' );
95+
$('.wcct-update-icon').remove();
96+
$(this).text('Installing...');
97+
$(this).addClass( 'updating-message' );
98+
loader.show();
99+
var remote_message = $( '#wcct_remote_notice' );
100+
wp.ajax.send( 'activate_happy_addons', {
101+
success: function( response ) {
102+
$('.wcct-notice-wrap').hide();
103+
loader.hide();
104+
remote_message.show();
105+
remote_message.html('<p><strong>' + response.message + 'Happy Addons !</strong></p>');
106+
},
107+
error: function( error ) {
108+
loader.hide();
109+
remote_message.html('<p><strong>' + response.message + '</strong></p>');
110+
}
111+
} );
112+
} );
113+
91114
})( jQuery );

conversion-tracking.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: WooCommerce Conversion Tracking
44
Plugin URI: https://wedevs.com/products/plugins/woocommerce-conversion-tracking/
55
Description: Adds various conversion tracking codes to cart, checkout, registration success and product page on WooCommerce
6-
Version: 2.0.2
6+
Version: 2.0.3
77
Author: Tareq Hasan
88
Author URI: https://tareq.co/
99
License: GPL2
@@ -54,7 +54,7 @@ class WeDevs_WC_Conversion_Tracking {
5454
*
5555
* @var string
5656
*/
57-
public $version = '2.0.2';
57+
public $version = '2.0.3';
5858

5959
/**
6060
* Holds various class instances
@@ -181,6 +181,7 @@ public function init_hooks() {
181181
add_action( 'init', array( $this, 'init_tracker' ) );
182182
add_action( 'admin_notices', array( $this, 'check_woocommerce_exist' ) );
183183
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
184+
add_action( 'admin_notices', array( $this, 'happy_addons_ads_banner' ) );
184185
}
185186

186187
/**
@@ -286,6 +287,40 @@ public function check_woocommerce_exist() {
286287
<?php
287288
}
288289
}
290+
291+
/**
292+
* Add happy addons ads banner
293+
*
294+
* @return void
295+
*/
296+
public function happy_addons_ads_banner() {
297+
if ( ! class_exists( '\Elementor\Plugin' ) ) {
298+
return;
299+
}
300+
301+
if ( class_exists( '\Happy_Addons\Elementor\Base' ) ) {
302+
return;
303+
}
304+
305+
?>
306+
<div id="wcct_remote_notice" class="notice notice-success">
307+
</div>
308+
<div class="notice wcct-notice-wrap">
309+
<div class="wcct-message-icon">
310+
<img src="<?php echo WCCT_ASSETS . '/images/happy-addons.png'?>" alt="">
311+
</div>
312+
<div class="wcct-message-content">
313+
<p><?php _e( 'Reach beyond your imagination in creating web pages. <strong> Try Happy Addons for Elementor to shape your dream.</strong> 😊') ?></p>
314+
</div>
315+
<div class="wcct-message-action">
316+
<a href="" id="wcct-install-happ-addons" class="button button-primary"> <i class="dashicons dashicons-update wcct-update-icon"></i> Install Now For FREE</a>
317+
<p></strong><a target="_blank" href="https://wordpress.org/plugins/happy-elementor-addons/">Read more details ➔</a>
318+
</p>
319+
</div>
320+
</div>
321+
322+
<?php
323+
}
289324
}
290325

291326
function wcct_init() {

includes/class-ajax.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class WCCT_Ajax {
1010
*/
1111
public function __construct() {
1212
add_action( 'wp_ajax_wcct_save_settings', array( $this, 'wcct_save_settings' ) );
13+
add_action( 'wp_ajax_activate_happy_addons', array( $this, 'wcct_install_happy_addons' ) );
1314
}
1415

1516
/**
@@ -42,4 +43,50 @@ public function wcct_save_settings() {
4243
) );
4344

4445
}
46+
/**
47+
* Install the Happy addons via ajax
48+
*
49+
* @return json
50+
*/
51+
public function wcct_install_happy_addons() {
52+
53+
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
54+
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
55+
56+
$upgrader = new Plugin_Upgrader( new WP_Ajax_Upgrader_Skin() );
57+
58+
$plugin = 'happy-elementor-addons';
59+
$api = plugins_api( 'plugin_information', array( 'slug' => $plugin, 'fields' => array( 'sections' => false ) ) );
60+
61+
62+
if (is_wp_error($api)) {
63+
die(sprintf(__('ERROR: Error fetching plugin information: %s', 'woocommerce-conversion-tracking'), $api->get_error_message()));
64+
}
65+
66+
add_filter( 'upgrader_package_options', function ( $options ) {
67+
$options['clear_destination'] = true;
68+
$options['hook_extra'] = [
69+
'type' => 'plugin',
70+
'action' => 'install',
71+
'plugin' => 'happy-elementor-addons/plugin.php',
72+
];
73+
return $options;
74+
});
75+
76+
$result = $upgrader->install( $api->download_link );
77+
78+
if ( is_wp_error( $result ) ) {
79+
wp_send_json_error( $result );
80+
}
81+
82+
$result = activate_plugin( 'happy-elementor-addons/plugin.php' );
83+
84+
if ( is_wp_error( $result ) ) {
85+
wp_send_json_error( $result );
86+
}
87+
wp_send_json_success([
88+
'message' => __( 'Successfully installed and activate,', 'woocommerce-conversion-tracking' )
89+
]);
90+
}
91+
4592
}

includes/integrations/class-integration-facebook.php

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ public function enqueue_script() {
9898
echo $this->build_event( 'PageView', array() );
9999
?>
100100
</script>
101-
102-
<noscript><img height="1" width="1" style="display:none"
103-
src="https://www.facebook.com/tr?id=<?php echo $facebook_pixel_id; ?>&ev=PageView&noscript=1"
104-
/></noscript>
105101
<?php
106102

107-
$this->add_to_cart_ajax();
103+
$this->print_event_script();
104+
105+
if ( ! class_exists( 'WeDevs_WC_Conversion_Tracking_Pro' ) ) {
106+
$this->add_to_cart_ajax();
107+
}
108108
}
109109

110110
/**
@@ -139,13 +139,17 @@ public function add_to_cart_ajax() {
139139
if ( ! $this->event_enabled( 'AddToCart' ) ) {
140140
return;
141141
}
142+
143+
$integration_settins = $this->get_integration_settings();
144+
$facebook_pixel_id = ! empty( $integration_settins[0]['pixel_id'] ) ? $integration_settins[0]['pixel_id'] : '';
142145
?>
143146
<script type="text/javascript">
144147
jQuery(function($) {
145-
$(document).on('added_to_cart', function (event, fragments, hash, button) {
146-
fbq('track', 'AddToCart', {
147-
content_ids: [ $(button).data('product_id') ],
148-
content_type: 'product',
148+
$(document).on('added_to_cart', function (event, fragments, dhash, button) {
149+
wcfbq('<?php echo $facebook_pixel_id ?>', 'AddToCart', {
150+
content_ids: [ $(button).data('product_id') ],
151+
content_type: 'product',
152+
currency: '<?php echo get_woocommerce_currency()?>'
149153
});
150154
});
151155
});
@@ -247,6 +251,73 @@ public function get_product_categories( $product_id ) {
247251
'categories' => $categories
248252
);
249253
}
254+
255+
public function print_event_script() {
256+
?>
257+
<script>
258+
(function (window, document) {
259+
if (window.wcfbq) return;
260+
window.wcfbq = (function () {
261+
if (arguments.length > 0) {
262+
var pixelId, trackType, contentObj;
263+
264+
if (typeof arguments[0] == 'string') pixelId = arguments[0];
265+
if (typeof arguments[1] == 'string') trackType = arguments[1];
266+
if (typeof arguments[2] == 'object') contentObj = arguments[2];
267+
268+
var params = [];
269+
if (typeof pixelId === 'string' && pixelId.replace(/\s+/gi, '') != '' &&
270+
typeof trackType === 'string' && trackType.replace(/\s+/gi, '')) {
271+
params.push('id=' + encodeURIComponent(pixelId));
272+
switch (trackType) {
273+
case 'PageView':
274+
case 'ViewContent':
275+
case 'Search':
276+
case 'AddToCart':
277+
case 'InitiateCheckout':
278+
case 'AddPaymentInfo':
279+
case 'Lead':
280+
case 'CompleteRegistration':
281+
case 'Purchase':
282+
case 'AddToWishlist':
283+
params.push('ev=' + encodeURIComponent(trackType));
284+
break;
285+
default:
286+
return;
287+
}
288+
289+
params.push('dl=' + encodeURIComponent(document.location.href));
290+
if (document.referrer) params.push('rl=' + encodeURIComponent(document.referrer));
291+
params.push('if=false');
292+
params.push('ts=' + new Date().getTime());
293+
294+
if (typeof contentObj == 'object') {
295+
for (var u in contentObj) {
296+
if (typeof contentObj[u] == 'object' && contentObj[u] instanceof Array) {
297+
if (contentObj[u].length > 0) {
298+
for (var y = 0; y < contentObj[u].length; y++) { contentObj[u][y] = (contentObj[u][y] + '').replace(/^\s+|\s+$/gi, '').replace(/\s+/gi, ' ').replace(/,/gi, '§'); }
299+
params.push('cd[' + u + ']=' + encodeURIComponent(contentObj[u].join(',').replace(/^/gi, '[\'').replace(/$/gi, '\']').replace(/,/gi, '\',\'').replace(/§/gi, '\,')));
300+
}
301+
}
302+
else if (typeof contentObj[u] == 'string')
303+
params.push('cd[' + u + ']=' + encodeURIComponent(contentObj[u]));
304+
}
305+
}
306+
307+
params.push('v=' + encodeURIComponent('2.7.19'));
308+
309+
var imgId = new Date().getTime();
310+
var img = document.createElement('img');
311+
img.id = 'fb_' + imgId, img.src = 'https://www.facebook.com/tr/?' + params.join('&'), img.width = 1, img.height = 1, img.style = 'display:none;';
312+
document.body.appendChild(img);
313+
window.setTimeout(function () { var t = document.getElementById('fb_' + imgId); t.parentElement.removeChild(t); }, 1000);
314+
}
315+
}
316+
});
317+
})(window, document);
318+
</script>
319+
<?php
320+
}
250321
}
251322

252323
return new WCCT_Integration_Facebook();

languages/woocommerce-conversion-tracking.pot

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
# Copyright (C) 2018 Tareq Hasan
1+
# Copyright (C) 2019 Tareq Hasan
22
# This file is distributed under the GPL2.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: WooCommerce Conversion Tracking 2.0\n"
5+
"Project-Id-Version: WooCommerce Conversion Tracking 2.0.2\n"
66
"Report-Msgid-Bugs-To: https://example.com\n"
7-
"POT-Creation-Date: 2018-02-22 11:39:03+00:00\n"
7+
"POT-Creation-Date: 2019-04-29 05:55:29+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
11-
"PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n"
11+
"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
1414
"X-Generator: grunt-wp-i18n 0.5.4\n"
1515

16-
#: conversion-tracking.php:268
16+
#: conversion-tracking.php:267
1717
msgid "Get PRO"
1818
msgstr ""
1919

20-
#: conversion-tracking.php:271
20+
#: conversion-tracking.php:270
2121
msgid "Docs"
2222
msgstr ""
2323

24-
#: conversion-tracking.php:272
24+
#: conversion-tracking.php:271
2525
msgid "Settings"
2626
msgstr ""
2727

28+
#: conversion-tracking.php:284
29+
msgid ""
30+
"<b>Woocommerce conversion tracking</b> requires <a target=\"_blank\" "
31+
"href=\"https://wordpress.org/plugins/woocommerce/\">Woocommerce</a>"
32+
msgstr ""
33+
2834
#: includes/class-admin.php:49
2935
msgid "Conversion Tracking"
3036
msgstr ""
@@ -75,7 +81,7 @@ msgstr ""
7581
msgid "Premium Features"
7682
msgstr ""
7783

78-
#: includes/class-integration-pro-features.php:137
84+
#: includes/class-integration-pro-features.php:138
7985
msgid "Get Premium"
8086
msgstr ""
8187

@@ -185,7 +191,7 @@ msgid "Insert conversion tracking code for this product."
185191
msgstr ""
186192

187193
#: includes/integrations/class-integration-custom.php:13
188-
#: includes/views/settings.php:154
194+
#: includes/views/settings.php:155
189195
msgid "Custom"
190196
msgstr ""
191197

@@ -279,6 +285,10 @@ msgstr ""
279285
msgid "Perfect Audience"
280286
msgstr ""
281287

288+
#: includes/views/settings.php:154
289+
msgid "Bing Ads"
290+
msgstr ""
291+
282292
#. Plugin Name of the plugin/theme
283293
msgid "WooCommerce Conversion Tracking"
284294
msgstr ""

0 commit comments

Comments
 (0)