i want edit this code to auto increment not just +2 for each user's click and instead increment number would be random ( + 2 , + 4 , ... )
if( $should_count && ( ( isset( $views_options['use_ajax'] ) && (int) $views_options['use_ajax'] === 0 ) || ( !defined( 'WP_CACHE' ) || !WP_CACHE ) ) ) {
update_post_meta( $id, 'views', $post_views + 2 );
do_action( 'postviews_increment_views', $post_views + 2 );
my full wp postview code bellow:
### Function: Calculate Post Views
add_action( 'wp_head', 'process_postviews' );
function process_postviews() {
global $user_ID, $post;
if ( is_int( $post ) ) {
$post = get_post( $post );
}
if ( ! wp_is_post_revision( $post ) && ! is_preview() ) {
if ( is_single() || is_page() ) {
$id = (int) $post->ID;
$views_options = get_option( 'views_options' );
if ( !$post_views = get_post_meta( $post->ID, 'views', true ) ) {
$post_views = 0;
}
$should_count = false;
switch( (int) $views_options['count'] ) {
case 0:
$should_count = true;
break;
case 1:
if( empty( $_COOKIE[ USER_COOKIE ] ) && (int) $user_ID === 0 ) {
$should_count = true;
}
break;
case 2:
if( (int) $user_ID > 0 ) {
$should_count = true;
}
break;
}
if ( isset( $views_options['exclude_bots'] ) && (int) $views_options['exclude_bots'] === 1 ) {
$bots = array(
'Google Bot' => 'google'
, 'MSN' => 'msnbot'
, 'Alex' => 'ia_archiver'
, 'Lycos' => 'lycos'
, 'Ask Jeeves' => 'jeeves'
, 'Altavista' => 'scooter'
, 'AllTheWeb' => 'fast-webcrawler'
, 'Inktomi' => 'slurp@inktomi'
, 'Turnitin.com' => 'turnitinbot'
, 'Technorati' => 'technorati'
, 'Yahoo' => 'yahoo'
, 'Findexa' => 'findexa'
, 'NextLinks' => 'findlinks'
, 'Gais' => 'gaisbo'
, 'WiseNut' => 'zyborg'
, 'WhoisSource' => 'surveybot'
, 'Bloglines' => 'bloglines'
, 'BlogSearch' => 'blogsearch'
, 'PubSub' => 'pubsub'
, 'Syndic8' => 'syndic8'
, 'RadioUserland' => 'userland'
, 'Gigabot' => 'gigabot'
, 'Become.com' => 'become.com'
, 'Baidu' => 'baiduspider'
, 'so.com' => '360spider'
, 'Sogou' => 'spider'
, 'soso.com' => 'sosospider'
, 'Yandex' => 'yandex'
);
$useragent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
foreach ( $bots as $name => $lookfor ) {
if ( ! empty( $useragent ) && ( false !== stripos( $useragent, $lookfor ) ) ) {
$should_count = false;
break;
}
}
}
$should_count = apply_filters( 'postviews_should_count', $should_count, $id );
if( $should_count && ( ( isset( $views_options['use_ajax'] ) && (int) $views_options['use_ajax'] === 0 ) || ( !defined( 'WP_CACHE' ) || !WP_CACHE ) ) ) {
update_post_meta( $id, 'views', $post_views + 2 );
do_action( 'postviews_increment_views', $post_views + 2 );
}
}
}
}