<?php if (defined('AAM_KEY')) { ?>
    <div class="aam-feature" id="post-content">
        <?php if (!defined('AAM_PLUS_PACKAGE')) { ?>
            <div class="row">
                <div class="col-xs-12">
                    <p class="aam-notification">
                        <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('You are allowed to manage access to unlimited number of posts, pages or custom post types but only on role, user or visitor levels. Consider to purchase %s[AAM Plus Package]%s extension to have the ability to also manage access to categories and custom taxonomies or to define the default access to all posts, pages or custom post types. For more information about this functionality check %sWhat is a WordPress post%s.', 'b'), '<a href="https://aamplugin.com/help/aam-plus-package-extension" target="_blank">', '</a>', '<a href="https://aamplugin.com/help/what-is-a-wordpress-post" target="_blank">', '</a>'); ?>
                    </p>
                </div>
            </div>
        <?php } else { ?>
            <div class="row">
                <div class="col-xs-12">
                    <p class="aam-info">
                        <?php echo sprintf(__('Manage access to posts, pages and custom post types. For more information about this functionality check %sHow to manage access to the WordPress content%s article.'), '<a href="https://aamplugin.com/help/how-to-manage-access-to-the-wordpress-content" target="_blank">', '</a>'); ?>
                    </p>
                </div>
            </div>
        <?php } ?>

        <?php if (defined('AAM_PLUS_PACKAGE') || AAM_Backend_Subject::getInstance()->getUID() != AAM_Core_Subject_Default::UID) { ?>
            <?php $current = $this->getCurrentObject();?>

            <div class="aam-post-breadcrumb">
                <a href="#" data-level="root"><i class="icon-home"></i> <?php echo __('Root', AAM_KEY); ?></a>
                <?php if ($current->id) { ?>
                    <span>
                        <i class="icon-angle-double-right"></i>
                        <?php echo ($current->type == 'post' ? $current->post->post_title : $current->term->name); ?>
                    </span>
                <?php } ?>
            </div>

            <div class="aam-overwrite hidden" id="post-overwritten">
                <span><i class="icon-check"></i> <?php echo __('Settings are customized', AAM_KEY); ?></span>
                <span><a href="#" id="post-reset" class="btn btn-xs btn-primary"><?php echo __('Reset To Default', AAM_KEY); ?></a></span>
            </div>
        
            <?php if ($current->id) { ?>
                <input type="hidden" id="load-post-object" value="<?php echo ($current->type == 'post' ? $current->post->ID : $current->term->term_id); ?>" />
                <input type="hidden" id="load-post-object-type" value="<?php echo $current->type; ?>" />
            <?php } ?>

            <div class="aam-container">
                <table id="post-list" class="table table-striped table-bordered">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Link</th>
                            <th width="5%">&nbsp;</th>
                            <th width="75%"><?php echo __('Title', AAM_KEY); ?></th>
                            <th><?php echo __('Actions', AAM_KEY); ?></th>
                        </tr>
                    </thead>
                    <tbody></tbody>
                </table>

                <div class="aam-slide-form aam-access-form" data-type="type">
                    <a href="#" class="btn btn-xs btn-primary post-back btn-right">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                    <?php echo apply_filters('aam-post-type-ui-filter', AAM_Backend_View::getInstance()->loadPartial('post-type.phtml')); ?>
                    <a href="#" class="btn btn-xs btn-primary post-back">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                </div>

                <div class="aam-slide-form aam-access-form" data-type="term">
                    <a href="#" class="btn btn-xs btn-primary post-back btn-right">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                    <?php echo apply_filters('aam-term-type-ui-filter', AAM_Backend_View::getInstance()->loadPartial('term-type.phtml')); ?>
                    <a href="#" class="btn btn-xs btn-primary post-back">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                </div>

                <div class="aam-slide-form aam-access-form" data-type="post">
                    <a href="#" class="btn btn-xs btn-primary post-back btn-right">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                    <table class="table table-striped table-bordered">
                        <tbody>
                            <?php $frontend = $this->getAccessOptionList('frontend'); ?>
                            <?php $backend = $this->getAccessOptionList('backend'); ?>
                            
                            <?php if (count($frontend) && AAM_Core_Config::get('frontend-access-control', true)) { ?>
                                <tr>
                                    <td colspan="2" class="aam-table-group">
                                        <i class="icon-doc-text-inv"></i> <strong><?php echo __('Frontend', AAM_KEY); ?></strong>
                                    </td>
                                </tr>

                                <?php foreach($frontend as $option => $data) { ?>
                                <tr>
                                    <td width="90%">
                                        <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
                                        <?php if (!empty($data['sub'])) { ?>
                                            <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
                                        <?php } ?>
                                        <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
                                    </td>
                                    <td>
                                        <div class="aam-row-actions">
                                            <i class="aam-row-action text-muted icon-check-empty" data-property="frontend.<?php echo $option; ?>"></i>
                                        </div>
                                    </td>
                                </tr>
                                <?php } ?>
                            <?php } ?>

                            <?php if (count($backend) && AAM_Core_Config::get('backend-access-control', true)) { ?>
                                <tr class="aam-backend-post-access">
                                    <td colspan="2" class="aam-table-group">
                                        <i class="icon-doc-text-inv"></i> <strong><?php echo __('Backend', AAM_KEY); ?></strong>
                                    </td>
                                </tr>
                                
                                <?php foreach($backend as $option => $data) { ?>
                                <tr class="aam-backend-post-access">
                                    <td width="90%">
                                        <strong class="aam-block aam-highlight text-uppercase"><?php echo $data['title']; ?></strong>
                                        <?php if (!empty($data['sub'])) { ?>
                                            <small><?php echo $data['sub']; ?>: <b id="<?php echo $data['preview']; ?>" data-ref="<?php echo $data['option']; ?>" class="option-preview">...</b> <a href="#modal-<?php echo str_replace('.', '-', $data['option']); ?>" data-toggle="modal" class="advanced-post-option" data-ref="<?php echo $data['option']; ?>" data-preview="#<?php echo $data['preview']; ?>"><?php echo __('change', AAM_KEY); ?></a></small>
                                        <?php } ?>
                                        <p class="aam-hint" data-dynamic-post-label="<?php echo $data['descr']; ?>"></p>
                                    </td>
                                    <td>
                                        <div class="aam-row-actions">
                                            <i class="aam-row-action text-muted icon-check-empty" data-property="backend.<?php echo $option; ?>"></i>
                                        </div>
                                    </td>
                                </tr>
                                <?php } ?>
                            <?php } ?>
                        </tbody>
                    </table>

                    <a href="#" class="btn btn-xs btn-primary post-back">&Lt; <?php echo __('Go Back', AAM_KEY); ?></a>
                </div>
            </div>
        <?php } ?>
                
        <?php require dirname(__FILE__) . '/../partial/post-advanced-settings.phtml'; ?>
    </div>
<?php }