From ce8a5d25e414b2bc0cb61c0031cf236eae70eb70 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 20 Jun 2024 15:48:14 +0200 Subject: [PATCH] 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. --- README.md | 15 +++++++++++++++ functions.php | 24 ++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..48d6656 --- /dev/null +++ b/README.md @@ -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 + - \ No newline at end of file diff --git a/functions.php b/functions.php index f28450c..9c62f3d 100644 --- a/functions.php +++ b/functions.php @@ -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/'); ?>

- +

@@ -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 = ''; + const doi = generateRandomDOI(doiPrefix); $('input[name="article_doi"]').val(doi); }); });