|
<?php |
|
namespace UFVJM\Widgets; |
|
|
|
/** |
|
* Adiciona o widget da barra de migalhas |
|
*/ |
|
class Breadcrumbs extends \WP_Widget { |
|
|
|
/** |
|
* Constrói o widget da barra de migalhas |
|
*/ |
|
public function __construct() { |
|
$widget_args = array( 'description' => __( 'Show website breadcrumbs', 'ufvjm' ) ); |
|
parent::__construct( 'breadcrumbs', __( 'Breadcrumbs', 'ufvjm' ), $widget_args ); |
|
} |
|
|
|
/** |
|
* Configura como a barra de migalhas será mostrada no site |
|
* |
|
* @see WP_Widget::widget() |
|
* |
|
* @param array $args Argumentos do widget. |
|
* @param array $instance Valores que são informados em Aparência > Widgets |
|
*/ |
|
public function widget( $args, $instance ) { |
|
global $post; |
|
if( !is_404() ) { |
|
|
|
/* @var $network_site_url string O endereço da home do portal. Você pode usar network_site_url() ou o endereço que voce quiser. */ |
|
$network_site_url = 'http://www.ufvjm.edu.br/'; |
|
|
|
echo $args['before_widget']; |
|
?> |
|
<nav class="laydiv"> |
|
<ul> |
|
<li class="home-link"> |
|
<a href="<?php echo esc_url( $network_site_url ); ?>" class="i" title="<?php _e( 'Back to Portal Homepage', 'ufvjm' ); ?>"> |
|
<span><?php _e( 'Portal Homepage', 'ufvjm' ); ?> »</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><?php _e( 'Categoria', 'ufvjm' ); ?></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' ); ?> <?php the_title_attribute(); ?>"> |
|
<?php the_title(); ?> |
|
</li> |
|
</ul> |
|
<div class="c"></div> |
|
</nav> |
|
<?php |
|
echo $args['after_widget']; |
|
} |
|
} |
|
|
|
} |