From 8065679729271fd1ecfb417abf6b5ec63573fe01 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Fri, 27 Oct 2023 15:21:31 -0300 Subject: [PATCH] Version 0.3.0 --- tainacan-blocksy/README.txt | 26 +- tainacan-blocksy/functions.php | 6 +- tainacan-blocksy/inc/customizer.php | 98 +++++- tainacan-blocksy/inc/integration.php | 17 + tainacan-blocksy/inc/navigation.php | 155 +++++++-- .../archive-elements/page-header-simpler.php | 44 ++- .../options/archive-elements/page-header.php | 28 +- .../options/posts/tainacan-item-archive.php | 22 +- .../single-elements/attachments-size.php | 2 +- .../document-attachments-structure.php | 34 ++ .../single-elements/section-labels.php | 6 +- tainacan-blocksy/inc/plugin.php | 18 - tainacan-blocksy/package-lock.json | 4 +- tainacan-blocksy/package.json | 2 +- .../sass/tainacan-item-archive.scss | 127 ++++--- .../sass/tainacan-item-single.scss | 168 ++++++++- .../static/images/header-boxed.svg | 214 ++++++++++++ .../static/images/header-simple.svg | 209 +++++++++++ .../static/images/header-type-1.svg | 188 ++++++++++ .../static/images/header-type-2.svg | 170 +++++++++ tainacan-blocksy/style.css | 310 ++++++++++++++--- tainacan-blocksy/style.css.map | 6 +- tainacan-blocksy/style.min.css | 2 +- tainacan-blocksy/style.min.css.map | 2 +- tainacan-blocksy/tainacan/archive-items.php | 313 ++++++++++------- .../tainacan/archive-repository.php | 150 +++++--- .../tainacan/archive-taxonomy.php | 329 ++++++++++-------- .../tainacan-item-single-attachments_new.php | 36 +- .../tainacan-item-single-document_new.php | 18 +- 29 files changed, 2168 insertions(+), 536 deletions(-) create mode 100644 tainacan-blocksy/static/images/header-boxed.svg create mode 100644 tainacan-blocksy/static/images/header-simple.svg create mode 100644 tainacan-blocksy/static/images/header-type-1.svg create mode 100644 tainacan-blocksy/static/images/header-type-2.svg diff --git a/tainacan-blocksy/README.txt b/tainacan-blocksy/README.txt index 0ec406f..bdefb81 100644 --- a/tainacan-blocksy/README.txt +++ b/tainacan-blocksy/README.txt @@ -2,10 +2,10 @@ Author: tainacan Contributors: wetah, vnmedeiros, leogermani, tainacan Tags: museums, libraries, archives, GLAM, collections, repository, tainacan, blocksy -Requires at least: 5.0 -Tested up to: 6.2.2 -Requires PHP: 5.6 -Stable tag: 0.2.0 +Requires at least: 5.9 +Tested up to: 6.4 +Requires PHP: 7.0 +Stable tag: 0.3.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -58,12 +58,26 @@ License details: https://github.com/tainacan/blocksy-tainacan/blob/master/LICENS == Changelog == += 0.3.0 = +* Adds page title default Blocksy banner options for Collection Items templates +* Adds page title section options to Repository and Taxonomy Term Items level templates +* Adds container size option to all Items list templates +* Adds thumbnail carousel positioning option for item single gallery (requires Tainacan 0.20.5) +* Adds inner spacing option for media gallery on item single gallery +* More improvements to compatibility with Blcoksy 2.0.0 +* Improves post navigation markup to use latest filters +* Bug fix: label "Document" and "Documents" not displaying in the correct situations +* Bug fix: translation issues in breadcrumbs +* Bug fix: moves tainacan_blocksy_post_class() to integration for its classes to also work on child themes +* Bug fix: positioning of relationship metadata thumbnail +* Bug fix: thumbnail not being found in items navigation leading to a warning + = 0.2.0 = * Adds Taxonomy Single (Terms list) page functionality (requires Tainacan 0.20.1) * New layout for the Item Page: Media Gallery above page title * Option to set default order by for Repository Items list * Fixes to item thumbnail display inside sections -* Compatibility with Blocksy 2.0.0 +* Initial compatibility with Blocksy 2.0.0 = 0.1.21 = * Fixes breadcrumb hierarchy when inside taxonomy archives @@ -72,7 +86,7 @@ License details: https://github.com/tainacan/blocksy-tainacan/blob/master/LICENS * Small css improvements to geo coordinate metadatum = 0.1.20 = -* Sorts related items by title +* Sorting related items by title * Small css improvements = 0.1.19 = diff --git a/tainacan-blocksy/functions.php b/tainacan-blocksy/functions.php index b8a3a9e..f65b1da 100644 --- a/tainacan-blocksy/functions.php +++ b/tainacan-blocksy/functions.php @@ -4,7 +4,7 @@ Plugin Name: Tainacan Support for Blocksy Plugin URI: https://tainacan.org/ Description: Tainacan plugin support for Blocksy theme Author: tainacan -Version: 0.2.0 +Version: 0.3.0 Text Domain: tainacan-blocksy License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -15,7 +15,7 @@ if (! defined('WP_DEBUG') ) { } /** Theme/plugin version */ -const TAINACAN_BLOCKSY_VERSION = '0.2.0'; +const TAINACAN_BLOCKSY_VERSION = '0.3.0'; const TAINACAN_BLOCKSY_IS_CHILD_THEME = false; /* Tools to define our next constants */ @@ -56,4 +56,4 @@ if ( TAINACAN_BLOCKSY_IS_CHILD_THEME || ( TAINACAN_BLOCKSY_IS_BLOCKSY_ACTIVATED require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/integration.php'; require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/customizer.php'; require TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/navigation.php'; -} \ No newline at end of file +} diff --git a/tainacan-blocksy/inc/customizer.php b/tainacan-blocksy/inc/customizer.php index 0947b5b..972e72e 100644 --- a/tainacan-blocksy/inc/customizer.php +++ b/tainacan-blocksy/inc/customizer.php @@ -7,7 +7,8 @@ if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_panel') ) { function tainacan_blocksy_add_repository_and_terms_items_options_panel($options) { - $options['tainacan_repository_items_list'] = blc_call_fnc( + /* Repository Items List */ + $repository_items_extra_options = blc_call_fnc( [ 'fnc' => 'blocksy_get_options', 'default' => 'array' @@ -16,7 +17,36 @@ if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_p [], false ); - $options['tainacan_terms_items_list'] = blc_call_fnc( + $repository_items_prefix = 'tainacan-repository-items_archive'; + + $items_extra_title_options = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archive-elements/page-header-simpler.php', [ + 'prefix' => $repository_items_prefix, + 'is_general_cpt' => true + ], false); + + $default_title_options = blocksy_get_options('general/page-title', [ + 'prefix' => $repository_items_prefix, + 'is_cpt' => true, + 'is_archive' => true, + 'enabled_label' => sprintf( + __('%s Title', 'blocksy'), + __('Items', 'tainacan-blocksy') + ), + ]); + + $default_title_options_keys = array_keys($default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options']); + + $default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$repository_items_prefix . '_hero_section']['choices'] = array_merge($default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$repository_items_prefix . '_hero_section']['choices'], $items_extra_title_options[$repository_items_prefix . '_page-header-panel']['inner-options'][$repository_items_prefix . '_page_header_background_style']['choices']); + $default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$repository_items_prefix . '_hero_section']['value'] = $items_extra_title_options[$repository_items_prefix . '_page-header-panel']['inner-options'][$repository_items_prefix . '_page_header_background_style']['choices']; + $default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$repository_items_prefix . '_hero_section']['sync'] = ''; + $default_title_options[$repository_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][1][$repository_items_prefix . '_hero_elements'] = $items_extra_title_options[$repository_items_prefix . '_page-header-panel']['inner-options'][$repository_items_prefix . '_hero_elements']; + + $options['tainacan_repository_items_list'] = $repository_items_extra_options; + + $options['tainacan_repository_items_list']['options']['tainacan_repository_items_list_section_options']['inner-options'][0] = $default_title_options; + + /* Term Items List */ + $term_items_extra_options = blc_call_fnc( [ 'fnc' => 'blocksy_get_options', 'default' => 'array' @@ -24,11 +54,39 @@ if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_p TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archives/tainacan-terms-items.php', [], false ); + + $term_items_prefix = 'tainacan-terms-items_archive'; + + $items_extra_title_options = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archive-elements/page-header.php', [ + 'prefix' => $term_items_prefix, + 'is_general_cpt' => true + ], false); + + $default_title_options = blocksy_get_options('general/page-title', [ + 'prefix' => $term_items_prefix, + 'is_cpt' => true, + 'is_archive' => true, + 'enabled_label' => sprintf( + __('%s Title', 'blocksy'), + __('Items', 'tainacan-blocksy') + ), + ]); + + $default_title_options_keys = array_keys($default_title_options[$term_items_prefix . '_hero_enabled']['inner-options']); + + $default_title_options[$term_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$term_items_prefix . '_hero_section']['choices'] = array_merge($default_title_options[$term_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$term_items_prefix . '_hero_section']['choices'], $items_extra_title_options[$term_items_prefix . '_page-header-panel']['inner-options'][$term_items_prefix . '_page_header_background_style']['choices']); + $default_title_options[$term_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$term_items_prefix . '_hero_section']['value'] = $items_extra_title_options[$term_items_prefix . '_page-header-panel']['inner-options'][$term_items_prefix . '_page_header_background_style']['value']; + $default_title_options[$term_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$term_items_prefix . '_hero_section']['sync'] = ''; + $default_title_options[$term_items_prefix . '_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][1][$term_items_prefix . '_hero_elements'] = $items_extra_title_options[$term_items_prefix . '_page-header-panel']['inner-options'][$term_items_prefix . '_hero_elements']; + + $options['tainacan_term_items_list'] = $term_items_extra_options; + + $options['tainacan_term_items_list']['options']['tainacan_terms_items_list_section_options']['inner-options'][0] = $default_title_options; + return $options; } } -add_filter( 'blocksy_extensions_customizer_options', 'tainacan_blocksy_add_repository_and_terms_items_options_panel' ); - +add_filter( 'blocksy_extensions_customizer_options', 'tainacan_blocksy_add_repository_and_terms_items_options_panel', 10, 1 ); /** * Adds extra customizer options to items single page template @@ -41,7 +99,7 @@ if ( !function_exists('tainacan_blocksy_custom_post_types_single_options') ) { $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); if ( in_array($post_type, $collections_post_types) ) { - + // Change the section title in the customizer $options['title'] = sprintf( __('Item from %s', 'tainacan-blocksy'), @@ -117,9 +175,25 @@ if ( !function_exists('tainacan_blocksy_custom_post_types_archive_options') ) { 'prefix' => $post_type_object->name, 'is_general_cpt' => true ], false); + + $items_extra_title_options = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archive-elements/page-header.php', [ + 'prefix' => $post_type_object->name, + 'is_general_cpt' => true + ], false); if ( is_array($items_extra_options) ) { + $default_title_options = $options['options'][$post_type . '_section_options']['inner-options'][1]; + $default_title_options_keys = array_keys($default_title_options[$post_type . '_archive_hero_enabled']['inner-options']); + + $default_title_options[$post_type . '_archive_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$post_type .'_archive_hero_section']['choices'] = array_merge($default_title_options[$post_type . '_archive_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$post_type .'_archive_hero_section']['choices'], $items_extra_title_options[$post_type . '_page-header-panel']['inner-options'][$post_type . '_page_header_background_style']['choices']); + $default_title_options[$post_type . '_archive_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$post_type .'_archive_hero_section']['value'] = $items_extra_title_options[$post_type . '_page-header-panel']['inner-options'][$post_type . '_page_header_background_style']['value']; + $default_title_options[$post_type . '_archive_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][0][$post_type .'_archive_hero_section']['sync'] = ''; + $default_title_options[$post_type . '_archive_hero_enabled']['inner-options'][$default_title_options_keys[0]]['options'][1][$post_type . '_archive_hero_elements'] = $items_extra_title_options[$post_type . '_page-header-panel']['inner-options'][$post_type . '_hero_elements']; + $options['options'][$post_type . '_section_options']['inner-options'] = $items_extra_options; + + $options['options'][$post_type . '_section_options']['inner-options'][0] = $default_title_options; + } // We also do some changes on the Collections @@ -168,7 +242,6 @@ add_filter( 'blocksy:custom_post_types:supported_list', 'tainacan_blocksy_custom */ if ( !function_exists('tainacan_blocksy_the_content_for_items') ) { function tainacan_blocksy_the_content_for_items( $content ) { - // This should only happen if we have Tainacan plugin installed if ( defined ('TAINACAN_VERSION') ) { @@ -203,4 +276,15 @@ if ( !function_exists('tainacan_blocksy_the_content_for_items') ) { } add_filter( 'the_content', 'tainacan_blocksy_the_content_for_items', 11); -?> \ No newline at end of file +/** + * New filter from Blocksy 2.0.0 to allow using the page title styles + * in the Repository and Terms items list. + */ +add_filter( + 'blocksy:hero:dynamic-styles:prefixes', + function ($prefixes) { + $prefixes[] = 'tainacan-repository-items_archive'; + $prefixes[] = 'tainacan-terms-items_archive'; + return $prefixes; + } +); \ No newline at end of file diff --git a/tainacan-blocksy/inc/integration.php b/tainacan-blocksy/inc/integration.php index df719ec..cb22dd7 100644 --- a/tainacan-blocksy/inc/integration.php +++ b/tainacan-blocksy/inc/integration.php @@ -144,3 +144,20 @@ function tainacan_blocksy_render_media_gallery_above_title() { } add_action( 'blocksy:hero:before', 'tainacan_blocksy_render_media_gallery_above_title'); +/** + * Adds extra class to help styling tainacan single items templates. + */ +if ( !function_exists('tainacan_blocksy_post_class') ) { + function tainacan_blocksy_post_class($classes) { + + $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers(); + $current_post_type = get_post_type(); + + if (in_array($current_post_type, $collections_post_types)) { + $classes[] = 'tainacan-item-single-page'; + } + + return $classes; + } +} +add_filter('post_class', 'tainacan_blocksy_post_class'); diff --git a/tainacan-blocksy/inc/navigation.php b/tainacan-blocksy/inc/navigation.php index 0e4abb7..1187a63 100644 --- a/tainacan-blocksy/inc/navigation.php +++ b/tainacan-blocksy/inc/navigation.php @@ -49,10 +49,10 @@ if ( !function_exists('tainacan_blocksy_get_adjacent_item_links') ) { $next_thumb = ''; if (function_exists('tainacan_get_adjacent_items') && isset($_GET['pos'])) { - if ($adjacent_items['next']) { + if ($adjacent_items['next'] && $adjacent_items['next']['thumbnail'] && $adjacent_items['next']['thumbnail']['tainacan-medium']) { $next_thumb = $adjacent_items['next']['thumbnail']['tainacan-medium'][0]; } - if ($adjacent_items['previous']) { + if ($adjacent_items['previous'] && $adjacent_items['previous']['thumbnail'] && $adjacent_items['previous']['thumbnail']['tainacan-medium']) { $previous_thumb = $adjacent_items['previous']['thumbnail']['tainacan-medium'][0]; } } else { @@ -110,6 +110,8 @@ if ( !function_exists('tainacan_blocksy_get_adjacent_item_links') ) { */ if ( !function_exists('blocksy_default_post_navigation') ) { function blocksy_default_post_navigation() { + $prefix = blocksy_manager()->screen->get_prefix(); + $next_post = apply_filters( 'blocksy:post-navigation:next-post', get_adjacent_post(false, '', true) @@ -120,11 +122,57 @@ if ( !function_exists('blocksy_default_post_navigation') ) { get_adjacent_post(false, '', false) ); + $post_nav_criteria = blocksy_get_theme_mod($prefix . '_post_nav_criteria', 'default'); + + if ($post_nav_criteria !== 'default') { + $post_type = get_post_type(); + $post_nav_taxonomy_default = array_keys(blocksy_get_taxonomies_for_cpt( + $post_type + ))[0]; + + $post_nav_taxonomy = blocksy_get_theme_mod( + $prefix . '_post_nav_taxonomy', + $post_nav_taxonomy_default + ); + + $next_post = apply_filters( + 'blocksy:post-navigation:next-post', + get_adjacent_post(true, '', true, $post_nav_taxonomy) + ); + + $previous_post = apply_filters( + 'blocksy:post-navigation:previous-post', + get_adjacent_post(true, '', false, $post_nav_taxonomy) + ); + } + if (! $next_post && ! $previous_post) { return ''; } - $prefix = blocksy_manager()->screen->get_prefix(); + $title_class = 'item-title'; + + $title_class .= ' ' . blocksy_visibility_classes(blocksy_get_theme_mod( + $prefix . '_post_nav_title_visibility', + [ + 'desktop' => true, + 'tablet' => true, + 'mobile' => false, + ] + )); + + $thumb_size = blocksy_get_theme_mod($prefix . '_post_nav_thumb_size', 'medium'); + + $thumb_class = ''; + + $thumb_class .= ' ' . blocksy_visibility_classes(blocksy_get_theme_mod( + $prefix . '_post_nav_thumb_visibility', + [ + 'desktop' => true, + 'tablet' => true, + 'mobile' => true, + ] + )); $container_class = 'post-navigation'; @@ -137,7 +185,7 @@ if ( !function_exists('blocksy_default_post_navigation') ) { ] )); - $post_slug = get_post_type() === 'post' ? __( 'Post', 'blocksy' ) : get_post_type_object( get_post_type() )->labels->singular_name; + $post_slug = 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'; @@ -150,44 +198,75 @@ if ( !function_exists('blocksy_default_post_navigation') ) { if ($next_post) { $next_title = ''; - if ($has_title) { - $next_title = $next_post->post_title; - } + $next_title = get_the_title($next_post); if ($has_thumb && get_post_thumbnail_id($next_post)) { - $next_post_image_output = blocksy_image( - [ - 'attachment_id' => get_post_thumbnail_id( $next_post ), - 'ratio' => '1/1', - 'inner_content' => '', - 'tag_name' => 'figure' - ] - ); + + if ( function_exists('blocksy_image') ) { + $next_post_image_output = blocksy_image( + [ + 'attachment_id' => get_post_thumbnail_id( $next_post ), + 'ratio' => '1/1', + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } else if ( function_exists('blocksy_media') ) { + $next_post_image_output = blocksy_media( + [ + 'attachment_id' => get_post_thumbnail_id($next_post), + 'post_id' => $next_post->ID, + 'ratio' => '1/1', + 'size' => $thumb_size, + 'class' => $thumb_class, + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } } } if ($previous_post) { $previous_title = ''; - if ( $has_title ) { - $previous_title = $previous_post->post_title; - } + + $previous_title = get_the_title($previous_post); if ($has_thumb && get_post_thumbnail_id($previous_post)) { - $previous_post_image_output = blocksy_image( - [ - 'attachment_id' => get_post_thumbnail_id( $previous_post ), - 'ratio' => '1/1', - 'inner_content' => '', - 'tag_name' => 'figure' - ] - ); + if ( function_exists('blocksy_image') ) { + $previous_post_image_output = blocksy_image( + [ + 'attachment_id' => get_post_thumbnail_id( $previous_post ), + 'ratio' => '1/1', + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } else if ( function_exists('blocksy_media') ) { + $previous_post_image_output = blocksy_media( + [ + 'attachment_id' => get_post_thumbnail_id($previous_post), + 'post_id' => $previous_post->ID, + 'ratio' => '1/1', + 'size' => $thumb_size, + 'class' => $thumb_class, + 'inner_content' => '', + 'tag_name' => 'figure' + ] + ); + } } } + $deep_link_args = [ + 'prefix' => $prefix, + 'suffix' => $prefix . '_has_post_nav' + ]; + ob_start(); ?> -