| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.3/wp-content/plugins/wp-statistics/src/Core/ |
Upload File : |
<?php
namespace WP_Statistics\Core;
use WP_STATISTICS\Option;
/**
* Base class containing shared initialization logic and utilities for core components.
*
* Provides helpers for option setup, required file loading, version checks and updates,
* and enforces an `execute()` method that concrete subclasses must implement.
*
* @package WP_Statistics\Core
*/
abstract class AbstractCore
{
/**
* Stores the current plugin version retrieved from the database.
*
* @var string
*/
protected $currentVersion;
/**
* Stores the latest version of the plugin defined by the codebase.
*
* @var string
*/
protected $latestVersion;
/**
* Whether operations are being performed network-wide (multisite network activation).
*
* @var bool
*/
protected $networkWide = false;
/**
* WordPress database access object.
*
* @var \wpdb
*/
protected $wpdb;
/**
* AbstractCore constructor.
*
* @return void
*/
public function __construct($networkWide = false)
{
$this->latestVersion = WP_STATISTICS_VERSION;
$this->networkWide = (bool)$networkWide;
$this->setWpdb();
}
/**
* Initialize the wpdb property from the global $wpdb.
*/
private function setWpdb()
{
global $wpdb;
$this->wpdb = $wpdb;
}
/**
* Initialize default options.
*
* @return void
*/
protected function initializeDefaultOptions()
{
$this->loadRequiredFiles();
$options = get_option(Option::$opt_name);
if (empty($options) || !is_array($options)) {
update_option(Option::$opt_name, Option::defaultOption());
}
}
/**
* Load required files.
*
* @return void
*/
private function loadRequiredFiles()
{
require_once WP_STATISTICS_DIR . 'includes/admin/class-wp-statistics-admin-template.php';
require_once WP_STATISTICS_DIR . 'includes/class-wp-statistics-option.php';
require_once WP_STATISTICS_DIR . 'includes/class-wp-statistics-helper.php';
require_once WP_STATISTICS_DIR . 'includes/class-wp-statistics-user-online.php';
require_once WP_STATISTICS_DIR . 'includes/class-wp-statistics-visitor.php';
}
/**
* Checks whether the plugin is a fresh installation.
*
* @return void
*/
protected function checkIsFresh()
{
$version = get_option('wp_statistics_plugin_version');
if (empty($version)) {
update_option('wp_statistics_is_fresh', true);
} else {
update_option('wp_statistics_is_fresh', false);
}
$installationTime = get_option('wp_statistics_installation_time');
if (empty($installationTime)) {
update_option('wp_statistics_installation_time', time());
}
}
/**
* Checks whether the plugin is updated.
*
* @return bool
*/
protected function isUpdated()
{
$this->currentVersion = get_option('wp_statistics_plugin_version', WP_STATISTICS_VERSION);
return $this->currentVersion != $this->latestVersion;
}
/**
* Update the plugin version.
*
* @return void
*/
protected function updateVersion()
{
update_option('wp_statistics_plugin_version', $this->latestVersion);
}
/**
* Execute the core function.
*
* @return void
*/
abstract public function execute();
}