• Hey everybody, i’m writing one class for plugin, they should count when user enter any post in wordpress, but i’ve got one function what checking that counter should work one time in two minutes, but they don’t working, pls can somebody look at my code, and maybe help me?)

    if ($this->isExperienceTime()) {
    			return false;
    		}
    
    		global $wpdb;
    		$meta_count      = absint( get_post_meta( $post_id, "decollete_post_views", true ) );
    		$meta_count      = $meta_count + 1;
    		update_post_meta( $post_id, "decollete_post_views", $meta_count );
    		$post           = $wpdb->get_row( "SELECT * FROM $wpdb->de_statistics WHERE blog_id = $this->blogid AND post_id = $post_id " );
    		//print_r($post);
    
    		if ($post->views_counts < $meta_count) {
    			$query = "UPDATE $wpdb->de_statistics SET views_counts = $meta_count WHERE blog_id = $this->blogid AND post_id = $post_id ";
    			echo $meta_count;
    			$wpdb->query( $query );
    		}
    	}
    
    	public function sessionStart()
    	{
    		if (!session_id()) {
    			session_start();
    		}
    		if ($this->isExperienceTime()) {
    			$_SESSION['time'] = time();
    		}
    
    	} // end sessionStart
    
    	public function isExperienceTime()
    	{
    		$to_time = time();
    		$from_time = $_SESSION['time'];
    		$minutes_period = round(abs($to_time - $from_time) / 60, 0);
    		echo $minutes_period;
    		if ($minutes_period >= 2) {
    			return true;
    		}
    		return false;
    	} // end isExperienceTime

    I will appreciate if somebody help me!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Pls help with my class’ is closed to new replies.