Version Description
Download this release
Release Info
Developer | PixelYourSite |
Plugin | PixelYourSite – Facebook Pixel (Events, WooCommerce & Easy Digital Downloads) |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- css/admin.css +142 -0
- facebook-pixel-master.php +130 -0
- inc/admin.php +258 -0
- inc/helper-functions.php +937 -0
- js/admin.js +156 -0
- js/public.js +114 -0
- readme.txt +58 -0
css/admin.css
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#facebook-pixel-panel-2, #facebook-pixel-panel-3{
|
2 |
+
display: none;
|
3 |
+
}
|
4 |
+
|
5 |
+
.facebook-pixel-body ul.facebook-pixel-menu li {
|
6 |
+
float: left;
|
7 |
+
padding: 10px 10px;
|
8 |
+
font-size: 14px;
|
9 |
+
font-weight: bold;
|
10 |
+
background-color: #ccc;
|
11 |
+
border-radius: 10px 10px 0 0;
|
12 |
+
border: 1px solid #777;
|
13 |
+
color: #222;
|
14 |
+
cursor: pointer;
|
15 |
+
margin-bottom: 0;
|
16 |
+
}
|
17 |
+
.facebook-pixel-body ul.facebook-pixel-menu li.selected, .facebook-pixel-body ul.facebook-pixel-menu li:hover{
|
18 |
+
background: #00a0d2;
|
19 |
+
border-color: #0073aa;
|
20 |
+
color: #fff;
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
.facebook-pixel-content {
|
25 |
+
overflow: hidden;
|
26 |
+
clear: both;
|
27 |
+
width: auto;
|
28 |
+
border: 1px solid #d3d3d3;
|
29 |
+
padding: 0 10px;
|
30 |
+
}
|
31 |
+
|
32 |
+
.facebook-pixel-panel .form-table td p{
|
33 |
+
|
34 |
+
font-size: 11px;
|
35 |
+
}
|
36 |
+
|
37 |
+
.woofp-input-value, .woofp-input-currency{
|
38 |
+
width: 130px;
|
39 |
+
}
|
40 |
+
|
41 |
+
.woofp-input-desc{
|
42 |
+
font-size: 10px;
|
43 |
+
}
|
44 |
+
|
45 |
+
.woofp-input-pageurl{
|
46 |
+
width: 300px;
|
47 |
+
}
|
48 |
+
|
49 |
+
.facebook-pixel-panel .woofp-pageurl-tr .woofp-remove-event {
|
50 |
+
font-size: 10px;
|
51 |
+
font-weight: normal;
|
52 |
+
margin-top: 2px;
|
53 |
+
padding: 1px 6px;
|
54 |
+
display: block;
|
55 |
+
}
|
56 |
+
|
57 |
+
.facebook-pixel-panel .form-table th {
|
58 |
+
font-weight: 600;
|
59 |
+
line-height: 1.3;
|
60 |
+
padding: 10px 0px 10px 0;
|
61 |
+
text-align: left;
|
62 |
+
vertical-align: top;
|
63 |
+
width: 170px;
|
64 |
+
}
|
65 |
+
|
66 |
+
#facebook-pixel-panel-3 .form-table th {
|
67 |
+
width: auto;
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
.woofp-events-help {
|
72 |
+
display: inline-block;
|
73 |
+
position: relative;
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
.woofp-events-help b.woofp-help-icon {
|
78 |
+
background-color: #00a0d2;
|
79 |
+
border-radius: 50%;
|
80 |
+
color: #fff;
|
81 |
+
display: inline-block;
|
82 |
+
font-size: 14px;
|
83 |
+
font-weight: bold;
|
84 |
+
height: 16px;
|
85 |
+
line-height: 16px;
|
86 |
+
margin-right: 10px;
|
87 |
+
padding: 4px 2px;
|
88 |
+
position: relative;
|
89 |
+
text-align: center;
|
90 |
+
width: 20px;
|
91 |
+
}
|
92 |
+
|
93 |
+
.woofp-events-help ul {
|
94 |
+
background: #fff none repeat scroll 0 0;
|
95 |
+
border: 1px solid #333;
|
96 |
+
color: #333;
|
97 |
+
display: none;
|
98 |
+
font-size: 11px;
|
99 |
+
height: 200px;
|
100 |
+
margin: 8px 5px 0 10px;
|
101 |
+
overflow-y: scroll;
|
102 |
+
padding: 5px 0;
|
103 |
+
position: absolute;
|
104 |
+
top: 0;
|
105 |
+
width: 300px;
|
106 |
+
z-index: 99;
|
107 |
+
font-weight: normal;
|
108 |
+
}
|
109 |
+
.woofp-events-help ul li {
|
110 |
+
margin: 4px;
|
111 |
+
padding: 3px 2px;
|
112 |
+
}
|
113 |
+
|
114 |
+
.woofp-events-help:hover ul{
|
115 |
+
display: block;
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
.woofp-events-help:hover ul li b {
|
120 |
+
clear: both;
|
121 |
+
color: #00a0d2;
|
122 |
+
float: left;
|
123 |
+
font-size: 12px;
|
124 |
+
width: 100%;
|
125 |
+
}
|
126 |
+
|
127 |
+
.facebook-pixel-panel td p b {
|
128 |
+
font-size: 16px;
|
129 |
+
color: #00a0d2;
|
130 |
+
}
|
131 |
+
.facebook-pixel-panel a {
|
132 |
+
color: #DD4E4E;
|
133 |
+
font-size: 14px;
|
134 |
+
}
|
135 |
+
|
136 |
+
tr.hide-standardevent{
|
137 |
+
/*display: none;*/
|
138 |
+
}
|
139 |
+
|
140 |
+
tr.show-standardevent{
|
141 |
+
|
142 |
+
}
|
facebook-pixel-master.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: PixelYourSite
|
4 |
+
Description: Add the Facebook Pixel code into your Wordpress site and set up standard events with just a few clicks. Fully compatible with Woocommerce, purchase event included.
|
5 |
+
Plugin URI: http://www.pixelyoursite.com/free
|
6 |
+
Author: PixelYourSite
|
7 |
+
Author URI: http://www.pixelyoursite.com
|
8 |
+
Version: 1.0
|
9 |
+
License: GPLv3
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
require_once('inc/helper-functions.php');
|
14 |
+
|
15 |
+
//Display Facebook Pixel Code
|
16 |
+
|
17 |
+
add_action('login_enqueue_scripts', 'woofp_pixelcode', 1);
|
18 |
+
add_action('wp_head', 'woofp_pixelcode', 1);
|
19 |
+
|
20 |
+
//add addtocart ajax support
|
21 |
+
//only if woocommerce installed
|
22 |
+
if( woofp_is_woocommerce() ){
|
23 |
+
add_action('wp_footer', 'woofp_addtocart_pixel');
|
24 |
+
}
|
25 |
+
|
26 |
+
/* Register script for front end */
|
27 |
+
add_action('wp_enqueue_scripts', 'tkwoofp_publicscripts');
|
28 |
+
|
29 |
+
|
30 |
+
/* Register Admin Page for plugin */
|
31 |
+
add_action('admin_menu', 'woofp_adminmenu');
|
32 |
+
|
33 |
+
/* Register scripts for admin Settings */
|
34 |
+
add_action('admin_enqueue_scripts', 'woofp_adminscripts');
|
35 |
+
|
36 |
+
//Ajax Save Admin Settings
|
37 |
+
add_action('wp_ajax_nopriv_woofbsavesettings' , 'ajax_woofbsavesettings');
|
38 |
+
add_action('wp_ajax_woofbsavesettings' , 'ajax_woofbsavesettings');
|
39 |
+
|
40 |
+
|
41 |
+
/* Plugin Front End Scripts */
|
42 |
+
function tkwoofp_publicscripts(){
|
43 |
+
|
44 |
+
wp_enqueue_script( 'woo-facebookpixel-script', plugins_url( 'js/public.js', __FILE__ ), array('jquery'), '1.0');
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
/* Register Plugin Admin Menu*/
|
49 |
+
function woofp_adminmenu(){
|
50 |
+
|
51 |
+
add_menu_page( 'PixelYourSite', 'PixelYourSite', 'manage_options', 'woo-facebookpixel', 'woofp_admin_page');
|
52 |
+
}
|
53 |
+
|
54 |
+
/* Admin page content */
|
55 |
+
function woofp_admin_page(){
|
56 |
+
|
57 |
+
$facebookpixel = woofp_admin_settings('facebookpixel');
|
58 |
+
$standardevent = woofp_admin_settings('standardevent');
|
59 |
+
$woocommerce_settings = woofp_admin_settings('woocommerce');
|
60 |
+
|
61 |
+
|
62 |
+
include('inc/admin.php');
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
/* admin css and js */
|
67 |
+
function woofp_adminscripts(){
|
68 |
+
|
69 |
+
/* include only if plugin admin page */
|
70 |
+
if(isset($_GET['page']) && $_GET['page'] == 'woo-facebookpixel' ){
|
71 |
+
|
72 |
+
wp_enqueue_style( 'woo-facebookpixel-style', plugins_url( 'css/admin.css', __FILE__ ));
|
73 |
+
wp_enqueue_script( 'woo-facebookpixel-script', plugins_url( 'js/admin.js', __FILE__ ), array('jquery'), '1.0');
|
74 |
+
wp_localize_script( 'woo-facebookpixel-script', 'woofp', array( 'ajaxurl'=> admin_url('admin-ajax.php'), 'loading' => admin_url('images/loading.gif') ) );
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Save Admin Settings
|
81 |
+
*
|
82 |
+
* @return array
|
83 |
+
* @author PixelYourSite
|
84 |
+
**/
|
85 |
+
function ajax_woofbsavesettings(){
|
86 |
+
|
87 |
+
$woo = 0;
|
88 |
+
if( woofp_is_woocommerce() ){
|
89 |
+
$woo = 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
//if ajax is valid
|
93 |
+
if( wp_verify_nonce( $_POST['woofpnonce'], 'woofp-nonce-action' ) ){
|
94 |
+
|
95 |
+
$facebookpixel = isset($_POST['facebookpixel']) ? $_POST['facebookpixel'] : '';
|
96 |
+
$standardevent = isset($_POST['standardevent']) ? $_POST['standardevent'] : '';
|
97 |
+
$woocommerce = isset($_POST['woocommerce']) ? $_POST['woocommerce'] : '';
|
98 |
+
|
99 |
+
//$woofp_options = get_option('woofp_admin_settings');
|
100 |
+
$woofp_options_update = array(
|
101 |
+
|
102 |
+
'facebookpixel' => $facebookpixel,
|
103 |
+
'standardevent' => $standardevent,
|
104 |
+
'woocommerce' => $woocommerce
|
105 |
+
|
106 |
+
);
|
107 |
+
|
108 |
+
//Save admin settings
|
109 |
+
update_option('woofp_admin_settings', $woofp_options_update);
|
110 |
+
$status = array( 'msg' => 'Settings Saved.', 'status' => 2 , 'woo' => $woo);
|
111 |
+
|
112 |
+
} else {
|
113 |
+
|
114 |
+
$status = array( 'msg' => 'cheating huh!', 'status' => 1, 'woo' => $woo);
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
|
119 |
+
//exit ajax
|
120 |
+
die(json_encode($status));
|
121 |
+
}
|
122 |
+
|
123 |
+
|
124 |
+
//Todo:
|
125 |
+
function woofp_plugin_activated(){
|
126 |
+
//todo
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
register_activation_hook( __FILE__, 'woofp_plugin_activated');
|
inc/admin.php
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<br>
|
3 |
+
<h2>PixelYourSite: Manage your Facebook Pixel</h2>
|
4 |
+
<br>
|
5 |
+
<p><b>Implement and control Facebook Pixel with just few clicks.</b></p>
|
6 |
+
<br>
|
7 |
+
|
8 |
+
<div class="facebook-pixel-wrap" id="facebook-pixel-wrap">
|
9 |
+
<div class="facebook-pixel-body">
|
10 |
+
<ul class="facebook-pixel-menu">
|
11 |
+
<li id="facebook-pixel-menu-1" class="selected">Facebook Pixel</li>
|
12 |
+
<li id="facebook-pixel-menu-2">Standard Events Setup</li>
|
13 |
+
<li id="facebook-pixel-menu-3">Woocommerce Setup</li>
|
14 |
+
</ul>
|
15 |
+
|
16 |
+
<div class="facebook-pixel-content">
|
17 |
+
<form action="" method="post" name="facebook-pixel-form" id="facebook-pixel-form">
|
18 |
+
|
19 |
+
<?php wp_nonce_field( 'woofp-nonce-action', 'woofpnonce' );?>
|
20 |
+
|
21 |
+
<div id="facebook-pixel-panel-1" class="facebook-pixel-panel">
|
22 |
+
|
23 |
+
<table class="form-table">
|
24 |
+
<tbody>
|
25 |
+
<tr>
|
26 |
+
<th scope="row"> </th>
|
27 |
+
<td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
|
28 |
+
</tr>
|
29 |
+
<tr>
|
30 |
+
<th scope="row">Your Pixel ID:</th>
|
31 |
+
<td>
|
32 |
+
<input type="text" name="facebookpixel[ID]" value="<?php echo woofp_get_option('facebookpixel', 'ID'); ?>">
|
33 |
+
<p class="description">Enter your Facebook Pixel ID here.</p>
|
34 |
+
</td>
|
35 |
+
</tr>
|
36 |
+
<tr>
|
37 |
+
<th scope="row"> </th>
|
38 |
+
<td>
|
39 |
+
<input type="checkbox" value="1" id="facebookpixel-activate" name="facebookpixel[activate]" <?php checked( '1', woofp_get_option('facebookpixel', 'activate'), true ); ?> />Activate Plugin General Settings.
|
40 |
+
<p class="description">Check this to enable Facebook Pixel.</p>
|
41 |
+
</td>
|
42 |
+
</tr>
|
43 |
+
|
44 |
+
<tr>
|
45 |
+
<th scope="row"> </th>
|
46 |
+
<td><input type="button" class="button button-primary woofp-savesettings" value="Save Settings" /></td>
|
47 |
+
</tr>
|
48 |
+
|
49 |
+
</tbody>
|
50 |
+
</table>
|
51 |
+
|
52 |
+
</div><!-- panel 1 -->
|
53 |
+
|
54 |
+
|
55 |
+
<?php
|
56 |
+
//if not active hide standard event url option
|
57 |
+
$hide_standardevent = 'show-standardevent ';
|
58 |
+
if( woofp_get_option('standardevent', 'activate') != 1 ) { $hide_standardevent .= ' hide-standardevent'; }
|
59 |
+
?>
|
60 |
+
|
61 |
+
<div id="facebook-pixel-panel-2" class="facebook-pixel-panel ">
|
62 |
+
<table class="form-table">
|
63 |
+
<tbody>
|
64 |
+
<tr>
|
65 |
+
<th scope="row"> </th>
|
66 |
+
<td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
|
67 |
+
</tr>
|
68 |
+
|
69 |
+
|
70 |
+
<tr class=" <?php echo $hide_standardevent; ?>">
|
71 |
+
<th scope="row"> </th>
|
72 |
+
<td><h3 style="float:left;">Customize your code with standard events <span class="woofp-events-help"><b class="woofp-help-icon">?</b><?php woofp_event_help(); ?></span></h3></td>
|
73 |
+
</tr>
|
74 |
+
|
75 |
+
<?php
|
76 |
+
|
77 |
+
if( !empty( $standardevent['pageurl'] ) ) {
|
78 |
+
|
79 |
+
|
80 |
+
foreach ( $standardevent['pageurl'] as $key => $link) {
|
81 |
+
|
82 |
+
$pageurl = $standardevent['pageurl'][$key];
|
83 |
+
$cartvalue = $standardevent['value'][$key];
|
84 |
+
$currency = $standardevent['currency'][$key];
|
85 |
+
$eventtype = $standardevent['eventtype'][$key];
|
86 |
+
|
87 |
+
?>
|
88 |
+
|
89 |
+
<tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
|
90 |
+
<th scope="row">Page(URL or Partial URL)</th>
|
91 |
+
<td>
|
92 |
+
<input type="text" name="standardevent[pageurl][]" value="<?php echo $pageurl; ?>" class="woofp-input-pageurl" />
|
93 |
+
|
94 |
+
<select name="standardevent[eventtype][]" class="woofp-input-event">
|
95 |
+
<option vlaue="">- Select Event -</option>
|
96 |
+
<?php echo woofp_event_types($eventtype); ?>
|
97 |
+
</select>
|
98 |
+
<p>
|
99 |
+
Value:<input type="text" name="standardevent[value][]" value="<?php echo $cartvalue; ?>" class=" woofp-input-value" />
|
100 |
+
Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">
|
101 |
+
<option value="">Select Currency</option>
|
102 |
+
<?php echo woofp_currency_options($currency); ?>
|
103 |
+
</select>
|
104 |
+
|
105 |
+
<span class="woofp-input-desc">*Mandatory for purchase event only.</span>
|
106 |
+
</p>
|
107 |
+
<p class="description">This Event will trigger on any URL that contains this string.</p>
|
108 |
+
</td>
|
109 |
+
</tr>
|
110 |
+
|
111 |
+
<?php
|
112 |
+
|
113 |
+
}
|
114 |
+
} else {
|
115 |
+
?>
|
116 |
+
|
117 |
+
<tr class="woofp-pageurl-tr <?php echo $hide_standardevent; ?>">
|
118 |
+
<th scope="row">Page(URL or Partial URL)</th>
|
119 |
+
<td>
|
120 |
+
<input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" />
|
121 |
+
|
122 |
+
<select name="standardevent[eventtype][]" class="woofp-input-event">
|
123 |
+
<option vlaue="">- Select Event -</option>
|
124 |
+
<?php echo woofp_event_types(''); ?>
|
125 |
+
</select>
|
126 |
+
<p>
|
127 |
+
Value:<input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />
|
128 |
+
Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">
|
129 |
+
<option value="">Select Currency</option>
|
130 |
+
<?php echo woofp_currency_options(''); ?>
|
131 |
+
</select>
|
132 |
+
|
133 |
+
<span class="woofp-input-desc">*Mandatory for purchase event only.</span>
|
134 |
+
</p>
|
135 |
+
<p class="description">This Event will trigger on any URL that contains this string.</p>
|
136 |
+
</td>
|
137 |
+
</tr>
|
138 |
+
|
139 |
+
<?php
|
140 |
+
}
|
141 |
+
?>
|
142 |
+
<tr class="<?php echo $hide_standardevent; ?>">
|
143 |
+
<th scope="row"> </th>
|
144 |
+
<td><input type="button" class="button button-secondary woofp-addevent" value="Add More Events" /></td>
|
145 |
+
</tr>
|
146 |
+
|
147 |
+
<tr>
|
148 |
+
<th scope="row"> </th>
|
149 |
+
<td>
|
150 |
+
<input type="checkbox" value="1" id="standardevent-activate" name="standardevent[activate]" <?php checked( '1', woofp_get_option('standardevent', 'activate'), true ); ?> />Activate Standard Event Setup.
|
151 |
+
<p class="description">Check this to enable Standard Event Setup.</p>
|
152 |
+
</td>
|
153 |
+
</tr>
|
154 |
+
|
155 |
+
<tr>
|
156 |
+
<th scope="row"> </th>
|
157 |
+
<td><input type="button" class="button button-primary woofp-savesettings" value="Save Standard Event Setup Settings" /></td>
|
158 |
+
</tr>
|
159 |
+
|
160 |
+
</tbody>
|
161 |
+
</table>
|
162 |
+
</div><!-- panel 2 -->
|
163 |
+
|
164 |
+
|
165 |
+
<div id="facebook-pixel-panel-3" class="facebook-pixel-panel">
|
166 |
+
<?php if( woofp_is_woocommerce() ){ ?>
|
167 |
+
<table class="form-table">
|
168 |
+
<tbody>
|
169 |
+
<tr>
|
170 |
+
<th scope="row"> </th>
|
171 |
+
<td><p><b>Important:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-help" target="_blank">Read this before starting.</a></p></td>
|
172 |
+
</tr>
|
173 |
+
|
174 |
+
<tr>
|
175 |
+
<th scope="row"> </th>
|
176 |
+
<td><p><b>Don't miss this:</b> <a href="http://www.pixelyoursite.com/facebook-pixel-plugin-woocommerce" target="_blank">Read this before activating WooCommerce Setup.</a></p></td>
|
177 |
+
</tr>
|
178 |
+
|
179 |
+
<tr>
|
180 |
+
<th scope="row"> </th>
|
181 |
+
<td><h3 style="float:left;">Activate Pixel Event for WooCommerce Flow</h3>
|
182 |
+
</td>
|
183 |
+
</tr>
|
184 |
+
<?php foreach ( woofp_woocommerce_events() as $key => $woocommerce_event) { ?>
|
185 |
+
|
186 |
+
|
187 |
+
<tr>
|
188 |
+
<th scope="row"><?php echo $woocommerce_event['title']; ?></th>
|
189 |
+
<td><input type="checkbox" name="woocommerce[events][<?php echo $woocommerce_event['event']; ?>]" value="1" <?php woofp_is_woocommerce_event($woocommerce_event['event'], $woocommerce_settings); ?> /> <?php echo $woocommerce_event['label']; ?></td>
|
190 |
+
</tr>
|
191 |
+
|
192 |
+
<?php } ?>
|
193 |
+
|
194 |
+
|
195 |
+
<tr>
|
196 |
+
<th scope="row"> </th>
|
197 |
+
<td>
|
198 |
+
<input type="checkbox" value="1" id="woocommerce-activate" name="woocommerce[activate]" <?php checked( '1', woofp_get_option('woocommerce', 'activate'), true ); ?> />Activate WooCommerce Setup.
|
199 |
+
<p class="description">Check this to enable WooCommerce Setup.</p>
|
200 |
+
</td>
|
201 |
+
</tr>
|
202 |
+
<tr>
|
203 |
+
<th scope="row"> </th>
|
204 |
+
<td><h3>Enable Facebook Dynamic Ads Mode</h3></td>
|
205 |
+
</tr>
|
206 |
+
<tr>
|
207 |
+
<th scope="row"> </th>
|
208 |
+
<td>
|
209 |
+
<input type="checkbox" value="1" name="woocommerce[addtocart]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'addtocart'), true ); ?> /><span class="disabled">Activate AddToCart for Facebook Dynamic Ads.</span>
|
210 |
+
<a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
|
211 |
+
<p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(AddToCart Page)</i></p>
|
212 |
+
</td>
|
213 |
+
</tr>
|
214 |
+
<tr>
|
215 |
+
<th scope="row"> </th>
|
216 |
+
<td>
|
217 |
+
<input type="checkbox" value="1" name="woocommerce[intiatecheckout]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'intiatecheckout'), true ); ?> /><span class="disabled">Activate InitiateCheckout for Facebook Dynamic Ads.</span>
|
218 |
+
<a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
|
219 |
+
<p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. </i>(Checkout Page)</i></p>
|
220 |
+
</td>
|
221 |
+
</tr>
|
222 |
+
<tr>
|
223 |
+
<th scope="row"> </th>
|
224 |
+
<td>
|
225 |
+
<input type="checkbox" value="1" name="woocommerce[purchase]" disabled="disabled" <?php checked( '1', woofp_get_option('woocommerce', 'purchase'), true ); ?> /><span class="disabled">Activate Purchase for Facebook Dynamic Ads.</span>
|
226 |
+
<a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo" target="_blank">Update to the Pro Version</a>
|
227 |
+
<p class="description">This will enable value, currency, content_name, content_category, content_ids, num_items. <i>(Order Recieved/Thank You Page)</i></p>
|
228 |
+
</td>
|
229 |
+
</tr>
|
230 |
+
<tr>
|
231 |
+
<th scope="row"> </th>
|
232 |
+
<td>
|
233 |
+
<h2>Limited Offer:</h2><a href="http://www.pixelyoursite.com/facebook-pixel-plugin-pro-woo-offer">Click Here to get your 50% Off Coupon</a>
|
234 |
+
<p>*To Setup a "AddPaymentInfo" event go to Standard Event Setup tab and add it there. It will only work if payment page is on this server and inside WordPress.</p>
|
235 |
+
</td>
|
236 |
+
</tr>
|
237 |
+
<tr>
|
238 |
+
<th scope="row"> </th>
|
239 |
+
<td><input type="button" class="button button-primary woofp-savesettings" value="Save WooCommerce Settings" /></td>
|
240 |
+
</tr>
|
241 |
+
</tbody>
|
242 |
+
</table>
|
243 |
+
|
244 |
+
<?php } else { ?>
|
245 |
+
<div>
|
246 |
+
<br>
|
247 |
+
<p>Please Install and Activate <b>WooCommerce</b> to enable WooCommerce Integeration.</p>
|
248 |
+
</div>
|
249 |
+
<?php } ?>
|
250 |
+
</div><!-- panel 3 -->
|
251 |
+
|
252 |
+
|
253 |
+
</form>
|
254 |
+
</div>
|
255 |
+
</div>
|
256 |
+
</div>
|
257 |
+
|
258 |
+
</div>
|
inc/helper-functions.php
ADDED
@@ -0,0 +1,937 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Get Admin Settings
|
4 |
+
*
|
5 |
+
* @return array
|
6 |
+
* @author PixelYourSite
|
7 |
+
**/
|
8 |
+
function woofp_admin_settings($option_name='all'){
|
9 |
+
|
10 |
+
|
11 |
+
$settings = get_option('woofp_admin_settings');
|
12 |
+
|
13 |
+
if(empty($settings)) {
|
14 |
+
|
15 |
+
$settings = array();
|
16 |
+
|
17 |
+
} else {
|
18 |
+
|
19 |
+
$options = array('facebookpixel', 'standardevent', 'woocommerce');
|
20 |
+
foreach ( $options as $key => $name ) {
|
21 |
+
|
22 |
+
if( !isset( $settings[$name]) || empty( $settings[$name] ) ){
|
23 |
+
|
24 |
+
$settings[$name] = array();
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
switch ($option_name) {
|
31 |
+
case 'all':
|
32 |
+
|
33 |
+
return $settings;
|
34 |
+
|
35 |
+
break;
|
36 |
+
|
37 |
+
case 'facebookpixel':
|
38 |
+
|
39 |
+
return ( isset($settings['facebookpixel']) ? $settings['facebookpixel'] : '' );
|
40 |
+
|
41 |
+
break;
|
42 |
+
|
43 |
+
case 'standardevent':
|
44 |
+
|
45 |
+
return ( isset($settings['standardevent']) ? $settings['standardevent'] : '' );
|
46 |
+
|
47 |
+
|
48 |
+
break;
|
49 |
+
|
50 |
+
case 'woocommerce':
|
51 |
+
|
52 |
+
return ( isset($settings['woocommerce']) ? $settings['woocommerce'] : '' );
|
53 |
+
|
54 |
+
|
55 |
+
break;
|
56 |
+
|
57 |
+
default:
|
58 |
+
|
59 |
+
return $settings;
|
60 |
+
|
61 |
+
break;
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get Saved Option Value
|
67 |
+
*
|
68 |
+
* @return array|string
|
69 |
+
* @author PixelYourSite
|
70 |
+
**/
|
71 |
+
function woofp_get_option($name='', $option=''){
|
72 |
+
|
73 |
+
if(empty($name) || empty($option))
|
74 |
+
return '';
|
75 |
+
|
76 |
+
$settings = woofp_admin_settings();
|
77 |
+
|
78 |
+
if( isset( $settings[$name][$option] ) )
|
79 |
+
return $settings[$name][$option];
|
80 |
+
else
|
81 |
+
return '';
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Current Page Full URL
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
* @author PixelYourSite
|
89 |
+
**/
|
90 |
+
function woofp_current_url(){
|
91 |
+
|
92 |
+
$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
93 |
+
$current_url = rtrim($current_url, '/');
|
94 |
+
|
95 |
+
return $current_url;
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Return Javascript Code for facebook standard event
|
100 |
+
* ( With fallback for No Javascript )
|
101 |
+
*
|
102 |
+
* @return array
|
103 |
+
* @author PixelYourSite
|
104 |
+
**/
|
105 |
+
function woofp_page_event(){
|
106 |
+
|
107 |
+
$facebookpixel = woofp_admin_settings('facebookpixel');
|
108 |
+
$standardevent = woofp_admin_settings('standardevent');
|
109 |
+
$woocommerce_settings = woofp_admin_settings('woocommerce');
|
110 |
+
|
111 |
+
|
112 |
+
$pixelcode = "";
|
113 |
+
|
114 |
+
/* whether facebook pixel is activated */
|
115 |
+
if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 ){
|
116 |
+
|
117 |
+
$pixel_id = isset($facebookpixel['ID']) ? $facebookpixel['ID'] : '';
|
118 |
+
$current_url = woofp_current_url();
|
119 |
+
$event_added = array();
|
120 |
+
|
121 |
+
|
122 |
+
$nojs_pixelcode = "";
|
123 |
+
|
124 |
+
$pixelcode .= "\n";
|
125 |
+
$nojs_pixelcode .= "\n";
|
126 |
+
|
127 |
+
|
128 |
+
$pixelcode .= "// Insert Your Facebook Pixel ID below. \n fbq('init', '".$pixel_id."'); \n\n";
|
129 |
+
|
130 |
+
$eventtype = 'PageView';
|
131 |
+
|
132 |
+
$pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype ) . " \n\n";
|
133 |
+
$nojs_pixelcode .= "<!-- Default Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype ) . " \n\n";
|
134 |
+
$event_added[] = array( $current_url, $eventtype );
|
135 |
+
|
136 |
+
|
137 |
+
/* whether standerd events is activated */
|
138 |
+
if( isset($standardevent['activate']) && $standardevent['activate'] == 1 ){
|
139 |
+
|
140 |
+
|
141 |
+
|
142 |
+
|
143 |
+
if( isset($standardevent['pageurl']) && !empty( $standardevent['pageurl'] ) ) {
|
144 |
+
|
145 |
+
foreach ( $standardevent['pageurl'] as $key => $link) {
|
146 |
+
|
147 |
+
//if url or event is empty don't go further
|
148 |
+
if( empty($standardevent['pageurl'][$key]) || empty($standardevent['eventtype'][$key]) )
|
149 |
+
continue;
|
150 |
+
|
151 |
+
$pageurl = rtrim($standardevent['pageurl'][$key], '/');
|
152 |
+
$cartvalue = $standardevent['value'][$key];
|
153 |
+
$currency = $standardevent['currency'][$key];
|
154 |
+
$eventtype = $standardevent['eventtype'][$key];
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
|
160 |
+
|
161 |
+
//Add pixel event for added url
|
162 |
+
if( !woofp_is_eventadded( $event_added, $eventtype ) && woofp_match_url($current_url, $pageurl, $eventtype) == 'true' ){
|
163 |
+
$event_added[] = array($current_url, $eventtype );
|
164 |
+
|
165 |
+
|
166 |
+
$pixelcode .= "//Standard Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'standardevent') . " \n\n";
|
167 |
+
$nojs_pixelcode .= "<!-- Standard Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'standardevent') . " \n\n";
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
} /* foreach standardevent['pageurl'] */
|
172 |
+
|
173 |
+
} /* not empty $standardevent['pageurl'] */
|
174 |
+
|
175 |
+
|
176 |
+
} /* standerd event activated */
|
177 |
+
|
178 |
+
/* Woocommerce settings */
|
179 |
+
if( isset($woocommerce_settings['activate']) && $woocommerce_settings['activate'] == 1 && woofp_is_woocommerce() ){
|
180 |
+
|
181 |
+
global $woocommerce;
|
182 |
+
|
183 |
+
$cartvalue = $woocommerce->cart->get_cart_total();
|
184 |
+
$currency = get_woocommerce_currency();
|
185 |
+
|
186 |
+
$cartvalue = strip_tags($cartvalue);
|
187 |
+
$cartvalue = preg_replace("/[^0-9\.]/", "", $cartvalue);
|
188 |
+
|
189 |
+
//Add pixel event for woocommerce pages
|
190 |
+
foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
|
191 |
+
|
192 |
+
$eventtype = $woocommerc_event['event'];
|
193 |
+
|
194 |
+
if(
|
195 |
+
woofp_is_woocommerce_page($woocommerc_event['page'])
|
196 |
+
&& !woofp_is_eventadded( $event_added, $woocommerc_event['event'] )
|
197 |
+
&& woofp_is_woocommerce_event($woocommerc_event['event'], $woocommerce_settings, false)
|
198 |
+
)
|
199 |
+
{
|
200 |
+
|
201 |
+
|
202 |
+
$event_added[] = array( $current_url, $eventtype );
|
203 |
+
|
204 |
+
$pixelcode .= "//WooCommerce Event\n" . woofp_get_event( $eventtype, $cartvalue, $currency, 'woocommerce') . " \n\n";
|
205 |
+
$nojs_pixelcode .= "<!-- WooCommerce Event --> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'woocommerce') . " \n\n";
|
206 |
+
|
207 |
+
}
|
208 |
+
|
209 |
+
|
210 |
+
} /* foreach woofp_woocommerce_events*/
|
211 |
+
|
212 |
+
} /* Woocommerce Settings */
|
213 |
+
|
214 |
+
|
215 |
+
|
216 |
+
//Search Page
|
217 |
+
if( isset($_GET['s']) && $_GET['s'] !='' ){
|
218 |
+
|
219 |
+
$eventtype = 'Search';
|
220 |
+
|
221 |
+
if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
|
222 |
+
$pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n";
|
223 |
+
$nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
|
224 |
+
$event_added[] = array( $current_url, $eventtype );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
//registered page
|
229 |
+
if( isset($_GET['checkemail']) && $_GET['checkemail'] =='registered' ){
|
230 |
+
|
231 |
+
$eventtype = 'CompleteRegistration';
|
232 |
+
if( !woofp_is_eventadded( $event_added, $eventtype ) ) {
|
233 |
+
$pixelcode .= "//Default Event \n" . woofp_get_event( $eventtype, 'default') . " \n\n";
|
234 |
+
$nojs_pixelcode .= "<!-- Default Event--> \n" . woofp_get_event_noscript( $pixel_id, $eventtype, 'default') . " \n\n";
|
235 |
+
$event_added[] = array( $current_url, $eventtype );
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
|
240 |
+
}/* facebook pixel activated */
|
241 |
+
|
242 |
+
$pixelcode .= "\n";
|
243 |
+
$nojs_pixelcode .= "\n";
|
244 |
+
|
245 |
+
return array($pixelcode, $nojs_pixelcode);
|
246 |
+
}
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
/* Todo Prevent Duplicate Event*/
|
251 |
+
function woofp_is_eventadded($addedevents, $event){
|
252 |
+
|
253 |
+
return false;
|
254 |
+
|
255 |
+
if(!empty($addedevents)){
|
256 |
+
|
257 |
+
$result = false;
|
258 |
+
$current_url = woofp_current_url();
|
259 |
+
|
260 |
+
|
261 |
+
foreach ($addedevents as $key => $addedevent) {
|
262 |
+
|
263 |
+
if( woofp_match_url($current_url, $addedevent[0]) == 'true' && $event == $addedevent[1] ){
|
264 |
+
|
265 |
+
$result = true;
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
} else {
|
270 |
+
|
271 |
+
$result = false;
|
272 |
+
}
|
273 |
+
|
274 |
+
return $result;
|
275 |
+
}
|
276 |
+
|
277 |
+
function woofp_get_event($event='', $value=false, $currency='USD', $type=''){
|
278 |
+
|
279 |
+
switch ($event) {
|
280 |
+
|
281 |
+
case 'PageView':
|
282 |
+
|
283 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
284 |
+
return "fbq('track', 'PageView' , {value: '".$value."', currency: '".$currency."'});";
|
285 |
+
else
|
286 |
+
return "fbq('track', 'PageView');";
|
287 |
+
|
288 |
+
case 'ViewContent':
|
289 |
+
|
290 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
291 |
+
return "fbq('track', 'ViewContent', {value: '".$value."', currency: '".$currency."'});";
|
292 |
+
else
|
293 |
+
return "fbq('track', 'ViewContent');";
|
294 |
+
|
295 |
+
break;
|
296 |
+
|
297 |
+
case 'Search':
|
298 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
299 |
+
return "fbq('track', 'Search', {value: '".$value."', currency: '".$currency."'});";
|
300 |
+
else
|
301 |
+
return "fbq('track', 'Search')";
|
302 |
+
|
303 |
+
break;
|
304 |
+
|
305 |
+
|
306 |
+
case 'AddToCart':
|
307 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
308 |
+
return "fbq('track', 'AddToCart', {value: '".$value."', currency: '".$currency."'});";
|
309 |
+
else
|
310 |
+
return "fbq('track', 'AddToCart');";
|
311 |
+
|
312 |
+
break;
|
313 |
+
|
314 |
+
case 'ProductAddToCart':
|
315 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
316 |
+
return "fbq('track', 'AddToCart', {value: '".$value."', currency: '".$currency."'});";
|
317 |
+
else
|
318 |
+
return "fbq('track', 'AddToCart', 'AddToCart');";
|
319 |
+
|
320 |
+
break;
|
321 |
+
|
322 |
+
|
323 |
+
case 'AddToWishlist':
|
324 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
325 |
+
return "fbq('track', 'AddToWishlist', {value: '".$value."', currency: '".$currency."'});";
|
326 |
+
else
|
327 |
+
return "fbq('track', 'AddToWishlist');";
|
328 |
+
|
329 |
+
break;
|
330 |
+
|
331 |
+
|
332 |
+
case 'InitiateCheckout':
|
333 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
334 |
+
return "fbq('track', 'InitiateCheckout', {value: '".$value."', currency: '".$currency."'});";
|
335 |
+
else
|
336 |
+
return "fbq('track', 'InitiateCheckout');";
|
337 |
+
|
338 |
+
break;
|
339 |
+
|
340 |
+
|
341 |
+
case 'AddPaymentInfo':
|
342 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
343 |
+
return "fbq('track', 'AddPaymentInfo', {value: '".$value."', currency: '".$currency."'});";
|
344 |
+
else
|
345 |
+
return "fbq('track', 'AddPaymentInfo');";
|
346 |
+
|
347 |
+
break;
|
348 |
+
|
349 |
+
|
350 |
+
case 'Purchase':
|
351 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
352 |
+
return "fbq('track', 'Purchase', {value: '".$value."', currency: '".$currency."'});";
|
353 |
+
else
|
354 |
+
return "fbq('track', 'Purchase', {value: '0.00', currency: 'USD'});";
|
355 |
+
|
356 |
+
break;
|
357 |
+
|
358 |
+
|
359 |
+
|
360 |
+
case 'Lead':
|
361 |
+
if( $type == 'standardevent' && $value != false && is_numeric( $value ) )
|
362 |
+
return "fbq('track', 'Lead', {value: '".$value."', currency: '".$currency."'});";
|
363 |
+
else
|
364 |
+
return "fbq('track', 'Lead');";
|
365 |
+
|
366 |
+
break;
|
367 |
+
|
368 |
+
|
369 |
+
|
370 |
+
case 'CompleteRegistration':
|
371 |
+
if( $type == 'standardevent' && $value != '' && ( is_float($value) || is_int($value) ) )
|
372 |
+
return "fbq('track', 'CompleteRegistration', {value: '".$value."', currency: '".$currency."'});";
|
373 |
+
else
|
374 |
+
return "fbq('track', 'CompleteRegistration');";
|
375 |
+
|
376 |
+
break;
|
377 |
+
|
378 |
+
default:
|
379 |
+
|
380 |
+
return "";
|
381 |
+
|
382 |
+
break;
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
function woofp_get_event_noscript($pixel_id, $event, $type=''){
|
387 |
+
|
388 |
+
return '<noscript><img height="1" width="1" style="display:none"
|
389 |
+
src="https://www.facebook.com/tr?id='.$pixel_id.'&ev='.$event.'&noscript=1"
|
390 |
+
/></noscript>';
|
391 |
+
|
392 |
+
}
|
393 |
+
|
394 |
+
function woofp_event_types($current=''){
|
395 |
+
?>
|
396 |
+
|
397 |
+
<option <?php echo selected( 'ViewContent', $current, true ); ?> value="ViewContent">ViewContent</option>
|
398 |
+
<option <?php echo selected( 'Search', $current, true ); ?> value="Search">Search</option>
|
399 |
+
<option <?php echo selected( 'AddToCart', $current, true ); ?> value="AddToCart">AddToCart</option>
|
400 |
+
<option <?php echo selected( 'AddToWishlist', $current, true ); ?> value="AddToWishlist">AddToWishlist</option>
|
401 |
+
<option <?php echo selected( 'InitiateCheckout', $current, true ); ?> value="InitiateCheckout">InitiateCheckout</option>
|
402 |
+
<option <?php echo selected( 'AddPaymentInfo', $current, true ); ?> value="AddPaymentInfo">AddPaymentInfo</option>
|
403 |
+
<option <?php echo selected( 'Purchase', $current, true ); ?> value="Purchase">Purchase</option>
|
404 |
+
<option <?php echo selected( 'Lead', $current, true ); ?> value="Lead">Lead</option>
|
405 |
+
<option <?php echo selected( 'CompleteRegistration', $current, true ); ?> value="CompleteRegistration">CompleteRegistration</option>
|
406 |
+
|
407 |
+
<?php
|
408 |
+
}
|
409 |
+
|
410 |
+
function woofp_event_help(){
|
411 |
+
?>
|
412 |
+
<ul class="woofp-event-help">
|
413 |
+
<li><b>ViewContent:</b> Track key page views (ex: product page, landing page or article)</li>
|
414 |
+
<li><b>Search:</b> Track searches on your website (ex. product searches)</li>
|
415 |
+
<li><b>AddToCart:</b> Track when items are added to a shopping cart (ex. click/landing page on Add to Cart button)</li>
|
416 |
+
<li><b>AddToWishlist:</b> Track when items are added to a wishlist (ex. click/landing page on Add to Wishlist button)</li>
|
417 |
+
<li><b>InitiateCheckout:</b> Track when people enter the checkout flow (ex. click/landing page on checkout button)</li>
|
418 |
+
<li><b>AddPaymentInfo:</b> Track when payment information is added in the checkout flow (ex. click/landing page on billing info)</li>
|
419 |
+
<li><b>Purchase:</b> Track purchases or checkout flow completions (ex. landing on "Thank You" or confirmation page)</li>
|
420 |
+
<li><b>Lead:</b> Track when a user expresses interest in your offering (ex. form submission, sign up for trial, landing on pricing page)</li>
|
421 |
+
<li><b>CompleteRegistration:</b> Track when a registration form is completed (ex. complete subscription, sign up for a service)</li>
|
422 |
+
</ul>
|
423 |
+
<?php
|
424 |
+
}
|
425 |
+
|
426 |
+
|
427 |
+
|
428 |
+
function woofp_currency_options( $current='USD' ){
|
429 |
+
?>
|
430 |
+
<option <?php echo selected( 'AUD', $current, true ); ?> value="AUD">Australian Dollar</option>
|
431 |
+
<option <?php echo selected( 'BRL', $current, true ); ?> value="BRL">Brazilian Real </option>
|
432 |
+
<option <?php echo selected( 'CAD', $current, true ); ?> value="CAD">Canadian Dollar</option>
|
433 |
+
<option <?php echo selected( 'CZK', $current, true ); ?> value="CZK">Czech Koruna</option>
|
434 |
+
<option <?php echo selected( 'DKK', $current, true ); ?> value="DKK">Danish Krone</option>
|
435 |
+
<option <?php echo selected( 'EUR', $current, true ); ?> value="EUR">Euro</option>
|
436 |
+
<option <?php echo selected( 'HKD', $current, true ); ?> value="HKD">Hong Kong Dollar</option>
|
437 |
+
<option <?php echo selected( 'HUF', $current, true ); ?> value="HUF">Hungarian Forint </option>
|
438 |
+
<option <?php echo selected( 'ILS', $current, true ); ?> value="ILS">Israeli New Sheqel</option>
|
439 |
+
<option <?php echo selected( 'JPY', $current, true ); ?> value="JPY">Japanese Yen</option>
|
440 |
+
<option <?php echo selected( 'MYR', $current, true ); ?> value="MYR">Malaysian Ringgit</option>
|
441 |
+
<option <?php echo selected( 'MXN', $current, true ); ?> value="MXN">Mexican Peso</option>
|
442 |
+
<option <?php echo selected( 'NOK', $current, true ); ?> value="NOK">Norwegian Krone</option>
|
443 |
+
<option <?php echo selected( 'NZD', $current, true ); ?> value="NZD">New Zealand Dollar</option>
|
444 |
+
<option <?php echo selected( 'PHP', $current, true ); ?> value="PHP">Philippine Peso</option>
|
445 |
+
<option <?php echo selected( 'PLN', $current, true ); ?> value="PLN">Polish Zloty</option>
|
446 |
+
<option <?php echo selected( 'GBP', $current, true ); ?> value="GBP">Pound Sterling</option>
|
447 |
+
<option <?php echo selected( 'SGD', $current, true ); ?> value="SGD">Singapore Dollar</option>
|
448 |
+
<option <?php echo selected( 'SEK', $current, true ); ?> value="SEK">Swedish Krona</option>
|
449 |
+
<option <?php echo selected( 'CHF', $current, true ); ?> value="CHF">Swiss Franc</option>
|
450 |
+
<option <?php echo selected( 'TWD', $current, true ); ?> value="TWD">Taiwan New Dollar</option>
|
451 |
+
<option <?php echo selected( 'THB', $current, true ); ?> value="THB">Thai Baht</option>
|
452 |
+
<option <?php echo selected( 'TRY', $current, true ); ?> value="TRY">Turkish Lira</option>
|
453 |
+
<option <?php echo selected( 'USD', $current, true ); ?> value="USD">U.S. Dollar</option>
|
454 |
+
|
455 |
+
<?php
|
456 |
+
}
|
457 |
+
|
458 |
+
|
459 |
+
function woofp_pixelcode(){
|
460 |
+
|
461 |
+
//load facebook pixel on front only
|
462 |
+
if( !is_admin() ){
|
463 |
+
|
464 |
+
$facebookpixel = woofp_admin_settings('facebookpixel');
|
465 |
+
|
466 |
+
if( isset($facebookpixel['activate']) && $facebookpixel['activate'] == 1 ) {
|
467 |
+
?>
|
468 |
+
|
469 |
+
<!-- Facebook Pixel Code -->
|
470 |
+
|
471 |
+
<script>
|
472 |
+
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
473 |
+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
|
474 |
+
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
|
475 |
+
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
|
476 |
+
document,'script','//connect.facebook.net/en_US/fbevents.js');
|
477 |
+
|
478 |
+
/* pixel plugin code */
|
479 |
+
<?php
|
480 |
+
|
481 |
+
$facebookpixel_code = woofp_page_event();
|
482 |
+
echo $facebookpixel_code[0];
|
483 |
+
?>
|
484 |
+
/* pixel plugin code */
|
485 |
+
|
486 |
+
</script>
|
487 |
+
<?php echo $facebookpixel_code[1]; ?>
|
488 |
+
|
489 |
+
<!-- End Facebook Pixel Code -->
|
490 |
+
|
491 |
+
<?php
|
492 |
+
}
|
493 |
+
|
494 |
+
} else {
|
495 |
+
?>
|
496 |
+
<img src="<?php echo admin_url('admin-ajax.php'); ?>" style="display:none;">
|
497 |
+
|
498 |
+
<?php
|
499 |
+
}
|
500 |
+
|
501 |
+
|
502 |
+
|
503 |
+
}
|
504 |
+
|
505 |
+
|
506 |
+
/*
|
507 |
+
Woocommerce Related Functions
|
508 |
+
Check if woocommerce is install and activated.
|
509 |
+
*/
|
510 |
+
|
511 |
+
function woofp_addtocart_urls($woofp_options=''){
|
512 |
+
|
513 |
+
|
514 |
+
$facebookpixel = $woofp_options['facebookpixel'];
|
515 |
+
$standardevent = $woofp_options['standardevent'];
|
516 |
+
$woocommerce_settings = $woofp_options['woocommerce'];
|
517 |
+
|
518 |
+
|
519 |
+
|
520 |
+
/* whether facebook pixel is activated */
|
521 |
+
if( woofp_get_option('facebookpixel', 'activate') == 1 ){
|
522 |
+
|
523 |
+
/* whether standerd events is activated */
|
524 |
+
if( woofp_get_option('standardevent', 'activate') == 1 ){
|
525 |
+
|
526 |
+
|
527 |
+
|
528 |
+
$results = array();
|
529 |
+
if( isset( $standardevent['pageurl'] ) && !empty($standardevent['pageurl']) ){
|
530 |
+
|
531 |
+
foreach ( $standardevent['pageurl'] as $key => $link) {
|
532 |
+
|
533 |
+
$pageurl = rtrim($standardevent['pageurl'][$key], '/');
|
534 |
+
$cartvalue = $standardevent['value'][$key];
|
535 |
+
$currency = $standardevent['currency'][$key];
|
536 |
+
$eventtype = $standardevent['eventtype'][$key];
|
537 |
+
|
538 |
+
if( !in_array($pageurl, $results) && $eventtype == 'AddToCart' )
|
539 |
+
$results[] = $pageurl;
|
540 |
+
|
541 |
+
|
542 |
+
}
|
543 |
+
|
544 |
+
}
|
545 |
+
|
546 |
+
if( woofp_get_option('woocommerce', 'activate') == 1 ){
|
547 |
+
|
548 |
+
//Add pixel event for woocommerce pages
|
549 |
+
foreach (woofp_woocommerce_events() as $key => $woocommerc_event) {
|
550 |
+
|
551 |
+
$eventtype = $woocommerc_event['event'];
|
552 |
+
if( !in_array( '***', $results) && woofp_is_woocommerce_event($eventtype, $woocommerce_settings, false) && $eventtype == 'AddToCart' )
|
553 |
+
$results[] = '***';
|
554 |
+
}
|
555 |
+
|
556 |
+
}
|
557 |
+
|
558 |
+
}
|
559 |
+
|
560 |
+
}
|
561 |
+
|
562 |
+
|
563 |
+
return $results;
|
564 |
+
|
565 |
+
}
|
566 |
+
|
567 |
+
|
568 |
+
function woofp_addtocart_pixel(){
|
569 |
+
|
570 |
+
//Run AddToCart Event when product are added using ajax
|
571 |
+
//todo: woocommerce_cart_redirect_after_add
|
572 |
+
|
573 |
+
$woofp_options = get_option('woofp_admin_settings');
|
574 |
+
$facebookpixel = $woofp_options['facebookpixel'];
|
575 |
+
$standardevent = $woofp_options['standardevent'];
|
576 |
+
$woocommerce_settings = $woofp_options['woocommerce'];
|
577 |
+
|
578 |
+
|
579 |
+
|
580 |
+
|
581 |
+
if (
|
582 |
+
get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes'
|
583 |
+
|
584 |
+
) {
|
585 |
+
|
586 |
+
$php_array = woofp_addtocart_urls($woofp_options);
|
587 |
+
$js_array = json_encode($php_array);
|
588 |
+
|
589 |
+
|
590 |
+
?>
|
591 |
+
<script type="text/javascript">
|
592 |
+
|
593 |
+
/*
|
594 |
+
//Run AddToCart Event when product are added using ajax
|
595 |
+
*/
|
596 |
+
jQuery(function($){
|
597 |
+
|
598 |
+
jQuery(document).on( 'click', '.add_to_cart_button', function() {
|
599 |
+
|
600 |
+
var current_url = jQuery(this).attr('href');
|
601 |
+
|
602 |
+
|
603 |
+
<?php echo "var url_array = ". $js_array . ";\n"; ?>
|
604 |
+
<?php echo "var homeurl = '". home_url() . "';\n"; ?>
|
605 |
+
for (i = 0; i < url_array.length; i++) {
|
606 |
+
|
607 |
+
if (current_url.indexOf('http://') < 0 || current_url.indexOf('https://') < 0){
|
608 |
+
current_url = homeurl + current_url;
|
609 |
+
}
|
610 |
+
|
611 |
+
if( current_url.indexOf(url_array[i]) !== 0 || url_array[i] == '***' ){
|
612 |
+
|
613 |
+
fbq('track', 'AddToCart');
|
614 |
+
console.log('AddToCart');
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
|
619 |
+
});
|
620 |
+
|
621 |
+
});
|
622 |
+
</script>
|
623 |
+
<?php }
|
624 |
+
}
|
625 |
+
|
626 |
+
|
627 |
+
|
628 |
+
function woofp_is_woocommerce_page ($page) {
|
629 |
+
|
630 |
+
switch ($page) {
|
631 |
+
|
632 |
+
case 'woocommerce_view_content':
|
633 |
+
|
634 |
+
if( is_woocommerce() ){
|
635 |
+
return true;
|
636 |
+
}
|
637 |
+
|
638 |
+
case 'woocommerce_added_to_cart':
|
639 |
+
|
640 |
+
return false;
|
641 |
+
|
642 |
+
break;
|
643 |
+
|
644 |
+
|
645 |
+
case 'woocommerce_cart_page_id':
|
646 |
+
|
647 |
+
return is_cart();
|
648 |
+
|
649 |
+
break;
|
650 |
+
|
651 |
+
case 'woocommerce_checkout_page_id':
|
652 |
+
|
653 |
+
if( is_checkout() && !is_wc_endpoint_url() )
|
654 |
+
return true;
|
655 |
+
else
|
656 |
+
return false;
|
657 |
+
|
658 |
+
break;
|
659 |
+
|
660 |
+
case 'woocommerce_thanks_page_id':
|
661 |
+
|
662 |
+
if( is_wc_endpoint_url( 'order-received' ) )
|
663 |
+
return true;
|
664 |
+
else
|
665 |
+
return false;
|
666 |
+
|
667 |
+
|
668 |
+
break;
|
669 |
+
|
670 |
+
case 'woocommerce_search_product':
|
671 |
+
|
672 |
+
if ( isset($_GET['s']) && ( isset($_GET['post_type']) && $_GET['post_type'] == 'product' ) ) {
|
673 |
+
|
674 |
+
return true ;
|
675 |
+
|
676 |
+
} else {
|
677 |
+
|
678 |
+
return false;
|
679 |
+
}
|
680 |
+
|
681 |
+
break;
|
682 |
+
|
683 |
+
default:
|
684 |
+
return false;
|
685 |
+
break;
|
686 |
+
}
|
687 |
+
|
688 |
+
}
|
689 |
+
|
690 |
+
|
691 |
+
/**
|
692 |
+
* Return appropriate pixel events for woocommerce pages
|
693 |
+
*
|
694 |
+
* @return array
|
695 |
+
* @author PixelYourSite
|
696 |
+
**/
|
697 |
+
function woofp_woocommerce_events(){
|
698 |
+
|
699 |
+
$woocommerce_events = array(
|
700 |
+
|
701 |
+
array(
|
702 |
+
'event' => 'ViewContent',
|
703 |
+
'page' => 'woocommerce_view_content',
|
704 |
+
'title' => 'Any WooCommerce Page',
|
705 |
+
'label' => 'ViewContent Event'
|
706 |
+
),
|
707 |
+
|
708 |
+
array(
|
709 |
+
'event' => 'ProductAddToCart',
|
710 |
+
'page' => 'woocommerce_added_to_cart',
|
711 |
+
'title' => 'Product Added to Cart',
|
712 |
+
'label' => 'AddToCart Event'
|
713 |
+
),
|
714 |
+
|
715 |
+
array(
|
716 |
+
'event' => 'AddToCart',
|
717 |
+
'page' => 'woocommerce_cart_page_id',
|
718 |
+
'title' => 'AddToCart Page',
|
719 |
+
'label' => 'AddToCart Event'
|
720 |
+
),
|
721 |
+
array(
|
722 |
+
'event' => 'InitiateCheckout',
|
723 |
+
'page' => 'woocommerce_checkout_page_id',
|
724 |
+
'title' => 'CheckOut Page',
|
725 |
+
'label' => 'InitiateCheckout Event'
|
726 |
+
),
|
727 |
+
/*array(
|
728 |
+
'event' => 'AddPaymentInfo',
|
729 |
+
'page' => 'woocommerce_checkout_page_id',
|
730 |
+
'title' => 'Checkout Page',
|
731 |
+
'label' => 'AddPaymentInfo Event'
|
732 |
+
),*/
|
733 |
+
array(
|
734 |
+
'event' => 'Purchase',
|
735 |
+
'page' => 'woocommerce_thanks_page_id',
|
736 |
+
'title' => 'Thankyou Page',
|
737 |
+
'label' => 'Purchase Event'
|
738 |
+
),
|
739 |
+
/*array(
|
740 |
+
'event' => 'Search',
|
741 |
+
'page' => 'woocommerce_search_product',
|
742 |
+
'title' => 'Product Search',
|
743 |
+
'label' => ' Search Event'
|
744 |
+
),*/
|
745 |
+
|
746 |
+
);
|
747 |
+
|
748 |
+
return $woocommerce_events;
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* Check if woocommerce event is activated in settings
|
753 |
+
* @return string | true/false
|
754 |
+
* @author PixelYourSite
|
755 |
+
**/
|
756 |
+
function woofp_is_woocommerce_event($event, $settings, $echo=true){
|
757 |
+
|
758 |
+
|
759 |
+
if( isset( $settings['events'] ) && !empty($settings['events']) && isset($settings['events'][$event]) && $settings['events'][$event] == 1 ){
|
760 |
+
$checked = 'checked="checked"';
|
761 |
+
$return = true;
|
762 |
+
} else {
|
763 |
+
|
764 |
+
$checked = '';
|
765 |
+
$return = false;
|
766 |
+
}
|
767 |
+
|
768 |
+
if($echo){
|
769 |
+
echo $checked;
|
770 |
+
} else {
|
771 |
+
|
772 |
+
return $return;
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
function woofp_startsWith($haystack, $needle) {
|
777 |
+
// search backwards starting from haystack length characters from the end
|
778 |
+
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
|
779 |
+
}
|
780 |
+
|
781 |
+
function woofp_endsWith($haystack, $needle) {
|
782 |
+
// search forward starting from end minus needle length characters
|
783 |
+
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
|
784 |
+
}
|
785 |
+
|
786 |
+
|
787 |
+
function woofp_valid_url($value){
|
788 |
+
$pattern = "@^(?:https?://)?(?:[a-z0-9-]+\.)*((?:[a-z0-9-]+\.)[a-z]+)@";
|
789 |
+
|
790 |
+
if (!preg_match($pattern, $value)){
|
791 |
+
return false;
|
792 |
+
}
|
793 |
+
|
794 |
+
return true;
|
795 |
+
}
|
796 |
+
|
797 |
+
/**
|
798 |
+
* add http:// to url if missing
|
799 |
+
*
|
800 |
+
* @return string
|
801 |
+
* @author PixelYourSite
|
802 |
+
**/
|
803 |
+
function woofp_addhttp($url=''){
|
804 |
+
|
805 |
+
if (preg_match("#https?://#", $url) === 0) {
|
806 |
+
$url = 'http://'.$url;
|
807 |
+
}
|
808 |
+
|
809 |
+
return $url;
|
810 |
+
}
|
811 |
+
|
812 |
+
|
813 |
+
/**
|
814 |
+
* Remove http(s)/www. from url
|
815 |
+
*
|
816 |
+
* @return string
|
817 |
+
* @author PixelYourSite
|
818 |
+
**/
|
819 |
+
function woofp_remove_protocol($url=''){
|
820 |
+
|
821 |
+
if(empty($url) && !woofp_valid_url($url))
|
822 |
+
return $url;
|
823 |
+
|
824 |
+
$url = str_replace(array('http://', 'https://', 'http://www.', 'https://www.'), '', $url);
|
825 |
+
|
826 |
+
$url = trim($url);
|
827 |
+
$url = trim($url, '//');
|
828 |
+
$url = rtrim($url, '/');
|
829 |
+
|
830 |
+
return $url;
|
831 |
+
}
|
832 |
+
|
833 |
+
|
834 |
+
function woofp_match_url($current_url, $match_url, $eventtype='' ){
|
835 |
+
|
836 |
+
$current_url = woofp_remove_protocol($current_url);
|
837 |
+
$match_url = woofp_remove_protocol($match_url);
|
838 |
+
|
839 |
+
if(strpos($match_url, '*') !== false && woofp_endsWith($match_url, '*') ){
|
840 |
+
|
841 |
+
$temp_url = $match_url;
|
842 |
+
$temp_url = rtrim($temp_url, '*');
|
843 |
+
|
844 |
+
$temp_url = trim($temp_url);
|
845 |
+
$temp_url = trim($temp_url, '//');
|
846 |
+
$temp_url = rtrim($temp_url, '/');
|
847 |
+
|
848 |
+
|
849 |
+
|
850 |
+
if ( woofp_valid_url($temp_url) === true) {
|
851 |
+
|
852 |
+
$current_postid = url_to_postid( woofp_addhttp($current_url) );
|
853 |
+
$match_postid = url_to_postid( woofp_addhttp($temp_url) );
|
854 |
+
$current_length = strlen($current_url);
|
855 |
+
$match_length = strlen($temp_url);
|
856 |
+
|
857 |
+
$postmatch = false;
|
858 |
+
|
859 |
+
if( $current_postid && $match_postid && $current_postid == $match_postid ){
|
860 |
+
$postmatch = true;
|
861 |
+
}
|
862 |
+
|
863 |
+
|
864 |
+
$strcmp1 = strcmp($temp_url, $current_url);
|
865 |
+
$strcmp2 = strcmp($current_url, $temp_url);
|
866 |
+
|
867 |
+
$found1 = ( (strpos($temp_url, $current_url) !== false ) ? 'true' : 'false' );
|
868 |
+
$found2 = ( (strpos($current_url, $temp_url) !== false ) ? 'true' : 'false' );
|
869 |
+
|
870 |
+
if( $match_length > $current_length && $found1 == 'true' ){
|
871 |
+
|
872 |
+
$ret = ( ( $strcmp1 < 0 || $postmatch ) ? 'true' : 'false' );
|
873 |
+
|
874 |
+
} else if( $match_length < $current_length && $found2 == 'true' ){
|
875 |
+
|
876 |
+
$ret = ( ( $strcmp2 > 0 || $postmatch ) ? 'true' : 'false' );
|
877 |
+
|
878 |
+
} else {
|
879 |
+
|
880 |
+
$ret = ( ( $strcmp1 == 0 || $postmatch ) ? 'true' : 'false' );
|
881 |
+
|
882 |
+
}
|
883 |
+
|
884 |
+
|
885 |
+
return $ret;
|
886 |
+
|
887 |
+
} else {
|
888 |
+
|
889 |
+
|
890 |
+
return 'false';
|
891 |
+
}
|
892 |
+
|
893 |
+
} else {
|
894 |
+
|
895 |
+
|
896 |
+
if ( woofp_valid_url($match_url) === true ) {
|
897 |
+
|
898 |
+
$current_postid = url_to_postid( woofp_addhttp($current_url) );
|
899 |
+
$match_postid = url_to_postid( woofp_addhttp($match_url) );
|
900 |
+
|
901 |
+
$postmatch = false;
|
902 |
+
if( $current_postid && $match_postid && $current_postid == $match_postid ){
|
903 |
+
$postmatch = true;
|
904 |
+
}
|
905 |
+
|
906 |
+
$strcmp = strcmp( $current_url, $match_url );
|
907 |
+
$ret = ( ( $strcmp == 0 || $postmatch ) ? 'true' : 'false' );
|
908 |
+
|
909 |
+
|
910 |
+
return $ret;
|
911 |
+
|
912 |
+
} else {
|
913 |
+
|
914 |
+
$strpos = strpos($current_url, $match_url);
|
915 |
+
$ret = ( $strpos !== false ? 'true' : 'false' );
|
916 |
+
|
917 |
+
|
918 |
+
return $ret;
|
919 |
+
|
920 |
+
}
|
921 |
+
|
922 |
+
}
|
923 |
+
}
|
924 |
+
|
925 |
+
function woofp_is_woocommerce(){
|
926 |
+
|
927 |
+
if ( !class_exists( 'WooCommerce' ) ) {
|
928 |
+
|
929 |
+
return false;
|
930 |
+
|
931 |
+
} else {
|
932 |
+
|
933 |
+
|
934 |
+
return true;
|
935 |
+
}
|
936 |
+
|
937 |
+
}
|
js/admin.js
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function($){
|
2 |
+
|
3 |
+
|
4 |
+
/* Tabs */
|
5 |
+
$('.facebook-pixel-body ul li').on('click', function(event) {
|
6 |
+
|
7 |
+
event.preventDefault();
|
8 |
+
var i = $(this).attr('id').replace('facebook-pixel-menu-', '');
|
9 |
+
$('.facebook-pixel-body ul li').removeClass('selected');
|
10 |
+
$(this).addClass('selected');
|
11 |
+
|
12 |
+
$('.facebook-pixel-panel').hide();
|
13 |
+
$('#facebook-pixel-panel-'+i).show();
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
});
|
18 |
+
|
19 |
+
/* Add remove button for removing pageurl option */
|
20 |
+
function woofp_removebutton(){
|
21 |
+
|
22 |
+
|
23 |
+
$('.woofp-pageurl-tr').each(function(index, el) {
|
24 |
+
|
25 |
+
|
26 |
+
var $this = $(this);
|
27 |
+
if( index > 0 ){
|
28 |
+
|
29 |
+
|
30 |
+
//insert remove button for pageurl/event option except first
|
31 |
+
var th = $this.find('th:first');
|
32 |
+
if( th.find('input.woofp-remove-event').length < 1 ){
|
33 |
+
th.html( th.html() + '<input type="button" class="button button-secondary woofp-remove-event" value="Remove" />');
|
34 |
+
}
|
35 |
+
|
36 |
+
} else {
|
37 |
+
|
38 |
+
//insert reset button for first pageurl/event option
|
39 |
+
var th = $this.find('th:first');
|
40 |
+
if( th.find('input.woofp-reset-event').length < 1 ){
|
41 |
+
th.html( th.html() + '<input type="button" class="button button-secondary woofp-reset-event" value="Reset" />');
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
});
|
46 |
+
|
47 |
+
}
|
48 |
+
woofp_removebutton();
|
49 |
+
|
50 |
+
/* Reset standard event */
|
51 |
+
$(document).on('click', '.woofp-reset-event', function(event) {
|
52 |
+
|
53 |
+
event.preventDefault();
|
54 |
+
var $this = $(this);
|
55 |
+
$(this).closest('tr.woofp-pageurl-tr').find('input').not(':button, :submit, :reset, :hidden').val('')
|
56 |
+
$(this).closest('tr.woofp-pageurl-tr').find('select option:eq(0)').prop('selected', true);
|
57 |
+
|
58 |
+
});
|
59 |
+
|
60 |
+
/* Remove standard event */
|
61 |
+
$(document).on('click', '.woofp-remove-event', function(event) {
|
62 |
+
|
63 |
+
event.preventDefault();
|
64 |
+
var $this = $(this);
|
65 |
+
$(this).closest('tr.woofp-pageurl-tr').remove();
|
66 |
+
|
67 |
+
});
|
68 |
+
|
69 |
+
/* Add more Event */
|
70 |
+
$(document).on('click', '.woofp-addevent', function(event) {
|
71 |
+
|
72 |
+
event.preventDefault();
|
73 |
+
var events_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-event').html();
|
74 |
+
var currencty_options = $('tr.woofp-pageurl-tr:first td:first select.woofp-input-currency').html();
|
75 |
+
|
76 |
+
var html = '';
|
77 |
+
html += '<tr class="woofp-pageurl-tr">';
|
78 |
+
html += '<th scope="row">Page(URL or Partial URL)</th>';
|
79 |
+
html += '<td>';
|
80 |
+
html += '<input type="text" name="standardevent[pageurl][]" value="" class="woofp-input-pageurl" />';
|
81 |
+
html += '<select name="standardevent[eventtype][]">';
|
82 |
+
html += events_options;
|
83 |
+
html += '</select>';
|
84 |
+
html += '<p>';
|
85 |
+
html += 'Value:<input type="text" name="standardevent[value][]" value="" class=" woofp-input-value" />';
|
86 |
+
html += 'Currency:<select name="standardevent[currency][]" class=" woofp-input-currency">';
|
87 |
+
html += '<option value="">Select Currency</option>';
|
88 |
+
html += currencty_options;
|
89 |
+
html += '</select>';
|
90 |
+
html += '<span class="woofp-input-desc">*Mandatory for purchase event only.</span>';
|
91 |
+
html += '</p>';
|
92 |
+
html += '<p class="description">This Event will trigger on any URL that contains this string.</p>';
|
93 |
+
html += '</td>';
|
94 |
+
html += '</tr>';
|
95 |
+
|
96 |
+
var $this = $(this);
|
97 |
+
|
98 |
+
$this.closest('tr').before(html).hide().fadeIn();
|
99 |
+
woofp_removebutton();
|
100 |
+
|
101 |
+
});
|
102 |
+
|
103 |
+
/*
|
104 |
+
Save Settings
|
105 |
+
*/
|
106 |
+
$(document).on('click', '.woofp-savesettings', function(event){
|
107 |
+
|
108 |
+
event.preventDefault();
|
109 |
+
|
110 |
+
var data = $('#facebook-pixel-form').serialize();
|
111 |
+
data = 'action=woofbsavesettings&'+data;
|
112 |
+
|
113 |
+
var loader = '<img src="'+woofp.loading+'" alt="Loading..." class="woofp-loading" style="display:inline; padding:10px 10px;" />';
|
114 |
+
var $this = $(this);
|
115 |
+
|
116 |
+
$this.prop('disabled', true);
|
117 |
+
$this.after(loader);
|
118 |
+
|
119 |
+
var facebookpixel = $('#facebookpixel-activate').prop('checked');
|
120 |
+
var standardevent = $('#standardevent-activate').prop('checked');
|
121 |
+
var woocommerce = $('#woocommerce-activate').prop('checked');
|
122 |
+
|
123 |
+
$.ajax({
|
124 |
+
url: woofp.ajaxurl,
|
125 |
+
type: 'POST',
|
126 |
+
dataType: 'json',
|
127 |
+
data: data,
|
128 |
+
})
|
129 |
+
.done(function(data) {
|
130 |
+
|
131 |
+
if( data.woo == 0 ){
|
132 |
+
|
133 |
+
location.reload(true);
|
134 |
+
|
135 |
+
} else {
|
136 |
+
|
137 |
+
if( standardevent ){
|
138 |
+
$('tr.show-standardevent').removeClass('hide-standardevent');
|
139 |
+
} else {
|
140 |
+
|
141 |
+
$('tr.show-standardevent').addClass('hide-standardevent');
|
142 |
+
}
|
143 |
+
|
144 |
+
$this.next('img.woofp-loading').remove();
|
145 |
+
$this.prop('disabled', false);
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
});
|
150 |
+
|
151 |
+
|
152 |
+
|
153 |
+
});
|
154 |
+
|
155 |
+
|
156 |
+
});
|
js/public.js
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function woofp_parse_str(str, array) {
|
2 |
+
|
3 |
+
var strArr = String(str)
|
4 |
+
.replace(/^&/, '')
|
5 |
+
.replace(/&$/, '')
|
6 |
+
.split('&'),
|
7 |
+
sal = strArr.length,
|
8 |
+
i, j, ct, p, lastObj, obj, lastIter, undef, chr, tmp, key, value,
|
9 |
+
postLeftBracketPos, keys, keysLen,
|
10 |
+
fixStr = function(str) {
|
11 |
+
return decodeURIComponent(str.replace(/\+/g, '%20'));
|
12 |
+
};
|
13 |
+
|
14 |
+
if (!array) {
|
15 |
+
array = this.window;
|
16 |
+
}
|
17 |
+
|
18 |
+
for (i = 0; i < sal; i++) {
|
19 |
+
tmp = strArr[i].split('=');
|
20 |
+
key = fixStr(tmp[0]);
|
21 |
+
value = (tmp.length < 2) ? '' : fixStr(tmp[1]);
|
22 |
+
|
23 |
+
while (key.charAt(0) === ' ') {
|
24 |
+
key = key.slice(1);
|
25 |
+
}
|
26 |
+
if (key.indexOf('\x00') > -1) {
|
27 |
+
key = key.slice(0, key.indexOf('\x00'));
|
28 |
+
}
|
29 |
+
if (key && key.charAt(0) !== '[') {
|
30 |
+
keys = [];
|
31 |
+
postLeftBracketPos = 0;
|
32 |
+
for (j = 0; j < key.length; j++) {
|
33 |
+
if (key.charAt(j) === '[' && !postLeftBracketPos) {
|
34 |
+
postLeftBracketPos = j + 1;
|
35 |
+
} else if (key.charAt(j) === ']') {
|
36 |
+
if (postLeftBracketPos) {
|
37 |
+
if (!keys.length) {
|
38 |
+
keys.push(key.slice(0, postLeftBracketPos - 1));
|
39 |
+
}
|
40 |
+
keys.push(key.substr(postLeftBracketPos, j - postLeftBracketPos));
|
41 |
+
postLeftBracketPos = 0;
|
42 |
+
if (key.charAt(j + 1) !== '[') {
|
43 |
+
break;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
if (!keys.length) {
|
49 |
+
keys = [key];
|
50 |
+
}
|
51 |
+
for (j = 0; j < keys[0].length; j++) {
|
52 |
+
chr = keys[0].charAt(j);
|
53 |
+
if (chr === ' ' || chr === '.' || chr === '[') {
|
54 |
+
keys[0] = keys[0].substr(0, j) + '_' + keys[0].substr(j + 1);
|
55 |
+
}
|
56 |
+
if (chr === '[') {
|
57 |
+
break;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
obj = array;
|
62 |
+
for (j = 0, keysLen = keys.length; j < keysLen; j++) {
|
63 |
+
key = keys[j].replace(/^['"]/, '')
|
64 |
+
.replace(/['"]$/, '');
|
65 |
+
lastIter = j !== keys.length - 1;
|
66 |
+
lastObj = obj;
|
67 |
+
if ((key !== '' && key !== ' ') || j === 0) {
|
68 |
+
if (obj[key] === undef) {
|
69 |
+
obj[key] = {};
|
70 |
+
}
|
71 |
+
obj = obj[key];
|
72 |
+
} else { // To insert new dimension
|
73 |
+
ct = -1;
|
74 |
+
for (p in obj) {
|
75 |
+
if (obj.hasOwnProperty(p)) {
|
76 |
+
if (+p > ct && p.match(/^\d+$/g)) {
|
77 |
+
ct = +p;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
key = ct + 1;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
lastObj[key] = value;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
|
92 |
+
jQuery(function($){
|
93 |
+
|
94 |
+
|
95 |
+
/*$( document ).ajaxComplete(function( event, xhr, settings ) {
|
96 |
+
|
97 |
+
var ajaxurl = settings.url;
|
98 |
+
var ajaxdata = settings.data;
|
99 |
+
//var ajaxresponse = xhr.responseText;
|
100 |
+
|
101 |
+
if( ajaxurl == '/?wc-ajax=add_to_cart' ){
|
102 |
+
|
103 |
+
var dataObj = {};
|
104 |
+
woofp_parse_str(ajaxdata, dataObj);
|
105 |
+
console.log(dataObj);
|
106 |
+
if( dataObj.product_id != '' ){
|
107 |
+
fbq('track', 'AddToCart');
|
108 |
+
}
|
109 |
+
|
110 |
+
});*/
|
111 |
+
|
112 |
+
|
113 |
+
});
|
114 |
+
|
readme.txt
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== PixelYourSite: Manage your Facebook Pixel ===
|
2 |
+
Contributors: PixelYourSite
|
3 |
+
Tags: Facebook, Facebook pixel, Facebook pixel events, tracking, standard events, Facebook events, Facebook standard events, new Facebook pixel
|
4 |
+
Requires at least: 3.0.1
|
5 |
+
Tested up to: 4.3.1
|
6 |
+
Stable tag: 1.0
|
7 |
+
License: GPLv3
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
+
|
10 |
+
Insert the Facebook Pixel code into your WordPress site and start tracking standard events with just a few clicks (Woocommerce ready)
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
As you probably know, Facebook will retire the old Facebook Conversion Pixel in 2016. They recommend the use the Facebook Pixel for conversion tracking, optimization and remarketing. **This plugin will help you insert the pixel code on every page with just one click, setup standard events and add them value or currency**. There is an **out of the box setup for Woocommerce** that will configure all the necessary standard events for you.
|
14 |
+
|
15 |
+
<p style="text-align: center;">Visit this page for <strong><a href="http://www.pixelyoursite.com/free" target="_blank"><span style="color:#DE4D4D;">more details about how to use the plugin: Click Here</span></a></strong></p>
|
16 |
+
|
17 |
+
* You can **insert the pixel on every page of your website with just a few clicks**. No need to edit any post or pages.
|
18 |
+
|
19 |
+
* You can **set up and track any type of events and you can set the value and the currency** for each event.
|
20 |
+
|
21 |
+
* You can **insert the Facebook pixel and start tracking events on any Woocommerce** website with just one click.
|
22 |
+
|
23 |
+
* You can **automatically track the cart value in Woocommerce for any purchase event** (Pro Version Only)
|
24 |
+
|
25 |
+
* Out of the box **Facebook Dynamic Ads** setup for your Woocommerce website (Pro Version Only)
|
26 |
+
|
27 |
+
|
28 |
+
<p style="text-align: center;">Visit this page for <strong><a href="http://www.pixelyoursite.com/free" target="_blank"><span style="color:#DE4D4D;">more details about how to use the plugin: Click Here</span></a></strong></p>
|
29 |
+
|
30 |
+
== Installation ==
|
31 |
+
* From the WP admin panel, click \"Plugins\" -> \"Add new\".
|
32 |
+
* In the browser input box, type \"PixelYourSite\".
|
33 |
+
* Select the \"PixelYourSite\" plugin (authored by \"PixelYourSite\"), and click \"Install\".
|
34 |
+
* Activate the plugin.
|
35 |
+
|
36 |
+
OR...
|
37 |
+
|
38 |
+
* Download the plugin from this page.
|
39 |
+
* Save the .zip file to a location on your computer.
|
40 |
+
* Open the WP admin panel, and click \"Plugins\" -> \"Add new\".
|
41 |
+
* Click \"upload\".. then browse to the .zip file downloaded from this page.
|
42 |
+
* Click \"Install\".. and then \"Activate plugin\".
|
43 |
+
|
44 |
+
OR...
|
45 |
+
|
46 |
+
* Download the plugin from this page.
|
47 |
+
* Extract the .zip file to a location on your computer.
|
48 |
+
* Use either FTP or your hosts cPanel to gain access to your website file directories.
|
49 |
+
* Browse to the `wp-content/plugins` directory.
|
50 |
+
* Upload the extracted `wp_edit` folder to this directory location.
|
51 |
+
* Open the WP admin panel.. click the \"Plugins\" page.. and click \"Activate\" under the newly added plugin.
|
52 |
+
|
53 |
+
|
54 |
+
== Frequently Asked Questions ==
|
55 |
+
We maintain an up to date FAQ page on our site:
|
56 |
+
|
57 |
+
<strong><a href="http://www.pixelyoursite.com/facebool-pixel-master-faq" target="_blank"><span style="color:#DE4D4D;">Click here for the FAQ page</span></a></strong>
|
58 |
+
|