summaryrefslogtreecommitdiff
path: root/inc/custom-comments.php
diff options
context:
space:
mode:
authorMax2018-10-15 23:46:42 +0200
committerMax2018-10-15 23:46:42 +0200
commit00c9709fd9763542e848f6278db8ba26af5c9886 (patch)
tree92cb1c1ee4c467118e1e5a4c7e233d3feac6efa8 /inc/custom-comments.php
downloadfuselkoenig_de-00c9709fd9763542e848f6278db8ba26af5c9886.tar.gz
Initial commit.
Diffstat (limited to 'inc/custom-comments.php')
-rw-r--r--inc/custom-comments.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/inc/custom-comments.php b/inc/custom-comments.php
new file mode 100644
index 0000000..c4aa7c7
--- /dev/null
+++ b/inc/custom-comments.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Comment layout.
+ *
+ * @package understrap
+ */
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit; // Exit if accessed directly.
+}
+
+// Comments form.
+add_filter( 'comment_form_default_fields', 'understrap_bootstrap_comment_form_fields' );
+
+/**
+ * Creates the comments form.
+ *
+ * @param string $fields Form fields.
+ *
+ * @return array
+ */
+
+if ( ! function_exists( 'understrap_bootstrap_comment_form_fields' ) ) {
+
+ function understrap_bootstrap_comment_form_fields( $fields ) {
+ $commenter = wp_get_current_commenter();
+ $req = get_option( 'require_name_email' );
+ $aria_req = ( $req ? " aria-required='true'" : '' );
+ $html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0;
+ $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
+ $fields = array(
+ 'author' => '<div class="form-group comment-form-author textfield-box"><label for="author">' . __( 'Name',
+ 'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
+ '<input class="form-control" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . '></div>',
+ 'email' => '<div class="form-group comment-form-email textfield-box"><label for="email">' . __( 'E-Mail',
+ 'understrap' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
+ '<input class="form-control" id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . '></div>',
+ 'url' => '<div class="form-group comment-form-url textfield-box"><label for="url">' . __( 'Webseite',
+ 'understrap' ) . '</label> ' .
+ '<input class="form-control" id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30"></div>',
+ 'cookies' => '<div class="form-group form-check comment-form-cookies-consent"><input class="form-check-input" id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' /> ' .
+ '<label class="form-check-label" for="wp-comment-cookies-consent">' . __( 'Save my name, email, and website in this browser for the next time I comment', 'understrap' ) . '</label></div>',
+ );
+
+ return $fields;
+ }
+} // endif function_exists( 'understrap_bootstrap_comment_form_fields' )
+
+add_filter( 'comment_form_defaults', 'understrap_bootstrap_comment_form' );
+
+/**
+ * Builds the form.
+ *
+ * @param string $args Arguments for form's fields.
+ *
+ * @return mixed
+ */
+
+if ( ! function_exists( 'understrap_bootstrap_comment_form' ) ) {
+
+ function understrap_bootstrap_comment_form( $args ) {
+ $args['comment_field'] = '<div class="form-group comment-form-comment">
+ <div class="textfield-box">
+ <label for="comment">' . _x( 'Kommentar', 'noun', 'understrap' ) . ( ' <span class="required">*</span>' ) . '</label>
+ <textarea class="form-control" id="comment" name="comment" aria-required="true" cols="45" rows="8"></textarea>
+ </div>
+ </div>';
+ $args['class_submit'] = 'btn btn-secondary'; // since WP 4.1.
+ return $args;
+ }
+} // endif function_exists( 'understrap_bootstrap_comment_form' )