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 / Preload.php

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

35 lines 928 B
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 Preload
8 {
9 private $settings;
10
11 public function __construct(Settings $settings)
12 {
13 $this->settings = $settings;
14 add_action('wp_head', [$this, 'assets'], 3);
15 }
16
17 public function assets()
18 {
19 if ($this->settings->logo) {
20 echo sprintf('<link rel="preload" href="%s" as="image" />', esc_attr($this->settings->logo));
21 echo "\r\n";
22 }
23
24 if ($this->settings->backgroundImage) {
25 $file = wp_get_attachment_url($this->settings->backgroundImage);
26 $type = wp_check_filetype($file);
27
28 if (strpos($type['type'], 'image') !== false && $this->settings->logo !== $this->settings->backgroundImage) {
29 echo sprintf('<link rel="preload" href="%s" as="image" />', esc_attr($file));
30 echo "\r\n";
31 }
32 }
33 }
34 }
35