Crazy Egg - Version 2.0

Version Description

New Admin Menu added.

=

Download this release

Release Info

Developer crazyegg
Plugin Icon 128x128 Crazy Egg
Version 2.0
Comparing to
See all releases

Code changes from version 1.1 to 2.0

Files changed (4) hide show
  1. crazyegg-heatmap-tracking.php +68 -69
  2. images/icon.png +0 -0
  3. readme.txt +17 -24
  4. views/options.php +19 -0
crazyegg-heatmap-tracking.php CHANGED
@@ -1,90 +1,89 @@
1
  <?php
2
  /*
3
- Plugin Name: Crazyegg-Heatmap-Tracking
4
- Plugin URI: http://www.crazyegg.com/
5
- Description: Enables Crazyegg.com heatmap tracking on your WordPress site.
6
- Version: 1.1
7
- Author: Crazyegg
8
  Author URI: http://www.crazyegg.com
9
  License: GPL
10
  */
11
 
12
- /* Puts code on Wordpress pages */
13
- add_action('wp_footer', 'crazyegg_tracking_code');
 
 
14
 
15
- /* Runs when plugin is activated */
16
- register_activation_hook(__FILE__, 'cht_install');
 
 
 
 
 
 
 
 
17
 
18
- /* Runs on plugin deactivation*/
19
- register_deactivation_hook(__FILE__, 'cht_remove' );
 
20
 
21
- if (is_admin()) {
22
- /* Call the html code */
23
- add_action('admin_menu', 'cht_admin_menu');
24
 
25
- function cht_admin_menu() {
26
- add_options_page('Crazyegg Heatmap Tracking', 'Crazyegg Heatmap Tracking', 'administrator', 'crazyegg-heatmap-tracking', 'cht_html_page');
 
 
 
 
 
 
 
27
  }
28
- }
29
 
30
- function cht_install() {
31
- /* Creates new database field */
32
- add_option("cht_account_number", '', '', 'yes');
33
- }
34
 
35
- function cht_remove() {
36
- /* Deletes the database field */
37
- delete_option('cht_account_number');
38
- }
39
 
40
- function cht_html_page() {
41
- ?>
42
- <div class="wrap">
43
- <div id="icon-plugins" class="icon32"></div>
44
- <h2>Crazyegg Heatmap Tracking</h2>
45
- <form method="POST" action="options.php">
46
- <?php wp_nonce_field('update-options'); ?>
47
- <table class="form-table">
48
- <tr valign="top">
49
- <th scope="row">
50
- <label for="cht_account_number">Account Number</label>
51
- </th>
52
- <td>
53
- <input id="cht_account_number" name="cht_account_number" value="<?php echo get_option('cht_account_number'); ?>" class="regular-text" />
54
- <span class="description">(ex. 00111111)</span>
55
- </td>
56
- </tr>
57
- </table>
58
- <p style="width: 80%;">This is your numerical CrazyEgg account ID, it is 8 digits long. The easy way to find it is by logging in to your CrazyEgg account and clicking the "What's my code" link located at the top of your Dashboard.</p>
59
- <p style="width: 80%;">Or it would be shown to you immediately after creating a Snapshot on your Dashboard.</p>
60
- <p><a href="http://www.crazyegg.com" target="_blank">http://www.crazyegg.com</a></p>
61
- <input type="hidden" name="action" value="update" />
62
- <input type="hidden" name="page_options" value="cht_account_number" />
63
- <p class="submit">
64
- <input class="button-primary" type="submit" name="Save" value="<?php _e('Save'); ?>" />
65
- </p>
66
- </form>
67
- </div>
68
- <?php
69
- }
70
 
