Adds link pagination to default item page header. Still need some adjustments.
This commit is contained in:
parent
dc5aa58c50
commit
cae6ed82f6
|
@ -139,7 +139,7 @@
|
|||
}
|
||||
}
|
||||
header {
|
||||
.header-meta{
|
||||
.header-meta {
|
||||
color: #898d8f !important;
|
||||
font: {
|
||||
size: 0.75rem;
|
||||
|
@ -155,6 +155,14 @@
|
|||
height: 24px;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
.pagination {
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
span {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
img{
|
||||
height: auto;
|
||||
|
|
|
@ -125,3 +125,104 @@ function tainacan_filter_cancel_comment_reply_link( $formatted_link, $link, $tex
|
|||
}
|
||||
add_filter( 'cancel_comment_reply_link', 'tainacan_filter_cancel_comment_reply_link', 10, 3 );
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves an item adjacent link, either using WP strategy or Tainacan plugin tainacan_get_adjacent_items()
|
||||
*
|
||||
* @param string $thumbnail: accepts 'small' and 'large', defaults to null
|
||||
*/
|
||||
function tainacan_get_adjacent_item_links($thumbnail = null) {
|
||||
|
||||
if (function_exists('tainacan_get_adjacent_items') && isset($_GET['pos'])) {
|
||||
$adjacent_items = tainacan_get_adjacent_items();
|
||||
|
||||
if (isset($adjacent_items['next'])) {
|
||||
$next_link_url = $adjacent_items['next']['url'];
|
||||
$next_title = $adjacent_items['next']['title'];
|
||||
} else {
|
||||
$next_link_url = false;
|
||||
}
|
||||
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
|
||||
$previous_link_url = get_permalink( get_previous_post() );
|
||||
$next_link_url = get_permalink( get_next_post() );
|
||||
|
||||
//Get the title of the previous post and next post
|
||||
$previous_title = get_the_title( get_previous_post() );
|
||||
$next_title = get_the_title( get_next_post() );
|
||||
}
|
||||
|
||||
$previous = '';
|
||||
$next = '';
|
||||
|
||||
switch ($thumbnail) {
|
||||
|
||||
case 'small':
|
||||
//Get the thumnail url of the previous and next post
|
||||
if (function_exists('tainacan_get_adjacent_items') && isset($_GET['pos'])) {
|
||||
if ($adjacent_items['next']) {
|
||||
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-small'][0];
|
||||
}
|
||||
if ($adjacent_items['previous']) {
|
||||
$previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-small'][0];
|
||||
}
|
||||
} else {
|
||||
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-small' );
|
||||
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-small' );
|
||||
}
|
||||
|
||||
// Creates the links
|
||||
$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> <span>' .
|
||||
$previous_title . '</span><img src="' . $previous_thumb . '" alt="">' .
|
||||
'</a>';
|
||||
$next = $next_link_url === false ? '' :
|
||||
'<a class="has-small-thumbnail" rel="next" href="' . $next_link_url . '">' .
|
||||
'<img src="' . $next_thumb . '" alt=""><span>' . $next_title .
|
||||
'</span> <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i>' .
|
||||
'</a>';
|
||||
break;
|
||||
|
||||
case 'large':
|
||||
|
||||
if (function_exists('tainacan_get_adjacent_items') && isset($_GET['pos'])) {
|
||||
if ($adjacent_items['next']) {
|
||||
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-medium'][0];
|
||||
}
|
||||
if ($adjacent_items['previous']) {
|
||||
$previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-medium'][0];
|
||||
}
|
||||
} else {
|
||||
//Get the thumnail url of the previous and next post
|
||||
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-medium' );
|
||||
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-medium' );
|
||||
}
|
||||
|
||||
// Creates the links
|
||||
$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> ' .
|
||||
'<div><img src="' . $previous_thumb . '" alt=""><span>' . $previous_title .
|
||||
'</span></div></a>';
|
||||
$next = $next_link_url === false ? '' :
|
||||
'<a class="has-large-thumbnail" rel="next" href="' . $next_link_url . '">' .
|
||||
'<div><img src="' . $next_thumb . '" alt=""><span>' . $next_title .
|
||||
'</span></div> <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-36px"></i>' .
|
||||
'</a>';
|
||||
break;
|
||||
|
||||
default:
|
||||
$previous = $previous_link_url === false ? '' : '<a rel="prev" href="' . $previous_link_url . '"><i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-30px"></i> <span>' . $previous_title . '</span></a>';
|
||||
$next = $next_link_url === false ? '' :'<a rel="next" href="' . $next_link_url . '"><span>' . $next_title . '</span> <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i></a>';
|
||||
}
|
||||
|
||||
return ['next' => $next, 'previous' => $previous];
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -23,6 +23,10 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
|
|||
|
||||
echo '</style>';
|
||||
}
|
||||
|
||||
$adjacent_links = tainacan_get_adjacent_item_links();
|
||||
$previous = $adjacent_links['previous'];
|
||||
$next = $adjacent_links['next'];
|
||||
?>
|
||||
|
||||
<?php if ( get_theme_mod('tainacan_single_item_collection_header', false) ): ?>
|
||||
|
@ -170,7 +174,7 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
|
|||
<div class="mt-3 tainacan-single-post collection-single-item">
|
||||
<?php endif; ?>
|
||||
<header class="mb-4 tainacan-content">
|
||||
<div class="header-meta text-muted mb-2">
|
||||
<div class="header-meta text-muted mb-2 d-flex ">
|
||||
<?php
|
||||
if ( !get_theme_mod('tainacan_single_item_hide_item_meta', false) ) {
|
||||
echo '<span class="time">';
|
||||
|
@ -183,6 +187,17 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
|
|||
echo '</span>';
|
||||
}
|
||||
?>
|
||||
<div style="height: 1.125rem;" class="ml-auto d-flex justify-content-between">
|
||||
<div class="pagination">
|
||||
<?php echo $previous; ?>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<a href="<?php tainacan_the_collection_url(); ?>"><i class="tainacan-icon tainacan-icon-viewtable tainacan-icon-1-25em"></i></a>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<?php echo $next; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
|
@ -1,109 +1,30 @@
|
|||
<?php
|
||||
if (function_exists('tainacan_get_adjacent_items')) {
|
||||
$adjacent_items = tainacan_get_adjacent_items();
|
||||
|
||||
if (isset($adjacent_items['next'])) {
|
||||
$next_link_url = $adjacent_items['next']['url'];
|
||||
$next_title = $adjacent_items['next']['title'];
|
||||
} else {
|
||||
$next_link_url = false;
|
||||
}
|
||||
if (isset($adjacent_items['previous'])) {
|
||||
$previous_link_url = $adjacent_items['previous']['url'];
|
||||
$previous_title = $adjacent_items['previous']['title'];
|
||||
} else {
|
||||
$previous_link_url = false;
|
||||
}
|
||||
|
||||
// In this case, the user entered the page without any query params.
|
||||
if (!isset($adjacent_items['previous']) && !isset($adjacent_items['previous'])) {
|
||||
//Get the links to the Previous and Next Post
|
||||
$previous_link_url = get_permalink( get_previous_post() );
|
||||
$next_link_url = get_permalink( get_next_post() );
|
||||
|
||||
//Get the title of the previous post and next post
|
||||
$previous_title = get_the_title( get_previous_post() );
|
||||
$next_title = get_the_title( get_next_post() );
|
||||
}
|
||||
} else {
|
||||
//Get the links to the Previous and Next Post
|
||||
$previous_link_url = get_permalink( get_previous_post() );
|
||||
$next_link_url = get_permalink( get_next_post() );
|
||||
|
||||
//Get the title of the previous post and next post
|
||||
$previous_title = get_the_title( get_previous_post() );
|
||||
$next_title = get_the_title( get_next_post() );
|
||||
}
|
||||
|
||||
$previous = '';
|
||||
$next = '';
|
||||
$adjacent_links = [
|
||||
'next' => '',
|
||||
'previous' => ''
|
||||
];
|
||||
|
||||
switch (get_theme_mod('tainacan_single_item_navigation_options', 'thumbnail_small')) {
|
||||
|
||||
case 'link':
|
||||
$previous = $previous_link_url === false ? '' : '<a rel="prev" href="' . $previous_link_url . '"><i class="tainacan-icon tainacan-icon-arrowleft tainacan-icon-30px"></i> ' . $previous_title . '</a>';
|
||||
$next = $next_link_url === false ? '' :'<a rel="next" href="' . $next_link_url . '">' . $next_title . ' <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i></a>';
|
||||
break;
|
||||
|
||||
case 'thumbnail_small':
|
||||
//Get the thumnail url of the previous and next post
|
||||
if (function_exists('tainacan_get_adjacent_items')) {
|
||||
if ($adjacent_items['next']) {
|
||||
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-small'][0];
|
||||
}
|
||||
if ($adjacent_items['previous']) {
|
||||
$previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-small'][0];
|
||||
}
|
||||
} else {
|
||||
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-small' );
|
||||
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-small' );
|
||||
}
|
||||
|
||||
// Creates the links
|
||||
$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> ' .
|
||||
$previous_title . '<img src="' . $previous_thumb . '" alt="">' .
|
||||
'</a>';
|
||||
$next = $next_link_url === false ? '' :
|
||||
'<a class="has-small-thumbnail" rel="next" href="' . $next_link_url . '">' .
|
||||
'<img src="' . $next_thumb . '" alt="">' . $next_title .
|
||||
' <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-30px"></i>' .
|
||||
'</a>';
|
||||
$adjacent_links = tainacan_get_adjacent_item_links('small');
|
||||
break;
|
||||
|
||||
case 'thumbnail_large':
|
||||
|
||||
if (function_exists('tainacan_get_adjacent_items')) {
|
||||
if ($adjacent_items['next']) {
|
||||
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-medium'][0];
|
||||
}
|
||||
if ($adjacent_items['previous']) {
|
||||
$previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-medium'][0];
|
||||
}
|
||||
} else {
|
||||
//Get the thumnail url of the previous and next post
|
||||
$previous_thumb = get_the_post_thumbnail_url( get_previous_post(), 'tainacan-medium' );
|
||||
$next_thumb = get_the_post_thumbnail_url( get_next_post(), 'tainacan-medium' );
|
||||
}
|
||||
|
||||
// Creates the links
|
||||
$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> ' .
|
||||
'<div><img src="' . $previous_thumb . '" alt="">' . $previous_title .
|
||||
'</div></a>';
|
||||
$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> <i class="tainacan-icon tainacan-icon-arrowright tainacan-icon-36px"></i>' .
|
||||
'</a>';
|
||||
$adjacent_links = tainacan_get_adjacent_item_links('large');
|
||||
break;
|
||||
case 'link':
|
||||
$adjacent_links = tainacan_get_adjacent_item_links();
|
||||
break;
|
||||
|
||||
case 'none':
|
||||
default:
|
||||
return '';
|
||||
$adjacent_links = [
|
||||
'next' => '',
|
||||
'previous' => ''
|
||||
];
|
||||
}
|
||||
|
||||
$previous = $adjacent_links['previous'];
|
||||
$next = $adjacent_links['next'];
|
||||
?>
|
||||
<?php if ($previous !== '' || $next !== '') : ?>
|
||||
<div class="tainacan-single-post">
|
||||
|
|
Loading…
Reference in New Issue