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
|
@ -166,6 +166,24 @@ function duck_behavior_journal_customizer($wp_customize)
|
|||
'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');
|
||||
|
||||
|
@ -311,10 +329,11 @@ function render_article_authors_meta_box($post)
|
|||
function render_article_doi_meta_box($post)
|
||||
{
|
||||
$doi = get_post_meta($post->ID, 'article_doi', true);
|
||||
$doi_prefix = get_theme_mod('doi_prefix', '22.2222/DBJ/');
|
||||
?>
|
||||
<div id="article-doi">
|
||||
<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>
|
||||
</p>
|
||||
</div>
|
||||
|
@ -326,7 +345,8 @@ function render_article_doi_meta_box($post)
|
|||
|
||||
jQuery(document).ready(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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue