windhamdavid 11 years ago
parent
commit
30701b07d1
4 changed files with 169 additions and 89 deletions
  1. 8 23
      404.php
  2. 27 0
      archive.php
  3. 118 54
      inc/template.php
  4. 16 12
      search.php

+ 8 - 23
404.php

@@ -7,31 +7,16 @@
 						<?php the_date(); ?>
 					</div>
 					<?php if ( have_posts() ) : ?>
-
 					<header class="page-header">
-						<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyfourteen' ), get_search_query() ); ?></h1>
-					</header><!-- .page-header -->
-
-						<?php
-							// Start the Loop.
-							while ( have_posts() ) : the_post();
-
-								/*
-								 * Include the post format-specific template for the content. If you want to
-								 * use this in a child theme, then include a file called called content-___.php
-								 * (where ___ is the post format) and that will be used instead.
-								 */
-								get_template_part( 'content', get_post_format() );
-
+						<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'dw' ), get_search_query() ); ?></h1>
+					</header>
+						<?php while ( have_posts() ) : the_post();
+								the_excerpt();
 							endwhile;
-							// Previous/next post navigation.
-							twentyfourteen_paging_nav();
-
-						else :
-							// If no content, include the "No posts found" template.
-							get_template_part( 'content', 'none' );
-
-						endif;
+							dw_paging_nav();
+							else :
+								get_search_form();
+							endif;
 					?>
 				</div>
 			</div>

+ 27 - 0
archive.php

@@ -0,0 +1,27 @@
+<?php get_header(); ?>
+	<div id="container" class="one-column">
+		<div id="content" role="main">
+			<div class="entry-content archive">
+				<?php if ( have_posts() ) : ?>
+				<header class="page-header">
+					<h1 class="page-title"><?php single_month_title(); ?></h1>
+				</header>
+				<?php while ( have_posts() ) : the_post();?>
+				<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'dw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
+				<div class="entry-meta">
+					<div class="date">
+						<?php the_date(); ?>
+					</div>
+				</div>
+				<?php the_excerpt(); ?>
+				<?php endwhile;
+					dw_paging_nav();
+				else :
+					printf( __( 'Nothing Found', 'dw' ));		
+					get_search_form();
+				endif;
+				?>
+			</div>
+		</div>
+	</div>
+<?php get_footer(); ?>

+ 118 - 54
inc/template.php

@@ -1,57 +1,6 @@
 <?php
 
