Clicky by Yoast - Version 1.4.2.4

Version Description

=

  • Minor stability improvements to code.
  • Improved code formatting.
  • i18n updates
    • Replaced mangled fr_FR files
    • Updated tr_TK
Download this release

Release Info

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

Code changes from version 1.4.2.3 to 1.4.2.4

clicky.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /*
3
  Plugin Name: Clicky for WordPress
4
- Version: 1.4.2.3
5
- Plugin URI: http://yoast.com/wordpress/clicky/
6
  Description: Integrates Clicky on your blog!
7
- Author: Joost de Valk
8
- Author URI: http://yoast.com/
9
  */
10
 
11
  /**
@@ -18,87 +18,91 @@ Author URI: http://yoast.com/
18
  * Load the proper text domain
19
  */
20
  function clicky_init() {
21
- load_plugin_textdomain( 'clicky', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
22
  }
23
 
24
  add_action( 'plugins_loaded', 'clicky_init' );
25
 
26
- if ( !class_exists( 'Clicky_Admin' ) ) {
27
 
28
  require_once( 'yst_plugin_tools.php' );
29
- /**
30
- * Class Clicky_Admin
31
- *
32
- * Creates the admin for the Clicky for WordPress plugin by Yoast
33
- */
34
- class Clicky_Admin extends Clicky_Base_Plugin_Admin {
35
-
36
- /**
37
- * Menu slug for WordPress admin
38
- *
39
- * @access private
40
- * @var string
41
- */
42
- var $hook = 'clicky';
43
-
44
- /**
45
- * Name of the plugin (long version)
46
- *
47
- * @access private
48
- * @var string
49
- */
50
- var $longname = 'Clicky Configuration';
51
-
52
- /**
53
- * Name of the plugin (short version)
54
- *
55
- * @access private
56
- * @var string
57
- */
58
- var $shortname = 'Clicky';
59
-
60
- /**
61
- * Link to Clicky homepage
62
- *
63
- * @access private
64
- * @var string
65
- */
66
- var $homepage = 'http://yoast.com/wordpress/clicky/';
67
-
68
- /**
69
- * Link to Clicky RSS feed
70
- *
71
- * @access private
72
- * @var string
73
- */
 
74
  var $feed = 'http://getclicky.com/blog/rss';
75
 
76
- /**
77
- * Adds meta boxes to the Admin interface
78
- *
79
- * @link http://codex.wordpress.org/Function_Reference/add_meta_box
80
- * @link http://codex.wordpress.org/Function_Reference/get_post_types
81
- */
82
- function meta_box() {
83
  foreach ( get_post_types() as $pt ) {
84
- add_meta_box( 'clicky', __( 'Clicky Goal Tracking', 'clicky' ), array( 'Clicky_Admin', 'clicky_meta_box' ), $pt, 'side' );
 
 
 
85
  }
86
  }
87
 
88
- /**
89
- * Creates warnings for empty fields in the admin
90
- *
91
- * @uses clicky_get_options()
92
- * @uses clicky_warning()
93
- * @link http://codex.wordpress.org/Function_Reference/add_action
94
- */
95
- function clicky_admin_warnings() {
96
  $options = clicky_get_options();
97
- 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 ) {
98
- /**
99
- * Outputs a warning
100
- */
101
- function clicky_warning() {
102
  echo "<div id='clickywarning' class='updated fade'><p><strong>";
103
  _e( 'Clicky is almost ready. ', 'clicky' );
104
  echo "</strong>";
@@ -108,16 +112,17 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
108
  }
109
 
110
  add_action( 'admin_notices', 'clicky_warning' );
 
111
  return;
112
  }
113
  }
114
 
115
- /**
116
- * Add meta box for entering specific goals
117
- *
118
- * @link http://codex.wordpress.org/Function_Reference/get_post_meta
119
- */
120
- function clicky_meta_box() {
121
  global $post;
122
  $clicky_goal = get_post_meta( $post->ID, '_clicky_goal', true );
123
 
@@ -130,14 +135,14 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
130
  echo '</table>';
131
  }
132
 
133
- /**
134
- * Construct of class Clicky_admin
135
- *
136
- * @access private
137
- * @link http://codex.wordpress.org/Function_Reference/add_action
138
- * @link http://codex.wordpress.org/Function_Reference/add_filter
139
- */
140
- function __construct() {
141
  $this->filename = __FILE__;
142
 
143
  add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );
@@ -155,14 +160,15 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
155
  $this->clicky_admin_warnings();
156
  }
157
 
158
- /**
159
- * Updates post meta for '_clicky_goal' with goal ID and value
160
- *
161
- * @param int $pID The post ID
162
- * @link http://codex.wordpress.org/Function_Reference/delete_post_meta
163
- * @link http://codex.wordpress.org/Function_Reference/add_post_meta
164
- */
165
- function clicky_insert_post( $pID ) {
 
166
  $clicky_goal = array(
167
  'id' => $_POST['clicky_goal_id'],
168
  'value' => $_POST['clicky_goal_value']
@@ -171,57 +177,64 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
171
  add_post_meta( $pID, '_clicky_goal', $clicky_goal, true );
172
  }
173
 
174
- /**
175
- * Creates the dashboard page for Clicky for WordPress plugin by Yoast
176
- *
177
- * @link http://codex.wordpress.org/Function_Reference/add_dashboard_page
178
- */
179
- function register_dashboard_page() {
180
- add_dashboard_page( $this->shortname . ' ' . __( 'Stats', 'clicky' ), $this->shortname . ' ' . __( 'Stats', 'clicky' ), $this->accesslvl, $this->hook, array( &$this, 'dashboard_page' ) );
 
 
 
181
  }
182
 
183
- /**
184
- * Loads (external) stats page in an iframe
185
- *
186
- * @uses clicky_get_options()
187
- */
188
- function dashboard_page() {
189
  $options = clicky_get_options();
190
  ?>
191
- <br/>
192
- <iframe style="margin-left: 20px; width: 850px; height: 1000px;"
193
- src="https://clicky.com/stats/wp-iframe?site_id=<?php echo $options['site_id']; ?>&amp;sitekey=<?php echo $options['site_key']; ?>"></iframe>
194
  <?php
195
  }
196
 
197
- /**
198
- * Creates the configuration page for Clicky for WordPress by Yoast
199
- *
200
- * @uses clicky_get_options()
201
- * @link http://codex.wordpress.org/Function_Reference/current_user_can
202
- * @link http://codex.wordpress.org/Function_Reference/check_admin_referer
203
- * @link http://codex.wordpress.org/Function_Reference/update_option
204
- * @link http://codex.wordpress.org/Function_Reference/wp_nonce_field
205
- */
206
- function config_page() {
207
  $options = clicky_get_options();
208
 
209
  if ( isset( $_POST['submit'] ) ) {
210
- if ( !current_user_can( 'manage_options' ) ) die( __( 'You cannot edit the Clicky settings.', 'clicky' ) );
 
 
211
  check_admin_referer( 'clicky-config' );
212
 
213
  foreach ( array( 'site_id', 'site_key', 'admin_site_key', 'outbound_pattern' ) as $option_name ) {
214
- if ( isset( $_POST[$option_name] ) )
215
- $options[$option_name] = $_POST[$option_name];
216
- else
217
- $options[$option_name] = '';
 
218
  }
219
 
220
  foreach ( array( 'ignore_admin', 'track_names', 'cookies_disable' ) as $option_name ) {
221
- if ( isset( $_POST[$option_name] ) )
222
- $options[$option_name] = true;
223
- else
224
- $options[$option_name] = false;
 
225
  }
226
 
227
  if ( clicky_get_options() != $options ) {
@@ -237,145 +250,144 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
237
  echo "<script type=\"text/javascript\">setTimeout(function(){jQuery('#updatemessage').hide('slow');}, 3000);</script>";
238
  }
239
  ?>
240
- <div class="wrap">
241
- <a href="http://clicky.com/145844">
242
- <div id="clicky-icon"
243
- style="background: url('<?php echo plugins_url( '', __FILE__ ); ?>/images/clicky-32x32.png') no-repeat;"
244
- class="icon32"><br/></div>
245
- </a>
246
-
247
- <h2>Clicky <?php _e( "Configuration", 'clicky' ); ?></h2>
248
-
249
- <div class="postbox-container" style="width:70%;">
250
- <div class="metabox-holder">
251
- <div class="meta-box-sortables">
252
- <form action="" method="post" id="clicky-conf" enctype="multipart/form-data">
253
- <?php
254
- wp_nonce_field( 'clicky-config' );
255
-
256
- $content = '<p style="text-align:left; margin: 0 10px; font-size: 13px; line-height: 150%;">' . sprintf( __( 'Go to your %1$suser homepage on Clicky%2$s and click &quot;Preferences&quot; under the name of the domain, you will find the Site ID, Site Key, Admin Site Key and Database Server under Site information.', 'clicky' ), '<a href="http://getclicky.com/145844">', '</a>' ) . '</p>';
257
-
258
- $rows = array();
259
- $rows[] = array(
260
- 'id' => 'site_id',
261
- 'label' => __( 'Site ID', 'clicky' ),
262
- 'desc' => '',
263
- 'content' => '<input class="text" type="text" value="' . $options['site_id'] . '" name="site_id" id="site_id"/>',
264
- );
265
-
266
- $rows[] = array(
267
- 'id' => 'site_key',
268
- 'label' => __( 'Site Key', 'clicky' ),
269
- 'desc' => '',
270
- 'content' => '<input class="text" type="text" value="' . $options['site_key'] . '" name="site_key" id="site_key"/>',
271
- );
272
-
273
- $rows[] = array(
274
- 'id' => 'admin_site_key',
275
- 'label' => __( 'Admin Site Key', 'clicky' ),
276
- 'desc' => '',
277
- 'content' => '<input class="text" type="text" value="' . $options['admin_site_key'] . '" name="admin_site_key" id="admin_site_key"/>',
278
- );
279
-
280
- $content .= ' ' . $this->form_table( $rows );
281
- $this->postbox( 'clicky_settings', __( 'Clicky Settings', 'clicky' ), $content );
282
-
283
- $content = '<p style="text-align:left; margin: 0 10px; font-size: 13px; line-height: 150%;">' . sprintf( __( 'This plugin allows you to automatically create short URLs through the %1$sClicky.me service%2$s', 'clicky' ), '<a href="http://clicky.me">', '</a>,' ) . ' ' . __( 'and tweet your post immediately when you publish it. To do that, this plugin will need your Twitter username and pass.', 'clicky' ) . '</p>';
284
-
285
- $rows = array();
286
- $rows[] = array(
287
- 'id' => 'ignore_admin',
288
- 'label' => __( 'Ignore Admin users', 'clicky' ),
289
- 'desc' => __( 'If you are using a caching plugin, such as W3 Total Cache or WP-Supercache, please ensure that you have it configured to NOT use the cache for logged in users. Otherwise, admin users <em>will still</em> be tracked.', 'clicky' ),
290
- 'content' => '<input type="checkbox" ' . checked( $options['ignore_admin'], true, false ) . ' name="ignore_admin" id="ignore_admin"/>',
291
- );
292
-
293
- $rows[] = array(
294
- 'id' => 'cookies_disable',
295
- 'label' => __( 'Disable cookies', 'clicky' ),
296
- 'desc' => __( 'If you don\'t want Clicky to use cookies on your site, check this button. By doing so, uniques will instead be determined based on their IP address.', 'clicky' ),
297
- 'content' => '<input type="checkbox" ' . checked( $options['cookies_disable'], true, false ) . ' name="cookies_disable" id="cookies_disable"/>',
298
- );
299
-
300
- $rows[] = array(
301
- 'id' => 'track_names',
302
- 'label' => __( 'Track names of commenters', 'clicky' ),
303
- 'desc' => '',
304
- 'content' => '<input type="checkbox" ' . checked( $options['track_names'], true, false ) . ' name="track_names" id="track_names"/>'
305
- );
306
-
307
- $rows[] = array(
308
- 'id' => 'outbound_pattern',
309
- 'label' => __( 'Outbound Link Pattern', 'clicky' ),
310
- 'desc' => sprintf( __( 'If your site uses redirects for outbound links, instead of links that point directly to their external source (this is popular with affiliate links, for example), then you\'ll need to use this variable to tell our tracking code additional patterns to look for when automatically tracking outbound links. %1$sRead more here%1$s.', 'clicky' ), '<a href="https://secure.getclicky.com/helpy?type=customization#outbound_pattern">', '</a>' ),
311
- 'content' => '<input class="text" type="text" value="' . $options['outbound_pattern'] . '" name="outbound_pattern" id="outbound_pattern"/> ' . __( 'For instance: <code>/out/,/go/</code>', 'clicky' ),
312
- );
313
-
314
- $this->postbox( 'clicky_settings', __( 'Advanced Settings', 'clicky' ), $this->form_table( $rows ) );
315
-
316
- ?>
317
- <div class="submit">
318
- <input type="submit" class="button-primary" name="submit"
319
- value="<?php _e( "Update Clicky Settings", 'clicky' ); ?> &raquo;"/>
320
- </div>
321
- </form>
322
  </div>
323
  </div>
324
- </div>
325
- <div class="postbox-container" style="width:20%;">
326
- <div class="metabox-holder">
327
- <div class="meta-box-sortables">
328
- <?php
329
- $this->donate();
330
- $this->plugin_support();
331
- $this->yoast_news();
332
- $this->news();
333
- ?>
 
334
  </div>
335
- <br/><br/><br/>
336
  </div>
337
  </div>
338
- </div>
339
  <?php
340
  }
341
 
342
- /**
343
- * Creates (CSS for) head for the admin menu bar
344
- *
345
- * @link http://codex.wordpress.org/Function_Reference/add_action
346
- */
347
- function stats_admin_bar_head() {
348
  add_action( 'admin_bar_menu', array( &$this, 'stats_admin_bar_menu' ), 1200 );
349
  ?>
350
 
351
- <style type='text/css'>
352
- #wpadminbar .quicklinks li#wp-admin-bar-clickystats {
353
- height: 28px
354
- }
355
 
356
- #wpadminbar .quicklinks li#wp-admin-bar-clickystats a {
357
- height: 28px;
358
- padding: 0
359
- }
360
 
361
- #wpadminbar .quicklinks li#wp-admin-bar-clickystats a img {
362
- padding: 4px 5px;
363
- height: 20px;
364
- width: 99px;
365
- }
366
- </style>
367
  <?php
368
  }
