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 {
|
||||||
.header-meta{
|
.header-meta {
|
||||||
color: #898d8f !important;
|
color: #898d8f !important;
|
||||||
font: {
|
font: {
|
||||||
size: 0.75rem;
|
size: 0.75rem;
|
||||||
|
@ -155,6 +155,14 @@
|
||||||
height: 24px;
|
height: 24px;
|
||||||
padding-left: 1rem;
|
padding-left: 1rem;
|
||||||
}
|
}
|
||||||
|
.pagination {
|
||||||
|
a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
img{
|
img{
|
||||||
height: auto;
|
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 );
|
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>';
|
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) ): ?>
|
<?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">
|
<div class="mt-3 tainacan-single-post collection-single-item">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<header class="mb-4 tainacan-content">
|
<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
|
<?php
|
||||||
if ( !get_theme_mod('tainacan_single_item_hide_item_meta', false) ) {
|
if ( !get_theme_mod('tainacan_single_item_hide_item_meta', false) ) {
|
||||||
echo '<span class="time">';
|
echo '<span class="time">';
|
||||||
|
@ -183,6 +187,17 @@ if (get_theme_mod('tainacan_single_item_collection_header', false)) {
|
||||||
echo '</span>';
|
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>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
|
@ -1,109 +1,30 @@
|
||||||
<?php
|
<?php
|
||||||
if (function_exists('tainacan_get_adjacent_items')) {
|
|
||||||
$adjacent_items = tainacan_get_adjacent_items();
|
|
||||||
|
|
||||||
if (isset($adjacent_items['next'])) {
|
$adjacent_links = [
|
||||||
$next_link_url = $adjacent_items['next']['url'];
|
'next' => '',
|
||||||
$next_title = $adjacent_items['next']['title'];
|
'previous' => ''
|
||||||
} 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 = '';
|
|
||||||
|
|
||||||
switch (get_theme_mod('tainacan_single_item_navigation_options', 'thumbnail_small')) {
|
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':
|
case 'thumbnail_small':
|
||||||
//Get the thumnail url of the previous and next post
|
$adjacent_links = tainacan_get_adjacent_item_links('small');
|
||||||
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>';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'thumbnail_large':
|
case 'thumbnail_large':
|
||||||
|
$adjacent_links = tainacan_get_adjacent_item_links('large');
|
||||||
if (function_exists('tainacan_get_adjacent_items')) {
|
break;
|
||||||
if ($adjacent_items['next']) {
|
case 'link':
|
||||||
$next_thumb = $adjacent_items['next']['thumbnail']['tainacan-medium'][0];
|
$adjacent_links = tainacan_get_adjacent_item_links();
|
||||||
}
|
|
||||||
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>';
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'none':
|
case 'none':
|
||||||
default:
|
default:
|
||||||
return '';
|
$adjacent_links = [
|
||||||
|
'next' => '',
|
||||||
|
'previous' => ''
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$previous = $adjacent_links['previous'];
|
||||||
|
$next = $adjacent_links['next'];
|
||||||
?>
|
?>
|
||||||
<?php if ($previous !== '' || $next !== '') : ?>
|
<?php if ($previous !== '' || $next !== '') : ?>
|
||||||
<div class="tainacan-single-post">
|
<div class="tainacan-single-post">
|
||||||
|
|
Loading…
Reference in New Issue