| 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/matomo/classes/WpMatomo/ |
Upload File : |
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @package matomo
*/
namespace WpMatomo;
if ( ! defined( 'ABSPATH' ) ) {
exit; // if accessed directly
}
/**
* Every 90 days we show a please review notice until the user dismisses this notice or clicks on rate us.
* We only show this notice on Matomo screens.
*
* @todo validate the nonce
* phpcs:disable WordPress.Security.NonceVerification.Missing
*/
class Referral {
const OPTION_NAME_REFERRAL_DISMISSED = 'matomo-referral-dismissed';
/**
* @var int
*/
private $time;
public function __construct() {
$this->time = time();
}
/**
* @param int $time
*
* @internal for tests only
*/
public function set_time( $time ) {
$this->time = $time;
}
public function register_hooks() {
$self = $this;
add_action(
'wp_ajax_matomo_referral_dismiss_admin_notice',
function () use ( $self ) {
check_ajax_referer( 'matomo-referral-notice-dismiss' );
if ( is_admin() && $self->should_show() && $self->can_refer() ) {
// no need for an nonce check here as it's nothing critical
if ( ! empty( $_POST['forever'] ) ) {
$self->dismiss_forever();
} else {
$self->dismiss();
}
}
}
);
add_action(
'admin_notices',
function () use ( $self ) {
if ( $self->can_refer() && $self->should_show_on_screen() ) {
$self->render();
}
}
);
}
public function render() {
include 'views/referral.php';
}
public function should_show_on_screen() {
if ( ! is_admin() ) {
return false;
}
$screen = get_current_screen();
return $screen && $screen->id && strpos( $screen->id, 'matomo-' ) === 0;
}
public function can_refer() {
return current_user_can( Capabilities::KEY_VIEW );
}
public function dismiss_forever() {
$ten_years = 60 * 60 * 24 * 365 * 10;
update_option( self::OPTION_NAME_REFERRAL_DISMISSED, $this->time + $ten_years );
}
public function dismiss() {
update_option( self::OPTION_NAME_REFERRAL_DISMISSED, $this->time, true );
}
public function get_last_dismissed() {
return get_option( self::OPTION_NAME_REFERRAL_DISMISSED );
}
private function get_days_in_seconds( $num_days ) {
return 60 * 60 * 24 * $num_days;
}
public function should_show() {
$dismissed = $this->get_last_dismissed();
if ( ! $dismissed ) {
// the first time we check... we set it back 30 days cause we want to see first rating after 60 days
$this->time = $this->time - $this->get_days_in_seconds( 30 );
$this->dismiss();
return false;
}
$ninety_days_in_seconds = $this->get_days_in_seconds( 90 );
if ( $this->time > ( $dismissed + $ninety_days_in_seconds ) ) {
return true;
}
return false;
}
}