| Server IP : 167.99.224.18 / Your IP : 216.73.216.136 Web Server : Apache/2.4.41 (Ubuntu) System : Linux wordpress-ubuntu-s-1vcpu-1gb-nyc1-01 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.0.25 Disable Function : 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins-old/plausible-analytics/src/ |
Upload File : |
<?php
/**
* Plausible Analytics | Setup.
*
* @since 1.3.0
* @package WordPress
* @subpackage Plausible Analytics
*/
namespace Plausible\Analytics\WP;
class Setup {
/**
* Cron job handle
*
* @var string
*/
private $cron = 'plausible_analytics_update_js';
/**
* Filters and Hooks.
*
* @return void
*/
public function __construct() {
register_activation_hook( PLAUSIBLE_ANALYTICS_PLUGIN_FILE, [ $this, 'create_cache_dir' ] );
register_activation_hook( PLAUSIBLE_ANALYTICS_PLUGIN_FILE, [ $this, 'activate_cron' ] );
register_deactivation_hook( PLAUSIBLE_ANALYTICS_PLUGIN_FILE, [ $this, 'deactivate_cron' ] );
// Attach the cron script to the cron action.
add_action( $this->cron, [ $this, 'load_cron_script' ] );
// This assures that the local file is downloaded/updated when settings are saved.
add_action( 'plausible_analytics_settings_saved', [ $this, 'load_cron_script' ] );
}
/**
* Create Cache-dir upon (re)activation.
*/
public function create_cache_dir() {
$upload_dir = Helpers::get_proxy_resource( 'cache_dir' );
if ( ! is_dir( $upload_dir ) ) {
wp_mkdir_p( $upload_dir ); // @codeCoverageIgnore
}
}
/**
* Register hook to schedule script in wp_cron()
*
* @codeCoverageIgnore
*/
public function activate_cron() {
if ( ! wp_next_scheduled( $this->cron ) ) {
wp_schedule_event( time(), 'daily', $this->cron );
}
}
/**
* Deactivate cron when plugin is deactivated.
*
* @codeCoverageIgnore
*/
public function deactivate_cron() {
if ( wp_next_scheduled( $this->cron ) ) {
wp_clear_scheduled_hook( $this->cron );
}
}
/**
* Triggers the cron script.
*
* @codeCoverageIgnore
*/
public function load_cron_script() {
new Cron();
}
}