Version Description
/ 29.04.2015 = * Renew the tracking mechanism
Download this release
Release Info
| Developer | sergej.mueller |
| Plugin | |
| Version | 1.4.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.0 to 1.4.1
- inc/statify_backend.class.php +1 -2
- inc/statify_frontend.class.php +50 -43
- readme.txt +5 -2
- statify.php +1 -1
- views/js_snippet.view.php +1 -1
- views/widget_back.view.php +4 -2
inc/statify_backend.class.php
CHANGED
|
@@ -37,8 +37,7 @@ class Statify_Backend
|
|
| 37 |
$input,
|
| 38 |
array(
|
| 39 |
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN" target="_blank">PayPal</a>',
|
| 40 |
-
'<a href="https://flattr.com/t/1733733" target="_blank">Flattr</a>'
|
| 41 |
-
'<a href="https://github.com/sergejmueller/statify/wiki" target="_blank">Wiki</a>'
|
| 42 |
)
|
| 43 |
);
|
| 44 |
}
|
| 37 |
$input,
|
| 38 |
array(
|
| 39 |
'<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN" target="_blank">PayPal</a>',
|
| 40 |
+
'<a href="https://flattr.com/t/1733733" target="_blank">Flattr</a>'
|
|
|
|
| 41 |
)
|
| 42 |
);
|
| 43 |
}
|
inc/statify_frontend.class.php
CHANGED
|
@@ -16,75 +16,70 @@ class Statify_Frontend extends Statify
|
|
| 16 |
|
| 17 |
|
| 18 |
/**
|
| 19 |
-
*
|
| 20 |
*
|
| 21 |
* @since 0.1.0
|
| 22 |
-
* @change 1.4.
|
| 23 |
*/
|
| 24 |
|
| 25 |
public static function track_visit()
|
| 26 |
{
|
| 27 |
-
/*
|
| 28 |
$use_snippet = self::$_options['snippet'];
|
| 29 |
$is_snippet = $use_snippet && get_query_var('statify_target');
|
| 30 |
|
| 31 |
-
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if ( $is_snippet ) {
|
| 33 |
$target = urldecode( get_query_var('statify_target') );
|
| 34 |
$referrer = urldecode( get_query_var('statify_referrer') );
|
| 35 |
} else if ( ! $use_snippet) {
|
| 36 |
-
$target = (
|
| 37 |
-
$referrer = (
|
| 38 |
} else {
|
| 39 |
return;
|
| 40 |
}
|
| 41 |
|
| 42 |
-
/*
|
| 43 |
-
if ( empty($target) OR !
|
| 44 |
return self::_jump_out($is_snippet);
|
| 45 |
}
|
| 46 |
|
| 47 |
-
/*
|
| 48 |
-
if ( empty($_SERVER['HTTP_USER_AGENT']) OR ! preg_match('/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $_SERVER['HTTP_USER_AGENT']) ) {
|
| 49 |
-
return self::_jump_out($is_snippet);
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
/* Filter */
|
| 53 |
-
if ( self::_skip_tracking() ) {
|
| 54 |
-
return self::_jump_out($is_snippet);
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
/* Global */
|
| 58 |
global $wpdb, $wp_rewrite;
|
| 59 |
|
| 60 |
-
/* Init */
|
| 61 |
$data = array(
|
| 62 |
'created' => '',
|
| 63 |
'referrer' => '',
|
| 64 |
'target' => ''
|
| 65 |
);
|
| 66 |
|
| 67 |
-
/*
|
| 68 |
$data['created'] = strftime(
|
| 69 |
'%Y-%m-%d',
|
| 70 |
current_time('timestamp')
|
| 71 |
);
|
| 72 |
|
| 73 |
-
/*
|
| 74 |
if ( ! empty($referrer) && strpos( $referrer, home_url() ) === false ) {
|
| 75 |
$data['referrer'] = esc_url_raw( $referrer, array('http', 'https') );
|
| 76 |
}
|
| 77 |
|
| 78 |
-
/*
|
| 79 |
$data['target'] = home_url($target, 'relative');
|
| 80 |
|
| 81 |
-
/*
|
| 82 |
-
if ( $wp_rewrite->permalink_structure
|
| 83 |
$data['target'] = parse_url($data['target'], PHP_URL_PATH);
|
| 84 |
}
|
| 85 |
|
| 86 |
-
/* Sanitize url */
|
| 87 |
-
$data['target'] =
|
| 88 |
|
| 89 |
/* Insert */
|
| 90 |
$wpdb->insert(
|
|
@@ -92,39 +87,46 @@ class Statify_Frontend extends Statify
|
|
| 92 |
$data
|
| 93 |
);
|
| 94 |
|
| 95 |
-
/*
|
| 96 |
return self::_jump_out($is_snippet);
|
| 97 |
}
|
| 98 |
|
| 99 |
|
| 100 |
/**
|
| 101 |
-
*
|
| 102 |
*
|
| 103 |
* @since 1.2.6
|
| 104 |
-
* @change 1.4.
|
| 105 |
*
|
| 106 |
-
* @hook boolean statify_skip_tracking
|
| 107 |
*
|
| 108 |
-
* @return boolean $skip_hook TRUE
|
| 109 |
*/
|
| 110 |
|
| 111 |
private static function _skip_tracking() {
|
|
|
|
| 112 |
if ( ( $skip_hook = apply_filters('statify_skip_tracking', NULL) ) !== NULL ) {
|
| 113 |
return $skip_hook;
|
| 114 |
}
|
| 115 |
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
}
|
| 118 |
|
| 119 |
|
| 120 |
/**
|
| 121 |
-
* JavaScript
|
| 122 |
*
|
| 123 |
* @since 1.1.0
|
| 124 |
-
* @change 1.
|
| 125 |
*
|
| 126 |
-
* @param boolean $is_snippet
|
| 127 |
-
* @return mixed Exit
|
| 128 |
*/
|
| 129 |
|
| 130 |
private static function _jump_out($is_snippet) {
|
|
@@ -139,13 +141,13 @@ class Statify_Frontend extends Statify
|
|
| 139 |
|
| 140 |
|
| 141 |
/**
|
| 142 |
-
*
|
| 143 |
*
|
| 144 |
* @since 1.1.0
|
| 145 |
-
* @change 1.
|
| 146 |
*
|
| 147 |
-
* @param array $vars
|
| 148 |
-
* @return array $vars
|
| 149 |
*/
|
| 150 |
|
| 151 |
public static function query_vars($vars) {
|
|
@@ -157,10 +159,10 @@ class Statify_Frontend extends Statify
|
|
| 157 |
|
| 158 |
|
| 159 |
/**
|
| 160 |
-
*
|
| 161 |
*
|
| 162 |
* @since 1.1.0
|
| 163 |
-
* @change 1.4.
|
| 164 |
*/
|
| 165 |
|
| 166 |
public static function wp_footer()
|
|
@@ -170,6 +172,11 @@ class Statify_Frontend extends Statify
|
|
| 170 |
return;
|
| 171 |
}
|
| 172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
/* Load template */
|
| 174 |
load_template(
|
| 175 |
wp_normalize_path(
|
| 16 |
|
| 17 |
|
| 18 |
/**
|
| 19 |
+
* Track the page view
|
| 20 |
*
|
| 21 |
* @since 0.1.0
|
| 22 |
+
* @change 1.4.1
|
| 23 |
*/
|
| 24 |
|
| 25 |
public static function track_visit()
|
| 26 |
{
|
| 27 |
+
/* Init vars */
|
| 28 |
$use_snippet = self::$_options['snippet'];
|
| 29 |
$is_snippet = $use_snippet && get_query_var('statify_target');
|
| 30 |
|
| 31 |
+
/* Skip tracking */
|
| 32 |
+
if ( self::_skip_tracking() ) {
|
| 33 |
+
return self::_jump_out($is_snippet);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/* Set target & referrer */
|
| 37 |
if ( $is_snippet ) {
|
| 38 |
$target = urldecode( get_query_var('statify_target') );
|
| 39 |
$referrer = urldecode( get_query_var('statify_referrer') );
|
| 40 |
} else if ( ! $use_snippet) {
|
| 41 |
+
$target = ( filter_has_var(INPUT_SERVER, 'REQUEST_URI') ? wp_unslash($_SERVER['REQUEST_URI']) : '/' );
|
| 42 |
+
$referrer = ( filter_has_var(INPUT_SERVER, 'HTTP_REFERER') ? wp_unslash($_SERVER['HTTP_REFERER']) : '' );
|
| 43 |
} else {
|
| 44 |
return;
|
| 45 |
}
|
| 46 |
|
| 47 |
+
/* Invalid target? */
|
| 48 |
+
if ( empty($target) OR ! wp_validate_redirect($target, false) ) {
|
| 49 |
return self::_jump_out($is_snippet);
|
| 50 |
}
|
| 51 |
|
| 52 |
+
/* Global vars */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
global $wpdb, $wp_rewrite;
|
| 54 |
|
| 55 |
+
/* Init rows */
|
| 56 |
$data = array(
|
| 57 |
'created' => '',
|
| 58 |
'referrer' => '',
|
| 59 |
'target' => ''
|
| 60 |
);
|
| 61 |
|
| 62 |
+
/* Set request timestamp */
|
| 63 |
$data['created'] = strftime(
|
| 64 |
'%Y-%m-%d',
|
| 65 |
current_time('timestamp')
|
| 66 |
);
|
| 67 |
|
| 68 |
+
/* Sanitize referrer url */
|
| 69 |
if ( ! empty($referrer) && strpos( $referrer, home_url() ) === false ) {
|
| 70 |
$data['referrer'] = esc_url_raw( $referrer, array('http', 'https') );
|
| 71 |
}
|
| 72 |
|
| 73 |
+
/* Relative target url */
|
| 74 |
$data['target'] = home_url($target, 'relative');
|
| 75 |
|
| 76 |
+
/* Trim target url */
|
| 77 |
+
if ( $wp_rewrite->permalink_structure ) {
|
| 78 |
$data['target'] = parse_url($data['target'], PHP_URL_PATH);
|
| 79 |
}
|
| 80 |
|
| 81 |
+
/* Sanitize target url */
|
| 82 |
+
$data['target'] = esc_url_raw($data['target']);
|
| 83 |
|
| 84 |
/* Insert */
|
| 85 |
$wpdb->insert(
|
| 87 |
$data
|
| 88 |
);
|
| 89 |
|
| 90 |
+
/* Jump! */
|
| 91 |
return self::_jump_out($is_snippet);
|
| 92 |
}
|
| 93 |
|
| 94 |
|
| 95 |
/**
|
| 96 |
+
* Rules to skip the tracking
|
| 97 |
*
|
| 98 |
* @since 1.2.6
|
| 99 |
+
* @change 1.4.1
|
| 100 |
*
|
| 101 |
+
* @hook boolean statify_skip_tracking (https://gist.github.com/sergejmueller/7612368)
|
| 102 |
*
|
| 103 |
+
* @return boolean $skip_hook TRUE if NO tracking is desired
|
| 104 |
*/
|
| 105 |
|
| 106 |
private static function _skip_tracking() {
|
| 107 |
+
/* Skip tracking via Hook */
|
| 108 |
if ( ( $skip_hook = apply_filters('statify_skip_tracking', NULL) ) !== NULL ) {
|
| 109 |
return $skip_hook;
|
| 110 |
}
|
| 111 |
|
| 112 |
+
/* Skip tracking via User Agent */
|
| 113 |
+
if ( ! filter_has_var(INPUT_SERVER, 'HTTP_USER_AGENT') OR ! preg_match('/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $_SERVER['HTTP_USER_AGENT']) ) {
|
| 114 |
+
return true;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
/* Skip tracking via Conditional_Tags */
|
| 118 |
+
return ( is_feed() OR is_trackback() OR is_robots() OR is_preview() OR is_user_logged_in() OR is_404() OR is_search() );
|
| 119 |
}
|
| 120 |
|
| 121 |
|
| 122 |
/**
|
| 123 |
+
* Send JavaScript headers or return false
|
| 124 |
*
|
| 125 |
* @since 1.1.0
|
| 126 |
+
* @change 1.3.1
|
| 127 |
*
|
| 128 |
+
* @param boolean $is_snippet Snippet type
|
| 129 |
+
* @return mixed Exit or return depending on snippet type
|
| 130 |
*/
|
| 131 |
|
| 132 |
private static function _jump_out($is_snippet) {
|
| 141 |
|
| 142 |
|
| 143 |
/**
|
| 144 |
+
* Declare GET variables for further use
|
| 145 |
*
|
| 146 |
* @since 1.1.0
|
| 147 |
+
* @change 1.3.1
|
| 148 |
*
|
| 149 |
+
* @param array $vars Input with existing variables
|
| 150 |
+
* @return array $vars Output with plugin variables
|
| 151 |
*/
|
| 152 |
|
| 153 |
public static function query_vars($vars) {
|
| 159 |
|
| 160 |
|
| 161 |
/**
|
| 162 |
+
* Print JavaScript snippet
|
| 163 |
*
|
| 164 |
* @since 1.1.0
|
| 165 |
+
* @change 1.4.1
|
| 166 |
*/
|
| 167 |
|
| 168 |
public static function wp_footer()
|
| 172 |
return;
|
| 173 |
}
|
| 174 |
|
| 175 |
+
/* Skip by rules */
|
| 176 |
+
if ( self::_skip_tracking() ) {
|
| 177 |
+
return;
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
/* Load template */
|
| 181 |
load_template(
|
| 182 |
wp_normalize_path(
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: sergej.mueller
|
|
| 3 |
Tags: stats, analytics, privacy, dashboard
|
| 4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN
|
| 5 |
Requires at least: 3.9
|
| 6 |
-
Tested up to: 4.2
|
| 7 |
Stable tag: trunk
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -64,7 +64,10 @@ For compatibility with caching plugins like [Cachify](http://cachify.de) *Statif
|
|
| 64 |
|
| 65 |
== Changelog ==
|
| 66 |
|
| 67 |
-
= 1.4.
|
|
|
|
|
|
|
|
|
|
| 68 |
* WordPress 4.2 support
|
| 69 |
* Plugin-wide code refactoring
|
| 70 |
* Translations for English and Russian
|
| 3 |
Tags: stats, analytics, privacy, dashboard
|
| 4 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN
|
| 5 |
Requires at least: 3.9
|
| 6 |
+
Tested up to: 4.2.1
|
| 7 |
Stable tag: trunk
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 64 |
|
| 65 |
== Changelog ==
|
| 66 |
|
| 67 |
+
= 1.4.1 / 29.04.2015 =
|
| 68 |
+
* Renew the tracking mechanism
|
| 69 |
+
|
| 70 |
+
= 1.4.0 / 16.04.2015 =
|
| 71 |
* WordPress 4.2 support
|
| 72 |
* Plugin-wide code refactoring
|
| 73 |
* Translations for English and Russian
|
statify.php
CHANGED
|
@@ -8,7 +8,7 @@ Author: Sergej Müller
|
|
| 8 |
Author URI: http://wpcoder.de
|
| 9 |
Plugin URI: http://statify.de
|
| 10 |
License: GPLv2 or later
|
| 11 |
-
Version: 1.4.
|
| 12 |
*/
|
| 13 |
|
| 14 |
/*
|
| 8 |
Author URI: http://wpcoder.de
|
| 9 |
Plugin URI: http://statify.de
|
| 10 |
License: GPLv2 or later
|
| 11 |
+
Version: 1.4.1
|
| 12 |
*/
|
| 13 |
|
| 14 |
/*
|
views/js_snippet.view.php
CHANGED
|
@@ -11,7 +11,7 @@ class_exists('Statify') OR exit; ?>
|
|
| 11 |
var e = document.createElement('script'),
|
| 12 |
s = document.getElementsByTagName('script')[0],
|
| 13 |
r = encodeURIComponent(document.referrer),
|
| 14 |
-
t = encodeURIComponent(location.pathname),
|
| 15 |
p = '?statify_referrer=' + r + '&statify_target=' + t;
|
| 16 |
|
| 17 |
e.async = true;
|
| 11 |
var e = document.createElement('script'),
|
| 12 |
s = document.getElementsByTagName('script')[0],
|
| 13 |
r = encodeURIComponent(document.referrer),
|
| 14 |
+
t = encodeURIComponent(location.pathname + location.search),
|
| 15 |
p = '?statify_referrer=' + r + '&statify_target=' + t;
|
| 16 |
|
| 17 |
e.async = true;
|
views/widget_back.view.php
CHANGED
|
@@ -49,6 +49,8 @@ class_exists('Statify') OR exit; ?>
|
|
| 49 |
|
| 50 |
<p class="meta-links">
|
| 51 |
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN" target="_blank">PayPal</a> •
|
| 52 |
-
<a href="https://flattr.com/t/1733733" target="_blank">Flattr</a>
|
| 53 |
-
|
|
|
|
|
|
|
| 54 |
</p>
|
| 49 |
|
| 50 |
<p class="meta-links">
|
| 51 |
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZAQUT9RLPW8QN" target="_blank">PayPal</a> •
|
| 52 |
+
<a href="https://flattr.com/t/1733733" target="_blank">Flattr</a>
|
| 53 |
+
<?php if ( strpos(get_locale(), 'de') !== false ) { ?>
|
| 54 |
+
• <a href="https://github.com/sergejmueller/statify/wiki" target="_blank">Wiki</a>
|
| 55 |
+
<?php } ?>
|
| 56 |
</p>
|
