WP Google Analytics Events - Version 1.5

Version Description

Download this release

Release Info

Developer yuvalo
Plugin Icon 128x128 WP Google Analytics Events
Version 1.5
Comparing to
See all releases

Code changes from version 1.4 to 1.5

css/style.css CHANGED
@@ -1,6 +1,5 @@
1
  #ga_main {
2
  float:left;
3
- width:80%;
4
  display: block;
5
  }
6
  #ga_main th {
@@ -10,11 +9,14 @@
10
  max-width: 400px;
11
  }
12
 
 
 
 
13
  .ga_events_sidebar {
14
  float:right;
15
- width: 195px;
16
  margin-top:52px;
17
- margin-right: 10px;
18
  }
19
  .ga_intable {
20
  margin-left:10px;
@@ -65,14 +67,13 @@
65
  border-radius: 7px;
66
  position: relative;
67
  }
68
- }
69
 
70
  .wpcta {
71
  text-align: center;
72
  }
73
 
74
  .ga_events_sidebar li {
75
- list-style-type: square !important;
76
  color: #FFF;
77
  font-size: 14px;
78
  }
@@ -119,4 +120,12 @@
119
 
120
  #mc_embed_signup input.email {
121
  width: 96% !important;
122
- }
 
 
 
 
 
 
 
 
1
  #ga_main {
2
  float:left;
 
3
  display: block;
4
  }
5
  #ga_main th {
9
  max-width: 400px;
10
  }
11
 
12
+ #ga_main li {
13
+ list-style-type: none;
14
+ }
15
  .ga_events_sidebar {
16
  float:right;
17
+ width: 250px;
18
  margin-top:52px;
19
+ margin-right: 30px;
20
  }
21
  .ga_intable {
22
  margin-left:10px;
67
  border-radius: 7px;
68
  position: relative;
69
  }
 
70
 
71
  .wpcta {
72
  text-align: center;
73
  }
74
 
75
  .ga_events_sidebar li {
76
+ list-style-type: none !important;
77
  color: #FFF;
78
  font-size: 14px;
79
  }
120
 
121
  #mc_embed_signup input.email {
122
  width: 96% !important;
123
+ }
124
+
125
+ a[href="admin.php?page=wp-google-analytics-events-upgrade"] {
126
+ color: #F7691D !important;
127
+ }
128
+
129
+ a[href="admin.php?page=wp-google-analytics-events-upgrade"]:hover {
130
+ color: #cf471c !important;
131
+ }
ga-scroll-event.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Google Analytics Events
4
  Plugin URI: http://wpflow.com
5
  Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
6
- Version: 1.4
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
@@ -17,13 +17,24 @@ along with this program; if not, write to the Free Software
17
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
  */
19
 
 
 
 
 
 
20
 
21
 
22
  /*
23
  * Plugin Activation
24
  */
25
 
 
 
 
26
  register_activation_hook( __FILE__, 'ga_events_install' );
 
 
 
27
 
28
 
