PluginProbe
Age Gate / 3.7.3
Age Gate v3.7.3
3.7.3 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 All 113 releases
age-gate / src / Presentation / FocusTrap.php

FocusTrap.php in Age Gate 3.7.3, at src/Presentation/FocusTrap.php

45 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AgeGate\Presentation;
4
5 use AgeGate\Common\Settings;
6
7 class FocusTrap
8 {
9 public function __construct()
10 {
11 add_action('wp_enqueue_scripts', [$this, 'assets'], 1);
12 }
13
14 public function assets()
15 {
16 $settings = Settings::getInstance();
17 $path = sprintf('%s%s%s', AGE_GATE_URL, 'dist', ($settings->rawAssets ? '/raw' : ''));
18 wp_enqueue_script('age-gate-focus', $path . '/focus.js', [], AGE_GATE_VERSION, !$settings->inHeader);
19
20 $elements = [
21 '.age-gate',
22 ];
23
24 if (is_admin_bar_showing()) {
25 $elements[] = '#wpadminbar';
26 }
27
28 if ($settings->inputType === 'buttons') {
29 $focused = null;
30 } elseif ($settings->stepped) {
31 $focused = 'age_gate[y]';
32 } else {
33 $focused = sprintf('age_gate[%s]', strtolower($settings->dateFormat[0] ?? 'd'));
34 }
35
36 wp_localize_script('age-gate-focus', 'agfocus', [
37 'focus' => $focused,
38 'elements' => array_merge(
39 apply_filters('age_gate/trap_focus/elements', []),
40 $elements
41 )
42 ]);
43 }
44 }
45