feat: Add DOI customization support and docs
Introduce DOI prefix customization via the WordPress Customizer, allowing users to set and modify the DOI prefix dynamically. Updated DOI generation to use the customizable prefix. Also, added README.md file documenting the theme's features and custom post types.
This commit is contained in:
parent
1feacfbb39
commit
ce8a5d25e4
2 changed files with 37 additions and 2 deletions
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# Duck Behavior Journal
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
This is the WordPress theme for the Duck Behavior Journal website. It is a custom theme that was built from scratch based on Bootstrap.
|
||||||
|
|
||||||
|
It includes:
|
||||||
|
|
||||||
|
- Custom post type for articles
|
||||||
|
- Field to list authors
|
||||||
|
- Lead author "et al." is listed on the index and archive pages
|
||||||
|
- Field for "DOI" (Digital Object Identifier)
|
||||||
|
- Generator for DOI starting with 22.2222/DBJ
|
||||||
|
- DOI link on the article page
|
||||||
|
-
|
|
@ -166,6 +166,24 @@ function duck_behavior_journal_customizer($wp_customize)
|
||||||
'type' => 'url',
|
'type' => 'url',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DOI Prefix Section
|
||||||
|
$wp_customize->add_section('doi_prefix_section', array(
|
||||||
|
'title' => __('DOI Prefix', 'duck-behavior-journal'),
|
||||||
|
'priority' => 50,
|
||||||
|
));
|
||||||
|
|
||||||
|
$wp_customize->add_setting('doi_prefix', array(
|
||||||
|
'default' => '22.2222/DBJ/',
|
||||||
|
'transport' => 'refresh',
|
||||||
|
));
|
||||||
|
|
||||||
|
$wp_customize->add_control('doi_prefix_control', array(
|
||||||
|
'label' => __('DOI Prefix', 'duck-behavior-journal'),
|
||||||
|
'section' => 'doi_prefix_section',
|
||||||
|
'settings' => 'doi_prefix',
|
||||||
|
'type' => 'text',
|
||||||
|
));
|
||||||
}
|
}
|
||||||
add_action('customize_register', 'duck_behavior_journal_customizer');
|
add_action('customize_register', 'duck_behavior_journal_customizer');
|
||||||
|
|
||||||
|
@ -311,10 +329,11 @@ function render_article_authors_meta_box($post)
|
||||||
function render_article_doi_meta_box($post)
|
function render_article_doi_meta_box($post)
|
||||||
{
|
{
|
||||||
$doi = get_post_meta($post->ID, 'article_doi', true);
|
$doi = get_post_meta($post->ID, 'article_doi', true);
|
||||||
|
$doi_prefix = get_theme_mod('doi_prefix', '22.2222/DBJ/');
|
||||||
?>
|
?>
|
||||||
<div id="article-doi">
|
<div id="article-doi">
|
||||||
<p>
|
<p>
|
||||||
<input type="text" name="article_doi" value="<?php echo esc_attr($doi); ?>" readonly />
|
<input type="text" name="article_doi" value="<?php echo esc_attr($doi); ?>" />
|
||||||
<button type="button" id="generate-doi-button" class="button"><?php _e('Generate DOI', 'duck-behavior-journal'); ?></button>
|
<button type="button" id="generate-doi-button" class="button"><?php _e('Generate DOI', 'duck-behavior-journal'); ?></button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -326,7 +345,8 @@ function render_article_doi_meta_box($post)
|
||||||
|
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
$('#generate-doi-button').on('click', function() {
|
$('#generate-doi-button').on('click', function() {
|
||||||
const doi = generateRandomDOI('22.2222/DBJ/');
|
const doiPrefix = '<?php echo esc_js($doi_prefix); ?>';
|
||||||
|
const doi = generateRandomDOI(doiPrefix);
|
||||||
$('input[name="article_doi"]').val(doi);
|
$('input[name="article_doi"]').val(doi);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue