diff --git a/functions.php b/functions.php index df0e2bd..ccbbec1 100644 --- a/functions.php +++ b/functions.php @@ -125,6 +125,258 @@ function blocksy_tainacan_get_adjacent_item_links() { return ['next' => $next, 'previous' => $previous]; } + +/** + * Copy of blocksy original post navigation function. + */ +function blocksy_default_post_navigation() { + $next_post = apply_filters( + 'blocksy:post-navigation:next-post', + get_adjacent_post(false, '', true) + ); + + $previous_post = apply_filters( + 'blocksy:post-navigation:previous-post', + get_adjacent_post(false, '', false) + ); + + if (! $next_post && ! $previous_post) { + return ''; + } + + $prefix = blocksy_manager()->screen->get_prefix(); + + $container_class = 'post-navigation'; + + $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod( + $prefix . '_post_nav_visibility', + [ + 'desktop' => true, + 'tablet' => true, + 'mobile' => true, + ] + )); + + $home_page_url = get_home_url(); + + $post_slug = get_post_type() === 'post' ? __( 'Post', 'blocksy' ) : get_post_type_object( get_post_type() )->labels->singular_name; + $post_slug = '' . $post_slug . ''; + + $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes'; + + if ($has_thumb) { + $container_class .= ' has-thumbnails'; + } + + $has_title = get_theme_mod($prefix . '_has_post_nav_title', 'yes') === 'yes'; + + $next_post_image_output = ''; + $previous_post_image_output = ''; + + if ($next_post) { + $next_title = ''; + + if ($has_title) { + $next_title = $next_post->post_title; + } + + if ($has_thumb) { + $next_post_image_output = blocksy_image( + [ + 'attachment_id' => get_post_thumbnail_id( $next_post ), + 'ratio' => '1/1', + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } + } + + if ($previous_post) { + $previous_title = ''; + if ( $has_title ) { + $previous_title = $previous_post->post_title; + } + + if ($has_thumb) { + $previous_post_image_output = blocksy_image( + [ + 'attachment_id' => get_post_thumbnail_id( $previous_post ), + 'ratio' => '1/1', + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } + } + + ob_start(); + + ?> + + + + screen->get_prefix(); + + if (get_theme_mod( $prefix . '_has_post_nav', $prefix === 'single_blog_post' ? 'yes' : 'no' ) === 'yes') { + + $container_class = 'post-navigation'; + + $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod( + $prefix . '_post_nav_visibility', + [ + 'desktop' => true, + 'tablet' => true, + 'mobile' => true, + ] + )); + + $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes'; + + if ($has_thumb) + $container_class .= ' has-thumbnails'; + + $adjacent_links = [ + 'next' => '', + 'previous' => '' + ]; + + $adjacent_links = blocksy_tainacan_get_adjacent_item_links(); + + $previous = $adjacent_links['previous']; + $next = $adjacent_links['next']; + } + + ?> + + + + screen->get_prefix(); - -if (get_theme_mod( $prefix . '_has_post_nav', $prefix === 'single_blog_post' ? 'yes' : 'no' ) === 'yes') { - - - $container_class = 'post-navigation'; - - $container_class .= ' ' . blocksy_visibility_classes(get_theme_mod( - $prefix . '_post_nav_visibility', - [ - 'desktop' => true, - 'tablet' => true, - 'mobile' => true, - ] - )); - - $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes'; - - if ($has_thumb) - $container_class .= ' has-thumbnails'; - - $adjacent_links = [ - 'next' => '', - 'previous' => '' - ]; - - $adjacent_links = blocksy_tainacan_get_adjacent_item_links(); - - $previous = $adjacent_links['previous']; - $next = $adjacent_links['next']; -} -?> - - - \ No newline at end of file