71
- function crazyegg_tracking_code() {
72
- $account_number = get_option("cht_account_number");
73
- if (!empty($account_number)) {
74
 
75
- $account_path = str_pad($account_number, 8, "0", STR_PAD_LEFT);
76
- $account_path = substr($account_path,0,4).'/'.substr($account_path,4,8);
77
- $account_path = "pages/scripts/".$account_path.".js";
 
 
78
 
79
- $script_host = "script.crazyegg.com";
 
 
 
 
 
 
80
 
81
- echo '<script type="text/javascript">
82
- setTimeout(function(){var a=document.createElement("script");
83
- var b=document.getElementsByTagName(\'script\')[0];
84
- a.src=document.location.protocol+"//'.$script_host.'/'.$account_path.'";
85
- a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
86
- </script>
87
- ';
88
  }
 
 
 
 
 
 
89
  }
90
  ?>
1
  <?php
2
  /*
3
+ Plugin Name: Crazy Egg
4
+ Plugin URI: http://www.crazyegg.com
5
+ Description: The easiest way to add the Crazy Egg tracking script to your WordPress blog!
6
+ Version: 2.0
7
+ Author: Crazy Egg
8
  Author URI: http://www.crazyegg.com
9
  License: GPL
10
  */
11
 
12
+ class CrazyEgg {
13
+ var $longName = 'Crazy Egg for WordPress Options';
14
+ var $shortName = 'Crazy Egg';
15
+ var $uniqueID = 'crazyegg-heatmap-tracking';
16
 
17
+ function __construct() {
18
+ register_deactivation_hook(__FILE__, array( $this, 'delete_option' ) );
19
+ add_action( 'wp_head', array( $this, 'add_script' ) );
20
+ if ( is_admin() ) {
21
+ add_action( 'admin_menu', array( $this, 'admin_menu_page' ) );
22
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
23
+ add_filter( 'plugin_action_links_'.plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
24
+ add_action( 'wp_loaded', array( $this, 'migration_check' ) );
25
+ }
26
+ }
27
 
28
+ public function delete_option() {
29
+ delete_option('crazy_egg_tracking_script');
30
+ }
31
 
32
+ public function add_script() {
33
+ echo get_option('crazy_egg_tracking_script');
34
+ }
35
 
36
+ public function admin_menu_page() {
37
+ add_menu_page(
38
+ $this->longName,
39
+ $this->shortName,
40
+ 'administrator',
41
+ $this->uniqueID,
42
+ array( $this, 'admin_options'),
43
+ plugins_url('images/icon.png', __FILE__)
44
+ );
45
  }
 
46
 
47
+ public function register_settings() {
48
+ register_setting( 'crazy-egg-options', 'crazy_egg_tracking_script' );
49
+ }
 
50
 
51
+ public function admin_options() {
52
+ include 'views/options.php';
53
+ }
 
54
 
55
+ public function add_settings_link( $links ) {
56
+ $settings_link = array( '<a href="admin.php?page=crazyegg-heatmap-tracking">Settings'.'</a>' );
57
+ return array_merge( $links, $settings_link );
58
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
+ public function migration_check() {
61
+ $accountNumber = get_option("cht_account_number");
 
62
 
63
+ if ($accountNumber) {
64
+ $accountPath = str_pad($accountNumber, 8, "0", STR_PAD_LEFT);
65
+ $accountPath = substr($accountPath,0,4).'/'.substr($accountPath,4,8);
66
+ $accountPath = "pages/scripts/".$accountPath.".js";
67
+ $scriptHost = "script.crazyegg.com";
68
 
69
+ $migrationScript = '<script type="text/javascript">
70
+ setTimeout(function(){var a=document.createElement("script");
71
+ var b=document.getElementsByTagName(\'script\')[0];
72
+ a.src=document.location.protocol+"//'.$scriptHost.'/'.$accountPath.'";
73
+ a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1);
74
+ </script>
75
+ ';
76
 
77
+ update_option('crazy_egg_tracking_script', $migrationScript);
78
+ delete_option('cht_account_number');
79
+ }
80
+ }
 
 
 
81
  }
82
+
83
+ add_action( 'init', 'CrazyEggForWordPress' );
84
+ function CrazyEggForWordPress() {
85
+ global $CrazyEggForWordPress;
86
+
87
+ $CrazyEggForWordPress = new CrazyEgg();
88
  }
89
  ?>
images/icon.png ADDED
Binary file
readme.txt CHANGED
@@ -1,37 +1,30 @@
1
- === Crazyegg Heatmap Tracking ===
2
  Contributors: crazyegg
3
- Tags: crazyegg, traffic, tracking, clicktracking
4
- Requires at least: 2.0.2
5
- Tested up to: 4.6.1
6
- Stable tag: 1.1
7
 
8
- The official Crazyegg.com heatmap tracking plugin for Wordpress.
9
 
10
  == Description ==
11
-
12
- This plugin enables Crazyegg.com heatmap tracking on your WordPress site, with a limited amount of configuration.
13
 
14
  == Installation ==
15
-
16
- 1. Upload the `crazyegg-heatmap-tracking` directory into the `/wp-content/plugins/` directory on your server.
17
- 2. Activate the plugin through the 'Plugins' menu in WordPress.
18
- 3. Using the "WordPress *General* Settings" menu, navigate to Crazyegg Heatmap Tracking and enter your Crazyegg.com Account Number.
19
 
20
  == Frequently Asked Questions ==
 
 
21
 
22
- = Do I have to have Wordpress newer than 2.7? =
23
-
24
- This plugin should be compatible with all older versions of WordPress up until plugins were first introduced.
25
 
26
  == Changelog ==
27
-
28
- = 1.1 =
29
- * New domain added for tracking script.
30
-
31
- = 1.0 =
32
- * The first version of this plugin.
33
 
34
  == Upgrade Notice ==
35
-
36
- = 1.0 =
37
- This is needed.
1
+ === Crazy Egg ===
2
  Contributors: crazyegg
3
+ Tags: analytics, click, crazyegg, crazy egg, heat maps, heatmap, heatmaps, marketing, reports, tracking, traffic, visitor recordings
4
+ Requires at least: 2.7
5
+ Tested up to: 4.7.2
 
6
 
7
+ The easiest, free way to add your Crazy Egg tracking script to your WordPress site. The official Crazy Egg Plugin for WordPress.
8
 
9
  == Description ==
10
+ Crazy Egg is a free plugin that allows you to painlessly add Crazy Egg's tracking script to your WordPress site. The tracking script lets Crazy Egg track your visitors.
 
11
 
12
  == Installation ==
13
+ 1. Install Crazy Egg through the [WordPress.org](https://www.wordpress.org) plugin repository or by [uploading the files to your server](http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/).
14
+ 2. [Sign])https://app.crazyegg.com/login) into your Crazy Egg account and copy your [tracking script](https://app.crazyegg.com/instructions).
15
+ 3. Click the Crazy Egg tab in the left admin menu.
16
+ 4. Paste your tracking script in the provided field and click Save Changes.
17
 
18
  == Frequently Asked Questions ==
19
+ = Do I need a Crazy Egg account? =
20
+ Yes, a Crazy Egg account is needed. You can sign up for a free trial at [crazyegg.com](https://www.crazyegg.com).
21
 
22
+ == Screenshots ==
23
+ 1. Quick, simple and easy way of installing Crazy Egg on your WordPress site.
 
24
 
25
  == Changelog ==
26
+ = 2.0 =
27
+ New Admin Menu added.
 
 
 
 
28
 
29
  == Upgrade Notice ==
30
+ Note: This upgrade will require that you copy and paste your tracking script into the provided field. Your WordPress site will not track if this step is skipped.
 
 
views/options.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h1>Crazy Egg for WordPress</h1>
3
+ <p>Grab your Crazy Egg tracking script <a href="https://app.crazyegg.com/instructions" target="_blank">here</a>, and paste it below.</p>
4
+ <form action="options.php" method="post">
5
+ <?php
6
+ settings_fields( 'crazy-egg-options' );
7
+ do_settings_sections( 'crazy-egg' );
8
+ ?>
9
+ <table class="form-table">
10
+ <tr valign="top">
11
+ <th>Your Tracking Script:</th>
12
+ <td>
13
+ <textarea name="crazy_egg_tracking_script" rows="8" cols="80"><?php echo esc_attr( get_option('crazy_egg_tracking_script') ); ?></textarea>
14
+ </td>
15
+ </tr>
16
+ </table>
17
+ <?php submit_button(); ?>
18
+ </form>
19
+ </div>