| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/self/cwd/wp-content/plugins/age-gate/src/Admin/ |
Upload File : |
<?php
namespace AgeGate\Admin;
class Update
{
public function __construct()
{
add_action('init', [$this, 'updateCheck'], 1);
add_action('in_plugin_update_message-age-gate/age-gate.php', [$this, 'updateWarnings']);
}
/**
* Check for version changes
*
* @return void
*/
public function updateCheck()
{
if (AGE_GATE_VERSION !== get_option('age_gate_version')) {
\AgeGate\Update\Activate::activate();
}
}
public function updateWarnings($plugin)
{
$current = $plugin['Version'];
$new = $plugin['new_version'];
$method = 'get' . $this->getMagnitude($current, $new) . 'Message';
$devs = [
'dev',
'alpha',
'beta',
'rc',
];
$version = AGE_GATE_VERSION . $current;
$found = false;
foreach ($devs as $str) {
if ($found) {
continue;
}
$found = stripos($version, $str) !== false;
}
if ($found) {
echo wp_kses_post($this->getDevMessage());
return;
}
echo wp_kses_post($this->$method());
}
private function getMagnitude($current, $new)
{
$current = explode('.', (string) $current);
$new = explode('.', (string) $new);
if ($new[0] > $current[0]) {
return 'Major';
} elseif ($new[1] > $current[1]) {
return 'Minor';
} elseif (isset($new[2]) && isset($current[2]) && $new[2] > $current[2]) {
return 'Patch';
}
return 'unknown';
}
private function getPatchMessage()
{
return '<br><br>' . __('This is a patch release of Age Gate, updating directly should not cause any issues, however do ensure you have backed up any previous version settings.', 'age-gate') . ' ';
}
private function getMinorMessage()
{
$message = '<br><br><b>' . __('WARNING', 'age-gate') . ':</b> ' . __('This is a minor release of Age Gate that could have unexpected results on your site.', 'age-gate') . ' ';
$message .= __('While it should be safe to update, it is advised that you test locally or on a staging site first.', 'age-gate');
return $message;
}
private function getMajorMessage()
{
$message = '<br><br><b>' . __('WARNING', 'age-gate') . ':</b> ' . __('This is a milestone release of Age Gate that could have unexpected results on your site.', 'age-gate') . ' ';
$message .= __('It is advised that you do not update on a live website and test locally or on a staging site first.', 'age-gate') . '<br><br>';
$message .= __('The update link has been disabled just to be safe, but if you are sure you want to update you can enable the update link here: ', 'age-gate') . '<button class="button-link age-gate-enable-update" type="button">' . __('Enable update', 'age-gate') . '</button>';
$message .= $this->disableUpdate();
return $message;
}
private function getDevMessage()
{
$message = '<br><br><b>' . __('WARNING', 'age-gate') . ':</b> ' . __('You are updating from a development version of Age Gate, some features, settings or functionality may no longer be available. Check the release notes and proceed with caution', 'age-gate') . ' <button class="button-link age-gate-enable-update" type="button">' . __('Enable update', 'age-gate') . '</button>';
$message .= $this->disableUpdate();
return $message;
}
private function getUnknownMessage()
{
}
private function disableUpdate()
{
return '<style>#age-gate-update .update-link {pointer-events: none;cursor: default; opacity:0.3;}</style>';
}
}