| 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 : /home/httpd/html/xxxupdates.com/public_html/wp-content/plugins/age-gate/src/Admin/User/ |
Upload File : |
<?php
namespace AgeGate\Admin\User;
use AgeGate\Utility\Cookie;
use AgeGate\Common\Settings;
use AgeGate\Common\Admin\AbstractController;
/**
* Determine placement of toolbar link
*
* @package AgeGate
* @copyright 2022 Phil Baker
*/
class Toolbar extends AbstractController
{
protected const INIT = false;
public function register(): void
{
add_action('admin_bar_menu', [$this, 'toolbarLink'], 1000);
add_action('wp_enqueue_scripts', [$this, 'enqueue']);
}
public function required(): bool
{
$settings = Settings::getInstance();
return !is_admin() && $settings->toolbar;
}
public function data(): array
{
return [];
}
public function fields(): array
{
return [];
}
public function enqueue(): void
{
if (is_admin_bar_showing()) {
$settings = Settings::getInstance();
$path = sprintf('%s%s%s', AGE_GATE_URL, 'dist', ($settings->rawAssets ? '/raw' : ''));
wp_enqueue_script('age-gate-toolbar', $path . '/toolbar.js', [], AGE_GATE_VERSION, true);
wp_enqueue_style('age-gate-toolbar', $path . '/toolbar.css', [], AGE_GATE_VERSION);
}
}
public function toolbarLink($adminBar)
{
if (!is_admin_bar_showing()) {
return;
}
$settings = Settings::getInstance();
echo sprintf('<script>var ag_cookie_domain = "%s"; var ag_cookie_name = "%s"</script>', esc_attr(Cookie::getDomain()), esc_attr($settings->getCookieName())); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$parent = [
'id' => 'age-gate',
'title' => '<span class="screen-reader-text">' . __('Age Gate', 'age-gate') . '</span>',
'href' => esc_url(
add_query_arg(
[
'page' => 'age-gate',
],
admin_url('admin.php')
)
)
];
$adminBar->add_node($parent);
$child = [
'id' => 'age-gate-toggle',
'title' => 'Toggle',
'parent' => 'age-gate',
'href' => esc_url(
add_query_arg(
[
'page' => 'age-gate',
'ag_switch' => '1',
'_wpnonce' => wp_create_nonce('age-gate-toggle'),
'ls' => $settings->useLocalStorage,
],
admin_url('admin.php')
)
),
'meta' => [
'title' => $settings->cookieDomain
]
];
$adminBar->add_node($child);
}
}