Skip to content

Instantly share code, notes, and snippets.

Created April 13, 2015 14:36
Show Gist options
  • Save anonymous/0fb0456902245edb4131 to your computer and use it in GitHub Desktop.
Save anonymous/0fb0456902245edb4131 to your computer and use it in GitHub Desktop.
<?php
namespace UFVJM\Widgets;
class Breadcrumbs extends \WP_Widget {
public function __construct() {
$widget_args = array( 'description' => __( 'Show website breadcrumbs', 'ufvjm' ) );
parent::__construct( 'breadcrumbs', __( 'Breadcrumbs', 'ufvjm' ), $widget_args );
}
public function widget( $args, $instance ) {
global $post;
if( !is_404() ) {
echo $args['before_widget'];
?>
<nav class="laydiv">
<ul>
<li class="home-link">
<a href="<?php echo network_site_url(); ?>" class="i" title="<?php _e( 'Back to Portal Homepage', 'ufvjm' ); ?>">
<span><?php _e( 'Portal Homepage', 'ufvjm' ); ?> &raquo;</span>
</a>
</li>
<?php if (get_current_blog_id() !== 1) { ?>
<li class="with-link">
<a href="<?php echo \esc_attr( \home_url() ); ?>" class="pathway" title="<?php _e( 'Go to', 'ufvjm' ); ?> <?php bloginfo( 'name' ); ?>">
<span><?php bloginfo( 'name' ); ?></span>
</a>
</li>
<?php } ?>
<?php
if(is_single()) {
$the_category = get_the_category();
$categories[0] = $the_category;
if($the_category) {
?>
<li class="with-link">
<a href="#"><span>Categoria</span></a>
</li>
<?php
}
}
elseif( is_page() ) {
if($post->post_parent) {
$anc = get_post_ancestors( $post->ID );
$title = get_the_title();
?>
<li class="with-link">
<?php foreach ($anc as $ancestor) { ?>
<a href="<?php echo \get_page_link($ancestor); ?>">
<span><?php echo \get_the_title($ancestor); ?></span>
</a>
<?php } ?>
</li>
<?php
}
} ?>
<li class="show-last" title="<?php \_e( 'You are here:', 'ufvjm' ); ?>&nbsp;<?php the_title_attribute(); ?>">
<?php the_title(); ?>
</li>
</ul>
<div class="c"></div>
</nav>
<?php
echo $args['after_widget'];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment