Clicky by Yoast - Version 1.2

Version Description

  • Update to work with the new CDN per this post.
  • Remove clicky.me integration that was no longer working anyway due to Twitter API changes.
Download this release

Release Info

Developer joostdevalk
Plugin Icon 128x128 Clicky by Yoast
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.5 to 1.2

Files changed (2) hide show
  1. clicky.php +6 -151
  2. readme.txt +20 -3
clicky.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Clicky for WordPress
4
- Version: 1.1.5
5
  Plugin URI: http://getclicky.com/goodies/#wordpress
6
  Description: Integrates Clicky on your blog!
7
  Author: Joost de Valk
@@ -25,8 +25,8 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
25
  var $feed = 'http://getclicky.com/blog/rss';
26
 
27
  function meta_box() {
28
- add_meta_box('clickyme',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'post','side');
29
- add_meta_box('clickyme',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'page','side');
30
  }
31
 
32
  function clicky_admin_warnings() {
@@ -49,31 +49,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
49
  global $post;
50
  $options = clicky_get_options();
51
  $clicky_goal = get_post_meta($post->ID,'_clicky_goal',true);
52
- $clicky_tweetpost = get_post_meta($post->ID,'_clicky_tweetpost',true);
53
 
54
- if ($clicky_tweetpost == '' && $post->post_type == 'post')
55
- $clicky_tweetpost = true;
56
-
57
- if ($options['allow_clickyme_integration']) {
58
- if ($post->post_status == 'publish') {
59
- $shorturl = clickyme_shorturl($post->ID);
60
- echo '<p><strong>'.__('Twitter', 'clicky').'</strong></p>';
61
- echo '<p>';
62
- _e('The Clicky.me short URL for this post is', 'clicky');
63
- echo '<a href="'.$shorturl.'">'.$shorturl.'</a>. <a target="_blank" href="http://twitter.com/home?status='.urlencode($post->post_title.' - '.$shorturl).'">';
64
- _e('Tweet this post', 'clicky');
65
- echo '</a></p><br/>';
66
- } else {
67
- if (!$options['auto_tweet']) {
68
- echo '<p><strong>'.__('Twitter', 'clicky').'</strong></p>';
69
- echo '<p>';
70
- _e('This post is not published yet, a short URL will be created for it once the post is published. Do you want it to be tweeted automatically too?', 'clicky');
71
- echo '<br/><br/>';
72
- echo '<input type="checkbox" name="clicky_tweetpost" '.checked($clicky_tweetpost,true,false).'/> '.__('Tweet post on publish', 'clicky').'</p>';
73
- echo '<br/>';
74
- }
75
- }
76
- }
77
  echo '<p><strong>'.__('Goal Tracking', 'clicky').'</strong></p>';
78
  echo '<p>';
79
  printf(__('Clicky can track Goals for you too, %1$sread the documentation here%2$s. To be able to track a goal on this post, you need to specify the goal ID here. Optionally, you can also provide the goal revenue.'),'<a href="http://getclicky.com/stats/goals-setup">','</a>');
@@ -109,14 +85,6 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
109
  $clicky_goal['value'] = $clicky_goal_value;
110
  delete_post_meta($pID,'_clicky_goal');
111
  add_post_meta($pID,'_clicky_goal',$clicky_goal, true);
112
-
113
- if ($options['allow_clickyme_integration'] && !$options['auto_tweet']) {
114
- delete_post_meta($pID,'_clicky_tweetpost');
115
- if (isset($clicky_tweetpost))
116
- add_post_meta($pID,'_clicky_tweetpost',true, true);
117
- else
118
- add_post_meta($pID,'_clicky_tweetpost',false, true);
119
- }
120
  }
121
 
122
  function register_dashboard_page() {
@@ -145,7 +113,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
145
  $options[$option_name] = '';
146
  }
147
 
