'; // Define the email field with Bootstrap styling and localized placeholder. $author_personal_blog_comment_field['email'] = ''; // Define the URL field with Bootstrap styling and localized placeholder. $author_personal_blog_comment_field['url'] = ''; return $author_personal_blog_comment_field; } /** * Customizes the default comment form settings. * * Modifies the comment textarea, submit button, and reply title, and adds a nonce field * for security. * * @param array $default_form The default comment form settings. * @return array The modified comment form settings. */ add_filter( 'comment_form_defaults', 'author_personal_blog_comment_default_form' ); function author_personal_blog_comment_default_form( $default_form ) { // Customize the comment textarea with Bootstrap styling and placeholder. $default_form['comment_field'] = ''; // Customize the submit button with Bootstrap styling. $default_form['submit_button'] = ''; // Add a nonce field for CSRF protection. $default_form['comment_notes_before'] = $default_form['comment_notes_before'] . wp_nonce_field( 'comment_form_nonce', 'comment_form_nonce', true, false ); // Set the reply title with localized text. $default_form['title_reply'] = esc_attr__( 'Leave A Comment', 'author-personal-blog' ); // Wrap the reply title in h4 tags. $default_form['title_reply_before'] = '

'; $default_form['title_reply_after'] = '

'; return $default_form; } /** * Reorders the comment form fields. * * Ensures fields are displayed in the order: author, email, URL (if not WooCommerce), * comment, cookies. * * @param array $fields The default comment form fields. * @return array The reordered comment form fields. */ add_filter( 'comment_form_fields', 'author_personal_blog_comment_form_structure' ); function author_personal_blog_comment_form_structure( $fields ) { // Initialize an array to store reordered fields. $reordered_fields = array(); // Add author field. $reordered_fields['author'] = $fields['author']; // Add email field. $reordered_fields['email'] = $fields['email']; // Conditionally add URL field if not on a WooCommerce page. if ( function_exists( 'is_woocommerce' ) && is_callable( 'is_woocommerce' ) && ! is_woocommerce() ) { $reordered_fields['url'] = $fields['url']; } // Add comment field. $reordered_fields['comment'] = $fields['comment']; // Add cookies consent field. $reordered_fields['cookies'] = $fields['cookies']; return $reordered_fields; } /** * Customizes the display of individual comments and pingbacks. * * Used as a callback by wp_list_comments() to render each comment with a custom layout, * including avatar, author, date, content, and reply link. * * @since Shape 1.0 * @param WP_Comment $comment The comment object. * @param array $args An array of arguments for comment display. * @param int $depth The depth of the comment in the thread. */ if ( ! function_exists( 'author_personal_blog_comment_list' ) ) : function author_personal_blog_comment_list( $comment, $args, $depth ) { // Determine the HTML tag based on style (div or li). $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; // Set the add_below value for reply links. $add_below = ( 'div' === $args['style'] ) ? 'comment' : 'div-comment'; ?> < id="comment-">
comment_approved == '0' ) : ?>

$depth, 'max_depth' => $args['max_depth'], 'before' => '
', 'after' => '
', ) ) ); ?>