Skip to content

Commit

Permalink
* Fix PHP notices because of undefined variables in the comment funct…
Browse files Browse the repository at this point in the history
…ion.

* Make the comment markup cleanier and more HTML5 + some styling "fixing"
* The placeholder attributes on the comment fields have been removed. I don't really like them and IMO they just add clutter to the page.
* Clean up spacing issues in the affected functions (and a few more)
  • Loading branch information
tlongren committed Mar 29, 2012
1 parent 0e4740b commit a04f4b5
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 66 deletions.
122 changes: 68 additions & 54 deletions functions.php
Expand Up @@ -13,7 +13,7 @@ function html5press_layout_view() {
// Set html5press version // Set html5press version
define( 'html5press_version', '2.3-rc3' ); define( 'html5press_version', '2.3-rc3' );
function html5press_getinfo( $show = '' ) { function html5press_getinfo( $show = '' ) {
$output = ''; $output = '';


switch ( $show ) { switch ( $show ) {
case 'version' : case 'version' :
Expand Down Expand Up @@ -132,52 +132,66 @@ function html5press_sidebars() {
} }


// Setup comments form // Setup comments form
add_filter('comment_form_default_fields', 'html5press_comments'); add_filter( 'comment_form_default_fields', 'html5press_comments' );

function html5press_comments() { function html5press_comments() {
$req = get_option('require_name_email'); $commenter = wp_get_current_commenter();
$fields = array( $req = get_option( 'require_name_email' );
'author' => '<p><label for="author">' . __( 'Name','html5press' ) . '' . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . $aria_req = ( $req ? " aria-required='true'" : '' );
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' placeholder = "What should we call you?"' . ( $req ? ' required' : '' ) . '/></p>',
$fields = array(
'author' => '<p><label for="author">' . __( 'Name','html5press' ) . '' . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ( $req ? ' required' : '' ) . '/></p>',

'email' => '<p><label for="email">' . __( 'Email','html5press' ) . '' . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ( $req ? ' required' : '' ) . ' /></p>',


'email' => '<p><label for="email">' . __( 'Email','html5press' ) . '' . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . 'url' => '<p><label for="url">' . __( 'Website','html5press' ) . '</label>' .
'<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' placeholder="How can we reach you?"' . ( $req ? ' required' : '' ) . ' /></p>', '<input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>'
);


'url' => '<p><label for="url">' . __( 'Website','html5press' ) . '</label>' .
'<input id="url" name="url" type="url" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" placeholder="Have you got a website?" /></p>'
);
return $fields; return $fields;
} }


// Setup actual comment form field // Setup actual comment form field
add_filter('comment_form_field_comment', 'html5press_commentfield'); add_filter('comment_form_field_comment', 'html5press_commentfield');

function html5press_commentfield() { function html5press_commentfield() {
$commentArea = '<p><label for="comment">' . _x( 'Comment','noun','html5press' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required placeholder="What\'s on your mind?"></textarea></p>'; return '<p><label for="comment">' . _x( 'Comment','noun','html5press' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>';
return $commentArea;
} }


// Show comments the HTML5Press way // Show comments the HTML5Press way
function html5press_list_comments($comment, $args, $depth) { function html5press_list_comments( $comment, $args, $depth ) {

$GLOBALS['comment'] = $comment; ?> $GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='48',$default='<path_to_url>' ); ?>

<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>','html5press'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e( 'Your comment is awaiting moderation.','html5press' ) ?></em>
<br />
<?php endif; ?>

<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><time pubdate datetime="<?php comment_time( 'Y-m-d\TH:i:s' ); ?>" class="timeago"><?php printf( '%1$s at %2$s', get_comment_date(), get_comment_time() ); ?></time></a><?php edit_comment_link(__('(Edit)','html5press'),' ','') ?></div>

<?php comment_text() ?>


<div class="reply"> <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?> <div id="comment-<?php comment_ID(); ?>">
</div>
</div> <footer class="comment-meta">
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 48 ); ?>

<?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>', 'html5press' ), get_comment_author_link() ); ?>
</div> <!-- .comment-author.vcard -->

<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'html5press' ) ?></em>
<br />
<?php endif; ?>

<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
<time pubdate datetime="<?php comment_time( 'Y-m-d\TH:i:s' ); ?>" class="timeago"><?php printf( '%1$s at %2$s', get_comment_date(), get_comment_time() ); ?></time>
</a>
<?php edit_comment_link( __( '(Edit)', 'html5press' ), '', '' ); ?>
</footer> <!-- .comment-meta -->

<div class="comment-content"><?php comment_text(); ?></div>

<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div> <!-- .reply -->
</div> <!-- #comment-<?php comment_ID() ?> -->
<?php <?php
} }


Expand Down Expand Up @@ -251,41 +265,41 @@ function html5press_excerpt_length($length) {
// Link post titles to the link for link post formats // Link post titles to the link for link post formats
add_filter('post_link', 'html5press_link_filter', 10, 2); add_filter('post_link', 'html5press_link_filter', 10, 2);
function html5press_link_filter($link, $post) { function html5press_link_filter($link, $post) {
if (has_post_format('link', $post) && get_post_meta($post->ID, 'LinkFormatURL', true)) { if (has_post_format('link', $post) && get_post_meta($post->ID, 'LinkFormatURL', true)) {
$link = get_post_meta($post->ID, 'LinkFormatURL', true); $link = get_post_meta($post->ID, 'LinkFormatURL', true);
} }
return $link; return $link;
} }


// Add featured post images to RSS feed // Add featured post images to RSS feed
add_filter('the_excerpt_rss', 'html5press_feed_thumbnail'); add_filter('the_excerpt_rss', 'html5press_feed_thumbnail');
add_filter('the_content_feed', 'html5press_feed_thumbnail'); add_filter('the_content_feed', 'html5press_feed_thumbnail');
function html5press_feed_thumbnail($content) { function html5press_feed_thumbnail($content) {
global $post; global $post;
if(has_post_thumbnail($post->ID)) { if(has_post_thumbnail($post->ID)) {
$content = '<p>' . get_the_post_thumbnail($post->ID,array(200,200)) . $content = '<p>' . get_the_post_thumbnail($post->ID,array(200,200)) .
'</p>' . get_the_content(); '</p>' . get_the_content();
} }


return $content; return $content;
} }


// Add rel="lightbox" to images embedded in a post for greater slimbox2 usage // Add rel="lightbox" to images embedded in a post for greater slimbox2 usage
add_filter('the_content', 'html5press_addlightboxrel'); add_filter('the_content', 'html5press_addlightboxrel');
function html5press_addlightboxrel($content) { function html5press_addlightboxrel($content) {
global $post; global $post;
$pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; $pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$replacement = '<a$1href=$2$3.$4$5 rel="lightbox" title="'.$post->post_title.'"$6>'; $replacement = '<a$1href=$2$3.$4$5 rel="lightbox" title="'.$post->post_title.'"$6>';
$content = preg_replace($pattern, $replacement, $content); $content = preg_replace($pattern, $replacement, $content);
return $content; return $content;
} }


// Add rel="lightbox" to gallery images and make a set out of them for next/prev functionality // Add rel="lightbox" to gallery images and make a set out of them for next/prev functionality
add_filter( 'wp_get_attachment_link' , 'html5press_addlightboxrel_to_gallery' ); add_filter( 'wp_get_attachment_link' , 'html5press_addlightboxrel_to_gallery' );
function html5press_addlightboxrel_to_gallery( $attachment_link ) { function html5press_addlightboxrel_to_gallery( $attachment_link ) {
global $post; global $post;
$pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; $pattern = "/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
$replacement = '<a$1href=$2$3.$4$5 rel="lightbox-gallery" title="'.$post->post_title.'"$6>'; $replacement = '<a$1href=$2$3.$4$5 rel="lightbox-gallery" title="'.$post->post_title.'"$6>';
$content = preg_replace($pattern, $replacement, $attachment_link); $content = preg_replace($pattern, $replacement, $attachment_link);
return $content; return $content;
} }
Expand Down Expand Up @@ -449,19 +463,19 @@ function widget($args, $instance) {
// Make links and Twitter names clickable // Make links and Twitter names clickable
if ($clickable) : if ($clickable) :
// Match URLs // Match URLs
$text = preg_replace('`\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))`', '<a href="$0">$0</a>', $text); $text = preg_replace('`\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))`', '<a href="$0">$0</a>', $text);


// Match @name // Match @name
$text = preg_replace('/(@)([a-zA-Z0-9\_]+)/', '@<a href="https://twitter.com/$2">$2</a>', $text); $text = preg_replace('/(@)([a-zA-Z0-9\_]+)/', '@<a href="https://twitter.com/$2">$2</a>', $text);
// Match #hashtags // Match #hashtags
$text = preg_replace('/(#)([a-zA-Z0-9\_]+)/', '#<a href="http://twitter.com/search/%23$2">$2</a>', $text); $text = preg_replace('/(#)([a-zA-Z0-9\_]+)/', '#<a href="http://twitter.com/search/%23$2">$2</a>', $text);
endif; endif;


// Display date/time // Display date/time
if ($datedisplay) $result .= ' if ($datedisplay) $result .= '
<span class="twitter-date"><a href="'. $t->get_permalink() .'"><time datetime="'.$html5time.'" class="timeago" pubdate>' . $time . '</time></a></span>' . ($datebreak ? '<br />' : ' - '); <span class="twitter-date"><a href="'. $t->get_permalink() .'"><time datetime="'.$html5time.'" class="timeago" pubdate>' . $time . '</time></a></span>' . ($datebreak ? '<br />' : ' - ');
// Display message without username prefix // Display message without username prefix
$prefixlen = strlen($username . ": "); $prefixlen = strlen($username . ": ");
$result .= ' $result .= '
<span class="twitter-text">' . substr($text, $prefixlen, strlen($text) - $prefixlen) . '</span>'; <span class="twitter-text">' . substr($text, $prefixlen, strlen($text) - $prefixlen) . '</span>';
Expand Down
35 changes: 23 additions & 12 deletions style.css
Expand Up @@ -11,9 +11,9 @@ License URI: license.txt
*/ */


/** /**
* HTML5 And CSS3 Theme version 2.0 * Jayj HTML5 theme 2.0
* By Jayj.dk * By Jayj.dk
* Download for free at http://jayj.dk/a-free-html5-and-css3-theme/ * Download for free at http://jayj.dk/free-html5-css3-theme/
Released under New BSD License Released under New BSD License
http://www.opensource.org/licenses/bsd-license.php http://www.opensource.org/licenses/bsd-license.php
Expand Down Expand Up @@ -81,14 +81,13 @@ q:before, q:after { content: ""; content: none; }


body { body {
color: #333; color: #333;
font: 16px/28px Georgia, 'Times New Roman', Times, serif; font: 16px/28px Georgia, serif;


/* CSS3 gradient background pattern @credits http://leaverou.me/demos/css3-patterns.html */ /* CSS3 gradient background pattern @credits http://leaverou.me/demos/css3-patterns.html */
background: url(images/bg.png) repeat fixed; /* Image fallback for Firefox and browsers who don't support gradients */ background: url(images/bg.png) repeat fixed; /* Image fallback for Firefox and browsers who don't support gradients */


background-color: #eee; /* Change this to change both stribe colors */ background-color: #eee; /* Change this to change both stribe colors */



background-image: -webkit-gradient(linear, 0 100%, 100% 0, background-image: -webkit-gradient(linear, 0 100%, 100% 0,
color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent), color-stop(.25, rgba(255, 255, 255, .2)), color-stop(.25, transparent),
color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .2)),
Expand Down Expand Up @@ -915,9 +914,11 @@ a#toTop:hover {
padding: 0 4px 5px; padding: 0 4px 5px;
} }
#main #gallery-1 .gallery-item {width:auto !important;} #main #gallery-1 .gallery-item {width:auto !important;}
/* Comments */

/* =Comments /* =Comments
-------------------------------------------------------------- */ -------------------------------------------------------------- */

/* Comments link */ /* Comments link */
.hentry .comments-link a { .hentry .comments-link a {
background: url(images/comment-bubble.png) no-repeat right top; background: url(images/comment-bubble.png) no-repeat right top;
Expand Down Expand Up @@ -946,10 +947,9 @@ a#toTop:hover {
margin: 0; margin: 0;
} }
.commentlist li.comment { .commentlist li.comment {
border-bottom:thin solid #464646; border-bottom: 1px solid #464646;
line-height: 24px;
margin: 0 0 24px 0; margin: 0 0 24px 0;
padding: 0 0 0 56px; padding: 10px 0 10px 56px;
position: relative; position: relative;
} }
/* /*
Expand All @@ -973,9 +973,20 @@ a#toTop:hover {
} }
.commentlist .avatar { .commentlist .avatar {
position: absolute; position: absolute;
top: 4px; top: 7px;
left: 0; left: 5px;
}

.comment-meta {
font-size: 14px;
line-height: 1.6;
margin: 0 0 15px 10px;
} }

.reply {
font-size: 14px;
}

.comment-author { .comment-author {
} }
.comment-author cite { .comment-author cite {
Expand Down Expand Up @@ -1033,10 +1044,10 @@ h3#reply-title {
} }
#respond label { #respond label {
color: #333; color: #333;
font-size: 12px; font-size: 13px;
} }
#respond input { #respond input {
margin: 0 0 9px; margin: 0 0 20px;
width: 95%; width: 95%;
} }
#respond textarea { #respond textarea {
Expand Down

0 comments on commit a04f4b5

Please sign in to comment.