369
 
370
- /**
371
- * Adds Clicky (graph) to the admin bar of the website
372
- *
373
- * @param obj $wp_admin_bar Class that contains all information for the admin bar. Passed by reference.
374
- * @uses clicky_get_options()
375
- * @uses create_graph()
376
- * @link http://codex.wordpress.org/Class_Reference/WP_Admin_Bar
377
- */
378
- function stats_admin_bar_menu( &$wp_admin_bar ) {
 
379
  $options = clicky_get_options();
380
 
381
  $img_src = $this->create_graph();
@@ -384,29 +396,35 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
384
 
385
  $title = __( 'Visitors over 48 hours. Click for more Clicky Site Stats.', 'clicky' );
386
 
387
- $menu = array( 'id' => 'clickystats', 'title' => "<img width='99' height='20' src='${img_src}' alt='$title' title='$title' />", 'href' => $url );
 
 
 
 
388
 
389
  $wp_admin_bar->add_menu( $menu );
390
  }
391
 
392
- /**
393
- * Creates the graph to be used in the admin bar
394
- *
395
- * @uses clicky_get_options()
396
- * @link http://codex.wordpress.org/Function_Reference/wp_remote_get
397
- * @link http://codex.wordpress.org/Function_Reference/is_wp_error
398
- * @return bool|string Returns base64-encoded image on succes (String) or fail (boolean) on failure
399
- */
400
- function create_graph() {
401
  $options = clicky_get_options();
402
 
403
- if ( !function_exists( 'imagecreate' ) )
404
  return false;
 
405
 
406
  $resp = wp_remote_get( "http://api.getclicky.com/api/stats/4?site_id=" . $options['site_id'] . "&sitekey=" . $options['site_key'] . "&type=visitors&hourly=1&date=last-3-days" );
407
 
408
- if ( is_wp_error( $resp ) || !isset( $resp['response']['code'] ) || $resp['response']['code'] != 200 )
409
- return;
 
410
 
411
  $xml = simplexml_load_string( $resp['body'] );
412
 
@@ -415,21 +433,22 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
415
  $k = 0;
416
  $values = array();
417
  foreach ( $xml->type->date as $value ) {
418
- foreach ( $xml->type->date[$i]->item->value as $art ) //nested loop for multiple values in tag
419
  {
420
 
421
- $data = (int) ( $xml->type->date[$i]->item->value[$j] ); //$i and $j is used to iterate multiples of both tags respectively
422
  array_push( $values, $data );
423
  $j = $j + 1;
424
  $k++;
425
- if ( $k == 48 )
426
  break 2;
 
427
  }
428
  $j = 0; //so that in next item it starts from 0(zero)
429
- $i++;
430
  }
431
  if ( count( $values ) == 0 ) {
432
- return;
433
  }
434
  $values = array_reverse( $values );
435
  //-----------------------------------------------------------------------------------------------------------------------------
@@ -463,13 +482,14 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
463
 
464
  # ------- Max value is required to adjust the scale -------
465
  $max_value = max( $values );
466
- if ( $max_value == 0 )
467
  $max_value = 1;
 
468
  $ratio = $graph_height / $max_value;
469
 
470
 
471
  # ----------- Draw the bars here ------
472
- for ( $i = 0; $i < $total_bars; $i++ ) {
473
  # ------ Extract key and value pair from the current pointer position
474
  list( $key, $value ) = each( $values );
475
  $x1 = $margins + $gap + $i * ( $gap + $bar_width );
@@ -502,13 +522,14 @@ if ( !class_exists( 'Clicky_Admin' ) ) {
502
  */
503
  function clicky_get_options() {
504
  $options = get_option( 'clicky' );
505
- if ( !is_array( $options ) ) {
506
  clicky_defaults();
507
  } else {
508
  $options['site_id'] = trim( $options['site_id'] );
509
  $options['site_key'] = trim( $options['site_key'] );
510
  $options['admin_site_key'] = trim( $options['admin_site_key'] );
511
  }
 
512
  return $options;
513
  }
514
 
@@ -519,13 +540,13 @@ function clicky_get_options() {
519
  */
520
  function clicky_defaults() {
521
  $options = array(
522
- 'site_id' => '',
523
- 'site_key' => '',
524
- 'admin_site_key' => '',
525
- 'outbound_pattern' => '',
526
- 'ignore_admin' => false,
527
- 'track_names' => true,
528
- 'cookies_disable' => false,
529
  );
530
  add_option( 'clicky', $options );
531
  }
@@ -533,40 +554,45 @@ function clicky_defaults() {
533
  /**
534
  * Add clicky scripts to footer
535
  *
 
 
536
  * @link http://codex.wordpress.org/Function_Reference/current_user_can
537
  */
538
  function clicky_script() {
539
  $options = clicky_get_options();
540
 
541
- if ( is_preview() )
542
- return;
 
543
 
544
  // Bail early if current user is admin and ignore admin is true
545
  if ( $options['ignore_admin'] && current_user_can( "manage_options" ) ) {
546
  echo "\n<!-- " . __( "Clicky tracking not shown because you're an administrator and you've configured Clicky to ignore administrators.", 'clicky' ) . " -->\n";
547
- return;
 
548
  }
549
 
550
 
551
  // Debug
552
  ?>
553
- <!-- Clicky Web Analytics - http://getclicky.com, WordPress Plugin by Yoast - http://yoast.com/wordpress/clicky/ -->
554
- <?php
555
  // Track commenter name if track_names is true
556
  if ( $options['track_names'] ) {
557
  ?>
558
- <script type='text/javascript'>
559
- function clicky_gc(name) {
560
- var ca = document.cookie.split(';');
561
- for (var i in ca) {
562
- if (ca[i].indexOf(name + '=') != -1)
563
- return decodeURIComponent(ca[i].split('=')[1]);
 
 
 
564
  }
565
- return '';
566
- }
567
- var username_check = clicky_gc('comment_author_<?php echo md5( get_option( "siteurl" ) ); ?>');
568
- if( username_check ) var clicky_custom_session = { username: username_check };
569
- </script>
570
  <?php
571
  }
572
 
@@ -576,10 +602,11 @@ function clicky_script() {
576
  if ( is_singular() ) {
577
  global $post;
578
  $clicky_goal = get_post_meta( $post->ID, '_clicky_goal', true );
579
- if ( is_array( $clicky_goal ) && !empty( $clicky_goal['id'] ) ) {
580
  $clicky_extra .= 'var clicky_goal = { id: "' . trim( $clicky_goal['id'] ) . '"';
581
- if ( isset( $clicky_goal['value'] ) && !empty( $clicky_goal['value'] ) )
582
  $clicky_extra .= ', revenue: "' . $clicky_goal['value'] . '"';
 
583
  $clicky_extra .= ' };' . "\n";
584
  }
585
  }
@@ -588,8 +615,9 @@ function clicky_script() {
588
  $patterns = explode( ',', $options['outbound_pattern'] );
589
  $pattern = '';
590
  foreach ( $patterns as $pat ) {
591
- if ( $pattern != '' )
592
  $pattern .= ',';
 
593
  $pat = trim( str_replace( '"', '', str_replace( "'", "", $pat ) ) );
594
  $pattern .= "'" . $pat . "'";
595
  }
@@ -600,32 +628,33 @@ function clicky_script() {
600
  $clicky_extra .= "clicky_custom.cookies_disable = 1;\n";
601
  }
602
 
603
- if ( !empty( $clicky_extra ) ) {
604
  ?>
 
 
 
 
 
605
  <script type="text/javascript">
606
- var clicky_custom = clicky_custom || {};
607
- <?php echo $clicky_extra; ?>
 
 
 
 
 
 
 
 
 
 
 
608
  </script>
609
- <?php } ?>
610
- <script type="text/javascript">
611
- var clicky = { log:function () {
612
- return;
613
- }, goal:function () {
614
- return;
615
- }};
616
- var clicky_site_id = <?php echo $options['site_id']; ?>;
617
- (function () {
618
- var s = document.createElement('script');
619
- s.type = 'text/javascript';
620
- s.async = true;
621
- s.src = '//static.getclicky.com/js';
622
- ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild(s);
623
- })();
624
- </script>
625
- <noscript><p><img alt="Clicky" width="1" height="1"
626
- src="//in.getclicky.com/<?php echo $options['site_id']; ?>ns.gif"/></p></noscript>
627
- <!-- End Clicky Tracking -->
628
  <?php
 
629
  }
630
 
631
  add_action( 'wp_footer', 'clicky_script', 90 );
@@ -635,36 +664,44 @@ add_action( 'wp_footer', 'clicky_script', 90 );
635
  *
636
  * @uses clicky_get_options()
637
  * @link http://codex.wordpress.org/Function_Reference/wp_remote_get
 
638
  * @param array $a The array with basic log-data
 
639
  * @return bool Returns true on success or false on failure
640
  */
641
  function clicky_log( $a ) {
642
  $options = clicky_get_options();
643
 
644
- if ( !isset( $options['site_id'] ) || empty( $options['site_id'] ) || !isset( $options['admin_site_key'] ) || empty( $options['admin_site_key'] ) )
645
- return;
 
646
 
647
  $type = $a['type'];
648
- if ( !in_array( $type, array( "pageview", "download", "outbound", "click", "custom", "goal" ) ) )
649
  $type = "pageview";
 
650
 
651
  $file = "http://in.getclicky.com/in.php?site_id=" . $options['site_id'] . "&sitekey_admin=" . $options['admin_site_key'] . "&type=" . $type;
652
 
653
  # referrer and user agent - will only be logged if this is the very first action of this session
654
- if ( $a['ref'] )
655
  $file .= "&ref=" . urlencode( $a['ref'] );
 
656
 
657
- if ( $a['ua'] )
658
  $file .= "&ua=" . urlencode( $a['ua'] );
 
659
 
660
  # we need either a session_id or an ip_address...
661
  if ( is_numeric( $a['session_id'] ) ) {
662
  $file .= "&session_id=" . $a['session_id'];
663
  } else {
664
- if ( !$a['ip_address'] )
665
- $a['ip_address'] = $_SERVER['REMOTE_ADDR']; # automatically grab IP that PHP gives us.
666
- if ( !preg_match( "#^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#", $a['ip_address'] ) )
 
667
  return false;
 
668
  $file .= "&ip_address=" . $a['ip_address'];
669
  }
670
 
@@ -673,39 +710,46 @@ function clicky_log( $a ) {
673
  if ( is_numeric( $a['goal'] ) ) {
674
  $file .= "&goal[id]=" . $a['goal'];
675
  } else {
676
- if ( !is_numeric( $a['goal']['id'] ) )
677
  return false;
678
- foreach ( $a['goal'] as $key => $value )
 
679
  $file .= "&goal[" . urlencode( $key ) . "]=" . urlencode( $value );
 
680
  }
681
  }
682
 
683
  # custom data, must come in as array of key=>values
684
- foreach ( $a['custom'] as $key => $value )
685
  $file .= "&custom[" . urlencode( $key ) . "]=" . urlencode( $value );
 
686
 
687
  if ( $type == "goal" || $type == "custom" ) {
688
  # dont do anything, data has already been cat'd
689
  } else {
690
  if ( $type == "outbound" ) {
691
- if ( !preg_match( "#^(https?|telnet|ftp)#", $a['href'] ) )
692
  return false;
 
693
  } else {
694
  # all other action types must start with either a / or a #
695
- if ( !preg_match( "#^(/|\#)#", $a['href'] ) )
696
  $a['href'] = "/" . $a['href'];
 
697
  }
698
  $file .= "&href=" . urlencode( $a['href'] );
699
- if ( $a['title'] )
700
  $file .= "&title=" . urlencode( $a['title'] );
 
701
  }
 
702
  return wp_remote_get( $file ) ? true : false;
703
  }
704
 
705
  /**
706
  * Tracks comments that are not spam and not ping- or trackbacks
707
  *
708
- * @param int $commentID The ID of the comment that needs to be tracked
709
  * @param int $comment_status Status of the comment (e.g. spam)
710
  */
711
  function clicky_track_comment( $commentID, $comment_status ) {
@@ -716,14 +760,14 @@ function clicky_track_comment( $commentID, $comment_status ) {
716
  if ( $comment->comment_type != 'pingback' && $comment->comment_type != 'trackback' ) {
717
  clicky_log(
718
  array(
719
- "type" => "click",
720
- "href" => "/wp-comments-post.php",
721
- "title" => __( "Posted a comment", 'clicky' ),
722
- "ua" => $comment->comment_agent,
723
- "ip_address" => $comment->comment_author_IP,
724
- "custom" => array(
725
- "username" => $comment->comment_author,
726
- "email" => $comment->comment_author_email,
727
  )
728
  )
729
  );
1
  <?php
2
  /*
3
  Plugin Name: Clicky for WordPress
4
+ Version: 1.4.2.4
5
+ Plugin URI: https://yoast.com/wordpress/plugins/clicky/
6
  Description: Integrates Clicky on your blog!
7
+ Author: Team Yoast
8
+ Author URI: https://yoast.com/
9
  */
10
 
11
  /**
18
  * Load the proper text domain
19
  */
20
  function clicky_init() {
21
+ load_plugin_textdomain( 'clicky', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
22
  }
23
 
24
  add_action( 'plugins_loaded', 'clicky_init' );
25
 
26
+ if ( ! class_exists( 'Clicky_Admin' ) ) {
27
 
28
  require_once( 'yst_plugin_tools.php' );
29
+
30
+ /**
31
+ * Class Clicky_Admin
32
+ *
33
+ * Creates the admin for the Clicky for WordPress plugin by Yoast
34
+ */
35
+ class Clicky_Admin extends Clicky_Base_Plugin_Admin {
36
+
37
+ /**
38
+ * Menu slug for WordPress admin
39
+ *
40
+ * @access private
41
+ * @var string
42
+ */
43
+ var $hook = 'clicky';
44
+
45
+ /**
46
+ * Name of the plugin (long version)
47
+ *
48
+ * @access private
49
+ * @var string
50
+ */
51
+ var $longname = 'Clicky Configuration';
52
+
53
+ /**
54
+ * Name of the plugin (short version)
55
+ *
56
+ * @access private
57
+ * @var string
58
+ */
59
+ var $shortname = 'Clicky';
60
+
61
+ /**
62
+ * Link to Clicky homepage
63
+ *
64
+ * @access private
65
+ * @var string
66
+ */
67
+ var $homepage = 'http://yoast.com/wordpress/clicky/';
68
+
69
+ /**
70
+ * Link to Clicky RSS feed
71
+ *
72
+ * @access private
73
+ * @var string
74
+ */
75
  var $feed = 'http://getclicky.com/blog/rss';
76
 
77
+ /**
78
+ * Adds meta boxes to the Admin interface
79
+ *
80
+ * @link http://codex.wordpress.org/Function_Reference/add_meta_box
81
+ * @link http://codex.wordpress.org/Function_Reference/get_post_types
82
+ */
83
+ function meta_box() {
84
  foreach ( get_post_types() as $pt ) {
85
+ add_meta_box( 'clicky', __( 'Clicky Goal Tracking', 'clicky' ), array(
86
+ 'Clicky_Admin',
87
+ 'clicky_meta_box'
88
+ ), $pt, 'side' );
89
  }
90
  }
91
 
92
+ /**
93
+ * Creates warnings for empty fields in the admin
94
+ *
95
+ * @uses clicky_get_options()
96
+ * @uses clicky_warning()
97
+ * @link http://codex.wordpress.org/Function_Reference/add_action
98
+ */
99
+ function clicky_admin_warnings() {
100
  $options = clicky_get_options();
101
+ 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 ) {
102
+ /**
103
+ * Outputs a warning
104
+ */
105
+ function clicky_warning() {
106
  echo "<div id='clickywarning' class='updated fade'><p><strong>";
107
  _e( 'Clicky is almost ready. ', 'clicky' );
108
  echo "</strong>";
112
  }
113
 
114
  add_action( 'admin_notices', 'clicky_warning' );
115
+
116
  return;
117
  }
118
  }
119
 
120
+ /**
121
+ * Add meta box for entering specific goals
122
+ *
123
+ * @link http://codex.wordpress.org/Function_Reference/get_post_meta
124
+ */
125
+ function clicky_meta_box() {
126
  global $post;
127
  $clicky_goal = get_post_meta( $post->ID, '_clicky_goal', true );
128
 
135
  echo '</table>';
136
  }
137
 
138
+ /**
139
+ * Construct of class Clicky_admin
140
+ *
141
+ * @access private
142
+ * @link http://codex.wordpress.org/Function_Reference/add_action
143
+ * @link http://codex.wordpress.org/Function_Reference/add_filter
144
+ */
145
+ function __construct() {
146
  $this->filename = __FILE__;
147
 
148
  add_action( 'admin_menu', array( &$this, 'register_settings_page' ) );
160
  $this->clicky_admin_warnings();
161
  }
162
 
163
+ /**
164
+ * Updates post meta for '_clicky_goal' with goal ID and value
165
+ *
166
+ * @param int $pID The post ID
167
+ *
168
+ * @link http://codex.wordpress.org/Function_Reference/delete_post_meta
169
+ * @link http://codex.wordpress.org/Function_Reference/add_post_meta
170
+ */
171
+ function clicky_insert_post( $pID ) {
172
  $clicky_goal = array(
173
  'id' => $_POST['clicky_goal_id'],
174
  'value' => $_POST['clicky_goal_value']
177
  add_post_meta( $pID, '_clicky_goal', $clicky_goal, true );
178
  }
179
 
180
+ /**
181
+ * Creates the dashboard page for Clicky for WordPress plugin by Yoast
182
+ *
183
+ * @link http://codex.wordpress.org/Function_Reference/add_dashboard_page
184
+ */
185
+ function register_dashboard_page() {
186
+ add_dashboard_page( $this->shortname . ' ' . __( 'Stats', 'clicky' ), $this->shortname . ' ' . __( 'Stats', 'clicky' ), $this->accesslvl, $this->hook, array(
187
+ &$this,
188
+ 'dashboard_page'
189
+ ) );
190
  }
191
 
192
+ /**
193
+ * Loads (external) stats page in an iframe
194
+ *
195
+ * @uses clicky_get_options()
196
+ */
197
+ function dashboard_page() {
198
  $options = clicky_get_options();
199
  ?>
200
+ <br />
201
+ <iframe style="margin-left: 20px; width: 850px; height: 1000px;"
202
+ src="https://clicky.com/stats/wp-iframe?site_id=<?php echo $options['site_id']; ?>&amp;sitekey=<?php echo $options['site_key']; ?>"></iframe>
203
  <?php
204
  }
205
 
206
+ /**
207
+ * Creates the configuration page for Clicky for WordPress by Yoast
208
+ *
209
+ * @uses clicky_get_options()
210
+ * @link http://codex.wordpress.org/Function_Reference/current_user_can
211
+ * @link http://codex.wordpress.org/Function_Reference/check_admin_referer
212
+ * @link http://codex.wordpress.org/Function_Reference/update_option
213
+ * @link http://codex.wordpress.org/Function_Reference/wp_nonce_field
214
+ */
215
+ function config_page() {
216
  $options = clicky_get_options();
217
 
218
  if ( isset( $_POST['submit'] ) ) {
219
+ if ( ! current_user_can( 'manage_options' ) ) {
220
+ die( __( 'You cannot edit the Clicky settings.', 'clicky' ) );
221
+ }
222
  check_admin_referer( 'clicky-config' );
223
 
224
  foreach ( array( 'site_id', 'site_key', 'admin_site_key', 'outbound_pattern' ) as $option_name ) {
225
+ if ( isset( $_POST[ $option_name ] ) ) {
226
+ $options[ $option_name ] = $_POST[ $option_name ];
227
+ } else {
228
+ $options[ $option_name ] = '';
229
+ }
230
  }
231
 
232
  foreach ( array( 'ignore_admin', 'track_names', 'cookies_disable' ) as $option_name ) {
233
+ if ( isset( $_POST[ $option_name ] ) ) {
234
+ $options[ $option_name ] = true;
235
+ } else {
236
+ $options[ $option_name ] = false;
237
+ }
238
  }
239
 
240
  if ( clicky_get_options() != $options ) {
250
  echo "<script type=\"text/javascript\">setTimeout(function(){jQuery('#updatemessage').hide('slow');}, 3000);</script>";
251
  }
252
  ?>
253
+ <div class="wrap">
254
+ <a href="http://clicky.com/145844">
255
+ <div id="clicky-icon"
256
+ style="background: url('<?php echo plugins_url( '', __FILE__ ); ?>/images/clicky-32x32.png') no-repeat;"
257
+ class="icon32"><br /></div>
258
+ </a>
259
+
260
+ <h2>Clicky <?php _e( "Configuration", 'clicky' ); ?></h2>
261
+
262
+ <div class="postbox-container" style="width:70%;">
263
+ <div class="metabox-holder">
264
+ <div class="meta-box-sortables">
265
+ <form action="" method="post" id="clicky-conf" enctype="multipart/form-data">
266
+ <?php
267
+ wp_nonce_field( 'clicky-config' );
268
+
269
+ $content = '<p style="text-align:left; margin: 0 10px; font-size: 13px; line-height: 150%;">' . sprintf( __( 'Go to your %1$suser homepage on Clicky%2$s and click &quot;Preferences&quot; under the name of the domain, you will find the Site ID, Site Key, Admin Site Key and Database Server under Site information.', 'clicky' ), '<a href="http://getclicky.com/145844">', '</a>' ) . '</p>';
270
+
271
+ $rows = array();
272
+ $rows[] = array(
273
+ 'id' => 'site_id',
274
+ 'label' => __( 'Site ID', 'clicky' ),
275
+ 'desc' => '',
276
+ 'content' => '<input class="text" type="text" value="' . $options['site_id'] . '" name="site_id" id="site_id"/>',
277
+ );
278
+
279
+ $rows[] = array(
280
+ 'id' => 'site_key',
281
+ 'label' => __( 'Site Key', 'clicky' ),
282
+ 'desc' => '',
283
+ 'content' => '<input class="text" type="text" value="' . $options['site_key'] . '" name="site_key" id="site_key"/>',
284
+ );
285
+
286
+ $rows[] = array(
287
+ 'id' => 'admin_site_key',
288
+ 'label' => __( 'Admin Site Key', 'clicky' ),
289
+ 'desc' => '',
290
+ 'content' => '<input class="text" type="text" value="' . $options['admin_site_key'] . '" name="admin_site_key" id="admin_site_key"/>',
291
+ );
292
+
293
+ $content .= ' ' . $this->form_table( $rows );
294
+ $this->postbox( 'clicky_settings', __( 'Clicky Settings', 'clicky' ), $content );
295
+
296
+ $rows = array();
297
+ $rows[] = array(
298
+ 'id' => 'ignore_admin',
299
+ 'label' => __( 'Ignore Admin users', 'clicky' ),
300
+ 'desc' => __( 'If you are using a caching plugin, such as W3 Total Cache or WP-Supercache, please ensure that you have it configured to NOT use the cache for logged in users. Otherwise, admin users <em>will still</em> be tracked.', 'clicky' ),
301
+ 'content' => '<input type="checkbox" ' . checked( $options['ignore_admin'], true, false ) . ' name="ignore_admin" id="ignore_admin"/>',
302
+ );
303
+
304
+ $rows[] = array(
305
+ 'id' => 'cookies_disable',
306
+ 'label' => __( 'Disable cookies', 'clicky' ),
307
+ 'desc' => __( 'If you don\'t want Clicky to use cookies on your site, check this button. By doing so, uniques will instead be determined based on their IP address.', 'clicky' ),
308
+ 'content' => '<input type="checkbox" ' . checked( $options['cookies_disable'], true, false ) . ' name="cookies_disable" id="cookies_disable"/>',
309
+ );
310
+
311
+ $rows[] = array(
312
+ 'id' => 'track_names',
313
+ 'label' => __( 'Track names of commenters', 'clicky' ),
314
+ 'desc' => '',
315
+ 'content' => '<input type="checkbox" ' . checked( $options['track_names'], true, false ) . ' name="track_names" id="track_names"/>'
316
+ );
317
+
318
+ $rows[] = array(
319
+ 'id' => 'outbound_pattern',
320
+ 'label' => __( 'Outbound Link Pattern', 'clicky' ),
321
+ 'desc' => sprintf( __( 'If your site uses redirects for outbound links, instead of links that point directly to their external source (this is popular with affiliate links, for example), then you\'ll need to use this variable to tell our tracking code additional patterns to look for when automatically tracking outbound links. %1$sRead more here%1$s.', 'clicky' ), '<a href="https://secure.getclicky.com/helpy?type=customization#outbound_pattern">', '</a>' ),
322
+ 'content' => '<input class="text" type="text" value="' . $options['outbound_pattern'] . '" name="outbound_pattern" id="outbound_pattern"/> ' . __( 'For instance: <code>/out/,/go/</code>', 'clicky' ),
323
+ );
324
+
325
+ $this->postbox( 'clicky_settings', __( 'Advanced Settings', 'clicky' ), $this->form_table( $rows ) );
326
+
327
+ ?>
328
+ <div class="submit">
329
+ <input type="submit" class="button-primary" name="submit"
330
+ value="<?php _e( "Update Clicky Settings", 'clicky' ); ?> &raquo;" />
331
+ </div>
332
+ </form>
333
+ </div>
 
334
  </div>
335
  </div>
336
+ <div class="postbox-container" style="width:20%;">
337
+ <div class="metabox-holder">
338
+ <div class="meta-box-sortables">
339
+ <?php
340
+ $this->donate();
341
+ $this->plugin_support();
342
+ $this->yoast_news();
343
+ $this->news();
344
+ ?>
345
+ </div>
346
+ <br /><br /><br />
347
  </div>
 
348
  </div>
349
  </div>
 
350
  <?php
351
  }
352
 
353
+ /**
354
+ * Creates (CSS for) head for the admin menu bar
355
+ *
356
+ * @link http://codex.wordpress.org/Function_Reference/add_action
357
+ */
358
+ function stats_admin_bar_head() {
359
  add_action( 'admin_bar_menu', array( &$this, 'stats_admin_bar_menu' ), 1200 );
360
  ?>
361
 
362
+ <style type='text/css'>
363
+ #wpadminbar .quicklinks li#wp-admin-bar-clickystats {
364
+ height: 28px
365
+ }
366
 
367
+ #wpadminbar .quicklinks li#wp-admin-bar-clickystats a {
368
+ height: 28px;
369
+ padding: 0
370
+ }
371
 
372
+ #wpadminbar .quicklinks li#wp-admin-bar-clickystats a img {
373
+ padding: 4px 5px;
374
+ height: 20px;
375
+ width: 99px;
376
+ }
377
+ </style>
378
  <?php
379
  }
380
 
381
+ /**
382
+ * Adds Clicky (graph) to the admin bar of the website
383
+ *
384
+ * @param object $wp_admin_bar Class that contains all information for the admin bar. Passed by reference.
385
+ *
386
+ * @uses clicky_get_options()
387
+ * @uses create_graph()
388
+ * @link http://codex.wordpress.org/Class_Reference/WP_Admin_Bar
389
+ */
390
+ function stats_admin_bar_menu( &$wp_admin_bar ) {
391
  $options = clicky_get_options();
392
 
393
  $img_src = $this->create_graph();
396
 
397
  $title = __( 'Visitors over 48 hours. Click for more Clicky Site Stats.', 'clicky' );
398
 
399
+ $menu = array(
400
+ 'id' => 'clickystats',
401
+ 'title' => "<img width='99' height='20' src='" . $img_src . "' alt='" . $title . "' title='" . $title . "' />",
402
+ 'href' => $url
403
+ );
404
 
405
  $wp_admin_bar->add_menu( $menu );
406
  }
407
 
408
+ /**
409
+ * Creates the graph to be used in the admin bar
410
+ *
411
+ * @uses clicky_get_options()
412
+ * @link http://codex.wordpress.org/Function_Reference/wp_remote_get
413
+ * @link http://codex.wordpress.org/Function_Reference/is_wp_error
414
+ * @return bool|string Returns base64-encoded image on succes (String) or fail (boolean) on failure
415
+ */
416
+ function create_graph() {
417
  $options = clicky_get_options();
418
 
419
+ if ( ! function_exists( 'imagecreate' ) ) {
420
  return false;
421
+ }
422
 
423
  $resp = wp_remote_get( "http://api.getclicky.com/api/stats/4?site_id=" . $options['site_id'] . "&sitekey=" . $options['site_key'] . "&type=visitors&hourly=1&date=last-3-days" );
424
 
425
+ if ( is_wp_error( $resp ) || ! isset( $resp['response']['code'] ) || $resp['response']['code'] != 200 ) {
426
+ return false;
427
+ }
428
 
429
  $xml = simplexml_load_string( $resp['body'] );
430
 
433
  $k = 0;
434
  $values = array();
435
  foreach ( $xml->type->date as $value ) {
436
+ foreach ( $xml->type->date[ $i ]->item->value as $art ) //nested loop for multiple values in tag
437
  {
438
 
439
+ $data = (int) ( $xml->type->date[ $i ]->item->value[ $j ] ); //$i and $j is used to iterate multiples of both tags respectively
440
  array_push( $values, $data );
441
  $j = $j + 1;
442
  $k++;
443
+ if ( $k == 48 ) {
444
  break 2;
445
+ }
446
  }
447
  $j = 0; //so that in next item it starts from 0(zero)
448
+ $i ++;
449
  }
450
  if ( count( $values ) == 0 ) {
451
+ return false;
452
  }
453
  $values = array_reverse( $values );
454
  //-----------------------------------------------------------------------------------------------------------------------------
482
 
483
  # ------- Max value is required to adjust the scale -------
484
  $max_value = max( $values );
485
+ if ( $max_value == 0 ) {
486
  $max_value = 1;
487
+ }
488
  $ratio = $graph_height / $max_value;
489
 
490
 
491
  # ----------- Draw the bars here ------
492
+ for ( $i = 0; $i < $total_bars; $i ++ ) {
493
  # ------ Extract key and value pair from the current pointer position
494
  list( $key, $value ) = each( $values );
495
  $x1 = $margins + $gap + $i * ( $gap + $bar_width );
522
  */
523
  function clicky_get_options() {
524
  $options = get_option( 'clicky' );
525
+ if ( ! is_array( $options ) ) {
526
  clicky_defaults();
527
  } else {
528
  $options['site_id'] = trim( $options['site_id'] );
529
  $options['site_key'] = trim( $options['site_key'] );
530
  $options['admin_site_key'] = trim( $options['admin_site_key'] );
531
  }
532
+
533
  return $options;
534
  }
535
 
540
  */
541
  function clicky_defaults() {
542
  $options = array(
543
+ 'site_id' => '',
544
+ 'site_key' => '',
545
+ 'admin_site_key' => '',
546
+ 'outbound_pattern' => '',
547
+ 'ignore_admin' => false,
548
+ 'track_names' => true,
549
+ 'cookies_disable' => false,
550
  );
551
  add_option( 'clicky', $options );
552
  }
554
  /**
555
  * Add clicky scripts to footer
556
  *
557
+ * @return bool
558
+ *
559
  * @link http://codex.wordpress.org/Function_Reference/current_user_can
560
  */
561
  function clicky_script() {
562
  $options = clicky_get_options();
563
 
564
+ if ( is_preview() ) {
565
+ return false;
566
+ }
567
 
568
  // Bail early if current user is admin and ignore admin is true
569
  if ( $options['ignore_admin'] && current_user_can( "manage_options" ) ) {
570
  echo "\n<!-- " . __( "Clicky tracking not shown because you're an administrator and you've configured Clicky to ignore administrators.", 'clicky' ) . " -->\n";
571
+
572
+ return false;
573
  }
574
 
575
 
576
  // Debug
577
  ?>
578
+ <!-- Clicky Web Analytics - http://getclicky.com, WordPress Plugin by Yoast - http://yoast.com/wordpress/clicky/ -->
579
+ <?php
580
  // Track commenter name if track_names is true
581
  if ( $options['track_names'] ) {
582
  ?>
583
+ <script type='text/javascript'>
584
+ function clicky_gc(name) {
585
+ var ca = document.cookie.split(';');
586
+ for (var i in ca) {
587
+ if (ca[i].indexOf(name + '=') != -1) {
588
+ return decodeURIComponent(ca[i].split('=')[1]);
589
+ }
590
+ }
591
+ return '';
592
  }
593
+ var username_check = clicky_gc('comment_author_<?php echo md5( get_option( "siteurl" ) ); ?>');
594
+ if (username_check) var clicky_custom_session = { username: username_check };
595
+ </script>
 
 
596
  <?php
597
  }
598
 
602
  if ( is_singular() ) {
603
  global $post;
604
  $clicky_goal = get_post_meta( $post->ID, '_clicky_goal', true );
605
+ if ( is_array( $clicky_goal ) && ! empty( $clicky_goal['id'] ) ) {
606
  $clicky_extra .= 'var clicky_goal = { id: "' . trim( $clicky_goal['id'] ) . '"';
607
+ if ( isset( $clicky_goal['value'] ) && ! empty( $clicky_goal['value'] ) ) {
608
  $clicky_extra .= ', revenue: "' . $clicky_goal['value'] . '"';
609
+ }
610
  $clicky_extra .= ' };' . "\n";
611
  }
612
  }
615
  $patterns = explode( ',', $options['outbound_pattern'] );
616
  $pattern = '';
617
  foreach ( $patterns as $pat ) {
618
+ if ( $pattern != '' ) {
619
  $pattern .= ',';
620
+ }
621
  $pat = trim( str_replace( '"', '', str_replace( "'", "", $pat ) ) );
622
  $pattern .= "'" . $pat . "'";
623
  }
628
  $clicky_extra .= "clicky_custom.cookies_disable = 1;\n";
629
  }
630
 
631
+ if ( ! empty( $clicky_extra ) ) {
632
  ?>
633
+ <script type="text/javascript">
634
+ var clicky_custom = clicky_custom || {};
635
+ <?php echo $clicky_extra; ?>
636
+ </script>
637
+ <?php } ?>
638
  <script type="text/javascript">
639
+ var clicky = { log: function () {
640
+ return true;
641
+ }, goal : function () {
642
+ return true;
643
+ }};
644
+ var clicky_site_id = <?php echo $options['site_id']; ?>;
645
+ (function () {
646
+ var s = document.createElement('script');
647
+ s.type = 'text/javascript';
648
+ s.async = true;
649
+ s.src = '//static.getclicky.com/js';
650
+ ( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild(s);
651
+ })();
652
  </script>
653
+ <noscript><p><img alt="Clicky" width="1" height="1"
654
+ src="//in.getclicky.com/<?php echo $options['site_id']; ?>ns.gif" /></p></noscript>
655
+ <!-- End Clicky Tracking -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
656
  <?php
657
+ return true;
658
  }
659
 
660
  add_action( 'wp_footer', 'clicky_script', 90 );
664
  *
665
  * @uses clicky_get_options()
666
  * @link http://codex.wordpress.org/Function_Reference/wp_remote_get
667
+ *
668
  * @param array $a The array with basic log-data
669
+ *
670
  * @return bool Returns true on success or false on failure
671
  */
672
  function clicky_log( $a ) {
673
  $options = clicky_get_options();
674
 
675
+ if ( ! isset( $options['site_id'] ) || empty( $options['site_id'] ) || ! isset( $options['admin_site_key'] ) || empty( $options['admin_site_key'] ) ) {
676
+ return false;
677
+ }
678
 
679
  $type = $a['type'];
680
+ if ( ! in_array( $type, array( "pageview", "download", "outbound", "click", "custom", "goal" ) ) ) {
681
  $type = "pageview";
682
+ }
683
 
684
  $file = "http://in.getclicky.com/in.php?site_id=" . $options['site_id'] . "&sitekey_admin=" . $options['admin_site_key'] . "&type=" . $type;
685
 
686
  # referrer and user agent - will only be logged if this is the very first action of this session
687
+ if ( $a['ref'] ) {
688
  $file .= "&ref=" . urlencode( $a['ref'] );
689
+ }
690
 
691
+ if ( $a['ua'] ) {
692
  $file .= "&ua=" . urlencode( $a['ua'] );
693
+ }
694
 
695
  # we need either a session_id or an ip_address...
696
  if ( is_numeric( $a['session_id'] ) ) {
697
  $file .= "&session_id=" . $a['session_id'];
698
  } else {
699
+ if ( ! $a['ip_address'] ) {
700
+ $a['ip_address'] = $_SERVER['REMOTE_ADDR'];
701
+ } # automatically grab IP that PHP gives us.
702
+ if ( ! preg_match( "#^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$#", $a['ip_address'] ) ) {
703
  return false;
704
+ }
705
  $file .= "&ip_address=" . $a['ip_address'];
706
  }
707
 
710
  if ( is_numeric( $a['goal'] ) ) {
711
  $file .= "&goal[id]=" . $a['goal'];
712
  } else {
713
+ if ( ! is_numeric( $a['goal']['id'] ) ) {
714
  return false;
715
+ }
716
+ foreach ( $a['goal'] as $key => $value ) {
717
  $file .= "&goal[" . urlencode( $key ) . "]=" . urlencode( $value );
718
+ }
719
  }
720
  }
721
 
722
  # custom data, must come in as array of key=>values
723
+ foreach ( $a['custom'] as $key => $value ) {
724
  $file .= "&custom[" . urlencode( $key ) . "]=" . urlencode( $value );
725
+ }
726
 
727
  if ( $type == "goal" || $type == "custom" ) {
728
  # dont do anything, data has already been cat'd
729
  } else {
730
  if ( $type == "outbound" ) {
731
+ if ( ! preg_match( "#^(https?|telnet|ftp)#", $a['href'] ) ) {
732
  return false;
733
+ }
734
  } else {
735
  # all other action types must start with either a / or a #
736
+ if ( ! preg_match( "#^(/|\#)#", $a['href'] ) ) {
737
  $a['href'] = "/" . $a['href'];
738
+ }
739
  }
740
  $file .= "&href=" . urlencode( $a['href'] );
741
+ if ( $a['title'] ) {
742
  $file .= "&title=" . urlencode( $a['title'] );
743
+ }
744
  }
745
+
746
  return wp_remote_get( $file ) ? true : false;
747
  }
748
 
749
  /**
750
  * Tracks comments that are not spam and not ping- or trackbacks
751
  *
752
+ * @param int $commentID The ID of the comment that needs to be tracked
753
  * @param int $comment_status Status of the comment (e.g. spam)
754
  */
755
  function clicky_track_comment( $commentID, $comment_status ) {
760
  if ( $comment->comment_type != 'pingback' && $comment->comment_type != 'trackback' ) {
761
  clicky_log(
762
  array(
763
+ "type" => "click",
764
+ "href" => "/wp-comments-post.php",
765
+ "title" => __( "Posted a comment", 'clicky' ),
766
+ "ua" => $comment->comment_agent,
767
+ "ip_address" => $comment->comment_author_IP,
768
+ "custom" => array(
769
+ "username" => $comment->comment_author,
770
+ "email" => $comment->comment_author_email,
771
  )
772
  )
773
  );
lang/clicky-fr_FR.mo CHANGED
Binary file
lang/clicky-fr_FR.po CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the Clicky WordPress plugin package.
3
  msgid ""
4
  msgstr ""
5
- "PO-Revision-Date: 2012-06-28 16:25:44+0000\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
2
  # This file is distributed under the same license as the Clicky WordPress plugin package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2012-06-28 16:06:52+0000\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
lang/clicky-tr_TK.mo CHANGED
Binary file
lang/clicky-tr_TK.po CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the Clicky WordPress plugin package.
3
  msgid ""
4
  msgstr ""
5
- "PO-Revision-Date: 2014-01-06 09:56:13+0000\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
@@ -148,7 +148,7 @@ msgstr "Twitter şifresi"
148
 
149
  #: clicky.php:273
150
  msgid "Prefix for Tweets"
151
- msgstr ""
152
 
153
  #: clicky.php:274
154
  msgid "This text will be put in front of Tweets that are published when a blog post is published"
@@ -172,7 +172,7 @@ msgstr "Bir yorum yazdı"
172
 
173
  #: yst_plugin_tools.php:64
174
  msgid "Settings"
175
- msgstr ""
176
 
177
  #: yst_plugin_tools.php:138
178
  msgid "Why not do any or all of the following:"
@@ -188,7 +188,7 @@ msgstr ""
188
 
189
  #: yst_plugin_tools.php:142
190
  msgid "Donate a token of your appreciation."
191
- msgstr ""
192
 
193
  #: yst_plugin_tools.php:144
194
  msgid "Like this plugin?"
@@ -208,7 +208,7 @@ msgstr "Destek mi lazım?"
208
 
209
  #: yst_plugin_tools.php:168
210
  msgid "Subscribe"
211
- msgstr ""
212
 
213
  #: yst_plugin_tools.php:169 yst_plugin_tools.php:171
214
  msgid "Latest news from Clicky"
@@ -222,4 +222,4 @@ msgid "Clicky for WordPress"
222
  msgstr "Wordpress için Clicky"
223
 
224
  msgid "Integrates Clicky on your blog!"
225
- msgstr ""
2
  # This file is distributed under the same license as the Clicky WordPress plugin package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2014-04-30 08:11:29+0000\n"
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
148
 
149
  #: clicky.php:273
150
  msgid "Prefix for Tweets"
151
+ msgstr "Twwetler için önek"
152
 
153
  #: clicky.php:274
154
  msgid "This text will be put in front of Tweets that are published when a blog post is published"
172
 
173
  #: yst_plugin_tools.php:64
174
  msgid "Settings"
175
+ msgstr "Ayarlar"
176
 
177
  #: yst_plugin_tools.php:138
178
  msgid "Why not do any or all of the following:"
188
 
189
  #: yst_plugin_tools.php:142
190
  msgid "Donate a token of your appreciation."
191
+ msgstr "Takdirinizi belirten bir bağış yapın."
192
 
193
  #: yst_plugin_tools.php:144
194
  msgid "Like this plugin?"
208
 
209
  #: yst_plugin_tools.php:168
210
  msgid "Subscribe"
211
+ msgstr "Abone ol"
212
 
213
  #: yst_plugin_tools.php:169 yst_plugin_tools.php:171
214
  msgid "Latest news from Clicky"
222
  msgstr "Wordpress için Clicky"
223
 
224
  msgid "Integrates Clicky on your blog!"
225
+ msgstr "Clicky 'i bloğunuza entegre edin!"
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://yoast.com/donate/
4
  Tags: analytics, statistics, clicky, getclicky, affiliate, outbound links, analysis, Joost de Valk, Yoast
5
  Requires at least: 2.8
6
  Tested up to: 3.5
7
- Stable tag: 1.4.2.3
8
 
9
  Integrates the Clicky (from getClicky.com) web analytics service into your blog.
10
 
@@ -39,6 +39,14 @@ Read the authors [review of Clicky Analytics](http://yoast.com/clicky-analytics-
39
 
40
  == Changelog ==
41
 
 
 
 
 
 
 
 
 
42
  = 1.4.2.3 =
43
 
44
  * Don't overwrite the `clicky_custom` variable when it's already there.
@@ -81,7 +89,7 @@ Read the authors [review of Clicky Analytics](http://yoast.com/clicky-analytics-
81
 
82
  = 1.4 =
83
 
84
- * Interface cleanup, interface no longer breaks on smaller resolutions.
85
  * No more unneeded JavaScript being loaded on the admin pages.
86
  * Made the Goal Tracking box work for all post types and made it smaller.
87
  * Removed some code that was no longer used.
@@ -109,7 +117,7 @@ Read the authors [review of Clicky Analytics](http://yoast.com/clicky-analytics-
109
 
110
  = 1.2 =
111
 
112
- * 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).
113
  * Remove clicky.me integration that was no longer working anyway due to Twitter API changes.
114
 
115
  = 1.1.5 =
@@ -141,7 +149,7 @@ Read the authors [review of Clicky Analytics](http://yoast.com/clicky-analytics-
141
 
142
  = 1.0.6 =
143
 
144
- * Auto-tweeting now only happens when a post is first published.
145
  * Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
146
  * Added extra check to make sure clicky.me returned a valid short URL before tweeting.
147
 
@@ -169,4 +177,4 @@ Read the authors [review of Clicky Analytics](http://yoast.com/clicky-analytics-
169
 
170
  = 1.0 =
171
 
172
- * Initial release.
4
  Tags: analytics, statistics, clicky, getclicky, affiliate, outbound links, analysis, Joost de Valk, Yoast
5
  Requires at least: 2.8
6
  Tested up to: 3.5
7
+ Stable tag: 1.4.2.4
8
 
9
  Integrates the Clicky (from getClicky.com) web analytics service into your blog.
10
 
39
 
40
  == Changelog ==
41
 
42
+ == 1.4.2.4 ==
43
+
44
+ * Minor stability improvements to code.
45
+ * Improved code formatting.
46
+ * i18n updates
47
+ * Replaced mangled fr_FR files
48
+ * Updated tr_TK
49
+
50
  = 1.4.2.3 =
51
 
52
  * Don't overwrite the `clicky_custom` variable when it's already there.
89
 
90
  = 1.4 =
91
 
92
+ * Interface cleanup, interface no longer breaks on smaller resolutions.
93
  * No more unneeded JavaScript being loaded on the admin pages.
94
  * Made the Goal Tracking box work for all post types and made it smaller.
95
  * Removed some code that was no longer used.
117
 
118
  = 1.2 =
119
 
120
+ * 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).
121
  * Remove clicky.me integration that was no longer working anyway due to Twitter API changes.
122
 
123
  = 1.1.5 =
149
 
150
  = 1.0.6 =
151
 
152
+ * Auto-tweeting now only happens when a post is first published.
153
  * Made sure there are no spaces in site ID, site key and admin site key are always trimmed.
154
  * Added extra check to make sure clicky.me returned a valid short URL before tweeting.
155
 
177
 
178
  = 1.0 =
179
 
180
+ * Initial release.