# age-gate/3.7.3/src/Presentation/Preload.php

Age Gate, version 3.7.3. 35 lines.

- Page: https://pluginprobe.com/plugins/age-gate/3.7.3/code/src/Presentation/Preload.php
- Raw: https://pluginprobe.com/plugins/age-gate/3.7.3/raw/src/Presentation/Preload.php
- Modified: 2025-03-27T08:14:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/age-gate/3.7.3/code/src/Presentation/Preload.php#L10-L20`.

```php
<?php

namespace AgeGate\Presentation;

use AgeGate\Common\Settings;

class Preload
{
    private $settings;

    public function __construct(Settings $settings)
    {
        $this->settings = $settings;
        add_action('wp_head', [$this, 'assets'], 3);
    }

    public function assets()
    {
        if ($this->settings->logo) {
            echo sprintf('<link rel="preload" href="%s" as="image" />', esc_attr($this->settings->logo));
            echo "\r\n";
        }

        if ($this->settings->backgroundImage) {
            $file = wp_get_attachment_url($this->settings->backgroundImage);
            $type = wp_check_filetype($file);

            if (strpos($type['type'], 'image') !== false && $this->settings->logo !== $this->settings->backgroundImage) {
                echo sprintf('<link rel="preload" href="%s" as="image" />', esc_attr($file));
                echo "\r\n";
            }
        }
    }
}

```
