From 8e54003030288269e0d41ea3b975e0be3966cc21 Mon Sep 17 00:00:00 2001 From: ap7 Date: Tue, 21 May 2019 15:06:48 +0800 Subject: [PATCH] Revised code Improved code structure, @see https://getuikit.com/docs/form. Added correct textdomain for i18n functions. Revised according to WordPress Coding Standards. Set input field width to "uk-form-width-large" for usablity. Updated global border color to ensure visiblity on white background. Recompile site.scss after update. --- comments.php | 109 +++++++++++++++++++++++++++++++-------- scss/_import-mixins.scss | 3 ++ scss/variables.scss | 2 +- 3 files changed, 91 insertions(+), 23 deletions(-) diff --git a/comments.php b/comments.php index 610d08a..9b1826e 100644 --- a/comments.php +++ b/comments.php @@ -24,7 +24,8 @@ + if ( have_comments() ) : + ?>

' . get_the_title() . '' + '' . esc_html( get_the_title() ) . '' ); } else { printf( // WPCS: XSS OK. @@ -49,35 +50,99 @@
    new ThemeWPUGPH_Comments(), - 'style' => 'ol', - 'short_ping' => true, - 'avatar_size' => 50, - ) ); + wp_list_comments( + array( + 'walker' => new ThemeWPUGPH_Comments(), + 'style' => 'ol', + 'short_ping' => true, + 'avatar_size' => 50, + ) + ); ?>
- + // If comments are closed and there are comments, let's leave a little note, shall we? + if ( ! comments_open() ) : + ?>

- 'uk-button uk-button-primary', - 'comment_field' => '

', - 'fields' => array( - 'author' => '

' . ' ' . ( $req ? '*' : '' ) . '

', - 'email' => '', - 'url' => '

' . '

', - ), - 'submit_button' => '', - )); + $field_required = $req ? 'required' : ''; + + // Comment field. + $comment_label = _x( 'Comment', 'noun', 'themewpugph' ); + $comment_field = << + +
+ +
+ +UIKIT3; + + // Author field. + $author_label = __( 'Name', 'themewpugph' ) . ( $req ? '*' : '' ); + $author_value = esc_attr( $commenter['comment_author'] ); + $author_field = << + +
+ +
+ +UIKIT3; + + // Email field. + $email_label = __( 'Email', 'themewpugph' ) . ( $req ? '*' : '' ); + $email_value = esc_attr( $commenter['comment_author_email'] ); + $email_field = << + +
+ +
+ +UIKIT3; + + // URL field. + $url_label = __( 'Website', 'themewpugph' ); + $url_value = esc_attr( $commenter['comment_author_url'] ); + $url_field = << + +
+ +
+ +UIKIT3; + + comment_form( + array( + 'class_form' => 'uk-form-stacked', + 'class_submit' => 'uk-button uk-button-primary', + 'comment_field' => $comment_field, + 'fields' => array( + 'author' => $author_field, + 'email' => $email_field, + 'url' => $url_field, + ), + 'submit_button' => '', + ) + ); ?> diff --git a/scss/_import-mixins.scss b/scss/_import-mixins.scss index e69de29..3ebb93e 100644 --- a/scss/_import-mixins.scss +++ b/scss/_import-mixins.scss @@ -0,0 +1,3 @@ +@mixin hook-form { + border: 1px solid $global-muted-color; +} \ No newline at end of file diff --git a/scss/variables.scss b/scss/variables.scss index 8894677..a26a1b6 100644 --- a/scss/variables.scss +++ b/scss/variables.scss @@ -82,7 +82,7 @@ $global-danger-background: #f0506e !default; // $global-border-width: 1px !default; -$global-border: #e5e5e5 !default; +$global-border: $global-muted-color !default; // // Box-Shadows