From 6777a247621995e49fc394657852dfa351b3fa18 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:31:31 +0100 Subject: [PATCH] Hide comment form inputs until clicked --- INSTALLATION.md | 1 + functions.php | 5 +++++ includes/functions/comments/_comments_form.php | 9 ++++++--- includes/functions/comments/_comments_threads.php | 1 - js/comments.min.js | 2 +- src/js/comments.js | 13 +++++++++++++ 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/INSTALLATION.md b/INSTALLATION.md index c5ea2669..e8fd8d71 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -729,3 +729,4 @@ define( 'CONSTANT_NAME', value ); | FICTIONEER_SHOW_OAUTH_HASHES | boolean | Whether to show OAuth ID hashes in user profiles (admin only). Default `false`. | FICTIONEER_DISALLOWED_KEY_NOTICE | boolean | Whether to show feedback for rejected comment content. Default `true`. | FICTIONEER_FILTER_STORY_CHAPTERS | boolean | Whether to filter selectable chapters by assigned story. Default `true`. +| FICTIONEER_COLLAPSE_COMMENT_FORM | boolean | Whether hide comment form inputs until the textarea is clicked. Default `true`. diff --git a/functions.php b/functions.php index 0804c08a..e172c03c 100644 --- a/functions.php +++ b/functions.php @@ -134,6 +134,11 @@ if ( ! defined( 'FICTIONEER_FILTER_STORY_CHAPTERS' ) ) { define( 'FICTIONEER_FILTER_STORY_CHAPTERS', true ); } +// Boolean: Only show the full comment form after clicking into it +if ( ! defined( 'FICTIONEER_COLLAPSE_COMMENT_FORM' ) ) { + define( 'FICTIONEER_COLLAPSE_COMMENT_FORM', true ); +} + // ============================================================================= // GLOBAL // ============================================================================= diff --git a/includes/functions/comments/_comments_form.php b/includes/functions/comments/_comments_form.php index 537f96b2..d5c3c69b 100644 --- a/includes/functions/comments/_comments_form.php +++ b/includes/functions/comments/_comments_form.php @@ -64,6 +64,7 @@ if ( ! function_exists( 'fictioneer_change_comment_fields' ) ) { $name_placeholder = $required ? __( 'Name *', 'fictioneer' ) : __( 'Name', 'fictioneer' ); $email_placeholder = $required ? __( 'Email (Gravatar) *', 'fictioneer' ) : __( 'Email (optional, Gravatar)', 'fictioneer' ); $privacy_policy_link = get_option( 'wp_page_for_privacy_policy' ) ? esc_url( get_privacy_policy_url() ) : false; + $hidden = FICTIONEER_COLLAPSE_COMMENT_FORM ? 'hidden' : ''; // Rebuild author field $fields['author'] = '
'; @@ -101,7 +102,7 @@ if ( ! function_exists( 'fictioneer_change_comment_fields' ) ) { * around the author and email fields. */ - $fields['author'] = '