-function dw_get_next_attachment_url() {
-	global $post;
-	$post = get_post( $post );
-	$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
- 
-	foreach ( $attachments as $k => $attachment ) {
-		if ( $attachment->ID == $post->ID )
-			break;
-	}
-	$k++;
-	if ( isset( $attachments[ $k ] ) )
-		return get_attachment_link( $attachments[ $k ]->ID );
-	else
-		return get_permalink( $post->post_parent );
-}
-
-
-function dw_posted_on() {
-	return sprintf( __( '<span %1$s></span> %2$s by %3$s', 'daw' ),
-		'class="meta-prep meta-prep-author"',
-		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
-			get_permalink(),
-			esc_attr( get_the_time() ),
-			get_the_date()
-		),
-		sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', 
-			get_author_posts_url( get_the_author_meta( 'ID' ) ),
-			sprintf( esc_attr__( 'View all posts by %s', 'daw' ), get_the_author() ),
-			get_the_author()
-		)
-	);
-	
-}
-
-function dw_posted_in() {
-	$tag_list = get_the_tag_list( '', ', ', '' );
-	if ( $tag_list ) {
-		$utility_text = __( '%1$s and tagged %2$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'dw' );
-	} else {
-		$utility_text = __( '%1$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'dw' );
-	}
-	return sprintf(
-		$utility_text,
-		get_the_category_list( ', ' ),
-		$tag_list,
-		get_permalink(),
-		the_title_attribute( 'echo=0' ),
-		get_post_comments_feed_link()
-	);	
-}
-
-
+if ( ! function_exists( 'dw_paging_nav' ) ) :
 function dw_paging_nav() {
 	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
 		return;
@@ -95,9 +44,65 @@ function dw_paging_nav() {
 	<?php
 	endif;
 }
+endif;
+
+if ( ! function_exists( 'dw_posted_on' ) ) :
+function dw_posted_on() {
+	return sprintf( __( '<span %1$s></span> %2$s by %3$s', 'daw' ),
+		'class="meta-prep meta-prep-author"',
+		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep">',
+			get_permalink(),
+			esc_attr( get_the_time() ),
+			get_the_date()
+		),
+		sprintf( '</span> <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>', 
+			get_author_posts_url( get_the_author_meta( 'ID' ) ),
+			sprintf( esc_attr__( 'View all posts by %s', 'daw' ), get_the_author() ),
+			get_the_author()
+		)
+	);
+	
+}
+endif;
 
+if ( ! function_exists( 'dw_posted_in' ) ) :
+function dw_posted_in() {
+	$tag_list = get_the_tag_list( '', ', ', '' );
+	if ( $tag_list ) {
+		$utility_text = __( '%1$s and tagged %2$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'dw' );
+	} else {
+		$utility_text = __( '%1$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'dw' );
+	}
+	return sprintf(
+		$utility_text,
+		get_the_category_list( ', ' ),
+		$tag_list,
+		get_permalink(),
+		the_title_attribute( 'echo=0' ),
+		get_post_comments_feed_link()
+	);	
+}
+endif;
 
+if ( ! function_exists( 'dw_get_next_attachment_url' ) ) :
+function dw_get_next_attachment_url() {
+	global $post;
+	$post = get_post( $post );
+	$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
+ 
+	foreach ( $attachments as $k => $attachment ) {
+		if ( $attachment->ID == $post->ID )
+			break;
+	}
+	$k++;
+	if ( isset( $attachments[ $k ] ) )
+		return get_attachment_link( $attachments[ $k ]->ID );
+	else
+		return get_permalink( $post->post_parent );
+}
+endif;
 
+if ( ! function_exists( 'dw_post_nav' ) ) :
 function dw_post_nav() {
 	$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
 	$next     = get_adjacent_post( false, '', false );
@@ -122,13 +127,72 @@ function dw_post_nav() {
 	</nav>
 	<?php
 }
+endif;
 
-
+if ( ! function_exists( 'dw_cat_list' ) ) :
 function dw_cat_list() {
 	return daw_term_list( 'category', ', ', __( 'Posted in %s', 'dw' ), __( 'Also posted in %s', 'daw' ) );
 }
+endif;
 
-
+if ( ! function_exists( 'dw_tag_list' ) ) :
 function dw_tag_list() {
 	return daw_term_list( 'post_tag', ', ', __( 'Tagged %s', 'dw' ), __( 'Also tagged %s', 'daw' ) );
 }
+endif;
+
+if ( ! function_exists( 'dw_term_list' ) ) :
+function daw_term_list( $taxonomy, $glue = ', ', $text = '', $also_text = '' ) {
+	global $wp_query, $post;
+	$current_term = $wp_query->get_queried_object();
+	$terms = wp_get_object_terms( $post->ID, $taxonomy );
+	if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {
+		foreach ( (array) $terms as $key => $term ) {
+			if ( $term->term_id == $current_term->term_id ) {
+				unset( $terms[$key] );
+				break;
+			}
+		}
+		$text = $also_text;
+	}
+	$tlist = array();
+	$rel = 'category' == $taxonomy ? 'rel="category"' : 'rel="tag"';
+	foreach ( (array) $terms as $term ) {
+		$tlist[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( sprintf( __( 'View all posts in %s', 'daw' ), $term->name ) ) . '" ' . $rel . '>' . $term->name . '</a>';
+	}
+	if ( ! empty( $tlist ) )
+		return sprintf( $text, join( $glue, $tlist ) );
+	return '';
+}
+endif;
+
+if ( ! function_exists( 'dw_comment' ) ) :
+function dw_comment( $comment, $args, $depth ) {
+	$GLOBALS ['comment'] = $comment; ?>
+	<?php if ( '' == $comment->comment_type ) : ?>
+	<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, 40 ); ?>
+			<?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>', 'daw' ), get_comment_author_link() ); ?>
+		</div>
+		<?php if ( $comment->comment_approved == '0' ) : ?>
+			<em><?php _e( 'Your comment is awaiting moderation.', 'daw' ); ?></em>
+			<br />
+		<?php endif; ?>
+
+		<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><?php printf( __( '%1$s at %2$s', 'daw' ), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)', 'daw' ),'  ','' ); ?></div>
+
+		<div class="comment-body"><?php comment_text(); ?></div>
+
+		<div class="reply">
+			<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
+		</div>
+	</div>
+
+	<?php else : ?>
+	<li class="post pingback">
+		<p><?php _e( 'Pingback: ', 'daw' ); ?><?php comment_author_link(); ?><?php edit_comment_link ( __('edit', 'daw'), '&nbsp;&nbsp;', '' ); ?></p>
+	<?php endif;
+}
+endif;

+ 16 - 12
search.php

@@ -3,21 +3,25 @@
 		<div id="content" role="main">
 			<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
 				<div class="entry-content">
-					<div class="date">
-						<?php the_date(); ?>
-					</div>
 					<?php if ( have_posts() ) : ?>
-
 					<header class="page-header">
-						<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyfourteen' ), get_search_query() ); ?></h1>
+						<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'dw' ), get_search_query() ); ?></h1>
 					</header>
-						<?php while ( have_posts() ) : the_post();
-								the_excerpt();
-							endwhile;
-								dw_paging_nav();
-							else :
-								get_template_part( 'content', 'none' );
-							endif;
+						<?php while ( have_posts() ) : the_post();?>
+						<h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'dw' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
+						<div class="entry-meta">
+							<div class="date">
+								<?php the_date(); ?>
+							</div>
+						</div>
+
+						<?php the_excerpt(); ?>
+						<?php endwhile;
+							dw_paging_nav();
+						else :
+							printf( __( 'Nothing Found', 'dw' ));		
+							get_search_form();
+						endif;
 						?>
 				</div>
 			</div>