Close

Account

Documentation

Forum

Menu

JNews View Counter Is Resting Views Count Back To Zero On Reaching 1000 Views

  • Post count: 14
    Munyendo
    November 26, 2017 at 6:54 pm #26014

    JNews view counter is resetting views count back to zero and starting to count afresh when the views reach 1000 instead of increasing. How do I resolve this?

    Post count: 11072
    Adek
    November 27, 2017 at 1:01 pm #26051

    Hi Munyendo,

    Regarding this issue, please take a look at this topic here http://support.jegtheme.com/forums/topic/view-counter-and-post-ads/#post-25686 and follow the instruction number 1. Let us know if you still getting a problem in there.

    Thank you

    Post count: 14
    Munyendo
    November 28, 2017 at 1:39 am #26093
    This reply has been marked as private.
    Post count: 2686
    Rai
    November 28, 2017 at 8:45 am #26111

    Hi @munyendo,

    Could you provide your code after updated?
    It seems there is unwanted string or wrong placement code.

    Thank you

    Post count: 14
    Munyendo
    November 28, 2017 at 6:01 pm #26152

    Below is the code after update of the function that is throwing an error

    <?php
    /**
    * @author : Jegtheme
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }

    /**
    * Class JNews Initial Counter
    */
    Class JNews_Initial_Counter
    {
    /**
    * @var JNews_Initial_Counter
    */
    private static $instance;

    /**
    * @return JNews_Initial_Counter
    */
    public static function getInstance()
    {
    if (null === static::$instance)
    {
    static::$instance = new static();
    }
    return static::$instance;
    }

    /**
    * Total fake view
    *
    * @param null $total
    * @param $post_id
    * @param string $range
    * @return mixed|null
    */

    public function get_total_fake_view($total = null, $post_id, $range = ‘all’)
        {
            $total = str_replace( ‘,’, ”, $total );
            $total = intval( $total );
     
            if ( ! $total )
            {
                $total = apply_filters(‘jnews_get_total_view’, 0, $post_id, $range);
            }
     
            $total = (int) $total + (int) jnews_get_option(‘single_view_initial_value’, 0);
     
            return $total;
        }

    /**
    * Fake share
    *
    * @param $post_id
    * @return float
    */
    public function fake_share($post_id)
    {
    $percentage = (int) jnews_get_option(‘single_social_share_view_percentage’, 0);
    $view = $this->get_total_fake_view(null, $post_id);

    return (int) round( $view * $percentage / 100 );
    }

    /**
    * Total fake share
    *
    * @param $total
    * @param $post_id
    * @return mixed
    */
    public function get_total_fake_share($total, $post_id)
    {
    $totalshare = $total + $this->fake_share($post_id);
    return $totalshare;
    }

    /**
    * @param $social
    * @return int|mixed|void
    */
    public function social_fake_percentage($social)
    {
    $percentage = 0;

    switch($social) {
    case “facebook” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 40, $social);
    break;
    case “twitter” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 25, $social);
    break;
    case “google” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 10, $social);
    break;
    case “pinterest” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 9, $social);
    break;
    case “linkedin” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 7, $social);
    break;
    case “vk” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 5, $social);
    break;
    case “buffer” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 3, $social);
    break;
    case “stumbleupon” :
    $percentage = apply_filters(‘jnews_share_fake_percentage’, 1, $social);
    break;
    }

    return $percentage;
    }

    /**
    * Social Share
    *
    * @param $totalshare
    * @param $post_id
    * @param string $social
    * @return mixed
    */
    public function social_share($totalshare, $post_id, $social = ‘facebook’)
    {
    $socialshare = round ( $this->fake_share($post_id) * $this->social_fake_percentage($social) / 100 );
    $totalshare = $totalshare + $socialshare;
    return $totalshare;
    }

    /**
    * Fake like
    *
    * @param $post_id
    * @param string $type
    * @return int
    */
    public function fake_like($post_id, $type = ‘like’)
    {
    $percentage = (int) jnews_get_option(‘single_like_view_percentage’, 0);

    $max_dislike = apply_filters(‘jnews_max_dislike’, 8);
    $title_length = str_word_count(get_the_title($post_id));
    $like_percentage = 100 – ( $title_length % $max_dislike );
    $like_percentage = min($like_percentage, 99);

    $real_view = $total = apply_filters(‘jnews_get_total_view’, 0, $post_id, ‘all’);
    $total_view = $this->get_total_fake_view($real_view, $post_id);

    $fake_like = round( $total_view * $percentage * $like_percentage / 10000 );
    $fake_dislike = round( $total_view * $percentage / 100 ) – $fake_like;

    if($type === ‘like’) {
    return (int) $fake_like;
    } else {
    return $fake_dislike;
    }

    }

    /**
    * Get total like with fake like
    *
    * @param $total
    * @param $post_id
    * @return int
    */
    public function total_like($total, $post_id)
    {
    $like = (int) $total + (int) $this->fake_like($post_id);
    return $like;
    }

    /**
    * Get total dislike
    *
    * @param $total
    * @param $post_id
    * @return int
    */
    public function total_dislike($total, $post_id)
    {
    $dislike = (int) $total + (int) $this->fake_like($post_id, ‘dislike’);
    return $dislike;
    }
    }

    Post count: 11072
    Adek
    November 29, 2017 at 9:20 am #26177

    Hi Munyendo,

    Please try to update your theme to the latest version of JNews v1.1.4. We just released a new version of JNews a few days ago that containing the fix that related to this issue. Also, after you have done with updating the theme, you will need to update JNews Social Share plugin and JNews View Counter as well if you’re not using the latest version yet.

    Thank you

You must be logged in to reply to this topic.