Skip to content

Commit

Permalink
Small changes to Breadcrumbs more schema info
Browse files Browse the repository at this point in the history
  • Loading branch information
djm56 committed Sep 15, 2016
1 parent 9491057 commit 9ae196f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 41 deletions.
4 changes: 4 additions & 0 deletions archive.php
Expand Up @@ -47,6 +47,10 @@
<?php the_excerpt();?>
</div>
<?php endwhile; ?>
<?php
if ( function_exists('wp_bootstrap_pagination') )
wp_bootstrap_pagination();
?>
</div>
<div class="col-sm-4"><?php get_sidebar('post'); ?></div>
</div>
Expand Down
18 changes: 4 additions & 14 deletions footer.php
Expand Up @@ -9,25 +9,15 @@
*
* Last Revised: Aug 26, 2016
*/
global $childDir;
?>
<footer class="container" itemscope itemtype="http://schema.org/WPFooter">
<div class="row">
<hr>
<div class="col-sm-6"><p><small>&copy; Anomalous, Bootpresswp</small></p></div>
<div class="col-sm-6"><p class="footer-copyright"><small>&copy; <?php echo date('Y') ?> <?php bloginfo('name');?> - All Rights Reserved</small></p></div>
<div class="col-sm-6">
<?php
wp_nav_menu( array(
'theme_location' => 'footer-menu',
'depth' => 1,
'container' => 'div',
'container_class' => 'footer-nav',
'container_id' => 'footer-nav',
'menu_class' => 'nav nav-pills',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
<nav role="navigation" class="footer-menu" aria-label="Navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">
<?php get_template_part('template-parts/organisms/menu', 'footer');?>
</nav>
</div>
</div>
</footer>
Expand Down
12 changes: 6 additions & 6 deletions functions.php
Expand Up @@ -151,12 +151,12 @@ function bootpresswp_content_nav( $nav_id ) {
?>

<?php if ( is_single() ) : // navigation links for single posts ?>
<ul class="pager">
<ul class="pager" itemscope itemtype="http://schema.org/SiteNavigationElement/Pagination">
<?php previous_post_link( '<li class="previous">%link</li>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'purecsspress' ) . '</span> %title' ); ?>
<?php next_post_link( '<li class="next">%link</li>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'purecsspress' ) . '</span>' ); ?>
</ul>
<?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>
<ul class="pager">
<ul class="pager" itemscope itemtype="http://schema.org/SiteNavigationElement/Pagination">
<?php if ( get_next_posts_link() ) : ?>
<li class="next"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'purecsspress' ) ); ?></li>
<?php endif; ?>
Expand Down Expand Up @@ -248,18 +248,18 @@ function bootstrapwp_comment( $comment, $args, $depth ) {
default :
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<article id="comment-<?php comment_ID(); ?>" class="comment" itemscope itemtype="http://schema.org/Comment">
<footer>
<div class="comment-author vcard">
<?php echo get_avatar( $comment, 40 ); ?>
<?php printf( __( '%s <span class="says">says:</span>', 'bootstrap' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
<?php printf( __( '<span itemprop="name">%s</span> <span class="says">says:</span>', 'bootstrap' ), sprintf( '<cite class="fn">%s</cite>', get_comment_author_link() ) ); ?>
</div>
<?php if ( $comment->comment_approved == '0' ) : ?>
<em><?php _e( 'Your comment is awaiting moderation.', 'bootstrap' ); ?></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( 'c' ); ?>">
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>"><time pubdate datetime="<?php comment_time( 'c' ); ?>" itemprop="dateCreated">
<?php
/* translators: 1: date, 2: time */
printf( __( '%1$s at %2$s', 'bootstrap' ), get_comment_date(), get_comment_time() ); ?>
Expand All @@ -268,7 +268,7 @@ function bootstrapwp_comment( $comment, $args, $depth ) {
?>
</div>
</footer>
<div class="comment-content"><?php comment_text(); ?></div>
<div class="comment-content" itemprop="text"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
Expand Down
18 changes: 9 additions & 9 deletions includes/wp_bootstrap_breadcrumbs.php
Expand Up @@ -7,16 +7,16 @@ function bootpresswp_breadcrumbs() {

$delimiter = '<span class="divider">/</span>';
$home = 'Home'; // text for the 'Home' link
$before = '<li class="active">'; // tag before the current crumb
$before = '<li class="active" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">'; // tag before the current crumb
$after = '</li>'; // tag after the current crumb

if (!is_home() && !is_front_page() || is_paged()) {

echo '<ol class="breadcrumb">';
echo '<ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">';

global $post;
$homeLink = home_url('/');
echo '<li><a href="' . $homeLink . '">' . $home . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . $homeLink . '"><span itemprop="name">' . $home . '</span></a><meta itemprop="position" content="1" /></li> ' . $delimiter . ' ';

if (is_category()) {
global $wp_query;
Expand All @@ -28,19 +28,19 @@ function bootpresswp_breadcrumbs() {
echo get_category_parents($parentCat, TRUE, ' ' . $delimiter . ' ');
echo $before . 'Archive by category "' . single_cat_title('', false) . '"' . $after;
} elseif (is_day()) {
echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo '<li><a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '">' . get_the_time('F') . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_time('d') . $after;
} elseif (is_month()) {
echo '<li><a href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . get_year_link(get_the_time('Y')) . '">' . get_the_time('Y') . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_time('F') . $after;
} elseif (is_year()) {
echo $before . get_the_time('Y') . $after;
} elseif (is_single() && !is_attachment()) {
if (get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
echo '<li><a href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . $homeLink . '/' . $slug['slug'] . '/">' . $post_type->labels->singular_name . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} else {
$cat = get_the_category();
Expand All @@ -56,7 +56,7 @@ function bootpresswp_breadcrumbs() {
$cat = get_the_category($parent->ID);
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' ');
echo '<li><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li> ' . $delimiter . ' ';
echo '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . get_permalink($parent) . '">' . $parent->post_title . '</a></li> ' . $delimiter . ' ';
echo $before . get_the_title() . $after;
} elseif (is_page() && !$post->post_parent) {
echo $before . get_the_title() . $after;
Expand All @@ -65,7 +65,7 @@ function bootpresswp_breadcrumbs() {
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '<li><a href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
$breadcrumbs[] = '<li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="' . get_permalink($page->ID) . '">' . get_the_title($page->ID) . '</a></li>';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
Expand Down
7 changes: 4 additions & 3 deletions includes/wp_bootstrap_navwalker.php
Expand Up @@ -21,7 +21,7 @@ class wp_bootstrap_navwalker extends Walker_Nav_Menu {
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\">\n";
$output .= "\n$indent<ul role=\"menu\" class=\" dropdown-menu\" itemscope itemtype=\"http://schema.org/SiteNavigationElement\">\n";
}

/**
Expand Down Expand Up @@ -73,12 +73,13 @@ public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';

$output .= $indent . '<li' . $id . $value . $class_names .'>';
$output .= $indent . '<li' . $id . $value . $class_names .' >';

$atts = array();
$atts['title'] = ! empty( $item->title ) ? $item->title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['itemprop'] = "url";

// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
Expand Down Expand Up @@ -185,7 +186,7 @@ public static function fallback( $args ) {
$fb_output .= '>';
}

$fb_output .= '<ul';
$fb_output .= '<ul itemscope itemtype="http://schema.org/SiteNavigationElement"';

if ( $menu_id )
$fb_output .= ' id="' . $menu_id . '"';
Expand Down
14 changes: 7 additions & 7 deletions includes/wp_bootstrap_pagination.php
Expand Up @@ -10,7 +10,7 @@ function wp_bootstrap_pagination( $args = array() ) {
'custom_query' => FALSE,
'previous_string' => __( '<i class="glyphicon glyphicon-chevron-left"></i>', 'text-domain' ),
'next_string' => __( '<i class="glyphicon glyphicon-chevron-right"></i>', 'text-domain' ),
'before_output' => '<div class="post-nav"><ul class="pager">',
'before_output' => '<div class="post-nav"><ul class="pager" class="pagination" role="navigation" itemscope itemtype="http://schema.org/SiteNavigationElement">',
'after_output' => '</ul></div>'
);

Expand Down Expand Up @@ -54,29 +54,29 @@ function wp_bootstrap_pagination( $args = array() ) {

$firstpage = esc_attr( get_pagenum_link(1) );
if ( $firstpage && (1 != $page) )
$echo .= '<li class="previous"><a href="' . $firstpage . '">' . __( 'First', 'text-domain' ) . '</a></li>';
$echo .= '<li class="previous"><a rel="prev" itemprop="name" href="' . $firstpage . '">' . __( 'First', 'text-domain' ) . '</a></li>';

if ( $previous && (1 != $page) )
$echo .= '<li><a href="' . $previous . '" title="' . __( 'previous', 'text-domain') . '">' . $args['previous_string'] . '</a></li>';
$echo .= '<li><a rel="prev" href="' . $previous . '" title="' . __( 'previous', 'text-domain') . '">' . $args['previous_string'] . '</a></li>';

if ( !empty($min) && !empty($max) ) {
for( $i = $min; $i <= $max; $i++ ) {
if ($page == $i) {
$echo .= '<li class="active"><span class="active">' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span></li>';
$echo .= '<li class="active" itemprop="url"><span class="active">' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span></li>';
} else {
$echo .= sprintf( '<li><a href="%s">%002d</a></li>', esc_attr( get_pagenum_link($i) ), $i );
$echo .= sprintf( '<li itemprop="url"><a href="%s" itemprop="name">%002d</a></li>', esc_attr( get_pagenum_link($i) ), $i );
}
}
}

$next = intval($page) + 1;
$next = esc_attr( get_pagenum_link($next) );
if ($next && ($count != $page) )
$echo .= '<li><a href="' . $next . '" title="' . __( 'next', 'text-domain') . '">' . $args['next_string'] . '</a></li>';
$echo .= '<li><a rel="next" itemprop="name" href="' . $next . '" title="' . __( 'next', 'text-domain') . '">' . $args['next_string'] . '</a></li>';

$lastpage = esc_attr( get_pagenum_link($count) );
if ( $lastpage ) {
$echo .= '<li class="next"><a href="' . $lastpage . '">' . __( 'Last', 'text-domain' ) . '</a></li>';
$echo .= '<li class="next"><a rel="next" itemprop="name" href="' . $lastpage . '">' . __( 'Last', 'text-domain' ) . '</a></li>';
}

if ( isset($echo) )
Expand Down
6 changes: 4 additions & 2 deletions single.php
Expand Up @@ -25,12 +25,14 @@

<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>

<?php wp_link_pages( array(
<?php
wp_link_pages( array(
'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'bootpresswp' ) . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
) ); ?>
) );
?>
<?php endwhile; ?>

<?php comments_template(); ?>
Expand Down
36 changes: 36 additions & 0 deletions template-parts/organisms/author.php
@@ -0,0 +1,36 @@
<?php
/**
* Author Template
*
* @package WordPress
* @subpackage Bootpresswp
* @since Bootpresswp 0.1
*
* Last Revised: Sep 1, 2016
*/
?>
<div itemscope itemtype="http://schema.org/NewsArticle">
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="https://google.com/article"/>
<h2 itemprop="headline">Article headline</h2>
<h3 itemprop="author" itemscope itemtype="https://schema.org/Person">
By <span itemprop="name">John Doe</span>
</h3>
<span itemprop="description">A most wonderful article</span>
<div itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
<img src="https://google.com/thumbnail1.jpg"/>
<meta itemprop="url" content="https://google.com/thumbnail1.jpg">
<meta itemprop="width" content="800">
<meta itemprop="height" content="800">
</div>
<div itemprop="publisher" itemscope itemtype="https://schema.org/Organization">
<div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject">
<img src="https://google.com/logo.jpg"/>
<meta itemprop="url" content="https://google.com/logo.jpg">
<meta itemprop="width" content="600">
<meta itemprop="height" content="60">
</div>
<meta itemprop="name" content="Google">
</div>
<meta itemprop="datePublished" content="2015-02-05T08:00:00+08:00"/>
<meta itemprop="dateModified" content="2015-02-05T09:20:00+08:00"/>
</div>
19 changes: 19 additions & 0 deletions template-parts/organisms/menu-footer.php
@@ -0,0 +1,19 @@
<?php

/**
* Menu Footer
*
* @package WordPress
* @subpackage Bootpresswp
* @since Bootpresswp 0.1
*
* Last Revised: Sep 1, 2016
*/
wp_nav_menu(array(
'theme_location' => 'footer-menu',
'depth' => 1,
'container' => null,
'menu_class' => 'nav nav-pills',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);

0 comments on commit 9ae196f

Please sign in to comment.