add test if navigation is at the end or start of the list

This commit is contained in:
vnmedeiros 2020-07-22 10:50:41 -03:00
parent 0242e471ef
commit 62e3d75b71
1 changed files with 15 additions and 12 deletions

View File

@ -1,15 +1,18 @@
<?php
if (function_exists('tainacan_get_adjacent_items')) {
$adjacent_items = tainacan_get_adjacent_items();
if ($adjacent_items['next']) {
if (isset($adjacent_items['next'])) {
$next_link_url = $adjacent_items['next']['url'];
$next_title = $adjacent_items['next']['title'];
} else {
$next_link_url = false;
}
if ($adjacent_items['previous']) {
if (isset($adjacent_items['previous'])) {
$previous_link_url = $adjacent_items['previous']['url'];
$previous_title = $adjacent_items['previous']['title'];
} else {
$previous_link_url = false;
}
} else {
//Get the links to the Previous and Next Post
@ -27,8 +30,8 @@
switch (get_theme_mod('tainacan_single_item_navigation_options', 'none')) {
case 'link':
$previous = '<a rel="prev" href="' . $previous_link_url . '"><i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-30px"></i>&nbsp; ' . $previous_title . '</a>';
$next = '<a rel="next" href="' . $next_link_url . '">' . $next_title . ' &nbsp;<i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i></a>';
$previous = $previous_link_url === false ? '' : '<a rel="prev" href="' . $previous_link_url . '"><i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-30px"></i>&nbsp; ' . $previous_title . '</a>';
$next = $next_link_url === false ? '' :'<a rel="next" href="' . $next_link_url . '">' . $next_title . ' &nbsp;<i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i></a>';
break;
case 'thumbnail_small':
@ -46,12 +49,12 @@
}
// Creates the links
$previous =
$previous = $previous_link_url === false ? '' :
'<a class="has-small-thumbnail" rel="prev" href="' . $previous_link_url . '">' .
'<i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-30px"></i>&nbsp;' .
$previous_title . '<img src="' . $previous_thumb . '" alt="">' .
'</a>';
$next =
$next = $next_link_url === false ? '' :
'<a class="has-small-thumbnail" rel="next" href="' . $next_link_url . '">' .
'<img src="' . $next_thumb . '" alt="">' . $next_title .
'&nbsp;<i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i>' .
@ -74,12 +77,12 @@
}
// Creates the links
$previous =
$previous = $previous_link_url === false ? '' :
'<a class="has-large-thumbnail" rel="prev" href="' . $previous_link_url . '">' .
'<i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-36px"></i>&nbsp;' .
'<div><img src="' . $previous_thumb . '" alt="">' . $previous_title .
'</div></a>';
$next =
$next = $next_link_url === false ? '' :
'<a class="has-large-thumbnail" rel="next" href="' . $next_link_url . '">' .
'<div><img src="' . $next_thumb . '" alt="">' . $next_title .
'</div>&nbsp;<i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-36px"></i>' .
@ -96,10 +99,10 @@
<h2 class="title-content-items"><?php echo __('Also in this collection', 'tainacan-interface') ?></h2>
<div id="item-single-navigation" class="d-flex justify-content-between margin-two-column">
<div class="pagination">
<?php previous_post_link($previous); ?>
<?php if($previous_link_url !== false) previous_post_link($previous); ?>
</div>
<div class="pagination">
<?php next_post_link($next); ?>
<?php if($next_link_url !== false) next_post_link($next); ?>
</div>
</div>
</div>