29
  function ga_events_install() {
@@ -34,259 +45,15 @@ function ga_events_install() {
34
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
35
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
36
  );
37
- update_option( 'ga_events_options', $ga_events_options );
38
-
39
- }
40
-
41
- /*
42
- * Plugin Admin Settings
43
- */
44
-
45
- add_action( 'admin_menu', 'ga_events_menu');
46
-
47
- function ga_events_menu() {
48
- add_options_page('WP Google Analytics Settings','WP Google Analytics Events','manage_options', __FILE__, 'ga_events_settings_page' );
49
- }
50
-
51
- function ga_events_settings_page() {
52
- ?>
53
- <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
54
- <div id="ga_main" class="wrap">
55
- <?php screen_icon( 'plugins' ); ?>
56
- <h2>GA Scroll Events Plugin</h2>
57
-
58
- <form method="post" action='options.php'>
59
- <?php settings_fields('ga_events_options'); ?>
60
- <?php do_settings_sections('ga_events'); ?>
61
- <input class="button-primary" type="submit" name="submit" value="Save Changes" />
62
- </form>
63
-
64
- </div>
65
- <div class="wrap ga_events_sidebar">
66
- <table class="form-table widefat" >
67
- <thead>
68
- <th>Upgrade to Pro</th>
69
- </thead>
70
- <tbody>
71
- <tr class="features">
72
- <td>
73
- <ul>
74
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>Assign Event Value</strong></li>
75
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
76
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>HTML Tags support</strong></li>
77
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>Bounce Rate Control</strong></li>
78
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>Improved link tracking</strong></li>
79
- <li><i class="fa fa-check-square-o fa-lg"></i><strong>Pro Support</strong></li>
80
- </ul>
81
- </td>
82
- </tr>
83
- <tr class="tfoot">
84
- <td>
85
- <div class="wpcta">
86
- <a class="btn btn-subscribe" href="http://wpflow.com/upgrade/">
87
- <span class="btn-title ">
88
- Starting from
89
- <span class="btn-data">
90
- <span class="price">$29</span>
91
- </span>
92
- </span>
93
- </a>
94
- </div>
95
- </td>
96
- </tr>
97
- </tbody>
98
- </table>
99
- <!-- Begin MailChimp Signup Form -->
100
- <link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
101
- <style type="text/css">
102
- #mc_embed_signup{background:#fff; clear:left; font:13px Helvetica,Arial,sans-serif; width:194px;}
103
- /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
104
- We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
105
- </style>
106
- <div id="mc_embed_signup">
107
- <form action="http://wpflow.us6.list-manage.com/subscribe/post?u=3a1990ecd0eee6198c11e5fc1&amp;id=7e01c30e7f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
108
- <div class="form-content">
109
- <h4>Receive plugin updates, news, promo codes and more</h4>
110
- <label for="mce-EMAIL">Subscribe to our mailing list</label>
111
- <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
112
- <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
113
- <div style="position: absolute; left: -5000px;"><input type="text" name="b_3a1990ecd0eee6198c11e5fc1_7e01c30e7f" value=""></div>
114
- </div>
115
- <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn-subscribe "></div>
116
- </form>
117
- </div>
118
-
119
- <!--End mc_embed_signup-->
120
- </div>
121
-
122
-
123
- <?php
124
- }
125
-
126
- function load_custom_wp_admin_style() {
127
- wp_register_style( 'custom_wp_admin_css', plugins_url('css/style.css', __FILE__));
128
- wp_enqueue_style( 'custom_wp_admin_css' );
129
- }
130
-
131
- add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
132
-
133
- add_action('admin_init', 'ga_events_admin_init');
134
-
135
- function ga_events_admin_init() {
136
- register_setting('ga_events_options','ga_events_options','ga_events_validate');
137
- add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
138
- add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
139
- add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
140
- add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
141
- add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events','ga_events_main');
142
- add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events','ga_events_main');
143
- add_settings_field('ga_events_sidebar', '','ga_events_setting_sidebar','ga_events','ga_events_main');
144
-
145
-
146
- }
147
-
148
- function ga_events_section_text() {
149
- echo "<a href='http://wpflow.com/documentation'>Plugin Documentation</a>";
150
- }
151
-
152
- function ga_events_setting_input() {
153
- $options = get_option('ga_events_options');
154
- $id = $options['id'];
155
- echo "<label>Google Analytics Identifier</label>";
156
- echo "<span class='ga_intable'><input class='inputs' id='id' name='ga_events_options[id]' type='text' value='$id' /></span>";
157
 
158
  }
159
 
 
160
 
