Skip to content

Commit

Permalink
Enhancements: Some html tags are allowed, comment area now toggles fr…
Browse files Browse the repository at this point in the history
…om one line to multi-line
  • Loading branch information
zanematthew committed Aug 18, 2013
1 parent cbb7c03 commit 5c8870f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 6 deletions.
35 changes: 32 additions & 3 deletions inc/css/style.css
Expand Up @@ -44,7 +44,6 @@
}

.inline-comments-container textarea {
letter-spacing: 0.1em;
height: 17px;
min-height: 17px;
width: 80%;
Expand All @@ -55,6 +54,9 @@

.inline-comments-container time {
font: normal 11px/1 helvetica, sans-serif;
background: rgba(255, 235, 205, 0.39);
margin: 10px 0 0;
float: left;
}

.inline-comments-more-container {
Expand Down Expand Up @@ -99,7 +101,7 @@
.inline-comments-content input[type="text"],
.inline-comments-content textarea {
border: 1px solid #BBB;
font: normal 13px/1 Helvetica, sans-serif, arial;
font: normal 13px/1.3em Helvetica, sans-serif, arial;
padding: 6px;
}

Expand All @@ -122,5 +124,32 @@
}

.inline-comments-highlight {
background: #ffff99;
background: #FFFFD7;
}


.inline-comments-annon {}
.inline-comments-administrator {
border-left: 2px solid #F00;
margin-left: -2px;
}

.inline-comments-subscriber {}

.inline-comments-allowed-tags-container {
word-wrap: normal;
margin: 5px 50px 5px 0;
color: #C0C0C0;
font-weight: 300;
text-shadow: 1px 1px 0 #FFF;
}


.inline-comments-content blockquote {
font-style: italic;
border-left: 1px solid #DDD;
float: left;
padding: 3px 10px;
margin: 5px 0;
color: #888;
}
8 changes: 8 additions & 0 deletions inc/js/script.js
Expand Up @@ -115,6 +115,14 @@ jQuery(document).ready(function( $ ){

$( document ).on('click', '.inline-comments-more-handle', function( event ){
event.preventDefault();
if ( $( this ).hasClass('inline-comments-more-open') ){
$( 'a', this ).html('more');
$('#comment').css('height', '0');
} else {
$( 'a', this ).html('less');
$('#comment').css('height', '150');
}
$( this ).toggleClass('inline-comments-more-open');
$('.inline-comments-more-container').toggle();
});
});
33 changes: 30 additions & 3 deletions inc/template-tags.php
Expand Up @@ -75,7 +75,21 @@ function inline_comments_add_comment(){

check_ajax_referer('inline_comments_nonce', 'security');

$comment = trim( wp_kses( $_POST['comment'], '' ) );
$comment = trim(
wp_kses( $_POST['comment'],
array(
'a' => array(
'href' => array(),
'title' => array()
),
'br' => array(),
'em' => array(),
'strong' => array(),
'blockquote' => array(),
'code' => array()
)
)
);

if ( empty( $comment ) ) die();

Expand Down Expand Up @@ -130,10 +144,23 @@ function inline_comments_load_template(){
'number' => 100,
'status' => 'approve',
'order' => 'ASC'
) ); ?>
) );

?>
<div class="inline-comments-container" id="comments_target">
<?php if ( $comments ) : foreach( $comments as $comment) : ?>
<div class="inline-comments-content" id="comment-<?php echo $comment->comment_ID; ?>">
<?php
$user = new WP_User( $comment->user_id );
$class = null;
if ( ! empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role ){
$class = $role;
}
} else {
$class = 'annon';
}
?>
<div class="inline-comments-content inline-comments-<?php echo $class; ?>" id="comment-<?php echo $comment->comment_ID; ?>">
<div class="inline-comments-p">
<?php inline_comments_profile_pic( $comment->comment_author_email ); ?>
<?php print $comment->comment_content; ?><br />
Expand Down
8 changes: 8 additions & 0 deletions readme.txt
Expand Up @@ -59,6 +59,14 @@ At the moment no, later versions might.

== Changelog ==

= 1.2.1 =
* Enhancement: Comment area now toggles from 1 line to multi-line
* Enhancement: The following `html` tags are now allowed `<a href="" title="">`, `<blockquote>`, `<code>`, `<em>`, `<strong>`
* Enhancement: Added additional styling for post authors
* Enhancement: User name links to their website
* Enhancement: You can now share direct links to comments
* Enhancement: Added setting to keep comment box open

= 1.2 =
* Comments now work on Pages (not just posts)
* Adding a setting to keep the 'more' section open
Expand Down
4 changes: 4 additions & 0 deletions templates/comments.php
Expand Up @@ -36,6 +36,10 @@
<textarea placeholder="Press enter to submit comment&#8230;" tabindex="4" id="comment" name="comment" id="inline-comments-textarea" class="inline-comments-auto-expand submit-on-enter"></textarea>
<span class="inline-comments-more-handle"><a href="#">more</a></span>
<div class="inline-comments-more-container" <?php if ( $user_email != null && isset( $keep_open ) && $keep_open != "on" ) : ?>style="display: none;"<?php endif; ?>>
<div class="inline-comments-allowed-tags-container">
Allowed <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes:
<code>&lt;a href="" title=""&gt; &lt;blockquote&gt; &lt;code&gt; &lt;em&gt; &lt;strong&gt;</code>
</div>
<div class="inline-comments-field"><input type="text" tabindex="5" name="user_name" id="inline_comments_user_name" placeholder="<?php print $name; ?>" value="<?php print $user_name; ?>" /></div>
<div class="inline-comments-field"><input type="email" required tabindex="5" name="user_email" id="inline_comments_user_email" placeholder="<?php print $email; ?>" value="<?php print $user_email; ?>" /></div>
<div class="inline-comments-field"><input type="url" required tabindex="6" name="user_url" id="inline_comments_user_url" placeholder="<?php print $website; ?>" value="<?php print $user_website; ?>" /></div>
Expand Down

0 comments on commit 5c8870f

Please sign in to comment.