148
- foreach (array('ignore_admin', 'track_names', 'allow_clickyme_integration','auto_tweet') as $option_name) {
149
  if (isset($_POST[$option_name]))
150
  $options[$option_name] = true;
151
  else
@@ -221,45 +189,6 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
221
 
222
  $this->postbox('clicky_settings',__('Advanced Settings', 'clicky'), $this->form_table($rows));
223
 
224
- $rows = array();
225
- $rows[] = array(
226
- 'id' => 'allow_clickyme_integration',
227
- 'label' => __('Allow Clicky.me integration', 'clicky'),
228
- 'desc' => '',
229
- 'content' => '<input type="checkbox" '.checked($options['allow_clickyme_integration'],true,false).' name="allow_clickyme_integration" id="allow_clickyme_integration"/>',
230
- );
231
-
232
- $rows[] = array(
233
- 'id' => 'auto_tweet',
234
- 'label' => __('Auto Tweet', 'clicky'),
235
- 'desc' => __('No need to check the box on each post, by checking this box, each post get\'s tweeted automatically.', 'clicky'),
236
- 'content' => '<input type="checkbox" '.checked($options['auto_tweet'],true,false).' name="auto_tweet" id="auto_tweet"/>',
237
- );
238
-
239
- $rows[] = array(
240
- 'id' => 'twitter_username',
241
- 'label' => __('Twitter username', 'clicky'),
242
- 'desc' => '',
243
- 'content' => '<input type="text" value="'.$options['twitter_username'].'" name="twitter_username" id="twitter_username"/>'
244
- );
245
-
246
- $rows[] = array(
247
- 'id' => 'twitter_password',
248
- 'label' => __('Twitter password', 'clicky'),
249
- 'desc' => '',
250
- 'content' => '<input type="password" value="'.$options['twitter_password'].'" name="twitter_password" id="twitter_password"/>'
251
- );
252
-
253
- $rows[] = array(
254
- 'id' => 'twitter_prefix',
255
- 'label' => __('Prefix for Tweets', 'clicky'),
256
- 'desc' => __('This text will be put in front of Tweets that are published when a blog post is published', 'clicky'),
257
- 'content' => '<input type="text" class="text" value="'.$options['twitter_prefix'].'" name="twitter_prefix" id="twitter_prefix"/>'
258
- );
259
-
260
- $this->postbox('clickyme_integration',__('Clicky.me &amp; Twitter Integration', 'clicky'), $content .' '. $this->form_table($rows));
261
-
262
-
263
  ?>
264
  <div class="submit">
265
  <input type="submit" class="button-primary" name="submit" value="<?php _e("Update Clicky Settings", 'clicky'); ?> &raquo;" />
@@ -304,86 +233,12 @@ function clicky_defaults() {
304
  'site_id' => '',
305
  'site_key' => '',
306
  'admin_site_key' => '',
307
- 'twitter_username' => '',
308
- 'twitter_password' => '',
309
- 'twitter_prefix' => '',
310
- 'auto_tweet' => false,
311
  'ignore_admin' => false,
312
  'track_names' => true,
313
- 'allow_clickyme_integration' => true,
314
  );
315
  add_option('clicky',$options);
316
  }
317
 