161
- function ga_events_setting_snippet_input() {
162
- $options = get_option('ga_events_options');
163
- $id = $options['exclude_snippet'];
164
- echo "<label>Don't add the GA tracking code</label>";
165
- echo "<span class='ga_intable'><input id='snippet' name='ga_events_options[exclude_snippet]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
166
-
167
- }
168
-
169
- function ga_events_setting_uni_input() {
170
- $options = get_option('ga_events_options');
171
- $id = $options['universal'];
172
- echo "<label>Universal Tracking Code</label>";
173
- echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
174
-
175
- }
176
-
177
- function ga_events_setting_divs_input() {
178
- $options = get_option('ga_events_options');
179
- $divs = $options['divs'];
180
- echo "<label>Scroll Events</label><br />";
181
- echo "<table class='widefat inputs inner_table'><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th></th></thead><tbody>";
182
- if (!($divs[0][0])){
183
- echo "<tr>";
184
- echo "<td><input id='divs' name='ga_events_options[divs][0][0]' type='text' value='".$divs[0][0]."' /></td>";
185
- echo "<td><select id='divs' name='ga_events_options[divs][0][1]'><option selected value='id' >id</option><option value='class'>class</option></select></td>";
186
- echo "<td><input id='divs' name='ga_events_options[divs][0][2]' type='text' value='".$divs[0][2]."' /></td>";
187
- echo "<td><input id='divs' name='ga_events_options[divs][0][3]' type='text' value='".$divs[0][3]."' /></td>";
188
- echo "<td><input id='divs' name='ga_events_options[divs][0][4]' type='text' value='".$divs[0][4]."' /></td>";
189
- echo "</tr>";
190
-
191
- }else{
192
- for ($i = 0; $i < sizeof($divs)+1; $i++){
193
-
194
- echo "<tr>";
195
- echo "<td><input id='divs' name='ga_events_options[divs][$i][0] type='text' value='".$divs[$i][0]."' /></td>";
196
- echo "<td><select id='divs' name='ga_events_options[divs][$i][1]'>";
197
- if ($divs[$i][1] == 'id'){
198
- echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
199
- }else {
200
- echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
201
- }
202
- echo "<td><input id='divs' name='ga_events_options[divs][$i][2]' type='text' value='".$divs[$i][2]."' /></td>";
203
- echo "<td><input id='divs' name='ga_events_options[divs][$i][3]' type='text' value='".$divs[$i][3]."' /></td>";
204
- echo "<td><input id='divs' name='ga_events_options[divs][$i][4]' type='text' value='".$divs[$i][4]."' /></td>";
205
- echo "<td><a class='remove' href=''>Remove</a></td>";
206
- echo "</tr>";
207
-
208
- }
209
-
210
- }
211
- echo "</tbody></table>";
212
- }
213
-
214
-
215
- function ga_events_setting_click_input() {
216
- $options = get_option('ga_events_options');
217
- $click = $options['click'];
218
- echo "<label>Click Events</label><br />";
219
- echo "<table class='widefat inputs inner_table'><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th></th></thead><tbody>";
220
- if (!($click[0][0])){
221
- echo "<tr>";
222
- echo "<td><input id='click' name='ga_events_options[click][0][0]' type='text' value='".$click[0][0]."' /></td>";
223
- echo "<td><select id='click' name='ga_events_options[click][0][1]'><option selected value='id'>id</option><option value='class'>class</option></select></td>";
224
- echo "<td><input id='click' name='ga_events_options[click][0][2]' type='text' value='".$click[0][2]."' /></td>";
225
- echo "<td><input id='click' name='ga_events_options[click][0][3]' type='text' value='".$click[0][3]."' /></td>";
226
- echo "<td><input id='click' name='ga_events_options[click][0][4]' type='text' value='".$click[0][4]."' /></td>";
227
- echo "</tr>";
228
-
229
- }else{
230
- for ($i = 0; $i < sizeof($click)+1; $i++){
231
-
232
- echo "<tr>";
233
- echo "<td><input id='divs' name='ga_events_options[click][$i][0] type='text' value='".$click[$i][0]."' /></td>";
234
- echo "<td><select id='click' name='ga_events_options[click][$i][1]'>";
235
- if ($click[$i][1] == 'id'){
236
- echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
237
- }else {
238
- echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
239
- }
240
- echo "<td><input id='click' name='ga_events_options[click][$i][2] type='text' value='".$click[$i][2]."' /></td>";
241
- echo "<td><input id='click' name='ga_events_options[click][$i][3] type='text' value='".$click[$i][3]."' /></td>";
242
- echo "<td><input id='click' name='ga_events_options[click][$i][4] type='text' value='".$click[$i][4]."' /></td>";
243
- echo "<td><a class='remove' href=''>Remove</a></td>";
244
- echo "</tr>";
245
-
246
- }
247
-
248
- }
249
- echo "</tbody></table>";
250
- echo "<script>
251
- jQuery('.remove').click(function (event) {
252
- event.preventDefault();
253
- jQuery(this).closest('tr').remove();
254
- });
255
- jQuery('.add').click(function (event) {
256
- event.preventDefault();
257
- });
258
- </script>
259
- ";
260
-
261
- }
262
-
263
- function ga_events_setting_sidebar(){
264
  }
