X7ROOT File Manager
Current Path:
/home/katmhsmi/public_html/wp-content/plugins/wp-statistics/includes
home
/
katmhsmi
/
public_html
/
wp-content
/
plugins
/
wp-statistics
/
includes
/
📁
..
📁
admin
📁
api
📄
class-wp-statistics-admin-bar.php
(9.23 KB)
📄
class-wp-statistics-cli.php
(9.35 KB)
📄
class-wp-statistics-country.php
(4.1 KB)
📄
class-wp-statistics-db.php
(7.71 KB)
📄
class-wp-statistics-exclusion.php
(16.2 KB)
📄
class-wp-statistics-frontend.php
(5.17 KB)
📄
class-wp-statistics-geoip.php
(2.41 KB)
📄
class-wp-statistics-helper.php
(79.16 KB)
📄
class-wp-statistics-historical.php
(1.49 KB)
📄
class-wp-statistics-hits.php
(6.29 KB)
📄
class-wp-statistics-install.php
(35 KB)
📄
class-wp-statistics-ip.php
(13.12 KB)
📄
class-wp-statistics-mail.php
(9.67 KB)
📄
class-wp-statistics-menus.php
(8.89 KB)
📄
class-wp-statistics-meta-box.php
(1.42 KB)
📄
class-wp-statistics-option.php
(10.73 KB)
📄
class-wp-statistics-pages.php
(21.81 KB)
📄
class-wp-statistics-privacy-erasers.php
(1.13 KB)
📄
class-wp-statistics-privacy-exporter.php
(1.59 KB)
📄
class-wp-statistics-purge.php
(9.84 KB)
📄
class-wp-statistics-referred.php
(9.94 KB)
📄
class-wp-statistics-rest-api.php
(2.68 KB)
📄
class-wp-statistics-schedule.php
(13.75 KB)
📄
class-wp-statistics-search-engine.php
(2.71 KB)
📄
class-wp-statistics-shortcode.php
(12.71 KB)
📄
class-wp-statistics-timezone.php
(12.44 KB)
📄
class-wp-statistics-uninstall.php
(3.43 KB)
📄
class-wp-statistics-user-agent.php
(1.38 KB)
📄
class-wp-statistics-user-online.php
(11.09 KB)
📄
class-wp-statistics-user.php
(9.93 KB)
📄
class-wp-statistics-visit.php
(1.44 KB)
📄
class-wp-statistics-visitor.php
(17.91 KB)
📄
class-wp-statistics-widget.php
(23.48 KB)
📄
class-wp-statistics.php
(15.69 KB)
📁
defines
📄
defines.php
(509 B)
📁
libraries
📄
template-functions.php
(29.29 KB)
Editing: class-wp-statistics-hits.php
<?php namespace WP_STATISTICS; use Exception; use WP_Statistics\Components\Singleton; use WP_Statistics\Service\Analytics\VisitorProfile; use WP_Statistics\Service\Integrations\IntegrationHelper; use WP_Statistics\Traits\ErrorLoggerTrait; class Hits extends Singleton { use ErrorLoggerTrait; /** * Rest-APi Hit Record Params Key * * @var string */ public static $rest_hits_key = 'wp_statistics_hit'; /** * Rest-Api Hit Data * * @var object */ public $rest_hits; /** * WP_Statistics Hits Class. * * @throws Exception */ public function __construct() { // Sanitize Hit Data if Has Rest-Api Process if (self::is_rest_hit()) { // Get Hit Data $this->rest_hits = (object)self::rest_params(); // Filter Data add_filter('wp_statistics_current_page', array($this, 'set_current_page')); add_filter('wp_statistics_page_uri', array($this, 'set_page_uri')); add_filter('wp_statistics_user_id', array($this, 'set_current_user')); } // Record Login Page Hits if (!Option::get('exclude_loginpage')) { add_action('init', array($this, 'trackLoginPageCallback')); } // Server Side Tracking add_action('wp', array($this, 'trackServerSideCallback')); } /** * Set Current Page * * @param $current_page * @return array */ public function set_current_page($current_page) { if (isset($this->rest_hits->source_type) and isset($this->rest_hits->source_id)) { return array( 'type' => esc_sql($this->rest_hits->source_type), 'id' => esc_sql($this->rest_hits->source_id), 'search_query' => isset($this->rest_hits->search_query) ? base64_decode($this->rest_hits->search_query) : '' ); } return $current_page; } /** * Set Page Uri * * @param $page_uri * @return string */ public function set_page_uri($page_uri) { return isset($this->rest_hits->page_uri) ? base64_decode($this->rest_hits->page_uri) : $page_uri; } /** * Set User ID * * @param $userId * @return mixed */ public function set_current_user($userId) { $userIdFromGlobalVar = isset($GLOBALS['wp_statistics_user_id']) ? $GLOBALS['wp_statistics_user_id'] : 0; if (!$userId && $userIdFromGlobalVar) { $userId = $userIdFromGlobalVar; } return $userId; } /** * Check If Record Hits in Rest-Api Request * * @return bool */ public static function is_rest_hit() { return (Helper::is_rest_request() and isset($_REQUEST[self::$rest_hits_key])); } /** * Get Params Value in Rest-APi Request Hit * * @param $params * @return Mixed */ public static function rest_params($params = false) { $data = array(); if (Helper::is_rest_request() and isset($_REQUEST[Hits::$rest_hits_key])) { foreach ($_REQUEST as $key => $value) { $data[$key] = $value; } return ($params === false ? $data : (isset($data[$params]) ? $data[$params] : false)); } return $data; } /** * Record the visitor * * @throws Exception */ public static function record($visitorProfile = null) { if (!$visitorProfile) { $visitorProfile = new VisitorProfile(); } /** * Check the exclusion */ $exclusion = Exclusion::check($visitorProfile); /** * Record exclusion if needed & then skip the tracking */ if ($exclusion['exclusion_match'] === true) { Exclusion::record($exclusion); self::errorListener(); throw new Exception($exclusion['exclusion_reason'], 200); } /** * Record User Views */ if (Visit::active()) { Visit::record(); } /** * Record Pages */ $pageId = false; if (Pages::active()) { $pageId = Pages::record($visitorProfile); } /** * Record Visitor Detail */ $visitorId = false; if (Visitor::active()) { $visitorId = Visitor::record($visitorProfile, ['page_id' => $pageId]); } /** * Record Visitor Relationship */ if ($visitorId && $pageId) { Visitor::save_visitors_relationships($pageId, $visitorId); } /** * Record User Online with the visitor request in the same time. */ self::recordOnline($visitorProfile); self::errorListener(); return $exclusion; } /** * Record the user online standalone * * @throws Exception */ public static function recordOnline($visitorProfile = null) { if (!UserOnline::active()) { return; } if (!$visitorProfile) { $visitorProfile = new VisitorProfile(); } if ($visitorProfile->getVisitorId() === 0) { return; } UserOnline::record($visitorProfile); self::errorListener(); } /** * Record Hits in Login Page * * @throws Exception */ public static function trackLoginPageCallback() { if (Helper::is_login_page()) { try { self::record(); } catch (Exception $e) { self::errorListener(); } } } /** * Server-Side Tracking Callback * * @throws Exception */ public static function trackServerSideCallback() { try { if (is_favicon() || is_admin() || is_preview() || Option::get('use_cache_plugin') || Helper::dntEnabled()) { return; } $isConsentGiven = IntegrationHelper::isConsentGiven(); $trackAnonymously = IntegrationHelper::shouldTrackAnonymously(); if ($isConsentGiven || $trackAnonymously) { self::record(); } } catch (Exception $e) { self::errorListener(); } } } Hits::instance();
Upload File
Create Folder