- -
- --
Documento
--
diff --git a/functions.php b/functions.php
index ca840b4..e0578d4 100644
--- a/functions.php
+++ b/functions.php
@@ -5,3 +5,133 @@ if (! defined('WP_DEBUG')) {
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
});
+
+
+/**
+ * Filters the content if we're in a single item page.
+ */
+function blocksy_tainacan_filter_the_content_in_the_main_loop( $content ) {
+
+ if ( is_singular() && in_the_loop() && is_main_query() && function_exists('tainacan_get_item') && tainacan_get_item(get_the_ID()) != null ) {
+ return get_template_part( 'template-parts/single-items-page' );
+ }
+
+ return $content;
+}
+add_filter( 'the_content', 'blocksy_tainacan_filter_the_content_in_the_main_loop', 10, 1 );
+
+
+/**
+ * Retrieves an item adjacent link, either using WP strategy or Tainacan plugin tainacan_get_adjacent_items()
+ */
+function blocksy_tainacan_get_adjacent_item_links() {
+
+ $has_thumb = get_theme_mod($prefix . '_has_post_nav_thumb', 'yes') === 'yes';
+
+ 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 = '';
+
+ if ($has_thumb) {
+
+ 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' );
+ }
+
+ $previous_post_image_output = blocksy_simple_image(
+ $previous_thumb,
+ [
+ 'inner_content' => '',
+ 'ratio' => '1/1',
+ 'tag_name' => 'figure'
+ ]
+ );
+
+ $next_post_image_output = blocksy_simple_image(
+ $next_thumb,
+ [
+ 'inner_content' => '',
+ 'ratio' => '1/1',
+ 'tag_name' => 'figure'
+ ]
+ );
+
+ } else {
+ $previous = $previous_link_url === false ? '' : ' ' . $previous_title . '';
+ $next = $next_link_url === false ? '' :'' . $next_title . ' ';
+ }
+
+ // Creates the links
+ $previous = $previous_link_url === false ? '' : (
+ ' ' .
+ ($has_thumb ? $previous_post_image_output : '') .
+ '