Adds option to change navigation item section label. If no query is passed, uses WordPress default strategy for displaying next and previous links.
This commit is contained in:
parent
d20a000303
commit
dc5aa58c50
|
@ -451,6 +451,29 @@ function tainacan_customize_register( $wp_customize ) {
|
|||
'fallback_refresh' => true
|
||||
) );
|
||||
|
||||
/**
|
||||
* Adds option to configure Item Navigation section label.
|
||||
*/
|
||||
$wp_customize->add_setting( 'tainacan_single_item_navigation_section_label', array(
|
||||
'type' => 'theme_mod',
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => __('Continue browsing', 'tainacan-interface'),
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'sanitize_text_field'
|
||||
) );
|
||||
$wp_customize->add_control( 'tainacan_single_item_navigation_section_label', array(
|
||||
'type' => 'text',
|
||||
'priority' => 0, // Within the section.
|
||||
'section' => 'tainacan_single_item_page',
|
||||
'label' => __( 'Label for the "Items navigation" or "Continue browsing" section', 'tainacan-interface' ),
|
||||
'description' => __( 'Leave blank it for not displaying any label.', 'tainacan-interface' )
|
||||
) );
|
||||
$wp_customize->selective_refresh->add_partial( 'tainacan_single_item_navigation_section_label', array(
|
||||
'selector' => '#single-item-navigation-label',
|
||||
'render_callback' => '__return_false',
|
||||
'fallback_refresh' => true
|
||||
) );
|
||||
|
||||
/**
|
||||
* Adds options to hide attachments file names on carousel.
|
||||
*/
|
||||
|
@ -633,7 +656,7 @@ function tainacan_customize_register( $wp_customize ) {
|
|||
$wp_customize->add_setting( 'tainacan_single_item_navigation_options', array(
|
||||
'type' => 'theme_mod',
|
||||
'capability' => 'edit_theme_options',
|
||||
'default' => 'none',
|
||||
'default' => 'thumbnail_small',
|
||||
'transport' => 'refresh',
|
||||
'sanitize_callback' => 'tainacan_sanitize_single_item_navigation_links_options',
|
||||
) );
|
||||
|
@ -641,8 +664,8 @@ function tainacan_customize_register( $wp_customize ) {
|
|||
'type' => 'select',
|
||||
'priority' => 3, // Within the section.
|
||||
'section' => 'tainacan_single_item_page',
|
||||
'label' => __( 'Navigation links to other items', 'tainacan-interface' ),
|
||||
'description' => __( 'Sets how next and previous items links will be displayed. This links only obey creation date order inside their collection.', 'tainacan-interface' ),
|
||||
'label' => __( 'Navigation links to adjacent items', 'tainacan-interface' ),
|
||||
'description' => __( 'Sets how next and previous items links will be displayed. If your Tainacan version is bellow 0.17, this links only obey creation date order inside their collection.', 'tainacan-interface' ),
|
||||
'choices' => tainacan_get_single_item_navigation_links_options()
|
||||
) );
|
||||
|
||||
|
|
|
@ -14,6 +14,17 @@
|
|||
} 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() );
|
||||
|
@ -27,7 +38,7 @@
|
|||
$previous = '';
|
||||
$next = '';
|
||||
|
||||
switch (get_theme_mod('tainacan_single_item_navigation_options', 'none')) {
|
||||
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>';
|
||||
|
@ -94,9 +105,13 @@
|
|||
return '';
|
||||
}
|
||||
?>
|
||||
<?php if ($previous !== '' && $next !== '') : ?>
|
||||
<?php if ($previous !== '' || $next !== '') : ?>
|
||||
<div class="tainacan-single-post">
|
||||
<h2 class="title-content-items"><?php echo __('Also in this collection', 'tainacan-interface') ?></h2>
|
||||
<?php if ( get_theme_mod('tainacan_single_item_navigation_section_label', __( 'Continue browsing', 'tainacan-interface' )) != '') : ?>
|
||||
<h2 class="title-content-items" id="single-item-navigation-label">
|
||||
<?php echo get_theme_mod('tainacan_single_item_navigation_section_label', __('Continue browsing', 'tainacan-interface')); ?>
|
||||
</h2>
|
||||
<?php endif; ?>
|
||||
<div id="item-single-navigation" class="d-flex justify-content-between margin-two-column">
|
||||
<div class="pagination">
|
||||
<?php echo $previous; ?>
|
||||
|
|
Loading…
Reference in New Issue