| 1 |
<?php |
| 2 |
$checked = false; |
| 3 |
|
| 4 |
if ($content->getType() === 'term') { |
| 5 |
$checked = get_term_meta($content->getID(), $contentOption, true); |
| 6 |
} else { |
| 7 |
$checked = get_post_meta($content->getID(), $contentOption, true); |
| 8 |
} |
| 9 |
|
| 10 |
$restricted = $settings->type === 'all' ? !$checked : $checked; |
| 11 |
?> |
| 12 |
|
| 13 |
<div class="ag-post-metabox"> |
| 14 |
<h4 class="ag-post-metabox__title" data-age="<?php echo esc_attr($content->getAge()) ?>" data-text-restrict="<?php echo esc_attr($settings->anonymous ? __('Restricted', 'age-gate') : __('Restricted to {0}', 'age-gate')) ?>" data-text-unrestrict="<?php echo esc_attr(__('Unrestricted', 'age-gate')) ?>"> |
| 15 |
<i class="dashicons <?php echo esc_attr($restricted ? 'dashicons-lock' : 'dashicons-unlock') ?>"></i> |
| 16 |
<span class="ag-post-metabox__text"> |
| 17 |
<?php /* translators: 1: Current content age restriction */ ?> |
| 18 |
<?php echo ($restricted ? esc_html($settings->anonymous ? __('Restricted', 'age-gate') : sprintf(__('Restricted to %s', 'age-gate'), $content->getAge())) : esc_html(__('Unrestricted', 'age-gate'))) ?> |
| 19 |
</span> |
| 20 |
<?php if ($settings->multiAge && $setAge && !$settings->anonymous) : ?> |
| 21 |
<button type="button" class="button-link ag-post-metabox__age-toggle"<?php echo (!$restricted ? ' style="display: none;"' : ''); ?>><?php echo esc_html__('Change', 'age-gate' ) ?></button> |
| 22 |
<?php endif; ?> |
| 23 |
</h4> |
| 24 |
|
| 25 |
<?php if ($settings->multiAge && $setAge && !$settings->anonymous) : ?> |
| 26 |
<?php $this->insert('post/meta/age') ?> |
| 27 |
<?php endif; ?> |
| 28 |
|
| 29 |
<?php if ($setRestriction) : ?> |
| 30 |
<div class="ag-post-metabox__item"> |
| 31 |
<?php $this->insert('post/type/' . $settings->type, ['checked' => $checked]) ?> |
| 32 |
</div> |
| 33 |
<?php endif; ?> |
| 34 |
<?php if ($content->getType() === 'post' && !$checked && $content->getRestricted() && $settings->type === 'selected') : ?> |
| 35 |
<?php |
| 36 |
$inherited = collect($content->getTerms())->where( 'age', $content->getAge())->first(); |
| 37 |
if ($inherited) : ?> |
| 38 |
<?php /* translators: 1: Current content age restriction. 2: Term name */ ?> |
| 39 |
<p><?php echo esc_html(sprintf(__('This content is unrestricted, but is inheriting an %1$s restriction from term %1$s', 'age-gate'), $content->getAge(), $inherited->name)) ?></p> |
| 40 |
<?php endif; ?> |
| 41 |
<?php endif; ?> |
| 42 |
<?php wp_nonce_field( 'age_gate_post_edit', '_agn') ?> |
| 43 |
</div> |
| 44 |
|