265
-
266
- function ga_events_validate($form){
267
- $updated = array();
268
- $updated['id'] = $form['id'];
269
- $updated['exclude_snippet'] = $form['exclude_snippet'];
270
- $updated['universal'] = $form['universal'];
271
-
272
- for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
273
- if ($form['divs'][$i][0]){
274
- $updated['divs'][$j] = $form['divs'][$i];
275
- $j++;
276
- }
277
- }
278
-
279
- for ($i = 0, $j = 0; $i< sizeof($form['click']); $i++){
280
- if ($form['click'][$i][0]){
281
- $updated['click'][$j] = $form['click'][$i];
282
- $j++;
283
- }
284
- }
285
-
286
- return $updated;
287
- }
288
-
289
-
290
  /*
291
  * Init
292
  */
@@ -302,7 +69,7 @@ function ga_events_scripts() {
302
  add_action( 'plugins_loaded', 'ga_events_setup');
303
 
304
  function ga_events_setup() {
305
- add_action( 'wp_head', 'ga_events_header', 100 );
306
  }
307
 
308
 
3
  Plugin Name: WP Google Analytics Events
4
  Plugin URI: http://wpflow.com
5
  Description: Adds the Google Analytics code to your website and enables you to send events on scroll or click.
6
+ Version: 1.5
7
  Author: Yuval Oren
8
  Author URI: http://wpflow.com
9
  License: GPLv2
17
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
  */
19
 
20
+ $plugin_path = plugin_dir_path(__FILE__);
21
+
22
+ require_once('includes/functions.php');
23
+ require_once(plugin_dir_path(__FILE__) ."/includes/admin.php");
24
+
25
 
26
 
27
  /*
28
  * Plugin Activation
29
  */
30
 
31
+
32
+
33
+
34
  register_activation_hook( __FILE__, 'ga_events_install' );
35
+ register_deactivation_hook( __FILE__, 'ga_events_deactivate' );
36
+
37
+
38
 
39
 
40
  function ga_events_install() {
45
  'divs' => array(array(id => '',type =>'', action => '', cat => '', label => '')),
46
  'click' => array(array(id => '',type =>'', action => '', cat => '', label => ''))
47
  );
48
+ if (!get_option('ga_events_options')) {
49
+ update_option( 'ga_events_options', $ga_events_options );
50
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  }
53
 
54
+ function ga_events_deactivate() {
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  /*
58
  * Init
59
  */
69
  add_action( 'plugins_loaded', 'ga_events_setup');
70
 
71
  function ga_events_setup() {
72
+ add_action( 'wp_head', 'ga_events_header', 100 );
73
  }
74
 
75
 
images/icon.png ADDED
Binary file
includes/admin.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+
3
+ /*
4
+ * Plugin Admin Settings
5
+ */
6
+
7
+
8
+ add_action( 'admin_menu', 'ga_events_menu');
9
+
10
+ function ga_events_menu() {
11
+ add_menu_page('WP Google Analytics Settings','WP GA Events','manage_options', 'wp-google-analytics-events', 'ga_events_settings_page', plugins_url( 'images/icon.png', dirname(__FILE__)));
12
+ add_submenu_page('wp-google-analytics-events','General Settings','General Settings', 'manage_options', 'wp-google-analytics-events' , 'ga_events_settings_page' );
13
+ add_submenu_page('wp-google-analytics-events','Click Tracking','Click Tracking', 'manage_options', 'wp-google-analytics-events-click' , 'ga_events_settings_page' );
14
+ add_submenu_page('wp-google-analytics-events','Scroll Tracking','Scroll Tracking', 'manage_options', 'wp-google-analytics-events-scroll' , 'ga_events_settings_page' );
15
+ add_submenu_page('wp-google-analytics-events','Upgrade','Upgrade Now', 'manage_options', 'wp-google-analytics-events-upgrade', 'ga_events_settings_page' );
16
+ }
17
+
18
+ function ga_events_settings_page() {
19
+ ?>
20
+ <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
21
+ <div id="ga_main" class="wrap">
22
+ <?php screen_icon( 'plugins' ); ?>
23
+ <h2>GA Scroll Events Plugin</h2>
24
+
25
+ <?php
26
+ $active_page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : 'wp-google-analytics-events';
27
+ ?>
28
+ <h2 class="nav-tab-wrapper">
29
+ <a href="?page=wp-google-analytics-events" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events' ? 'nav-tab-active' : ''; ?>">General Settings</a>
30
+ <a href="?page=wp-google-analytics-events-click" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events-click' ? 'nav-tab-active' : ''; ?>">Click Tracking</a>
31
+ <a href="?page=wp-google-analytics-events-scroll" class="nav-tab <?php echo $active_page == 'wp-google-analytics-events-scroll' ? 'nav-tab-active' : ''; ?>">Scroll Tracking</a>
32
+ </h2>
33
+
34
+ <form method="post" action='options.php'>
35
+ <?php settings_fields('ga_events_options'); ?>
36
+ <?php
37
+ $show_sidebar = true;
38
+ if ($active_page == 'wp-google-analytics-events-click') {
39
+ do_settings_sections('ga_events_click');
40
+ $show_sidebar = false;
41
+ } else if ($active_page == 'wp-google-analytics-events-scroll') {
42
+ do_settings_sections('ga_events_scroll');
43
+ $show_sidebar = false;
44
+ } else {
45
+ do_settings_sections('ga_events');
46
+ }
47
+ ?>
48
+ <input class="button-primary" type="submit" name="submit" value="Save Changes" />
49
+ </form>
50
+
51
+ </div>
52
+ <?php
53
+ if ($show_sidebar) {
54
+ ?>
55
+ <div class="wrap ga_events_sidebar">
56
+ <table class="form-table widefat" >
57
+ <thead>
58
+ <th>Upgrade to Pro</th>
59
+ </thead>
60
+ <tbody>
61
+ <tr class="features">
62
+ <td>
63
+ <ul>
64
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Set Value for Events</strong></li>
65
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Shortcode support</strong></li>
66
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>HTML Tag support</strong></li>
67
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Bounce Rate Control</strong></li>
68
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Improved link tracking</strong></li>
69
+ <li><i class="fa fa-check-square-o fa-lg"></i><strong>Pro Support</strong></li>
70
+ </ul>
71
+ </td>
72
+ </tr>
73
+ <tr class="tfoot">
74
+ <td>
75
+ <div class="wpcta">
76
+ <a class="btn btn-subscribe" href="http://wpflow.com/upgrade/">
77
+ <span class="btn-title ">
78
+ Starting from
79
+ <span class="btn-data">
80
+ <span class="price">$29</span>
81
+ </span>
82
+ </span>
83
+ </a>
84
+ </div>
85
+ </td>
86
+ </tr>
87
+ </tbody>
88
+ </table>
89
+ <!-- Begin MailChimp Signup Form -->
90
+ <link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
91
+ <style type="text/css">
92
+ #mc_embed_signup{background:#fff; clear:left; font:13px Helvetica,Arial,sans-serif; width:250px; margin-top:30px; }
93
+ /* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
94
+ We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
95
+ </style>
96
+ <div id="mc_embed_signup">
97
+ <form action="http://wpflow.us6.list-manage.com/subscribe/post?u=3a1990ecd0eee6198c11e5fc1&amp;id=7e01c30e7f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
98
+ <div class="form-content">
99
+ <h4>Receive plugin updates, news, promo codes and more</h4>
100
+ <label for="mce-EMAIL">Subscribe to our mailing list</label>
101
+ <input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
102
+ <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
103
+ <div style="position: absolute; left: -5000px;"><input type="text" name="b_3a1990ecd0eee6198c11e5fc1_7e01c30e7f" value=""></div>
104
+ </div>
105
+ <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn-subscribe "></div>
106
+ </form>
107
+ </div>
108
+
109
+ <!--End mc_embed_signup-->
110
+ </div>
111
+ <? } ?>
112
+
113
+
114
+ <?php
115
+
116
+ echo "<script>
117
+ jQuery('.remove').click(function (event) {
118
+ event.preventDefault();
119
+ jQuery(this).closest('tr').remove();
120
+ });
121
+ jQuery('.add').click(function (event) {
122
+ event.preventDefault();
123
+ });
124
+ </script>
125
+ ";
126
+ }
127
+
128
+ function load_custom_wp_admin_style() {
129
+ wp_register_style( 'custom_wp_admin_css', plugins_url('css/style.css', dirname(__FILE__)));
130
+ wp_enqueue_style( 'custom_wp_admin_css' );
131
+ }
132
+
133
+ add_action( 'admin_enqueue_scripts', 'load_custom_wp_admin_style' );
134
+
135
+ add_action('admin_init', 'ga_events_admin_init');
136
+
137
+ function ga_events_admin_init() {
138
+ register_setting('ga_events_options','ga_events_options','ga_events_validate');
139
+ add_settings_section('ga_events_main','WP Google Analytics Events Settings', 'ga_events_section_text','ga_events');
140
+ add_settings_section('ga_events_click_section','Click Tracking', 'ga_events_section_text','ga_events_click');
141
+ add_settings_section('ga_events_scroll_section','Scroll Tracking', 'ga_events_section_text','ga_events_scroll');
142
+ add_settings_field('ga_events_id', '','ga_events_setting_input','ga_events','ga_events_main');
143
+ add_settings_field('ga_events_exclude_snippet', '','ga_events_setting_snippet_input','ga_events','ga_events_main');
144
+ add_settings_field('ga_events_universal', '','ga_events_setting_uni_input','ga_events','ga_events_main');
145
+ add_settings_field('ga_events_divs', '','ga_events_setting_divs_input','ga_events_scroll','ga_events_scroll_section');
146
+ add_settings_field('ga_events_click', '','ga_events_setting_click_input','ga_events_click','ga_events_click_section');
147
+ add_settings_field('ga_events_sidebar', '','ga_events_setting_sidebar','ga_events','ga_events_main');
148
+
149
+
150
+ }
151
+
152
+ function ga_events_section_text() {
153
+ echo "<a href='http://wpflow.com/documentation'>Plugin Documentation</a>";
154
+ }
155
+
156
+ function ga_events_setting_input() {
157
+ $options = get_option('ga_events_options');
158
+ $id = $options['id'];
159
+ echo "<label>Google Analytics Identifier</label>";
160
+ echo "<span class='ga_intable'><input class='inputs' id='id' name='ga_events_options[id]' type='text' value='$id' /></span>";
161
+
162
+ }
163
+
164
+
165
+ function ga_events_setting_snippet_input() {
166
+ $options = get_option('ga_events_options');
167
+ $id = $options['exclude_snippet'];
168
+ echo "<label>Don't add the GA tracking code</label>";
169
+ echo "<span class='ga_intable'><input id='snippet' name='ga_events_options[exclude_snippet]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
170
+
171
+ }
172
+
173
+ function ga_events_setting_uni_input() {
174
+ $options = get_option('ga_events_options');
175
+ $id = $options['universal'];
176
+ echo "<label>Universal Tracking Code</label>";
177
+ echo "<span class='ga_intable'><input id='universal' name='ga_events_options[universal]' type='checkbox' value='1' " . checked( $id , 1,false) . " /></span>";
178
+ }
179
+
180
+ function ga_events_setting_divs_input() {
181
+ $options = get_option('ga_events_options');
182
+ $divs= $options['divs'];
183
+ echo "<label>Scroll Events</label><br />";
184
+ echo "<table class='widefat inputs inner_table'><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th></th></thead><tbody>";
185
+ if (!($divs[0][0])){
186
+ echo "<tr>";
187
+ echo "<td><input id='divs' name='ga_events_options[divs][0][0]' type='text' value='".$divs[0][0]."' /></td>";
188
+ echo "<td><select id='divs' name='ga_events_options[divs][0][1]'><option selected value='id' >id</option><option value='class'>class</option></select></td>";
189
+ echo "<td><input id='divs' name='ga_events_options[divs][0][2]' type='text' value='".$divs[0][2]."' /></td>";
190
+ echo "<td><input id='divs' name='ga_events_options[divs][0][3]' type='text' value='".$divs[0][3]."' /></td>";
191
+ echo "<td><input id='divs' name='ga_events_options[divs][0][4]' type='text' value='".$divs[0][4]."' /></td>";
192
+ echo "</tr>";
193
+
194
+ }else{
195
+ for ($i = 0; $i < sizeof($divs)+1; $i++){
196
+
197
+ echo "<tr>";
198
+ echo "<td><input id='divs' name='ga_events_options[divs][$i][0] type='text' value='".$divs[$i][0]."' /></td>";
199
+ echo "<td><select id='divs' name='ga_events_options[divs][$i][1]'>";
200
+ if ($divs[$i][1] == 'id'){
201
+ echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
202
+ }else {
203
+ echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
204
+ }
205
+ echo "<td><input id='divs' name='ga_events_options[divs][$i][2]' type='text' value='".$divs[$i][2]."' /></td>";
206
+ echo "<td><input id='divs' name='ga_events_options[divs][$i][3]' type='text' value='".$divs[$i][3]."' /></td>";
207
+ echo "<td><input id='divs' name='ga_events_options[divs][$i][4]' type='text' value='".$divs[$i][4]."' /></td>";
208
+ echo "<td><a class='remove' href=''>Remove</a></td>";
209
+ echo "</tr>";
210
+
211
+ }
212
+
213
+ }
214
+ echo "</tbody></table>";
215
+ }
216
+
217
+
218
+ function ga_events_setting_click_input() {
219
+ $options = get_option('ga_events_options');
220
+ $click = $options['click'];
221
+ echo "<label>Click Events</label><br />";
222
+ echo "<table class='widefat inputs inner_table'><thead><th>Element Name</th><th>Type</th><th>Event Category</th><th>Event Action</th><th>Event Label</th><th></th></thead><tbody>";
223
+ if (!($click[0][0])){
224
+ echo "<tr>";
225
+ echo "<td><input id='click' name='ga_events_options[click][0][0]' type='text' value='".$click[0][0]."' /></td>";
226
+ echo "<td><select id='click' name='ga_events_options[click][0][1]'><option selected value='id'>id</option><option value='class'>class</option></select></td>";
227
+ echo "<td><input id='click' name='ga_events_options[click][0][2]' type='text' value='".$click[0][2]."' /></td>";
228
+ echo "<td><input id='click' name='ga_events_options[click][0][3]' type='text' value='".$click[0][3]."' /></td>";
229
+ echo "<td><input id='click' name='ga_events_options[click][0][4]' type='text' value='".$click[0][4]."' /></td>";
230
+ echo "</tr>";
231
+
232
+ }else{
233
+ for ($i = 0; $i < sizeof($click)+1; $i++){
234
+
235
+ echo "<tr>";
236
+ echo "<td><input id='divs' name='ga_events_options[click][$i][0] type='text' value='".$click[$i][0]."' /></td>";
237
+ echo "<td><select id='click' name='ga_events_options[click][$i][1]'>";
238
+ if ($click[$i][1] == 'id'){
239
+ echo "<option selected value='id' >id</option><option value='class'>class</option></select></td>";
240
+ }else {
241
+ echo "<option value='id' >id</option><option selected value='class'>class</option></select></td>";
242
+ }
243
+ echo "<td><input id='click' name='ga_events_options[click][$i][2] type='text' value='".$click[$i][2]."' /></td>";
244
+ echo "<td><input id='click' name='ga_events_options[click][$i][3] type='text' value='".$click[$i][3]."' /></td>";
245
+ echo "<td><input id='click' name='ga_events_options[click][$i][4] type='text' value='".$click[$i][4]."' /></td>";
246
+ echo "<td><a class='remove' href=''>Remove</a></td>";
247
+ echo "</tr>";
248
+
249
+ }
250
+
251
+ }
252
+ echo "</tbody></table>";
253
+
254
+
255
+ }
256
+
257
+ function ga_events_setting_sidebar(){
258
+ }
259
+
260
+ function ga_events_validate($form){
261
+ $options = get_option('ga_events_options');
262
+ $updated = $options;
263
+ if (array_key_exists('divs', $form)) {
264
+ $updated['divs'] = array();
265
+ for ($i = 0, $j = 0; $i< sizeof($form['divs']); $i++){
266
+ if ($form['divs'][$i][0]){
267
+ $updated['divs'][$j] = $form['divs'][$i];
268
+ $j++;
269
+ }
270
+ }
271
+ } else if(array_key_exists('click', $form)) {
272
+ $updated['click'] = array();
273
+ for ($i = 0, $j = 0; $i< sizeof($form['click']); $i++){
274
+ if ($form['click'][$i][0]){
275
+ $updated['click'][$j] = $form['click'][$i];
276
+ $j++;
277
+ }
278
+ }
279
+ } else {
280
+ $updated['id'] = $form['id'];
281
+ $updated['exclude_snippet'] = $form['exclude_snippet'];
282
+ $updated['universal'] = $form['universal'];
283
+ }
284
+
285
+ return $updated;
286
+ }
287
+
288
+
289
+ add_action('admin_footer', 'ga_events_admin_footer');
290
+
291
+ function ga_events_admin_footer() {
292
+ ?>
293
+ <script>
294
+ jQuery('body').on('click','a[href="admin.php?page=wp-google-analytics-events-upgrade"]', function (e) {
295
+ e.preventDefault();
296
+ window.open('http://wpflow.com/upgrade', '_blank');
297
+ });
298
+ </script>
299
+ <?
300
+ }
301
+
302
+ ?>
includes/functions.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ function migrateOptions() {
5
+ $current_options = get_option('ga_events_options');
6
+ $new_options = array();
7
+ $new_options['id'] = $current_options['id'];
8
+ $new_options['exclude_snippet'] = $current_options['exclude_snippet'];
9
+ $new_options['universal'] = $current_options['universal'];
10
+ $new_options['events'] = array();
11
+ for ($i=0; $i < sizeof($current_options['divs']); $i++) {
12
+ $current_option = $current_options['divs'][$i];
13
+ $event = new Event('scroll', $current_option[0], $current_option[1], $current_option[2], $current_option[3], $current_option[4]);
14
+ array_push($new_options['events'], $event->getEventArray() );
15
+ }
16
+
17
+ for ($i=0; $i < sizeof($current_options['click']); $i++) {
18
+ $current_option = $current_options['click'][$i];
19
+ $event = new Event('click', $current_option[0], $current_option[1], $current_option[2], $current_option[3], $current_option[4]);
20
+ array_push($new_options['events'], $event->getEventArray() );
21
+ }
22
+
23
+ update_option('ga_events_options', $new_options);
24
+ // print(var_dump($new_options));
25
+ }
26
+
27
+
28
+ function isOptionMigrationRequired(){
29
+ $current_options = get_option('ga_events_options');
30
+ if (array_key_exists('divs', $current_options) || array_key_exists('clicks', $current_options)) {
31
+ return true;
32
+ }
33
+ return false;
34
+ }
35
+
36
+ ?>
js/main.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ /*global $, jQuery, document, window*/
2
+
3
+ jQuery('document').ready(function (){
4
+ jQuery('#the-list').on('click', '.edit-event', function (e) {
5
+ e.preventDefault();
6
+ jQuery('#event-dialog').dialog();
7
+ });
8
+ });
readme.txt CHANGED
@@ -1,8 +1,8 @@
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
  Tags: analytics, google, events, ga
4
- Tested up to: 4.1
5
- Stable tag: 1.4
6
  License: GPLv2
7
  Requires at least: 3.0
8
 
@@ -30,6 +30,9 @@ http://www.youtube.com/watch?v=UP8mfuV9huI
30
  == Screenshots ==
31
  1. Plugin Options screenshot-1.png
32
  2. Google Analytics real time events screenshot-2.png
 
 
 
33
  == Changelog == = Version 1.4 =
34
  You can now use the plugin along with Yoast Analytics.
35
  Just check the "Don't add the GA tracking code" option and if you are using the universal tracking code, check that option as well.
1
  === WP Google Analytics Events ===
2
  Contributors: yuvalo
3
  Tags: analytics, google, events, ga
4
+ Tested up to: 4.2
5
+ Stable tag: 1.5
6
  License: GPLv2
7
  Requires at least: 3.0
8
 
30
  == Screenshots ==
31
  1. Plugin Options screenshot-1.png
32
  2. Google Analytics real time events screenshot-2.png
33
+ == Changelog == = Version 1.5 =
34
+ 1. UI Changes
35
+ 2. Diactivating and reactivating the plugin will not delete previous settings
36
  == Changelog == = Version 1.4 =
37
  You can now use the plugin along with Yoast Analytics.
38
  Just check the "Don't add the GA tracking code" option and if you are using the universal tracking code, check that option as well.
uninstall.php CHANGED
@@ -2,5 +2,5 @@
2
  if( !defined( 'WP_UNINSTALL_PLUGIN' ) )
3
  exit ();
4
 
5
- delete_option( 'ga_scroll_events_install' );
6
- ?>
2
  if( !defined( 'WP_UNINSTALL_PLUGIN' ) )
3
  exit ();
4
 
5
+ //delete_option( 'ga_scroll_events_install' );
6
+ ?>