Skip to content

Commit

Permalink
Updated post metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
awmartin committed Apr 2, 2017
1 parent f50ec53 commit e86d6de
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 43 deletions.
52 changes: 26 additions & 26 deletions null.post.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ function NullPostSidebar() {
function NullPostContent($more=false) { function NullPostContent($more=false) {
$content = ""; $content = "";
if ($more) { if ($more) {
$content = get_post_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'null' ) ); $content = getPostContent( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'null' ) );
} else { } else {
$content = get_post_content(); $content = getPostContent();
} }
return $content; return $content;
} }


function get_post_content($more_link_text = null, $stripteaser = false){ function getPostContent($more_link_text = null, $stripteaser = false){
// Emulates the_content() without being stupid. // Emulates the_content() without being stupid.
$content = get_the_content($more_link_text, $stripteaser); $content = get_the_content($more_link_text, $stripteaser);
$content = apply_filters('the_content', $content); $content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content); $content = str_replace(']]>', ']]&gt;', $content);
return $content; return $content;
} }


function NullPostPagination() { function NullPostPagination() {
Expand All @@ -36,7 +36,7 @@ function NullPostPagination() {
} }


function NullReadMoreLink() { function NullReadMoreLink() {
return NullTag('p', NullLink('Read more...', get_permalink()), array('class' => 'read-more')); return NullLink('Read more...', get_permalink());
} }


function NullExcerpt($attr=null) { function NullExcerpt($attr=null) {
Expand Down Expand Up @@ -161,24 +161,24 @@ function NullPostThumbnailUrl($size='thumbnail') {
} }


function NullPostThumbnail($size='medium', $placeholder=false) { function NullPostThumbnail($size='medium', $placeholder=false) {
if (hasThumbnail()) { if (hasThumbnail()) {
$permalink = get_permalink(); $permalink = get_permalink();
$thumbnail = get_the_post_thumbnail(get_the_ID(), $size); // <img /> $thumbnail = get_the_post_thumbnail(get_the_ID(), $size); // <img />


$linkAttr = array('href' => $permalink); $linkAttr = array('href' => $permalink);
$content = NullTag('a', $thumbnail, $linkAttr); $content = NullTag('a', $thumbnail, $linkAttr);


$attr = array('class' => 'thumbnail'); $attr = array('class' => 'thumbnail');
return NullTag('div', $content, $attr); return NullTag('div', $content, $attr);
} else {
if ($placeholder) {
$attr = array('class' => 'thumbnail empty');
return NullTag('div', '&nbsp;', $attr);
} else { } else {
if ($placeholder) { $attr = array('class' => 'thumbnail empty');
$attr = array('class' => 'thumbnail empty'); return NullTag('div', '<!--no thumbnail here-->', $attr);
return NullTag('div', '&nbsp;', $attr);
} else {
$attr = array('class' => 'thumbnail empty');
return NullTag('div', '<!--no thumbnail here-->', $attr);
}
} }
}
} }


function NullPostFormat() { function NullPostFormat() {
Expand Down Expand Up @@ -228,9 +228,9 @@ function NullPostLink($content, $options=array()) {
function NullComments($args=array()) { function NullComments($args=array()) {
ob_start(); ob_start();


// If comments are open or we have at least one comment, load up the comment template if (comments_open()) :
if ( comments_open() || '0' != get_comments_number() )
comments_template(); comments_template();
endif;


$comments = ob_get_contents(); $comments = ob_get_contents();
ob_end_clean(); ob_end_clean();
Expand All @@ -243,6 +243,6 @@ function NullComments($args=array()) {
if (array_key_exists('after', $args)) { if (array_key_exists('after', $args)) {
$after = $args['after']; $after = $args['after'];
} }
return $before.$comments.$after; return $before . $comments . $after;
} }
?> ?>
54 changes: 37 additions & 17 deletions null.postmeta.php
Original file line number Original file line Diff line number Diff line change
@@ -1,24 +1,44 @@
<?php <?php


function get_null_posted_on() { function getNullPostedOn($by='$middot;') {
return sprintf( __( 'Posted on <a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a><span class="byline"> by <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'null' ), $authorId = get_the_author_meta( 'ID' );
esc_url( get_permalink() ), $authorUrl = esc_url(get_author_posts_url($authorId));
esc_attr( get_the_time() ), $datetime = esc_attr(get_the_date('c'));
esc_attr( get_the_date( 'c' ) ), $dateHtml = esc_html(get_the_date());
esc_html( get_the_date() ), $link = esc_url( get_permalink() );
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), $author = get_the_author();
esc_attr( sprintf( __( 'View all posts by %s', 'null' ), get_the_author() ) ),
get_the_author() $posted =
); NullTag('a',
NullTag('time', $dateHtml, array('datetime' => $datetime))
, array('href' => $link, 'rel' => 'bookmark'))
. ' ' . $by . ' '
. NullTag('span',
NullTag('a', $author, array('class' => 'url fn n', 'rel' => 'author', 'href' => $authorUrl))
, array('class' => 'author vcard'));
return $posted;
} }


// Returns HTML that shows "Posted on YYYY-MM-DD by Author" // Returns HTML that shows "Posted on YYYY-MM-DD by Author"
function NullPostedOn() { function NullPostedOn($options=array()) {
return NullTag( $before = '';
'div', if (array_key_exists('before', $options)):
get_null_posted_on(), $before = $options['before'] . ' ';
array('class' => 'post-meta') endif;
);
$after = '';
if (array_key_exists('before', $options)):
$after = ' ' . $options['after'];
endif;

$by = '&middot;';
if (array_key_exists('by', $options)):
$by = ' ' . $options['by'];
endif;

return NullTag('div',
$before . getNullPostedOn($by) . $after,
array('class' => 'post-meta'));
} }


function NullPostTags(){ function NullPostTags(){
Expand Down Expand Up @@ -73,7 +93,7 @@ function NullPostCategories($args=array()) {
if ($html) { if ($html) {
$cats[] = format_category($category, $args); $cats[] = format_category($category, $args);
} else { } else {
$cats[] = $category->name; $cats[] = esc_html($category->name);
} }
} }
} }
Expand Down

0 comments on commit e86d6de

Please sign in to comment.