✨feature: Build interior layout
This commit is contained in:
+40
-35
@@ -143,14 +143,17 @@ class Breadcrumbs {
|
||||
private static function getCustomPostTypeBreadcrumbs() {
|
||||
$breadcrumbs = array();
|
||||
$postType = get_post_type_object( get_post_type() );
|
||||
if ( $postType && ! in_array( get_post_type(), array( 'post', 'page' ), true ) ) {
|
||||
|
||||
if ( $postType && ! in_array( get_post_type(), array( 'post', 'page' ), true ) ) {
|
||||
$breadcrumbs[] = array(
|
||||
'url' => get_post_type_archive_link( $postType->name ),
|
||||
'label' => $postType->labels->name,
|
||||
);
|
||||
}
|
||||
$breadcrumbs[] = array( 'label' => get_the_title() );
|
||||
return $breadcrumbs;
|
||||
|
||||
$breadcrumbs[] = array( 'label' => get_the_title() );
|
||||
|
||||
return $breadcrumbs;
|
||||
}
|
||||
|
||||
/** Generates breadcrumbs for a static page.
|
||||
@@ -165,17 +168,21 @@ class Breadcrumbs {
|
||||
*/
|
||||
private static function getStaticPageBreadcrumbs( $post ) {
|
||||
$breadcrumbs = array();
|
||||
if ( $post->post_parent ) {
|
||||
|
||||
if ( $post->post_parent ) {
|
||||
$ancestors = array_reverse( get_post_ancestors( $post->ID ) );
|
||||
foreach ( $ancestors as $ancestor ) {
|
||||
|
||||
foreach ( $ancestors as $ancestor ) {
|
||||
$breadcrumbs[] = array(
|
||||
'url' => get_permalink( $ancestor ),
|
||||
'label' => get_the_title( $ancestor ),
|
||||
);
|
||||
}
|
||||
}
|
||||
$breadcrumbs[] = array( 'label' => get_the_title() );
|
||||
return $breadcrumbs;
|
||||
|
||||
$breadcrumbs[] = array( 'label' => get_the_title() );
|
||||
|
||||
return $breadcrumbs;
|
||||
}
|
||||
|
||||
/** Generates a breadcrumb for taxonomy archive pages.
|
||||
@@ -257,7 +264,8 @@ class Breadcrumbs {
|
||||
*/
|
||||
private static function getAuthorArchiveBreadcrumb() {
|
||||
$author = get_queried_object();
|
||||
return array( 'label' => 'Author: ' . $author->display_name );
|
||||
|
||||
return array( 'label' => 'Author: ' . $author->display_name );
|
||||
}
|
||||
|
||||
/** Generates the breadcrumb for search results.
|
||||
@@ -314,35 +322,32 @@ class Breadcrumbs {
|
||||
$isActive = ( $index === count( $items ) - 1 );
|
||||
$activeClass = $isActive ? ' active' : '';
|
||||
?>
|
||||
<span class="p-2 breadcrumb-item<?php echo esc_attr( $activeClass ); ?>"
|
||||
<?php
|
||||
if ( $isActive ) :
|
||||
?>
|
||||
aria-current="page"<?php endif; ?>>
|
||||
<?php if ( ! empty( $item['url'] ) ) : ?>
|
||||
<a href="<?php echo esc_url( $item['url'] ); ?>">
|
||||
<?php if ( $index === 0 ) : ?>
|
||||
<svg class="flex-shrink-0 w-5 h-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" aria-label="Home">
|
||||
<path d="M10.707 2.293a1 1 0 00-1.414 0l-7 7a1 1 0 001.414 1.414L4 10.414V17a1 1 0 001 1h2a1 1 0 001-1v-2a1 1 0 011-1h2a1 1 0 011 1v2a1 1 0 001 1h2a1 1 0 001-1v-6.586l.293.293a1 1 0 001.414-1.414l-7-7z" />
|
||||
</svg>
|
||||
<span class="sr-only"><?php echo esc_attr( $item['label'] ); ?></span>
|
||||
<?php else : ?>
|
||||
<?php echo esc_attr( $item['label'] ); ?>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php $ldItem['item'] = $item['url']; ?>
|
||||
<?php else : ?>
|
||||
<?php echo esc_attr( $item['label'] ); ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<span class="p-2 breadcrumb-item<?php echo esc_attr( $activeClass ); ?>"
|
||||
<?php if ( $isActive ) : ?>
|
||||
aria-current="page"
|
||||
<?php endif; ?>>
|
||||
|
||||
<?php $metadata['itemListElement'][] = $ldItem; ?>
|
||||
<?php if ( ! empty( $item['url'] ) ) : ?>
|
||||
<a href="<?php echo esc_url( $item['url'] ); ?>">
|
||||
<?php if ( $index === 0 ) : ?>
|
||||
<?php echo esc_attr( $item['label'] ); ?>
|
||||
<?php else : ?>
|
||||
<?php echo esc_attr( $item['label'] ); ?>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php $ldItem['item'] = $item['url']; ?>
|
||||
<?php else : ?>
|
||||
<?php echo esc_attr( $item['label'] ); ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
|
||||
<?php if ( ! $isActive ) : ?>
|
||||
<svg class="flex-shrink-0 w-5 h-5 text-light" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<?php endif; ?>
|
||||
<?php $metadata['itemListElement'][] = $ldItem; ?>
|
||||
|
||||
<?php if ( ! $isActive ) : ?>
|
||||
<svg class="flex-shrink-0 w-5 h-5 text-light" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
||||
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user