Adds several options to tweak items list options.

This commit is contained in:
mateuswetah 2020-12-23 09:38:30 -03:00
parent c1f45cf7c5
commit 978678310b
14 changed files with 411 additions and 10 deletions

View File

@ -404,11 +404,13 @@ function blocksy_tainacan_custom_post_types_single_options( $options, $post_type
if ( in_array($post_type, $collections_post_types) ) {
// Change the section title in the customizer
$options['title'] = sprintf(
__('Item from %s', 'blocksy-tainacan'),
$post_type_object->labels->name
);
// Extra options to the archive items list
$item_extra_options = blocksy_get_options(get_stylesheet_directory() . '/inc/options/posts/tainacan-item-single.php', [
'post_type' => $post_type_object,
'is_general_cpt' => true
@ -428,6 +430,41 @@ function blocksy_tainacan_custom_post_types_single_options( $options, $post_type
}
add_filter( 'blocksy:custom_post_types:single-options', 'blocksy_tainacan_custom_post_types_single_options', 10, 3 );
/**
* Adds extra customizer options to items single page template
*/
function blocksy_tainacan_custom_post_types_archive_options( $options, $post_type, $post_type_object ) {
// This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
$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(
__('Items list from %s', 'blocksy-tainacan'),
$post_type_object->labels->name
);
// Extra options to the archive items list
$items_extra_options = blocksy_get_options(get_stylesheet_directory() . '/inc/options/posts/tainacan-item-archive.php', [
'post_type' => $post_type_object,
'is_general_cpt' => true
], false);
if ( is_array($items_extra_options) ) {
$options['options'][$post_type . '_section_options']['inner-options'] = $items_extra_options;
}
}
}
return $options;
}
add_filter( 'blocksy:custom_post_types:archive-options', 'blocksy_tainacan_custom_post_types_archive_options', 10, 3 );
/**
* Removes tainacan metadatum and filters from the custom metadata options in the customizer controller.
*/
@ -486,3 +523,46 @@ add_action( 'wp_enqueue_scripts', 'blocksy_tainacan_swiper_scripts' );
/* Requires helpers */
require get_stylesheet_directory() . '/helpers/blocksy-integration.php';
/**
* Enqueues front-end CSS for the items page fixed filters logic.
*
* @see wp_add_inline_style()
*/
function blocksy_tainacan_items_page_filters_fixed_on_scroll_output() {
$prefix = blocksy_manager()->screen->get_prefix();
$should_use_fixed_filters_logic = (version_compare(TAINACAN_VERSION, '0.17') >= 0) && get_theme_mod( $prefix . '_filters_fixed_on_scroll', 'no' ) == 'yes';
if (!$should_use_fixed_filters_logic)
return;
$css = '
/* Items list fixed filter logic (Introduced in Tainacan 0.17) */
:not(.wp-block-tainacan-faceted-search)>.theme-items-list:not(.is-fullscreen).is-filters-menu-open.is-filters-menu-fixed-at-top .items-list-area {
margin-left: var(--tainacan-filter-menu-width-theme) !important;
}
:not(.wp-block-tainacan-faceted-search)>.theme-items-list:not(.is-fullscreen).is-filters-menu-open.is-filters-menu-fixed-at-top .filters-menu:not(.filters-menu-modal) {
position: fixed;
top: 0px !important;
z-index: 9;
}
:not(.wp-block-tainacan-faceted-search)>.theme-items-list:not(.is-fullscreen).is-filters-menu-open.is-filters-menu-fixed-at-top .filters-menu:not(.filters-menu-modal) .modal-content {
position: absolute;
top: 0px;
height: auto !important;
background: var(--tainacan-background-color, inherit);
}
:not(.wp-block-tainacan-faceted-search)>.theme-items-list:not(.is-fullscreen).is-filters-menu-open.is-filters-menu-fixed-at-top.is-filters-menu-fixed-at-bottom .filters-menu:not(.filters-menu-modal) {
position: absolute;
}
:not(.wp-block-tainacan-faceted-search)>.theme-items-list:not(.is-fullscreen).is-filters-menu-open.is-filters-menu-fixed-at-top.is-filters-menu-fixed-at-bottom .filters-menu:not(.filters-menu-modal) .modal-content {
top: auto;
bottom: 0;
}
';
echo '<style type="text/css" id="tainacan-fixed-filters-style">' . sprintf( $css ) . '</style>';
}
add_action( 'wp_head', 'blocksy_tainacan_items_page_filters_fixed_on_scroll_output');

View File

@ -0,0 +1,83 @@
<?php
if (! isset($prefix)) {
$prefix = '';
} else {
$prefix = $prefix . '_';
}
if (! isset($enabled)) {
$enabled = 'yes';
}
$options = [
$prefix . 'display_filters_panel' => [
'label' => __( 'Filters panel', 'blocksy-tainacan' ),
'type' => 'ct-panel',
'switch' => true,
'value' => $enabled,
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix,
]),
'inner-options' => [
$prefix . 'start_with_filters_hidden' => [
'label' => __( 'Start with filters hidden', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'no',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Load page with filters panel initially hidden.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
$prefix . 'show_hide_filters_button' => [
'label' => __( 'Show the "Hide filters" button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the button for hidding the filters panel.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
$prefix . 'show_hide_filters_button' => 'yes'
],
'options' => [
$prefix . 'show_filters_button_inside_search_control' => [
'label' => __( 'Show filters button inside search control', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the filters button inside the search control bar instead of floating aside.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
],
],
$prefix . 'filters_fixed_on_scroll' => [
'label' => __( 'Filters fixed on scroll', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'no',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'If you want filters panel to get fixed on screen when scrolling down the items list. This will only take effect if the items list itself is taller than the screen height.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
$prefix . 'filters_as_modal' => [
'label' => __( 'Filters as modal', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'no',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the filters panel as a full screen modal instead of aside, even on desktop.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
]
],
],
];

View File

@ -0,0 +1,48 @@
<?php
if (! isset($prefix)) {
$prefix = '';
$initial_prefix = '';
} else {
$initial_prefix = $prefix;
$prefix = $prefix . '_';
}
if (! isset($enabled)) {
$enabled = 'yes';
}
$options = [
$prefix . 'has_pagination' => [
'label' => __( 'Pagination', 'blocksy' ),
'type' => 'ct-panel',
'switch' => true,
'value' => $enabled,
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix,
'loader_selector' => 'section'
]),
'inner-options' => [
$prefix . 'show_items_per_page_button' => [
'label' => __( 'Show the "Items per page" button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the button for choosing how many items per page shoulb be loaded.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
$prefix . 'show_go_to_page_button' => [
'label' => __( 'Show the "Go to page" button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the button for jumping to an specific page.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
]
],
],
];

View File

@ -0,0 +1,131 @@
<?php
if (! isset($prefix)) {
$prefix = '';
} else {
$prefix = $prefix . '_';
}
$options = [
$prefix . 'search-control-panel' => [
'label' => __( 'Search control', 'blocksy-tainacan' ),
'type' => 'ct-panel',
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix,
]),
'inner-options' => [
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Textual search', 'blocksy-tainacan' ),
],
$prefix . 'show_search' => [
'label' => __( 'Show simple search', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display a simple textual search input for items title and description.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
$prefix . 'show_search' => 'yes'
],
'options' => [
$prefix . 'show_advanced_search' => [
'label' => __( 'Show advanced search', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display a link to open the advanced search panel.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Sorting', 'blocksy-tainacan' ),
],
$prefix . 'show_sorting_area' => [
'label' => __( 'Show sorting options', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display options related to the search such as the "Sort by" button and "Sort direction"', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
$prefix . 'show_sorting_area' => 'yes'
],
'options' => [
$prefix . 'show_sort_by_button' => [
'label' => __( 'Show "Sort by" button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the "Sort by" button, to select a metadata to sort by.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
],
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'View modes', 'blocksy-tainacan' ),
],
$prefix . 'show_inline_view_mode_options' => [
'label' => __( 'Show inline view mode options', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'no',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display view mode options as inline buttons instead of a dropdown.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
$prefix . 'show_fullscreen_with_view_modes' => [
'label' => __( 'Show full screen with view modes', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'no',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Offers full screen view mode options alongside other view modes instead of separated in the search control bar.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
$prefix . 'show_displayed_metadata_dropdown' => [
'label' => __( 'Show "Displayed metadata" dropdown', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display a dropdown for selecting the displayed metadata. This option may or not be present according to the current selected view mode.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Exposers', 'blocksy-tainacan' ),
],
$prefix . 'show_exposers_button' => [
'label' => __( 'Show "View as..." button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => 'yes',
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Display the "View as..." button, which opens the exposers modal.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_whole_page([
'prefix' => $prefix
])
],
],
],
];

View File

@ -0,0 +1,35 @@
<?php
$options = [
blocksy_get_options('general/page-title', [
'prefix' => $post_type->name . '_archive',
'is_cpt' => true,
'is_archive' => true,
'enabled_label' => sprintf(
__('%s Title', 'blocksy'),
$post_type->labels->name
),
]),
[
blocksy_rand_md5() => [
'type' => 'ct-title',
'label' => __( 'Page Elements', 'blocksy' ),
],
],
blocksy_get_options(get_stylesheet_directory() . '/inc/options/archive-elements/search-control.php', [
'prefix' => $post_type->name . '_archive',
], false),
blocksy_get_options(get_stylesheet_directory() . '/inc/options/archive-elements/filters-panel.php', [
'prefix' => $post_type->name . '_archive',
'enabled' => 'yes'
], false),
blocksy_get_options(get_stylesheet_directory() . '/inc/options/archive-elements/pagination.php', [
'prefix' => $post_type->name . '_archive',
'enabled' => 'yes'
], false),
];

View File

@ -29,6 +29,8 @@ $options = [
]),
'responsive' => true,
'divider' => 'top',
'sync' => 'live',
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix
])
],
];

View File

@ -0,0 +1 @@
import { render, createElement, Component, Fragment } from '@wordpress/element'

View File

@ -14,6 +14,7 @@
--tainacan-heading-color: var(--headingColor, rgba(44, 62, 80, 1));
--tainacan-label-color: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-info-color: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-skeleton-color: rgba(252, 252, 252, 0.5);
&:not(.is-fullscreen) {
justify-content: center;

View File

@ -33,6 +33,7 @@
--tainacan-heading-color: var(--headingColor, rgba(44, 62, 80, 1));
--tainacan-label-color: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-info-color: var(--color, rgba(44, 62, 80, 0.9));
--tainacan-skeleton-color: rgba(252, 252, 252, 0.5);
/* Search control */
/* Filters panel */
/* Items list container */

File diff suppressed because one or more lines are too long

2
style.min.css vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,9 @@
<?php
$prefix = blocksy_manager()->screen->get_prefix();
?>
<?php get_header(); ?>
<article class="page type-page hentry singular">
@ -19,7 +25,20 @@
<div class="entry-content">
<?php
tainacan_the_faceted_search([
'show-filters-button-inside-search-control' => true
'hide_filters' => get_theme_mod($prefix . '_display_filters_panel', 'yes') == 'no',
'start_with_filters_hidden' => get_theme_mod($prefix . '_start_with_filters_hidden', 'no') == 'yes',
'hide_hide_filters_button' => get_theme_mod($prefix . '_show_hide_filters_button', 'yes') == 'no',
'show_filters_button_inside_search_control' => get_theme_mod($prefix . '_show_filters_button_inside_search_control', 'yes') == 'yes',
'filters_as_modal' => get_theme_mod($prefix . '_filters_as_modal', 'no') == 'yes',
'hide_search' => get_theme_mod($prefix . '_show_search', 'yes') == 'no',
'hide_advanced_search' => get_theme_mod($prefix . '_show_advanced_search', 'yes') == 'no',
'hide_sorting_area' => get_theme_mod($prefix . '_show_sorting_area', 'yes') == 'no',
'hide_sort_by_button' => get_theme_mod($prefix . '_show_sort_by_button', 'yes') == 'no',
'hide_displayed_metadata_dropdown' => get_theme_mod($prefix . '_show_displayed_metadata_dropdown', 'yes') == 'no',
'show_inline_view_mode_options' => get_theme_mod($prefix . '_show_inline_view_mode_options', 'no') == 'yes',
'show_fullscreen_with_view_modes' => get_theme_mod($prefix . '_show_fullscreen_with_view_modes', 'no') == 'yes',
'hide_exposers_button' => get_theme_mod($prefix . '_show_exposers_button', 'yes') == 'no',
'hide_pagination_area' => get_theme_mod($prefix . '_has_pagination', 'yes') == 'no',
]);
?>
</div>

View File

@ -14,7 +14,7 @@
<?php if (has_post_thumbnail() && (get_theme_mod($prefix . '_show_thumbnail', 'no') === 'yes') ): ?>
<div class="tainacan-item-thumbnail-container">
<h3><?php _e( 'Thumbnail', 'blocksy-tainacan' ); ?></h3>
<?php the_post_thumbnail('tainacan-medium-full', array('class' => 'item-card--thumbnail')); ?>
<p><?php the_post_thumbnail('tainacan-medium-full', array('class' => 'item-card--thumbnail')); ?></p>
</div>
<?php endif; ?>
<?php do_action( 'blocksy-tainacan-single-item-metadata-begin' ); ?>