# age-gate/3.7.3/src/Admin/Post/PostTrait.php

Age Gate, version 3.7.3. 42 lines.

- Page: https://pluginprobe.com/plugins/age-gate/3.7.3/code/src/Admin/Post/PostTrait.php
- Raw: https://pluginprobe.com/plugins/age-gate/3.7.3/raw/src/Admin/Post/PostTrait.php
- Modified: 2022-09-11T18:42: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/Admin/Post/PostTrait.php#L10-L20`.

```php
<?php

namespace AgeGate\Admin\Post;

use Asylum\Utility\Language;
use AgeGate\Common\Settings;
use AgeGate\Common\Immutable\Constants as Immutable;

trait PostTrait
{
    private function restricted(array &$meta)
    {
        $settings = Settings::getInstance();

        $meta['restricted'] = ($settings->restrictionType === 'selected' && $meta['restrict']) || ($settings->restrictionType !== 'selected' && !$meta['bypass']);
        switch ($settings->restrictionType) {
            case 'selected':
                $meta['checked'] = ($meta['restrict']) ? 'checked' : 'unchecked';
                break;

            default:
                $meta['checked'] = ($meta['bypass']) ? 'checked' : 'unchecked';
                break;
        }
    }

    private function getMeta($postId)
    {
        $settings = Settings::getInstance();
        $language = Language::getInstance()->getObjectLanguage($postId);

        $default = $language ? $settings->$language['defaultAge'] ?? $settings->defaultAge : $settings->defaultAge;

        // TODO: Check post default age from Lang in WPML and WP-Multilang
        return [
            'age' => $settings->multiAge ? (get_post_meta($postId, Immutable::META_AGE, true) ?: $default) : $default,
            'bypass' => get_post_meta($postId, Immutable::META_BYPASS, true),
            'restrict' => get_post_meta($postId, Immutable::META_RESTRICT, true),
        ];
    }
}

```
