Add theme wrapper, re-organize template files
- Implement scribu’s Theme Wrapper (see base.php) - Move templates, comments.php, and searchform.php to templates/ folder - Rename loop- files to content- - Remove all hooks except roots_head and roots_footer - Use templates/page-header.php for page titles - Use head.php for everything in <head>
This commit is contained in:
99
templates/comments.php
Normal file
99
templates/comments.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php function roots_comment($comment, $args, $depth) {
|
||||
$GLOBALS['comment'] = $comment; ?>
|
||||
<li <?php comment_class(); ?>>
|
||||
<article id="comment-<?php comment_ID(); ?>">
|
||||
<header class="comment-author vcard">
|
||||
<?php echo get_avatar($comment, $size = '32'); ?>
|
||||
<?php printf(__('<cite class="fn">%s</cite>', 'roots'), get_comment_author_link()); ?>
|
||||
<time datetime="<?php echo comment_date('c'); ?>"><a href="<?php echo htmlspecialchars(get_comment_link($comment->comment_ID)); ?>"><?php printf(__('%1$s', 'roots'), get_comment_date(), get_comment_time()); ?></a></time>
|
||||
<?php edit_comment_link(__('(Edit)', 'roots'), '', ''); ?>
|
||||
</header>
|
||||
|
||||
<?php if ($comment->comment_approved == '0') { ?>
|
||||
<div class="alert alert-block fade in">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<p><?php _e('Your comment is awaiting moderation.', 'roots'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<section class="comment">
|
||||
<?php comment_text() ?>
|
||||
</section>
|
||||
|
||||
<?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth']))); ?>
|
||||
|
||||
</article>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (post_password_required()) { ?>
|
||||
<section id="comments">
|
||||
<div class="alert alert-block fade in">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<p><?php _e('This post is password protected. Enter the password to view comments.', 'roots'); ?></p>
|
||||
</div>
|
||||
</section><!-- /#comments -->
|
||||
<?php
|
||||
return;
|
||||
} ?>
|
||||
|
||||
<?php if (have_comments()) { ?>
|
||||
<section id="comments">
|
||||
<h3><?php printf(_n('One Response to “%2$s”', '%1$s Responses to “%2$s”', get_comments_number(), 'roots'), number_format_i18n(get_comments_number()), get_the_title()); ?></h3>
|
||||
|
||||
<ol class="commentlist">
|
||||
<?php wp_list_comments(array('callback' => 'roots_comment')); ?>
|
||||
</ol>
|
||||
|
||||
<?php if (get_comment_pages_count() > 1 && get_option('page_comments')) { // are there comments to navigate through ?>
|
||||
<nav id="comments-nav" class="pager">
|
||||
<div class="previous"><?php previous_comments_link(__('← Older comments', 'roots')); ?></div>
|
||||
<div class="next"><?php next_comments_link(__('Newer comments →', 'roots')); ?></div>
|
||||
</nav>
|
||||
|
||||
<?php } // check for comment navigation ?>
|
||||
|
||||
<?php if (!comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) { ?>
|
||||
<div class="alert alert-block fade in">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<p><?php _e('Comments are closed.', 'roots'); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</section><!-- /#comments -->
|
||||
<?php } ?>
|
||||
|
||||
<?php if (!have_comments() && !comments_open() && !is_page() && post_type_supports(get_post_type(), 'comments')) { ?>
|
||||
<section id="comments">
|
||||
<div class="alert alert-block fade in">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<p><?php _e('Comments are closed.', 'roots'); ?></p>
|
||||
</div>
|
||||
</section><!-- /#comments -->
|
||||
<?php } ?>
|
||||
|
||||
<?php if (comments_open()) { ?>
|
||||
<section id="respond">
|
||||
<h3><?php comment_form_title(__('Leave a Reply', 'roots'), __('Leave a Reply to %s', 'roots')); ?></h3>
|
||||
<p class="cancel-comment-reply"><?php cancel_comment_reply_link(); ?></p>
|
||||
<?php if (get_option('comment_registration') && !is_user_logged_in()) { ?>
|
||||
<p><?php printf(__('You must be <a href="%s">logged in</a> to post a comment.', 'roots'), wp_login_url(get_permalink())); ?></p>
|
||||
<?php } else { ?>
|
||||
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
|
||||
<?php if (is_user_logged_in()) { ?>
|
||||
<p><?php printf(__('Logged in as <a href="%s/wp-admin/profile.php">%s</a>.', 'roots'), get_option('siteurl'), $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php __('Log out of this account', 'roots'); ?>"><?php _e('Log out »', 'roots'); ?></a></p>
|
||||
<?php } else { ?>
|
||||
<label for="author"><?php _e('Name', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
|
||||
<input type="text" class="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?>>
|
||||
<label for="email"><?php _e('Email (will not be published)', 'roots'); if ($req) _e(' (required)', 'roots'); ?></label>
|
||||
<input type="email" class="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?>>
|
||||
<label for="url"><?php _e('Website', 'roots'); ?></label>
|
||||
<input type="url" class="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3">
|
||||
<?php } ?>
|
||||
<label for="comment"><?php _e('Comment', 'roots'); ?></label>
|
||||
<textarea name="comment" id="comment" class="input-xlarge" tabindex="4"></textarea>
|
||||
<p><input name="submit" class="btn btn-primary" type="submit" id="submit" tabindex="5" value="<?php _e('Submit Comment', 'roots'); ?>"></p>
|
||||
<?php comment_id_fields(); ?>
|
||||
<?php do_action('comment_form', $post->ID); ?>
|
||||
</form>
|
||||
<?php } // if registration required and not logged in ?>
|
||||
</section><!-- /#respond -->
|
||||
<?php } ?>
|
||||
4
templates/content-page.php
Normal file
4
templates/content-page.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<?php the_content(); ?>
|
||||
<?php wp_link_pages(array('before' => '<nav class="pagination">', 'after' => '</nav>')); ?>
|
||||
<?php endwhile; ?>
|
||||
16
templates/content-single.php
Normal file
16
templates/content-single.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<article <?php post_class() ?> id="post-<?php the_ID(); ?>">
|
||||
<header>
|
||||
<h1 class="entry-title"><?php the_title(); ?></h1>
|
||||
<?php roots_entry_meta(); ?>
|
||||
</header>
|
||||
<div class="entry-content">
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
<footer>
|
||||
<?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
|
||||
<?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
|
||||
</footer>
|
||||
<?php comments_template('/templates/comments.php'); ?>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
29
templates/content.php
Normal file
29
templates/content.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php if (!have_posts()) { ?>
|
||||
<div class="alert alert-block fade in">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
|
||||
</div>
|
||||
<?php get_search_form(); ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php while (have_posts()) : the_post(); ?>
|
||||
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
|
||||
<header>
|
||||
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
|
||||
<?php roots_entry_meta(); ?>
|
||||
</header>
|
||||
<div class="entry-content">
|
||||
<?php the_excerpt(); ?>
|
||||
</div>
|
||||
<footer>
|
||||
<?php the_tags('<ul class="entry-tags"><li>','</li><li>','</li></ul>'); ?>
|
||||
</footer>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
|
||||
<?php if ($wp_query->max_num_pages > 1) { ?>
|
||||
<nav id="post-nav" class="pager">
|
||||
<div class="previous"><?php next_posts_link(__('← Older posts', 'roots')); ?></div>
|
||||
<div class="next"><?php previous_posts_link(__('Newer posts →', 'roots')); ?></div>
|
||||
</nav>
|
||||
<?php } ?>
|
||||
7
templates/footer.php
Normal file
7
templates/footer.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<footer id="content-info" class="container" role="contentinfo">
|
||||
<?php dynamic_sidebar('sidebar-footer'); ?>
|
||||
<p>© <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p>
|
||||
</footer>
|
||||
|
||||
<?php wp_footer(); ?>
|
||||
<?php roots_footer(); ?>
|
||||
18
templates/head.php
Normal file
18
templates/head.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" <?php language_attributes(); ?>> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" <?php language_attributes(); ?>> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9" <?php language_attributes(); ?>> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" <?php language_attributes(); ?>> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?php wp_title('|', true, 'right'); bloginfo('name'); ?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/modernizr-2.6.1.min.js"></script>
|
||||
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
|
||||
<script>window.jQuery || document.write('<script src="<?php echo get_template_directory_uri(); ?>/js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
|
||||
|
||||
<?php wp_head(); ?>
|
||||
<?php roots_head(); ?>
|
||||
</head>
|
||||
@@ -1,8 +1,7 @@
|
||||
<header id="banner" class="navbar navbar-fixed-top" role="banner">
|
||||
<?php roots_header_inside(); ?>
|
||||
<div class="navbar-inner">
|
||||
<div class="<?php echo WRAP_CLASSES; ?>">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<header id="banner" role="banner">
|
||||
<?php roots_header_inside(); ?>
|
||||
<div class="<?php echo WRAP_CLASSES; ?>">
|
||||
<a class="brand" href="<?php echo home_url(); ?>/">
|
||||
<?php bloginfo('name'); ?>
|
||||
</a>
|
||||
<div class="container">
|
||||
<a class="brand" href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a>
|
||||
<nav id="nav-main" role="navigation">
|
||||
<?php wp_nav_menu(array('theme_location' => 'primary_navigation', 'menu_class' => 'nav nav-pills')); ?>
|
||||
</nav>
|
||||
38
templates/page-header.php
Normal file
38
templates/page-header.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
<?php
|
||||
if (is_home()) {
|
||||
if (get_option('page_for_posts', true)) {
|
||||
echo get_the_title(get_option('page_for_posts', true));
|
||||
} else {
|
||||
_e('Latest Posts', 'roots');
|
||||
}
|
||||
} elseif (is_archive()) {
|
||||
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
||||
if ($term) {
|
||||
echo $term->name;
|
||||
} elseif (is_post_type_archive()) {
|
||||
echo get_queried_object()->labels->name;
|
||||
} elseif (is_day()) {
|
||||
printf(__('Daily Archives: %s', 'roots'), get_the_date());
|
||||
} elseif (is_month()) {
|
||||
printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
|
||||
} elseif (is_year()) {
|
||||
printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
|
||||
} elseif (is_author()) {
|
||||
global $post;
|
||||
$author_id = $post->post_author;
|
||||
printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
|
||||
} else {
|
||||
single_cat_title();
|
||||
}
|
||||
} elseif (is_search()) {
|
||||
printf(__('Search Results for %s', 'roots'), get_search_query());
|
||||
} elseif (is_404()) {
|
||||
_e('File Not Found', 'roots');
|
||||
} else {
|
||||
the_title();
|
||||
}
|
||||
?>
|
||||
</h1>
|
||||
</div>
|
||||
5
templates/searchform.php
Normal file
5
templates/searchform.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<form role="search" method="get" id="searchform" class="form-search" action="<?php echo home_url('/'); ?>">
|
||||
<label class="hide" for="s"><?php _e('Search for:', 'roots'); ?></label>
|
||||
<input type="text" value="" name="s" id="s" class="search-query" placeholder="<?php _e('Search', 'roots'); ?> <?php bloginfo('name'); ?>">
|
||||
<input type="submit" id="searchsubmit" value="<?php _e('Search', 'roots'); ?>" class="btn">
|
||||
</form>
|
||||
1
templates/sidebar.php
Normal file
1
templates/sidebar.php
Normal file
@@ -0,0 +1 @@
|
||||
<?php dynamic_sidebar('sidebar-primary'); ?>
|
||||
Reference in New Issue
Block a user