Ticket #10910: test-on-default-theme.diff

File test-on-default-theme.diff, 4.4 KB (added by beaulebens, 3 years ago)

Implements the other attached patch to demonstrate some flexibility with the new comments form function on the default theme.

  • wp-content/themes/default/comments.php

     
    4545        <?php endif; ?> 
    4646<?php endif; ?> 
    4747 
     48<?php 
    4849 
    49 <?php if ( comments_open() ) : ?> 
     50function hookable_comments_log_in() { 
     51        if ( !is_user_logged_in() ) { 
     52                echo "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>"; 
     53                echo '<p><a href="#" onclick="javascript:jQuery(\'#log-in-form\').slideToggle(); return false;">Log in now</a> to save some time</p>'; 
     54                echo '<div id="log-in-form">' . wp_login_form( get_permalink() . '#respond' ) . '</div>'; 
     55                echo '<script type="text/javascript">jQuery(\'#log-in-form\').slideUp();</script>'; 
     56        } 
     57} 
    5058 
    51 <div id="respond"> 
     59function hookable_comments_please_log_in( $str ) { 
     60        $str = '<p>You must be logged in to comment.</p>' . wp_login_form( get_permalink() . '#respond' ); 
     61        if ( get_option( 'users_can_register' ) ) 
     62                $str .= '<p>' . sprintf( __( 'Not a member yet? <a href="%1$s">Register now</a>.' ), site_url( 'wp-register.php' ) ) . '</p>'; 
     63        return $str; 
     64} 
    5265 
    53 <h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3> 
     66function hookable_comments_logged_in( $str, $commenter, $identity ) { 
     67        if ( !empty( $commenter['comment_author_email'] ) ) { 
     68                $str = '<div style="border: dashed 1px #808080; padding: 3px 3px 3px 10px; background: #ebebeb; margin-right: -5px;"> 
     69                                        <div style="float: right;">' . get_avatar( $commenter['comment_author_email'], 24 ) . '</div> 
     70                                        <p>Howdy, <a href="' . admin_url( 'profile.php' ) . '">' . $identity . '</a>! You can comment below, or <a href="' . wp_logout_url( get_permalink() ) . '">logout</a> if you like.</p> 
     71                                </div>'; 
     72        } 
     73        return $str; 
     74} 
    5475 
    55 <div class="cancel-comment-reply"> 
    56         <small><?php cancel_comment_reply_link(); ?></small> 
    57 </div> 
     76function hookable_comments_extra_field( $fields ) { 
     77        $fields['twitter'] = '<p><input type="text" name="twitter" id="twitter" value="@" size="22" tabindex="4" /> <label for="twitter"><small>Twitter username (optional)</small></label></p>'; 
     78        return $fields; 
     79} 
    5880 
    59 <?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?> 
    60 <p>You must be <a href="<?php echo wp_login_url( get_permalink() ); ?>">logged in</a> to post a comment.</p> 
    61 <?php else : ?> 
     81add_action( 'comment_form_before', 'hookable_comments_log_in' ); 
     82add_filter( 'comment_form_must_log_in', 'hookable_comments_please_log_in' ); 
     83add_filter( 'comment_form_logged_in', 'hookable_comments_logged_in', 10, 3 ); 
     84add_filter( 'comment_form_default_fields', 'hookable_comments_extra_field' ); 
    6285 
    63 <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> 
     86?> 
    6487 
    65 <?php if ( is_user_logged_in() ) : ?> 
    66  
    67 <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p> 
    68  
    69 <?php else : ?> 
    70  
    71 <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> /> 
    72 <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p> 
    73  
    74 <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> /> 
    75 <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p> 
    76  
    77 <p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" /> 
    78 <label for="url"><small>Website</small></label></p> 
    79  
    80 <?php endif; ?> 
    81  
    82 <!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>--> 
    83  
    84 <p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p> 
    85  
    86 <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /> 
    87 <?php comment_id_fields(); ?> 
    88 </p> 
    89 <?php do_action('comment_form', $post->ID); ?> 
    90  
    91 </form> 
    92  
    93 <?php endif; // If registration required and not logged in ?> 
    94 </div> 
    95  
    96 <?php endif; // if you delete this the sky will fall on your head ?> 
     88<?php comment_form(); ?>