Kumi
7e94c6758b
Added two new meta boxes for articles: 'File Attachment' and 'Open Access'. The 'File Attachment' box allows users to upload and manage article attachments, while the 'Open Access' box indicates if an article is open access. Updated the single article template to display the abstract, attachment links, and access restrictions based on user login status or open access flag. This enhances content management and access control for articles.
62 lines
No EOL
3.4 KiB
PHP
62 lines
No EOL
3.4 KiB
PHP
<?php get_header(); ?>
|
|
|
|
<!-- Article Content -->
|
|
<section class="container my-5">
|
|
<div class="row">
|
|
<div class="col-lg-8 mx-auto">
|
|
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
|
|
<h1 class="display-4"><?php the_title(); ?></h1>
|
|
<p class="text-muted">
|
|
<?php
|
|
$authors = get_post_meta(get_the_ID(), 'article_authors', true);
|
|
if (!empty($authors)) {
|
|
echo implode('; ', array_map('esc_html', $authors));
|
|
} else {
|
|
the_author();
|
|
}
|
|
?>
|
|
<p class="text-muted">
|
|
<strong>DOI:</strong>
|
|
<a href="#" id="doi-link" data-doi="<?php echo esc_attr(get_post_meta(get_the_ID(), 'article_doi', true)); ?>">
|
|
<?php echo esc_html(get_post_meta(get_the_ID(), 'article_doi', true)); ?>
|
|
</a>
|
|
<span id="doi-copy-message" style="display: none; color: green; margin-left: 10px;"><?php _e('Copied!', 'duck-behavior-journal'); ?></span>
|
|
</p>
|
|
<p class="text-muted">
|
|
<strong>Status:</strong> <?php
|
|
$terms = get_the_terms(get_the_ID(), 'publication_status');
|
|
if (!empty($terms) && !is_wp_error($terms)) {
|
|
$term_list = array();
|
|
foreach ($terms as $term) {
|
|
$term_list[] = $term->name;
|
|
}
|
|
echo implode(', ', $term_list);
|
|
}
|
|
?>
|
|
</p>
|
|
<?php if (has_excerpt()) : ?>
|
|
<p class="text-muted"><strong>Abstract:</strong> <?php echo get_the_excerpt(); ?></p>
|
|
<?php endif; ?>
|
|
<?php
|
|
$attachment_id = get_post_meta(get_the_ID(), 'article_attachment_id', true);
|
|
$attachment_url = $attachment_id ? wp_get_attachment_url($attachment_id) : '';
|
|
$open_access = get_post_meta(get_the_ID(), 'article_open_access', true);
|
|
if ($attachment_url) :
|
|
if ($open_access == '1' || is_user_logged_in()) :
|
|
?>
|
|
<p><a href="<?php echo esc_url($attachment_url); ?>" class="btn btn-primary"><?php _e('Download Full Article', 'duck-behavior-journal'); ?></a></p>
|
|
<?php else : ?>
|
|
<p><strong>Note:</strong> <?php _e('The full paper is available for download for subscribers only.', 'duck-behavior-journal'); ?></p>
|
|
<?php endif;
|
|
endif; ?>
|
|
<hr>
|
|
<?php the_content(); ?>
|
|
<?php endwhile;
|
|
endif; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<script src="<?php echo get_template_directory_uri(); ?>/assets/js/clipboard.js"></script>
|
|
|
|
<?php get_footer(); ?>
|