Here is some change to support WP Super Cache.
WP-PostViews 1.62
function process_postviews() {
//...
//...
if($should_count) {
global $cache_enabled; //WP Super Cache enabled or not
if(defined('WP_CACHE') && WP_CACHE && $cache_enabled) {
echo "\n".'<!-- Start Of Script Generated By WP-PostViews -->'."\n";
//...
} else {
//...
}
}
//...
//...
}
function add_postviews_column($defaults) {
$defaults['views'] = __('Views', 'wp-postviews');
return $defaults;
}
//AJAX get post views
add_action( 'wp_ajax_postviews_get', 'postviews_get' );
add_action( 'wp_ajax_nopriv_postviews_get', 'postviews_get' );
function postviews_get() {
if ( !empty( $_GET['postviews_id'] ) ) {
$post_id = intval( $_GET['postviews_id'] );
if ( $post_id > 0 ) {
$views_options = get_option( 'views_options' );
$post_views = get_post_custom( $post_id );
$output = str_replace( '%VIEW_COUNT%', number_format_i18n( intval( $post_views['views'][0] ) ), $views_options['template'] );
$output = apply_filters( 'the_views', $output );
echo $output;
}
}
exit();
}
//the_views support WP Super Cache via AJAX
function the_views( $display = true, $prefix = '', $postfix = '', $always = false ) {
$output = '';
$views_options = get_option( 'views_options' );
if ( $always || should_views_be_displayed( $views_options ) ) {
global $cache_enabled;
if ( defined( 'WP_CACHE' ) && WP_CACHE && $cache_enabled ) {
global $post;
if ( is_int( $post ) ) {
$post = get_post( $post );
}
$id = intval( $post->ID );
wp_print_scripts( 'jquery' );
$output = "\n" . '<!-- Start Of Script WP-PostViews Get Action -->' . "\n";
$output .= '<font id="views_' . $id . '"> </font>' . "\n";
$output .= '<script type="text/javascript">' . "\n";
$output .= '/* <![CDATA[ */' . "\n";
$output .= "jQuery.ajax({type:'GET',url:'" . admin_url( 'admin-ajax.php', ( is_ssl() ? 'https' : 'http' ) ) . "',data:'postviews_id=" . $id . "&action=postviews_get',cache:false,complete:function(jqXHR,textStatus){var obj=jQuery('#views_" . $id . "');obj.before('" . $prefix . "'+jqXHR.responseText+'" . $postfix . "');obj.remove();}});\n";
$output .= '/* ]]> */' . "\n";
$output .= '</script>' . "\n";
$output .= '<!-- End Of Script WP-PostViews Get Action -->' . "\n";
} else {
$output = $prefix . str_replace( '%VIEW_COUNT%', number_format_i18n( intval( post_custom( 'views' ) ) ), $views_options['template'] ) . $postfix;
$output = apply_filters( 'the_views', $output );
}
}
if ( $display ) {
echo $output;
return '';
} else {
return $output;
}
}