Version Description
Download this release
Release Info
Developer | StatCounter |
Plugin | StatCounter – Free Real Time Visitor Stats |
Version | 2.0.8 |
Comparing to | |
See all releases |
Code changes from version 2.0.7 to 2.0.8
- StatCounter-Wordpress-Plugin.php +299 -299
- readme.txt +2 -2
StatCounter-Wordpress-Plugin.php
CHANGED
@@ -1,299 +1,299 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Plugin Name: Official StatCounter Plugin
|
4 |
-
* Version: 2.0.
|
5 |
-
* Plugin URI: http://statcounter.com/
|
6 |
-
* Description: Adds the StatCounter tracking code to your blog. <br>To get setup: 1) Activate this plugin 2) Enter your StatCounter Project ID and Security Code in the <a href="options-general.php?page=StatCounter-Wordpress-Plugin.php"><strong>options page</strong></a>.
|
7 |
-
* Author: Aodhan Cullen
|
8 |
-
* Author URI: http://statcounter.com/
|
9 |
-
*/
|
10 |
-
|
11 |
-
// Defaults, etc.
|
12 |
-
// the last 'false' should make these constants case sensitive
|
13 |
-
define("key_sc_project", "sc_project", false);
|
14 |
-
define("key_sc_position", "sc_position", false);
|
15 |
-
// legacy problem with sc_security naming
|
16 |
-
define("key_sc_security", "key_sc_security", false);
|
17 |
-
define("sc_project_default", "
|
18 |
-
define("sc_security_default", "" , false);
|
19 |
-
define("sc_position_default", "footer", false);
|
20 |
-
|
21 |
-
// Create the default key and status
|
22 |
-
add_option(key_sc_project, sc_project_default);
|
23 |
-
add_option(key_sc_security, sc_security_default);
|
24 |
-
add_option("sc_invisible", "0");
|
25 |
-
|
26 |
-
// Create a option page for settings
|
27 |
-
add_action('admin_menu' , '
|
28 |
-
add_action( 'admin_menu', 'statcounter_admin_menu' );
|
29 |
-
add_action('wp_head', '
|
30 |
-
|
31 |
-
function statcounter_admin_menu() {
|
32 |
-
$hook = add_submenu_page('index.php', __('StatCounter Stats'), __('StatCounter Stats'), 'publish_posts', 'statcounter', 'statcounter_reports_page');
|
33 |
-
add_action("load-$hook", 'statcounter_reports_load');
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
function statcounter_reports_load() {
|
38 |
-
add_action('admin_head', 'statcounter_reports_head');
|
39 |
-
}
|
40 |
-
|
41 |
-
function statcounter_reports_head() {
|
42 |
-
?>
|
43 |
-
<style type="text/css">
|
44 |
-
body { height: 100%; }
|
45 |
-
</style>
|
46 |
-
<?php
|
47 |
-
}
|
48 |
-
|
49 |
-
function statcounter_reports_page() {
|
50 |
-
$sc_project = get_option(key_sc_project);
|
51 |
-
if($sc_project==0) {
|
52 |
-
$sc_link = '//statcounter.com/';
|
53 |
-
} else {
|
54 |
-
$sc_link = '//statcounter.com/p'
|
55 |
-
}
|
56 |
-
|
57 |
-
echo '<iframe id="statcounter_frame" src="'
|
58 |
-
<p>Your browser does not support iframes.</p>
|
59 |
-
</iframe>';
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
// Hook in the options page function
|
66 |
-
function
|
67 |
-
global $wpdb;
|
68 |
-
add_options_page('StatCounter Options', 'StatCounter', "manage_options", basename(__FILE__), '
|
69 |
-
}
|
70 |
-
|
71 |
-
function
|
72 |
-
// If we are a postback, store the options
|
73 |
-
if ( isset( $_POST['info_update'] ) && check_admin_referer( 'update_sc_project_nonce', 'sc_project_nonce' ) ) {
|
74 |
-
|
75 |
-
// Update the Project ID
|
76 |
-
$sc_project = sanitize_text_field(trim($_POST[key_sc_project]));
|
77 |
-
if (ctype_digit($sc_project) == 0) {
|
78 |
-
echo "<script>alert('Project ID should be numbers only')</script>";
|
79 |
-
} else {
|
80 |
-
if ($sc_project == '') {
|
81 |
-
$sc_project = sc_project_default;
|
82 |
-
}
|
83 |
-
if (strlen($sc_project) > 16) {
|
84 |
-
echo "<script>alert('Project ID is invalid')</script>";
|
85 |
-
} else {
|
86 |
-
update_option(key_sc_project, $sc_project);
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
// Update the Security ID
|
91 |
-
$sc_security = sanitize_text_field(trim($_POST[key_sc_security]));
|
92 |
-
$sc_security = str_replace('"', '', $sc_security);
|
93 |
-
$sc_security = stripslashes($sc_security);
|
94 |
-
if (ctype_alnum(trim($sc_security, '"')) == 0) {
|
95 |
-
echo "<script>alert('Security code should be numbers and letters only')</script>";
|
96 |
-
} else {
|
97 |
-
if ($sc_security =='') {
|
98 |
-
$sc_security = sc_security_default;
|
99 |
-
}
|
100 |
-
if (strlen($sc_security) > 16) {
|
101 |
-
echo "<script>alert('Security code is invalid')</script>";
|
102 |
-
} else {
|
103 |
-
update_option(key_sc_security, $sc_security);
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
// Update the position
|
108 |
-
$sc_position = $_POST[key_sc_position];
|
109 |
-
if (($sc_position != 'header') && ($sc_position != 'footer')) {
|
110 |
-
$sc_position = sc_position_default;
|
111 |
-
}
|
112 |
-
|
113 |
-
update_option(key_sc_position, $sc_position);
|
114 |
-
|
115 |
-
// Force invisibility
|
116 |
-
$sc_invisible = $_POST['sc_invisible'];
|
117 |
-
if ($sc_invisible == 1) {
|
118 |
-
update_option('sc_invisible', "1");
|
119 |
-
} else {
|
120 |
-
update_option('sc_invisible', "0");
|
121 |
-
}
|
122 |
-
|
123 |
-
// Give an updated message
|
124 |
-
echo "<div class='updated'><p><strong>StatCounter options updated</strong></p></div>";
|
125 |
-
}
|
126 |
-
|
127 |
-
// Output the options page
|
128 |
-
?>
|
129 |
-
|
130 |
-
<form method="post" action="options-general.php?page=StatCounter-Wordpress-Plugin.php">
|
131 |
-
<?php wp_nonce_field( 'update_sc_project_nonce', 'sc_project_nonce' ); ?>
|
132 |
-
<div class="wrap">
|
133 |
-
<?php if (get_option( key_sc_project ) == "0") { ?>
|
134 |
-
<div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
|
135 |
-
StatCounter Plugin has been activated, but will not be enabled until you enter your <strong>Project ID</strong> and <strong>Security Code</strong>.
|
136 |
-
</div>
|
137 |
-
<?php } ?>
|
138 |
-
<h2>Using StatCounter</h2>
|
139 |
-
<blockquote><a href="http://statcounter.com" style="font-weight:bold;">StatCounter</a> is a free web traffic analysis service, which provides summary stats on all your traffic and a detailed analysis of your last 500 page views. This limit can be increased by upgrading to a paid service.</p>
|
140 |
-
<p>To activate the StatCounter service for your WordPress site:<ul>
|
141 |
-
<li><a href="http://statcounter.com/sign-up/" style="font-weight:bold;">Sign Up</a> with StatCounter or <a href="http://statcounter.com/add-project/" style="font-weight:bold;">add a new project</a> to your existing account</li>
|
142 |
-
<li>The installation process will detect your WordPress installation and provide you with your <strong>Project ID</strong> and <strong>Security Code</strong></li>
|
143 |
-
</ul></blockquote>
|
144 |
-
<h2>StatCounter Options</h2>
|
145 |
-
<blockquote>
|
146 |
-
<fieldset class='options'>
|
147 |
-
<table class="editform" cellspacing="2" cellpadding="5">
|
148 |
-
<tr>
|
149 |
-
<td>
|
150 |
-
<label for="<?php echo key_sc_project; ?>">Project ID:</label>
|
151 |
-
</td>
|
152 |
-
<td>
|
153 |
-
<?php
|
154 |
-
echo "<input type='text' size='11' ";
|
155 |
-
echo "name='".key_sc_project."' ";
|
156 |
-
echo "id='".key_sc_project."' ";
|
157 |
-
echo "value='".get_option(key_sc_project)."' />\n";
|
158 |
-
?>
|
159 |
-
</td>
|
160 |
-
</tr>
|
161 |
-
<tr>
|
162 |
-
<td>
|
163 |
-
<label for="<?php echo key_sc_security; ?>">Security Code:</label>
|
164 |
-
</td>
|
165 |
-
<td>
|
166 |
-
<?php
|
167 |
-
echo "<input type='text' size='9' ";
|
168 |
-
echo "name='".key_sc_security."' ";
|
169 |
-
echo "id='".key_sc_security."' ";
|
170 |
-
echo "value='".get_option(key_sc_security)."' />\n";
|
171 |
-
?>
|
172 |
-
</td>
|
173 |
-
</tr>
|
174 |
-
<tr>
|
175 |
-
<td>
|
176 |
-
<label for="<?php echo key_sc_position; ?>">Counter Position:</label>
|
177 |
-
</td>
|
178 |
-
<td>
|
179 |
-
<?php
|
180 |
-
echo "<select name='".key_sc_position."' id='".key_sc_position."'>\n";
|
181 |
-
|
182 |
-
echo "<option value='header'";
|
183 |
-
if(get_option(key_sc_position) == "header")
|
184 |
-
echo " selected='selected'";
|
185 |
-
echo ">Header</option>\n";
|
186 |
-
|
187 |
-
echo "<option value='footer'";
|
188 |
-
if(get_option(key_sc_position) != "header")
|
189 |
-
echo" selected='selected'";
|
190 |
-
echo ">Footer</option>\n";
|
191 |
-
|
192 |
-
echo "</select>\n";
|
193 |
-
?>
|
194 |
-
</td>
|
195 |
-
</tr>
|
196 |
-
<tr>
|
197 |
-
<td>
|
198 |
-
<label for="sc_invisible">Force invisibility:</label>
|
199 |
-
</td>
|
200 |
-
<td>
|
201 |
-
<?php
|
202 |
-
$checked = "";
|
203 |
-
if(get_option('sc_invisible')==1) {
|
204 |
-
$checked = "checked";
|
205 |
-
}
|
206 |
-
echo "<input type='checkbox' name='sc_invisible' id='sc_invisible' value='1' "
|
207 |
-
?>
|
208 |
-
</td>
|
209 |
-
</tr>
|
210 |
-
</table>
|
211 |
-
</fieldset>
|
212 |
-
</blockquote>
|
213 |
-
<p class="submit">
|
214 |
-
<input type='submit' name='info_update' value='Update Options' />
|
215 |
-
</p>
|
216 |
-
</div>
|
217 |
-
</form>
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
<?php
|
222 |
-
}
|
223 |
-
|
224 |
-
$sc_position = get_option(key_sc_position);
|
225 |
-
if ($sc_position=="header") {
|
226 |
-
add_action('wp_head', 'add_statcounter');
|
227 |
-
} else {
|
228 |
-
add_action('wp_footer', 'add_statcounter');
|
229 |
-
}
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
// The guts of the StatCounter script
|
234 |
-
function add_statcounter() {
|
235 |
-
global $user_level;
|
236 |
-
$sc_project = get_option(key_sc_project);
|
237 |
-
$sc_security = get_option(key_sc_security);
|
238 |
-
$sc_invisible = 0;
|
239 |
-
$sc_invisible = get_option('sc_invisible');
|
240 |
-
if (
|
241 |
-
( $sc_project > 0 )
|
242 |
-
) {
|
243 |
-
?>
|
244 |
-
<!-- Start of StatCounter Code -->
|
245 |
-
<script>
|
246 |
-
<!--
|
247 |
-
var sc_project=<?php echo esc_html($sc_project); ?>;
|
248 |
-
var sc_security="<?php echo esc_html($sc_security); ?>";
|
249 |
-
<?php
|
250 |
-
if($sc_invisible==1) {
|
251 |
-
echo "
|
252 |
-
}
|
253 |
-
|
254 |
-
define('HTTPS', isset($_SERVER['HTTPS']) && filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN));
|
255 |
-
$protocol = defined('HTTPS') ? "https:" : "http:";
|
256 |
-
|
257 |
-
?>
|
258 |
-
var scJsHost = (("https:" == document.location.protocol) ?
|
259 |
-
"https://secure." : "http://www.");
|
260 |
-
//-->
|
261 |
-
<?php
|
262 |
-
if($sc_invisible!=1) {
|
263 |
-
echo "\ndocument.write(\"<sc\"+\"ript src='\" +scJsHost +\"statcounter.com/counter/counter.js'></\"+\"script>\");";
|
264 |
-
}
|
265 |
-
?>
|
266 |
-
</script>
|
267 |
-
<?php
|
268 |
-
if($sc_invisible==1) {
|
269 |
-
if($protocol == "http:") {
|
270 |
-
echo "\n<script type=\"text/javascript\"
|
271 |
-
src=\"http://www.statcounter.com/counter/counter.js\"
|
272 |
-
async></script>";
|
273 |
-
} else if ($protocol == "https:"){
|
274 |
-
echo "\n<script type=\"text/javascript\"
|
275 |
-
src=\"https://secure.statcounter.com/counter/counter.js\"
|
276 |
-
async></script>";
|
277 |
-
}
|
278 |
-
}?>
|
279 |
-
<noscript><div class="statcounter"><a title="web analytics" href="<?php echo $protocol
|
280 |
-
<!-- End of StatCounter Code -->
|
281 |
-
<?php
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
function
|
286 |
-
if (is_single()) {
|
287 |
-
global $post;
|
288 |
-
$queried_post = get_post($pid);
|
289 |
-
$authorId = $queried_post->post_author;
|
290 |
-
?>
|
291 |
-
<script type="text/javascript">
|
292 |
-
var _statcounter = _statcounter || [];
|
293 |
-
_statcounter.push({"tags": {"author": "<?php the_author_meta( 'nickname', $authorId); ?>"}});
|
294 |
-
</script>
|
295 |
-
<?php
|
296 |
-
|
297 |
-
}
|
298 |
-
}
|
299 |
-
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Plugin Name: Official StatCounter Plugin
|
4 |
+
* Version: 2.0.8
|
5 |
+
* Plugin URI: http://statcounter.com/
|
6 |
+
* Description: Adds the StatCounter tracking code to your blog. <br>To get setup: 1) Activate this plugin 2) Enter your StatCounter Project ID and Security Code in the <a href="options-general.php?page=StatCounter-Wordpress-Plugin.php"><strong>options page</strong></a>.
|
7 |
+
* Author: Aodhan Cullen
|
8 |
+
* Author URI: http://statcounter.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Defaults, etc.
|
12 |
+
// the last 'false' should make these constants case sensitive
|
13 |
+
define("key_sc_project", "sc_project", false);
|
14 |
+
define("key_sc_position", "sc_position", false);
|
15 |
+
// legacy problem with sc_security naming
|
16 |
+
define("key_sc_security", "key_sc_security", false);
|
17 |
+
define("sc_project_default", "" , false);
|
18 |
+
define("sc_security_default", "" , false);
|
19 |
+
define("sc_position_default", "footer", false);
|
20 |
+
|
21 |
+
// Create the default key and status
|
22 |
+
add_option(key_sc_project, sc_project_default);
|
23 |
+
add_option(key_sc_security, sc_security_default);
|
24 |
+
add_option("sc_invisible", "0");
|
25 |
+
|
26 |
+
// Create a option page for settings
|
27 |
+
add_action('admin_menu' , 'add_statcounter_option_page' );
|
28 |
+
add_action( 'admin_menu', 'statcounter_admin_menu' );
|
29 |
+
add_action('wp_head', 'statcounter_addToTags');
|
30 |
+
|
31 |
+
function statcounter_admin_menu() {
|
32 |
+
$hook = add_submenu_page('index.php', __('StatCounter Stats'), __('StatCounter Stats'), 'publish_posts', 'statcounter', 'statcounter_reports_page');
|
33 |
+
add_action("load-$hook", 'statcounter_reports_load');
|
34 |
+
$hook = add_submenu_page('plugins.php', __('StatCounter Admin'), __('StatCounter Admin'), 'manage_options', 'statcounter_admin', 'statcounter_options_page');
|
35 |
+
}
|
36 |
+
|
37 |
+
function statcounter_reports_load() {
|
38 |
+
add_action('admin_head', 'statcounter_reports_head');
|
39 |
+
}
|
40 |
+
|
41 |
+
function statcounter_reports_head() {
|
42 |
+
?>
|
43 |
+
<style type="text/css">
|
44 |
+
body { height: 100%; }
|
45 |
+
</style>
|
46 |
+
<?php
|
47 |
+
}
|
48 |
+
|
49 |
+
function statcounter_reports_page() {
|
50 |
+
$sc_project = get_option(key_sc_project);
|
51 |
+
if($sc_project==0) {
|
52 |
+
$sc_link = '//statcounter.com/';
|
53 |
+
} else {
|
54 |
+
$sc_link = '//statcounter.com/p'.esc_html($sc_project).'/?source=wordpress';
|
55 |
+
}
|
56 |
+
|
57 |
+
echo '<iframe id="statcounter_frame" src="'.esc_url($sc_link).'" width="100%" height="2000">
|
58 |
+
<p>Your browser does not support iframes.</p>
|
59 |
+
</iframe>';
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
// Hook in the options page function
|
66 |
+
function add_statcounter_option_page() {
|
67 |
+
global $wpdb;
|
68 |
+
add_options_page('StatCounter Options', 'StatCounter', "manage_options", basename(__FILE__), 'statcounter_options_page');
|
69 |
+
}
|
70 |
+
|
71 |
+
function statcounter_options_page() {
|
72 |
+
// If we are a postback, store the options
|
73 |
+
if ( isset( $_POST[esc_html('info_update')] ) && check_admin_referer( 'update_sc_project_nonce', 'sc_project_nonce' ) ) {
|
74 |
+
|
75 |
+
// Update the Project ID
|
76 |
+
$sc_project = sanitize_text_field(trim($_POST[key_sc_project]));
|
77 |
+
if (ctype_digit($sc_project) == 0) {
|
78 |
+
echo "<script>alert('Project ID should be numbers only')</script>";
|
79 |
+
} else {
|
80 |
+
if ($sc_project == '') {
|
81 |
+
$sc_project = sc_project_default;
|
82 |
+
}
|
83 |
+
if (strlen($sc_project) > 16) {
|
84 |
+
echo "<script>alert('Project ID is invalid')</script>";
|
85 |
+
} else {
|
86 |
+
update_option(key_sc_project, $sc_project);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
// Update the Security ID
|
91 |
+
$sc_security = sanitize_text_field(trim($_POST[key_sc_security]));
|
92 |
+
$sc_security = str_replace('"', '', $sc_security);
|
93 |
+
$sc_security = stripslashes($sc_security);
|
94 |
+
if (ctype_alnum(trim($sc_security, '"')) == 0) {
|
95 |
+
echo "<script>alert('Security code should be numbers and letters only')</script>";
|
96 |
+
} else {
|
97 |
+
if ($sc_security =='') {
|
98 |
+
$sc_security = sc_security_default;
|
99 |
+
}
|
100 |
+
if (strlen($sc_security) > 16) {
|
101 |
+
echo "<script>alert('Security code is invalid')</script>";
|
102 |
+
} else {
|
103 |
+
update_option(key_sc_security, esc_textarea($sc_security));
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
// Update the position
|
108 |
+
$sc_position = $_POST[esc_html(key_sc_position)];
|
109 |
+
if (($sc_position != 'header') && ($sc_position != 'footer')) {
|
110 |
+
$sc_position = sc_position_default;
|
111 |
+
}
|
112 |
+
|
113 |
+
update_option(key_sc_position, $sc_position);
|
114 |
+
|
115 |
+
// Force invisibility
|
116 |
+
$sc_invisible = $_POST[esc_html('sc_invisible')];
|
117 |
+
if ($sc_invisible == 1) {
|
118 |
+
update_option('sc_invisible', "1");
|
119 |
+
} else {
|
120 |
+
update_option('sc_invisible', "0");
|
121 |
+
}
|
122 |
+
|
123 |
+
// Give an updated message
|
124 |
+
echo "<div class='updated'><p><strong>StatCounter options updated</strong></p></div>";
|
125 |
+
}
|
126 |
+
|
127 |
+
// Output the options page
|
128 |
+
?>
|
129 |
+
|
130 |
+
<form method="post" action="options-general.php?page=StatCounter-Wordpress-Plugin.php">
|
131 |
+
<?php wp_nonce_field( 'update_sc_project_nonce', 'sc_project_nonce' ); ?>
|
132 |
+
<div class="wrap">
|
133 |
+
<?php if (get_option( key_sc_project ) == "0") { ?>
|
134 |
+
<div style="margin:10px auto; border:3px #f00 solid; background-color:#fdd; color:#000; padding:10px; text-align:center;">
|
135 |
+
StatCounter Plugin has been activated, but will not be enabled until you enter your <strong>Project ID</strong> and <strong>Security Code</strong>.
|
136 |
+
</div>
|
137 |
+
<?php } ?>
|
138 |
+
<h2>Using StatCounter</h2>
|
139 |
+
<blockquote><a href="http://statcounter.com" style="font-weight:bold;">StatCounter</a> is a free web traffic analysis service, which provides summary stats on all your traffic and a detailed analysis of your last 500 page views. This limit can be increased by upgrading to a paid service.</p>
|
140 |
+
<p>To activate the StatCounter service for your WordPress site:<ul>
|
141 |
+
<li><a href="http://statcounter.com/sign-up/" style="font-weight:bold;">Sign Up</a> with StatCounter or <a href="http://statcounter.com/add-project/" style="font-weight:bold;">add a new project</a> to your existing account</li>
|
142 |
+
<li>The installation process will detect your WordPress installation and provide you with your <strong>Project ID</strong> and <strong>Security Code</strong></li>
|
143 |
+
</ul></blockquote>
|
144 |
+
<h2>StatCounter Options</h2>
|
145 |
+
<blockquote>
|
146 |
+
<fieldset class='options'>
|
147 |
+
<table class="editform" cellspacing="2" cellpadding="5">
|
148 |
+
<tr>
|
149 |
+
<td>
|
150 |
+
<label for="<?php echo esc_html(key_sc_project); ?>">Project ID:</label>
|
151 |
+
</td>
|
152 |
+
<td>
|
153 |
+
<?php
|
154 |
+
echo "<input type='text' size='11' ";
|
155 |
+
echo "name='".esc_html(key_sc_project)."' ";
|
156 |
+
echo "id='".esc_html(key_sc_project)."' ";
|
157 |
+
echo "value='".get_option(key_sc_project)."' />\n";
|
158 |
+
?>
|
159 |
+
</td>
|
160 |
+
</tr>
|
161 |
+
<tr>
|
162 |
+
<td>
|
163 |
+
<label for="<?php echo esc_html(key_sc_security); ?>">Security Code:</label>
|
164 |
+
</td>
|
165 |
+
<td>
|
166 |
+
<?php
|
167 |
+
echo "<input type='text' size='9' ";
|
168 |
+
echo "name='".esc_html(key_sc_security)."' ";
|
169 |
+
echo "id='".esc_html(key_sc_security)."' ";
|
170 |
+
echo "value='".get_option(key_sc_security)."' />\n";
|
171 |
+
?>
|
172 |
+
</td>
|
173 |
+
</tr>
|
174 |
+
<tr>
|
175 |
+
<td>
|
176 |
+
<label for="<?php echo esc_html(key_sc_position); ?>">Counter Position:</label>
|
177 |
+
</td>
|
178 |
+
<td>
|
179 |
+
<?php
|
180 |
+
echo "<select name='".esc_html(key_sc_position)."' id='".esc_html(key_sc_position)."'>\n";
|
181 |
+
|
182 |
+
echo "<option value='header'";
|
183 |
+
if(get_option(key_sc_position) == "header")
|
184 |
+
echo " selected='selected'";
|
185 |
+
echo ">Header</option>\n";
|
186 |
+
|
187 |
+
echo "<option value='footer'";
|
188 |
+
if(get_option(key_sc_position) != "header")
|
189 |
+
echo" selected='selected'";
|
190 |
+
echo ">Footer</option>\n";
|
191 |
+
|
192 |
+
echo "</select>\n";
|
193 |
+
?>
|
194 |
+
</td>
|
195 |
+
</tr>
|
196 |
+
<tr>
|
197 |
+
<td>
|
198 |
+
<label for="sc_invisible">Force invisibility:</label>
|
199 |
+
</td>
|
200 |
+
<td>
|
201 |
+
<?php
|
202 |
+
$checked = "";
|
203 |
+
if(get_option('sc_invisible')==1) {
|
204 |
+
$checked = "checked";
|
205 |
+
}
|
206 |
+
echo "<input type='checkbox' name='sc_invisible' id='sc_invisible' value='1' ".esc_html($checked).">\n";
|
207 |
+
?>
|
208 |
+
</td>
|
209 |
+
</tr>
|
210 |
+
</table>
|
211 |
+
</fieldset>
|
212 |
+
</blockquote>
|
213 |
+
<p class="submit">
|
214 |
+
<input type='submit' name='info_update' value='Update Options' />
|
215 |
+
</p>
|
216 |
+
</div>
|
217 |
+
</form>
|
218 |
+
|
219 |
+
|
220 |
+
|
221 |
+
<?php
|
222 |
+
}
|
223 |
+
|
224 |
+
$sc_position = get_option(key_sc_position);
|
225 |
+
if ($sc_position=="header") {
|
226 |
+
add_action('wp_head', 'add_statcounter');
|
227 |
+
} else {
|
228 |
+
add_action('wp_footer', 'add_statcounter');
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
|
233 |
+
// The guts of the StatCounter script
|
234 |
+
function add_statcounter() {
|
235 |
+
global $user_level;
|
236 |
+
$sc_project = get_option(key_sc_project);
|
237 |
+
$sc_security = get_option(key_sc_security);
|
238 |
+
$sc_invisible = 0;
|
239 |
+
$sc_invisible = get_option('sc_invisible');
|
240 |
+
if (
|
241 |
+
( $sc_project > 0 )
|
242 |
+
) {
|
243 |
+
?>
|
244 |
+
<!-- Start of StatCounter Code -->
|
245 |
+
<script>
|
246 |
+
<!--
|
247 |
+
var sc_project=<?php echo esc_html($sc_project); ?>;
|
248 |
+
var sc_security="<?php echo esc_html($sc_security); ?>";
|
249 |
+
<?php
|
250 |
+
if($sc_invisible==1) {
|
251 |
+
echo "var sc_invisible=1;\n";
|
252 |
+
}
|
253 |
+
|
254 |
+
define('HTTPS', isset($_SERVER['HTTPS']) && filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN));
|
255 |
+
$protocol = defined('HTTPS') ? "https:" : "http:";
|
256 |
+
|
257 |
+
?>
|
258 |
+
var scJsHost = (("https:" == document.location.protocol) ?
|
259 |
+
"https://secure." : "http://www.");
|
260 |
+
//-->
|
261 |
+
<?php
|
262 |
+
if($sc_invisible!=1) {
|
263 |
+
echo "\ndocument.write(\"<sc\"+\"ript src='\" +scJsHost +\"statcounter.com/counter/counter.js'></\"+\"script>\");";
|
264 |
+
}
|
265 |
+
?>
|
266 |
+
</script>
|
267 |
+
<?php
|
268 |
+
if($sc_invisible==1) {
|
269 |
+
if($protocol == "http:") {
|
270 |
+
echo "\n<script type=\"text/javascript\"
|
271 |
+
src=\"http://www.statcounter.com/counter/counter.js\"
|
272 |
+
async></script>";
|
273 |
+
} else if (esc_html($protocol) == "https:"){
|
274 |
+
echo "\n<script type=\"text/javascript\"
|
275 |
+
src=\"https://secure.statcounter.com/counter/counter.js\"
|
276 |
+
async></script>";
|
277 |
+
}
|
278 |
+
}?>
|
279 |
+
<noscript><div class="statcounter"><a title="web analytics" href="<?php echo esc_html($protocol) ?>//statcounter.com/"><img class="statcounter" src="<?php echo esc_html($protocol) ?>//c.statcounter.com/<?php echo esc_html($sc_project) ?>/0/<?php echo esc_html($sc_security) ?>/<?php echo esc_html($sc_invisible) ?>/" alt="web analytics" /></a></div></noscript>
|
280 |
+
<!-- End of StatCounter Code -->
|
281 |
+
<?php
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
function statcounter_addToTags($pid){
|
286 |
+
if (is_single()) {
|
287 |
+
global $post;
|
288 |
+
$queried_post = get_post($pid);
|
289 |
+
$authorId = $queried_post->post_author;
|
290 |
+
?>
|
291 |
+
<script type="text/javascript">
|
292 |
+
var _statcounter = _statcounter || [];
|
293 |
+
_statcounter.push({"tags": {"author": "<?php the_author_meta( 'nickname', esc_html($authorId)); ?>"}});
|
294 |
+
</script>
|
295 |
+
<?php
|
296 |
+
|
297 |
+
}
|
298 |
+
}
|
299 |
+
?>
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Aodhan Cullen
|
|
3 |
Donate link: http://statcounter.com/
|
4 |
Tags: web, statistics, stats, hit, counter, visitor, ip, tracker, analytics
|
5 |
Requires at least: 2.0.2
|
6 |
-
Tested up to: 5.
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
3 |
Donate link: http://statcounter.com/
|
4 |
Tags: web, statistics, stats, hit, counter, visitor, ip, tracker, analytics
|
5 |
Requires at least: 2.0.2
|
6 |
+
Tested up to: 5.9
|
7 |
+
Stable tag: 2.0.8
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|