318
- function clickyme_shorturl($pid) {
319
- $shorturl = get_post_meta($post->ID, '_clickyme_url', true);
320
- if (!$shorturl) {
321
- $options = clicky_get_options();
322
- if ( empty($options['site_id']) || empty($options['admin_site_key']) )
323
- return false;
324
-
325
- $res = wp_remote_get('http://clicky.me/app/api?site_id='.$options['site_id'].'&sitekey_admin='.$options['admin_site_key'].'&url='.get_permalink($pid));
326
- if (is_array($res) && $res['response']['code'] == 200) {
327
- $shorturl = trim($res['body']);
328
- if (preg_match( '#^http://#', $shorturl )) {
329
- add_post_meta($post->ID,'_clickyme_url',$shorturl,true);
330
- return $shorturl;
331
- } else {
332
- return false;
333
- }
334
- } else {
335
- return false;
336
- }
337
- }
338
- return $shorturl;
339
- }
340
-
341
- function publish_tweet($pid) {
342
- $options = clicky_get_options();
343
- if (!$options['allow_clickyme_integration'] || $options['twitter_username'] == "" || $options['twitter_password'] == "")
344
- return false;
345
-
346
- // Check if post has to be tweeted, if not, return false, else make sure it doesn't get tweeted twice.
347
- $clicky_tweetpost = get_post_meta($pid,'_clicky_tweetpost',true);
348
-
349
- if (!$options['auto_tweet'] && !$clicky_tweetpost) {
350
- return false;
351
- } else {
352
- delete_post_meta($pid,'_clicky_tweetpost');
353
- add_post_meta($pid,'_clicky_tweetpost',false, true);
354
- }
355
-
356
- $shorturl = clickyme_shorturl( $pid );
357
- if (!$shorturl) {
358
- // Short URL creation went wrong, make sure it tries again next time and bail.
359
- delete_post_meta($pid,'_clicky_tweetpost');
360
- add_post_meta($pid,'_clicky_tweetpost',true,true);
361
- return false;
362
- }
363
- $su_length = strlen( $shorturl );
364
- $status = trim( $options['twitter_prefix'] ).' '.get_the_title( $pid ).' -';
365
-
366
- // Make sure the tweet message isn't too long, so make sure the shorturl fits
367
- $max = 139 - $su_length;
368
- if ( strlen( $status ) > $max ) {
369
- $status = substr( 0, $max, $status );
370
- }
371
- $status .= ' '.$shorturl;
372
-
373
- $headers = array( 'Authorization' => 'Basic '.base64_encode($options['twitter_username'].":".$options['twitter_password']) );
374
- $request = new WP_Http;
375
- $result = $request->request(
376
- 'http://twitter.com/statuses/update.xml' ,
377
- array(
378
- 'method' => 'POST',
379
- 'body' => array('status' => $status),
380
- 'headers' => $headers )
381
- );
382
- return $result;
383
- }
384
- add_action('publish_post','publish_tweet');
385
- add_action('publish_page','publish_tweet');
386
-
387
  function clicky_script() {
388
  $options = clicky_get_options();
389
 
@@ -440,7 +295,7 @@ function clicky_script() {
440
  var s = document.createElement('script');
441
  s.type = 'text/javascript';
442
  s.async = true;
443
- s.src = ( document.location.protocol == 'https:' ? 'https://static.getclicky.com' : 'http://static.getclicky.com' ) + '/js';
444
  ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
445
  })();
446
  </script>
