开发者 | Pinoy.ca |
---|---|
更新时间 | 2010年3月2日 15:29 |
捐献地址: | 去捐款 |
PHP版本: | 2.1 及以上 |
WordPress版本: | 2.9 |
x
number of posts that readers visited on your blog, and the amount of time elapsed since they visited it, in a variety of forms:
SECRET_KEY
where available, to protect against rainbow tables.$_SERVER['HTTP_CLIENT_IP']
or $_SERVER['HTTP_X_FORWARDED_FOR']
instead of $_SERVER['REMOTE_ADDR']
where available.wp_query
, instead of individually.get_recently_viewed_posts( $max_shown = 10 )
returns a string of li's.recently_viewed_posts( $max_shown = 10 )
prints a divplugin-name.php
to the /wp-content/plugins/
directory<?php recently_viewed_posts(); ?>
in your templates, or install the Widget.We made this with speed foremost in mind. It ought to be as fast if not faster than any visitor tracking or logging plugin out there.
The first or topmost post in that page is recorded.
Inasmuch as it lets the public see that a reader represented by a certain green squiggly icon visited articles X, Y and Z around 50 seconds apart, yes, it is. The IP address is encrypted, and no one except the blog's administrator will be able to brute-force and get the reader's IP address. In that case, the blog admin will probably use the server logs instead.
The plugin remembers only the last MAX_RECENTLY_VIEWED_LINKS
, which is 16 by default. There are bigger, more flexible visitor tracking and logging plugins that can do what you want.
You can set MAX_RECENTLY_VIEWED_LINKS
in your wp-config.php, or just edit the plugin file directly. For example, define(MAX_RECENTLY_VIEWED_LINKS, 300);
would slow the plugin down. The best value should be 2 or 3 times how many visits you display.
Remember that it displays what other readers visited. Tell a friend across the country to visit your blog.
Did you put it where readers can see it, like at the end of each post? Using this as a sidebar widget is for cowards.
Create a handler for the recently_viewed_posts_new
filter in your theme's functions.php
that will return NULL
on your own visits. For example,
add_filter("recently_viewed_posts_new", "my_rvp_ignore_admin_visits"); function my_rvp_ignore_admin_visits( $item ) { return current_user_can('manage_options') ? null : $item; }
Create a handler for the recently_viewed_posts_entry_format
filter in your theme's functions.php
. For example, the following removes the icon and adds javascript interaction:
add_filter("recently_viewed_posts_entry_format", "my_rvp_format"); function my_rvp_format( $format, $item ) { return '<li onmouseover="javascript:dynamo()"><a href="%URL%">%LINK%</a> %TIME% ago</li>'; }
Meanwhile, the following uses the icon as the list item image, instead of a bullet:
add_filter("recently_viewed_posts_entry_format", "my_rvp_format_2"); function my_rvp_format_2( $format, $item ) { return '<li style="list-style-image:url(%ICON%)"><a href="%URL%">%LINK%</a> %TIME% ago</li>'; }
Isn't this more flexible (and uses less memory!) than a configuration screen? ;-)
Of course. See http://en.wikipedia.org/wiki/IP_address_spoofing for starters.
Hashing with a SECRET_KEY
salt makes this impossible.
Since the plugin code needs to run on each page load, this plugin will not run when Super Cache is installed and active. A future version will run in Super Cache half-on mode and another version after that will run in Super Cache full mode.