ID = $id; } public function on_video_start( $user_id, $post_id ) { do_action( 'thrive_video_start', [ 'item_id' => $this->ID, 'user_id' => $user_id, 'post_id' => $post_id, ] ); } public function save_range( $user_id, $post_id, $range_start, $range_end ) { do_action( 'thrive_video_update_watch_data', [ 'item_id' => $this->ID, 'user_id' => $user_id, 'post_id' => $post_id, 'range_start' => $range_start, 'range_end' => $range_end, ] ); } public function is_completed( $current_duration ) { $percentage_to_complete = $this->get_percentage_to_complete(); if ( ! $percentage_to_complete ) { $percentage_to_complete = 100; } $duration_to_complete = (int) $this->get_full_duration() * (int) $percentage_to_complete / 100; // If current duration is less than 5 seconds of the duration_to_complete, consider it as completed. return $current_duration >= $duration_to_complete - 5; } }