Version Description
- Auto-tweeting now only happens when a post is first published.
- Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
- Added extra check to make sure clicky.me returned a valid short URL before tweeting.
Download this release
Release Info
| Developer | joostdevalk |
| Plugin | |
| Version | 1.0.6 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.5 to 1.0.6
- clicky.php +47 -28
- readme.txt +8 -4
clicky.php
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Clicky for WordPress
|
| 4 |
-
Version: 1.0.
|
| 5 |
Plugin URI: http://getclicky.com/goodies/#wordpress
|
| 6 |
Description: Integrates Clicky on your blog!
|
| 7 |
Author: Joost de Valk
|
|
@@ -30,7 +30,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 30 |
}
|
| 31 |
|
| 32 |
function clicky_admin_warnings() {
|
| 33 |
-
$options =
|
| 34 |
if ( (!$options['site_id'] || empty($options['site_id']) || !$options['site_key'] || empty($options['site_key']) || !$options['admin_site_key'] || empty($options['admin_site_key'])) && !$_POST ) {
|
| 35 |
function clicky_warning() {
|
| 36 |
echo "<div id='clickywarning' class='updated fade'><p><strong>";
|
|
@@ -47,7 +47,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 47 |
|
| 48 |
function clicky_meta_box() {
|
| 49 |
global $post;
|
| 50 |
-
$options =
|
| 51 |
$clicky_goal = get_post_meta($post->ID,'_clicky_goal',true);
|
| 52 |
$clicky_tweetpost = get_post_meta($post->ID,'_clicky_tweetpost',true);
|
| 53 |
|
|
@@ -102,7 +102,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 102 |
|
| 103 |
function clicky_insert_post($pID) {
|
| 104 |
global $_POST;
|
| 105 |
-
$options =
|
| 106 |
extract($_POST);
|
| 107 |
$clicky_goal = array();
|
| 108 |
$clicky_goal['id'] = $clicky_goal_id;
|
|
@@ -124,15 +124,15 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 124 |
}
|
| 125 |
|
| 126 |
function dashboard_page() {
|
| 127 |
-
$options =
|
| 128 |
?>
|
| 129 |
<br/>
|
| 130 |
-
<iframe style="margin-left: 20px; width: 850px; height: 1000px;" src="http://getclicky.com/stats/wp-iframe?site_id=<?php echo
|
| 131 |
<?php
|
| 132 |
}
|
| 133 |
|
| 134 |
function config_page() {
|
| 135 |
-
$options =
|
| 136 |
|
| 137 |
if ( isset($_POST['submit']) ) {
|
| 138 |
if (!current_user_can('manage_options')) die(__('You cannot edit the Clicky settings.', 'clicky'));
|
|
@@ -152,7 +152,7 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 152 |
$options[$option_name] = false;
|
| 153 |
}
|
| 154 |
|
| 155 |
-
if (
|
| 156 |
update_option('clicky', $options);
|
| 157 |
$message = "<p>".__('Clicky settings have been updated.', 'clicky')."</p>";
|
| 158 |
}
|
|
@@ -287,6 +287,18 @@ if ( ! class_exists( 'Clicky_Admin' ) ) {
|
|
| 287 |
$clicky_admin = new Clicky_Admin();
|
| 288 |
}
|
| 289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
function clicky_defaults() {
|
| 291 |
$options = array(
|
| 292 |
'site_id' => '',
|
|
@@ -306,38 +318,48 @@ function clicky_defaults() {
|
|
| 306 |
function clickyme_shorturl($pid) {
|
| 307 |
$shorturl = get_post_meta($post->ID, '_clickyme_url', true);
|
| 308 |
if (!$shorturl) {
|
| 309 |
-
$options =
|
| 310 |
if ( empty($options['site_id']) || empty($options['admin_site_key']) )
|
| 311 |
return false;
|
| 312 |
|
| 313 |
$res = wp_remote_get('http://clicky.me/app/api?site_id='.$options['site_id'].'&sitekey_admin='.$options['admin_site_key'].'&url='.get_permalink($pid));
|
| 314 |
if ($res['response']['code'] == 200) {
|
| 315 |
$shorturl = trim($res['body']);
|
| 316 |
-
if (preg_match( '#^http://#', $shorturl ))
|
| 317 |
add_post_meta($post->ID,'_clickyme_url',$shorturl,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
}
|
| 319 |
}
|
| 320 |
return $shorturl;
|
| 321 |
}
|
| 322 |
|
| 323 |
function publish_tweet($pid) {
|
| 324 |
-
$options =
|
| 325 |
if (!$options['allow_clickyme_integration'] || $options['twitter_username'] == "" || $options['twitter_password'] == "")
|
| 326 |
return false;
|
| 327 |
|
| 328 |
-
if
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
add_post_meta($pid,'_clicky_tweetpost',false, true);
|
| 337 |
-
}
|
| 338 |
}
|
| 339 |
|
| 340 |
$shorturl = clickyme_shorturl( $pid );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
$su_length = strlen( $shorturl );
|
| 342 |
$status = trim( $options['twitter_prefix'] ).' '.get_the_title( $pid ).' -';
|
| 343 |
|
|
@@ -363,10 +385,7 @@ add_action('publish_post','publish_tweet');
|
|
| 363 |
add_action('publish_page','publish_tweet');
|
| 364 |
|
| 365 |
function clicky_script() {
|
| 366 |
-
$options =
|
| 367 |
-
if (!is_array($options)) {
|
| 368 |
-
clicky_defaults();
|
| 369 |
-
}
|
| 370 |
|
| 371 |
// Bail early if current user is admin and ignore admin is true
|
| 372 |
if( $options['ignore_admin'] && current_user_can("manage_options") ) {
|
|
@@ -412,15 +431,15 @@ function clicky_script() {
|
|
| 412 |
// Display the script
|
| 413 |
?>
|
| 414 |
<script src="http://static.getclicky.com/js" type="text/javascript"></script>
|
| 415 |
-
<script type="text/javascript">clicky.init(<?php echo
|
| 416 |
-
<noscript><p><img alt="Clicky" width="1" height="1" src="http://static.getclicky.com/<?php echo
|
| 417 |
<!-- End Clicky Tracking -->
|
| 418 |
<?php
|
| 419 |
}
|
| 420 |
add_action('wp_footer','clicky_script',90);
|
| 421 |
|
| 422 |
function clicky_log( $a ) {
|
| 423 |
-
$options =
|
| 424 |
|
| 425 |
if (!isset($options['site_id']) || empty($options['site_id']) || !isset($options['admin_site_key']) || empty($options['admin_site_key']))
|
| 426 |
return;
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Clicky for WordPress
|
| 4 |
+
Version: 1.0.6
|
| 5 |
Plugin URI: http://getclicky.com/goodies/#wordpress
|
| 6 |
Description: Integrates Clicky on your blog!
|
| 7 |
Author: Joost de Valk
|
| 30 |
}
|
| 31 |
|
| 32 |
function clicky_admin_warnings() {
|
| 33 |
+
$options = clicky_get_options();
|
| 34 |
if ( (!$options['site_id'] || empty($options['site_id']) || !$options['site_key'] || empty($options['site_key']) || !$options['admin_site_key'] || empty($options['admin_site_key'])) && !$_POST ) {
|
| 35 |
function clicky_warning() {
|
| 36 |
echo "<div id='clickywarning' class='updated fade'><p><strong>";
|
| 47 |
|
| 48 |
function clicky_meta_box() {
|
| 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 |
|
| 102 |
|
| 103 |
function clicky_insert_post($pID) {
|
| 104 |
global $_POST;
|
| 105 |
+
$options = clicky_get_options();
|
| 106 |
extract($_POST);
|
| 107 |
$clicky_goal = array();
|
| 108 |
$clicky_goal['id'] = $clicky_goal_id;
|
| 124 |
}
|
| 125 |
|
| 126 |
function dashboard_page() {
|
| 127 |
+
$options = clicky_get_options();
|
| 128 |
?>
|
| 129 |
<br/>
|
| 130 |
+
<iframe style="margin-left: 20px; width: 850px; height: 1000px;" src="http://getclicky.com/stats/wp-iframe?site_id=<?php echo $options['site_id']; ?>&sitekey=<?php echo $options['site_key']; ?>"></iframe>
|
| 131 |
<?php
|
| 132 |
}
|
| 133 |
|
| 134 |
function config_page() {
|
| 135 |
+
$options = clicky_get_options();
|
| 136 |
|
| 137 |
if ( isset($_POST['submit']) ) {
|
| 138 |
if (!current_user_can('manage_options')) die(__('You cannot edit the Clicky settings.', 'clicky'));
|
| 152 |
$options[$option_name] = false;
|
| 153 |
}
|
| 154 |
|
| 155 |
+
if (clicky_get_options() != $options) {
|
| 156 |
update_option('clicky', $options);
|
| 157 |
$message = "<p>".__('Clicky settings have been updated.', 'clicky')."</p>";
|
| 158 |
}
|
| 287 |
$clicky_admin = new Clicky_Admin();
|
| 288 |
}
|
| 289 |
|
| 290 |
+
function clicky_get_options() {
|
| 291 |
+
$options = get_option('clicky');
|
| 292 |
+
if (!is_array($options)) {
|
| 293 |
+
clicky_defaults();
|
| 294 |
+
} else {
|
| 295 |
+
$options['site_id'] = trim($options['site_id']);
|
| 296 |
+
$options['site_key'] = trim($options['site_key']);
|
| 297 |
+
$options['admin_site_key'] = trim($options['admin_site_key']);
|
| 298 |
+
}
|
| 299 |
+
return $options;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
function clicky_defaults() {
|
| 303 |
$options = array(
|
| 304 |
'site_id' => '',
|
| 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 ($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 |
|
| 385 |
add_action('publish_page','publish_tweet');
|
| 386 |
|
| 387 |
function clicky_script() {
|
| 388 |
+
$options = clicky_get_options();
|
|
|
|
|
|
|
|
|
|
| 389 |
|
| 390 |
// Bail early if current user is admin and ignore admin is true
|
| 391 |
if( $options['ignore_admin'] && current_user_can("manage_options") ) {
|
| 431 |
// Display the script
|
| 432 |
?>
|
| 433 |
<script src="http://static.getclicky.com/js" type="text/javascript"></script>
|
| 434 |
+
<script type="text/javascript">clicky.init(<?php echo $options['site_id']; ?>);</script>
|
| 435 |
+
<noscript><p><img alt="Clicky" width="1" height="1" src="http://static.getclicky.com/<?php echo $options['site_id']; ?>ns.gif" /></p></noscript>
|
| 436 |
<!-- End Clicky Tracking -->
|
| 437 |
<?php
|
| 438 |
}
|
| 439 |
add_action('wp_footer','clicky_script',90);
|
| 440 |
|
| 441 |
function clicky_log( $a ) {
|
| 442 |
+
$options = clicky_get_options();
|
| 443 |
|
| 444 |
if (!isset($options['site_id']) || empty($options['site_id']) || !isset($options['admin_site_key']) || empty($options['admin_site_key']))
|
| 445 |
return;
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://yoast.com/
|
|
| 4 |
Tags: analytics, statistics, clicky
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 2.9
|
| 7 |
-
Stable tag: 1.0.
|
| 8 |
|
| 9 |
Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
|
| 10 |
|
|
@@ -14,7 +14,7 @@ Integrates the Clicky web analytics service and optionally the Clicky.me short U
|
|
| 14 |
|
| 15 |
* Automatically adding your Clicky tracking code everywhere.
|
| 16 |
* Option to ignore admins.
|
| 17 |
-
* Option to store names
|
| 18 |
* Option to track posts & 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/).
|
|
@@ -33,9 +33,13 @@ Integrates the Clicky web analytics service and optionally the Clicky.me short U
|
|
| 33 |
|
| 34 |
== Changelog ==
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
= 1.0.5 =
|
| 37 |
* Minor copy changes.
|
| 38 |
-
* Added comment tracking through Clicky's Incoming API. Comments are tracked as a "click", but you can also set it as a goal, to learn how and for more details read this post: [Comment Tracking in Clicky](http://yoast.com/clicky-comment-tracking/).
|
| 39 |
|
| 40 |
= 1.0.4 =
|
| 41 |
* Made sure there's no spaces in the Site ID when displaying it, should solve blank Dashboard Stats Page issue.
|
|
@@ -52,4 +56,4 @@ Integrates the Clicky web analytics service and optionally the Clicky.me short U
|
|
| 52 |
* Added prefix option for Tweets that are sent out on publish.
|
| 53 |
|
| 54 |
= 1.0 =
|
| 55 |
-
* Initial release.
|
| 4 |
Tags: analytics, statistics, clicky
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 2.9
|
| 7 |
+
Stable tag: 1.0.6
|
| 8 |
|
| 9 |
Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
|
| 10 |
|
| 14 |
|
| 15 |
* Automatically adding your Clicky tracking code everywhere.
|
| 16 |
* Option to ignore admins.
|
| 17 |
+
* Option to store names of commenters.
|
| 18 |
* Option to track posts & 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/).
|
| 33 |
|
| 34 |
== Changelog ==
|
| 35 |
|
| 36 |
+
= 1.0.6 =
|
| 37 |
+
* Auto-tweeting now only happens when a post is first published.
|
| 38 |
+
* Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
|
| 39 |
+
* Added extra check to make sure clicky.me returned a valid short URL before tweeting.
|
| 40 |
+
|
| 41 |
= 1.0.5 =
|
| 42 |
* Minor copy changes.
|
|
|
|
| 43 |
|
| 44 |
= 1.0.4 =
|
| 45 |
* Made sure there's no spaces in the Site ID when displaying it, should solve blank Dashboard Stats Page issue.
|
| 56 |
* Added prefix option for Tweets that are sent out on publish.
|
| 57 |
|
| 58 |
= 1.0 =
|
| 59 |
+
* Initial release.
|