@@ -460,7 +315,7 @@ function clicky_log( $a ) {
460
  if( !in_array( $type, array( "pageview", "download", "outbound", "click", "custom", "goal" )))
461
  $type = "pageview";
462
 
463
- $file = "http://static.getclicky.com/in.php?site_id=".$options['site_id']."&sitekey_admin=".$options['admin_site_key']."&type=".$type;
464
 
465
  # referrer and user agent - will only be logged if this is the very first action of this session
466
  if( $a['ref'] )
1
  <?php
2
  /*
3
  Plugin Name: Clicky for WordPress
4
+ Version: 1.2
5
  Plugin URI: http://getclicky.com/goodies/#wordpress
6
  Description: Integrates Clicky on your blog!
7
  Author: Joost de Valk
25
  var $feed = 'http://getclicky.com/blog/rss';
26
 
27
  function meta_box() {
28
+ add_meta_box('clicky',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'post','side');
29
+ add_meta_box('clicky',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'page','side');
30
  }
31
 
32
  function clicky_admin_warnings() {
49
  global $post;
50
  $options = clicky_get_options();
51
  $clicky_goal = get_post_meta($post->ID,'_clicky_goal',true);
 
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  echo '<p><strong>'.__('Goal Tracking', 'clicky').'</strong></p>';
54
  echo '<p>';
55
  printf(__('Clicky can track Goals for you too, %1$sread the documentation here%2$s. To be able to track a goal on this post, you need to specify the goal ID here. Optionally, you can also provide the goal revenue.'),'<a href="http://getclicky.com/stats/goals-setup">','</a>');
85
  $clicky_goal['value'] = $clicky_goal_value;
86
  delete_post_meta($pID,'_clicky_goal');
87
  add_post_meta($pID,'_clicky_goal',$clicky_goal, true);
 
 
 
 
 
 
 
 
88
  }
89
 
90
  function register_dashboard_page() {
113
  $options[$option_name] = '';
114
  }
115
 
116
+ foreach (array('ignore_admin', 'track_names') as $option_name) {
117
  if (isset($_POST[$option_name]))
118
  $options[$option_name] = true;
119
  else
189
 
190
  $this->postbox('clicky_settings',__('Advanced Settings', 'clicky'), $this->form_table($rows));
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  ?>
193
  <div class="submit">
194
  <input type="submit" class="button-primary" name="submit" value="<?php _e("Update Clicky Settings", 'clicky'); ?> &raquo;" />
233
  'site_id' => '',
234
  'site_key' => '',
235
  'admin_site_key' => '',
 
 
 
 
236
  'ignore_admin' => false,
237
  'track_names' => true,
 
238
  );
239
  add_option('clicky',$options);
240
  }
241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  function clicky_script() {
243
  $options = clicky_get_options();
244
 
295
  var s = document.createElement('script');
296
  s.type = 'text/javascript';
297
  s.async = true;
298
+ s.src = ( document.location.protocol == 'https:' ? 'https://in.getclicky.com' : 'http://in.getclicky.com' ) + '/js';
299
  ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
300
  })();
301
  </script>
315
  if( !in_array( $type, array( "pageview", "download", "outbound", "click", "custom", "goal" )))
316
  $type = "pageview";
317
 
318
+ $file = "http://in.getclicky.com/in.php?site_id=".$options['site_id']."&sitekey_admin=".$options['admin_site_key']."&type=".$type;
319
 
320
  # referrer and user agent - will only be logged if this is the very first action of this session
321
  if( $a['ref'] )
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: joostdevalk
3
  Donate link: http://yoast.com/
4
  Tags: analytics, statistics, clicky
5
  Requires at least: 2.8
6
- Tested up to: 3.0.1
7
- Stable tag: 1.1.5
8
 
9
  Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
10
 
@@ -17,7 +17,6 @@ Integrates the [Clicky web analytics](http://getclicky.com/145844) service and o
17
  * Option to store names of commenters.
18
  * Option to track posts &amp; pages as goals and assign a revenue to that page or post.
19
  * An overview of your site's statistics on your dashboard.
20
- * Integration with the [Clicky.me Short URL service](http://clicky.me/).
21
  * Automatically create a short link for each now post and page.
22
  * Option to automatically tweet posts and pages on publish (either for each and every one or on a post by post basis), with the message being a prefix of your choice, the post title and then the short URL.
23
 
@@ -33,48 +32,66 @@ Integrates the [Clicky web analytics](http://getclicky.com/145844) service and o
33
 
34
  == Changelog ==
35
 
 
 
 
 
 
36
  = 1.1.5 =
 
37
  * Tiny improvement in error handling to prevent "Cannot use object of type WP_Error as array" error.
38
 
39
  = 1.1.4 =
 
40
  * Minor backend improvements.
41
 
42
  = 1.1.3 =
 
43
  * Fixed bug that would cause tracking not to work if commenter name tracking was not enabled.
44
 
45
  = 1.1.2 =
 
46
  * Another tiny bugfix on the js outputted.
47
 
48
  = 1.1.1 =
 
49
  * Removed tracking of category and author due to complaints. We'll see later if there's a way to add it back in more wisely.
50
 
51
  = 1.1 =
 
52
  * Switched to the new asynchronous javascript.
53
  * Added tracking of category and author as custom variables.
54
  * Fixed the bug that caused tweeting of updated posts.
55
  * Some slight updates to the backend.
56
 
57
  = 1.0.6 =
 
58
  * Auto-tweeting now only happens when a post is first published.
59
  * Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
60
  * Added extra check to make sure clicky.me returned a valid short URL before tweeting.
61
 
62
  = 1.0.5 =
 
63
  * Minor copy changes.
64
 
65
  = 1.0.4 =
 
66
  * Made sure there's no spaces in the Site ID when displaying it, should solve blank Dashboard Stats Page issue.
67
 
68
  = 1.0.3 =
 
69
  * Made all strings localizable (is that even a word).
70
  * Added .pot file to allow localization.
71
  * Added a Dutch translation.
72
 
73
  = 1.0.2 =
 
74
  * Added option to auto tweet articles, removing the checkbox from the add post screen. This makes sure auto tweet works when you're posting from within an external editor.
75
 
76
  = 1.0.1 =
 
77
  * Added prefix option for Tweets that are sent out on publish.
78
 
79
  = 1.0 =
 
80
  * Initial release.
3
  Donate link: http://yoast.com/
4
  Tags: analytics, statistics, clicky
5
  Requires at least: 2.8
6
+ Tested up to: 3.2
7
+ Stable tag: 1.2
8
 
9
  Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
10
 
17
  * Option to store names of commenters.
18
  * Option to track posts &amp; pages as goals and assign a revenue to that page or post.
19
  * An overview of your site's statistics on your dashboard.
 
20
  * Automatically create a short link for each now post and page.
21
  * Option to automatically tweet posts and pages on publish (either for each and every one or on a post by post basis), with the message being a prefix of your choice, the post title and then the short URL.
22
 
32
 
33
  == Changelog ==
34
 
35
+ = 1.2 =
36
+
37
+ * Update to work with the new CDN per [this post](http://getclicky.com/blog/264/important-were-moving-to-a-real-cdn-soon-depending-on-how-youve-set-up-tracking-you-may-need-to-take-action).
38
+ * Remove clicky.me integration that was no longer working anyway due to Twitter API changes.
39
+
40
  = 1.1.5 =
41
+
42
  * Tiny improvement in error handling to prevent "Cannot use object of type WP_Error as array" error.
43
 
44
  = 1.1.4 =
45
+
46
  * Minor backend improvements.
47
 
48
  = 1.1.3 =
49
+
50
  * Fixed bug that would cause tracking not to work if commenter name tracking was not enabled.
51
 
52
  = 1.1.2 =
53
+
54
  * Another tiny bugfix on the js outputted.
55
 
56
  = 1.1.1 =
57
+
58
  * Removed tracking of category and author due to complaints. We'll see later if there's a way to add it back in more wisely.
59
 
60
  = 1.1 =
61
+
62
  * Switched to the new asynchronous javascript.
63
  * Added tracking of category and author as custom variables.
64
  * Fixed the bug that caused tweeting of updated posts.
65
  * Some slight updates to the backend.
66
 
67
  = 1.0.6 =
68
+
69
  * Auto-tweeting now only happens when a post is first published.
70
  * Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
71
  * Added extra check to make sure clicky.me returned a valid short URL before tweeting.
72
 
73
  = 1.0.5 =
74
+
75
  * Minor copy changes.
76
 
77
  = 1.0.4 =
78
+
79
  * Made sure there's no spaces in the Site ID when displaying it, should solve blank Dashboard Stats Page issue.
80
 
81
  = 1.0.3 =
82
+
83
  * Made all strings localizable (is that even a word).
84
  * Added .pot file to allow localization.
85
  * Added a Dutch translation.
86
 
87
  = 1.0.2 =
88
+
89
  * Added option to auto tweet articles, removing the checkbox from the add post screen. This makes sure auto tweet works when you're posting from within an external editor.
90
 
91
  = 1.0.1 =
92
+
93
  * Added prefix option for Tweets that are sent out on publish.
94
 
95
  = 1.0 =
96
+
97
  * Initial release.