windhamdavid 5 years ago
parent
commit
cda0ccc826
5 changed files with 154 additions and 213 deletions
  1. 0 0
      content.php
  2. 12 186
      functions.php
  3. 0 5
      header.php
  4. 134 0
      inc/template.php
  5. 8 22
      search.php

+ 0 - 0
content.php


+ 12 - 186
functions.php

@@ -1,5 +1,12 @@
 <?php
 
+if ( ! function_exists( 'dw_setup' ) ):
+function dw_setup() {
+	require( get_template_directory() . '/inc/template.php' );
+}
+endif; 
+add_action( 'after_setup_theme', 'dw_setup' );
+
 remove_action('wp_head', 'index_rel_link' ); 
 remove_action('wp_head', 'rel_canonical');
 remove_action('wp_head', 'start_post_rel_link', 10, 0 );
@@ -29,194 +36,13 @@ function dw_remove_wp_ver_css_js( $src ) {
 add_filter( 'style_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
 add_filter( 'script_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
 
-
-function the_menus() {
-	register_nav_menus( array( 'main' => __( 'Main' )));
-}
-
-add_action( 'init', 'the_menus' );
-
-
-if ( ! function_exists( 'dw_get_page_number' ) ) :
-function dw_get_page_number() {
-	if ( get_query_var( 'paged' ) )
-		return ' | ' . __( 'Page ' , 'dw' ) . get_query_var( 'paged' );
-}
-endif;
-
-if ( ! function_exists( 'dw_the_page_number' ) ) :
-function dw_the_page_number() {
-	echo dw_get_page_number();
-}
-endif;
-
-if ( ! function_exists( 'dw_excerpt_length' ) ) :
-function dw_excerpt_length( $length ) {
-	return 40;
-}
-endif;
-add_filter( 'excerpt_length', 'dw_excerpt_length' );
-
-if ( ! function_exists( 'daw_excerpt_more' ) ) :
-function dw_excerpt_more( $more ) {
-	return '&nbsp;&hellip; <a href="'. get_permalink() . '">' . __('Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'daw') . '</a>';
-}
-endif;
-add_filter( 'excerpt_more', 'dw_excerpt_more' );
-
-
-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;
-
-// Remove inline styles on gallery shortcode
-if ( ! function_exists( 'dw_remove_gallery_css' ) ) :
-function dw_remove_gallery_css( $css ) {
-	return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css );
-}
-endif;
-add_filter( 'gallery_style', 'dw_remove_gallery_css' );
-
-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 we're viewing a Taxonomy page.. 
-	if ( isset( $current_term->taxonomy ) && $taxonomy == $current_term->taxonomy ) {
-		// Remove the term from display.
-		foreach ( (array) $terms as $key => $term ) {
-			if ( $term->term_id == $current_term->term_id ) {
-				unset( $terms[$key] );
-				break;
-			}
-		}
-		// Change to Also text as we've now removed something from the terms list.
-		$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_widgets_init' ) ) :
-function daw_widgets_init() {
-	// Area Login
-	register_sidebar( array (
-		'name' => 'Login Widget Area',
-		'id' => 'login-widget-area',
-		'description' => __( 'The login widget area' , 'daw' ),
-		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
-		'after_widget' => "</li>",
-		'before_title' => '<h3 class="widget-title">',
-		'after_title' => '</h3>',
-	) );
-}
-endif;
-add_action( 'init', 'daw_widgets_init' );
-
-
-function dw_remove_recent_comments_style() {
-	global $wp_widget_factory;
-	remove_action( 'wp_head', array( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'], 'recent_comments_style' ) );
-}
-add_action( 'widgets_init', 'dw_remove_recent_comments_style' );
-
-function dw_get_next_attachment_url() {
+add_action( 'wp_enqueue_scripts', 'dw_scripts' );
+function dw_scripts() {
 	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>.', 'daw' );
-	} else {
-		$utility_text = __( '%1$s. <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'daw' );
+	wp_enqueue_style( 'style', get_stylesheet_uri() );
+	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
+		wp_enqueue_script( 'comment-reply' );
 	}
-	return sprintf(
-		$utility_text,
-		get_the_category_list( ', ' ),
-		$tag_list,
-		get_permalink(),
-		the_title_attribute( 'echo=0' ),
-		get_post_comments_feed_link()
-	);	
 }
 
 ?>

+ 0 - 5
header.php

@@ -25,11 +25,6 @@
 			</div>
 			<div id="access" role="navigation">
 				 <!-- <?php wp_nav_menu( array( 'menu' => 'main','sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ); ?> -->
-				<div class="subnav">
-				<!-- <?php if($post->post_parent) $children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); else $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); if ($children) { ?>
-				<ul><?php echo $children; ?></ul>
-				<?php } ?> -->
-				</div>
 			</div>
 		</div>
 	</div>

+ 134 - 0
inc/template.php

@@ -0,0 +1,134 @@
+<?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()
+	);	
+}
+
+
+function dw_paging_nav() {
+	if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
+		return;
+	}
+
+	$paged        = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
+	$pagenum_link = html_entity_decode( get_pagenum_link() );
+	$query_args   = array();
+	$url_parts    = explode( '?', $pagenum_link );
+
+	if ( isset( $url_parts[1] ) ) {
+		wp_parse_str( $url_parts[1], $query_args );
+	}
+
+	$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
+	$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
+
+	$format  = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
+	$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
+
+	$links = paginate_links( array(
+		'base'     => $pagenum_link,
+		'format'   => $format,
+		'total'    => $GLOBALS['wp_query']->max_num_pages,
+		'current'  => $paged,
+		'mid_size' => 1,
+		'add_args' => array_map( 'urlencode', $query_args ),
+		'prev_text' => __( '&larr; Previous', 'dw' ),
+		'next_text' => __( 'Next &rarr;', 'dw' ),
+	) );
+
+	if ( $links ) :
+
+	?>
+	<nav class="navigation paging-navigation" role="navigation">
+		<h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'dw' ); ?></h1>
+		<div class="pagination loop-pagination">
+			<?php echo $links; ?>
+		</div>
+	</nav>
+	<?php
+	endif;
+}
+
+
+
+function dw_post_nav() {
+	$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
+	$next     = get_adjacent_post( false, '', false );
+
+	if ( ! $next && ! $previous ) {
+		return;
+	}
+
+	?>
+	<nav class="navigation post-navigation" role="navigation">
+		<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'dw' ); ?></h1>
+		<div class="nav-links">
+			<?php
+			if ( is_attachment() ) :
+				previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'dw' ) );
+			else :
+				previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'dw' ) );
+				next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'dw' ) );
+			endif;
+			?>
+		</div>
+	</nav>
+	<?php
+}
+
+
+function dw_cat_list() {
+	return daw_term_list( 'category', ', ', __( 'Posted in %s', 'dw' ), __( 'Also posted in %s', 'daw' ) );
+}
+
+
+function dw_tag_list() {
+	return daw_term_list( 'post_tag', ', ', __( 'Tagged %s', 'dw' ), __( 'Also tagged %s', 'daw' ) );
+}

+ 8 - 22
search.php

@@ -10,29 +10,15 @@
 
 					<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() );
-
+					</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_template_part( 'content', 'none' );
+							endif;
+						?>
 				</div>
 			</div>
 		</div>