Several adjustments to add new options on single item page customizer.

This commit is contained in:
mateuswetah 2020-11-17 22:04:40 -03:00
parent f56691fd7b
commit cd7bdde088
17 changed files with 212 additions and 63 deletions

View File

@ -10,11 +10,23 @@ const BLOCKSY_TAINACAN_VERSION = '0.0.1';
* Enqueue scripts and styles.
*/
add_action( 'wp_enqueue_scripts', function () {
// First, we enqueue parent theme styles
wp_enqueue_style( 'blocksy-parent-style', get_template_directory_uri() . '/style.css' );
// Then, this child theme styles
wp_enqueue_style( 'tainacan-blocksy-style',
get_stylesheet_directory_uri() . '/style.min.css',
array( 'blocksy-parent-style' )
);
// Now, some dynamic css that is generated using blocksy dynamic css logic
add_action('blocksy:global-dynamic-css:enqueue', function ($args) {
blocksy_theme_get_dynamic_styles(array_merge([
'path' => get_stylesheet_directory() . '/global.php',
'chunk' => 'global'
], $args));
}, 10, 3);
});
/**
@ -192,8 +204,13 @@ function blocksy_tainacan_swiper_scripts() {
if ( in_array($post_type, $collections_post_types) ) {
wp_enqueue_style( 'swiper', 'https://unpkg.com/swiper/swiper-bundle.min.css', array(), BLOCKSY_TAINACAN_VERSION );
wp_enqueue_script( 'swiper', 'https://unpkg.com/swiper/swiper-bundle.min.js', array(), BLOCKSY_TAINACAN_VERSION, true );
wp_enqueue_script( 'blocksy-tainacan-scripts', get_stylesheet_directory_uri() . '/js/attachments-carousel.js', ['swiper'], BLOCKSY_TAINACAN_VERSION, true );
wp_enqueue_script( 'blocksy-tainacan-scripts__swiper', get_stylesheet_directory_uri() . '/js/attachments-carousel.js', ['swiper'], BLOCKSY_TAINACAN_VERSION, true );
}
wp_enqueue_script( 'blocksy-tainacan-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', [], BLOCKSY_TAINACAN_VERSION, true );
}
}
add_action( 'wp_enqueue_scripts', 'blocksy_tainacan_swiper_scripts' );
/* Requires helpers */
require get_stylesheet_directory() . '/helpers/blocksy-integration.php';

23
global.php Normal file
View File

@ -0,0 +1,23 @@
<?php
if (! isset($prefix)) {
$prefix = '';
} else {
$prefix = $prefix . '_';
}
blc_call_fnc(['fnc' => 'blocksy_output_responsive'], [
'css' => $css,
'tablet_css' => $tablet_css,
'mobile_css' => $mobile_css,
'selector' => ".single-item-collection--metadata",
'variableName' => 'column-width',
'value' => get_theme_mod($prefix . '_metadata_columns', [
'mobile' => '200px',
'tablet' => '300px',
'desktop' => '400px',
]),
'unit' => ''
]);
?>

View File

@ -0,0 +1,30 @@
<?php
/**
* This is a dummy copy of the blc_call_fn function used in the blocksy-companion plugin
* Check their /framework/helpers/blocksy-integration.php file for more details
* I renamed the usage from 'fn' to 'fnc' to avoid future conflicts
*/
if (! function_exists('blc_call_fnc')) {
function blc_call_fnc($args = [], ...$params) {
$args = wp_parse_args(
$args,
[
'fnc' => null,
// string | null | array
'default' => ''
]
);
if (! $args['fnc']) {
throw new Error('$fnc must be specified!');
}
if (! function_exists($args['fnc'])) {
return $args['default'];
}
return call_user_func($args['fnc'], ...$params);
}
}

View File

@ -9,6 +9,14 @@ if (! isset($is_bbpress)) {
}
$options = [
blocksy_get_options(get_stylesheet_directory() . '/inc/options/single-elements/section-labels.php', [
'prefix' => $post_type->name . '_single',
'enabled' => 'yes'
], false),
blocksy_get_options(get_stylesheet_directory() . '/inc/options/single-elements/hide-download-button.php', [
'prefix' => $post_type->name . '_single',
'enabled' => 'no'
], false),
blocksy_get_options(get_stylesheet_directory() . '/inc/options/single-elements/show-title-metadata.php', [
'prefix' => $post_type->name . '_single',
'enabled' => 'yes'
@ -17,8 +25,7 @@ $options = [
'prefix' => $post_type->name . '_single',
'enabled' => 'no'
], false),
blocksy_get_options(get_stylesheet_directory() . '/inc/options/single-elements/section-labels.php', [
'prefix' => $post_type->name . '_single',
'enabled' => 'yes'
], false)
blocksy_get_options(get_stylesheet_directory() . '/inc/options/single-elements/metadata-columns.php', [
'prefix' => $post_type->name . '_single'
], false),
];

View File

@ -0,0 +1,24 @@
<?php
if (! isset($prefix)) {
$prefix = '';
} else {
$prefix = $prefix . '_';
}
if (! isset($enabled)) {
$enabled = 'no';
}
$options = [
$prefix . 'hide_download_button' => [
'label' => __( ' Document download button', 'blocksy-tainacan' ),
'type' => 'ct-switch',
'value' => $enabled,
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Toggle to never display a "Download" button when hovering the document.', 'blocksy-tainacan' ),
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix
])
]
];

View File

@ -0,0 +1,34 @@
<?php
if (! isset($prefix)) {
$prefix = '';
} else {
$prefix = $prefix . '_';
}
$options = [
$prefix . 'metadata_columns' => [
'label' => __( 'Metadata columns width', 'blocksy' ),
'type' => 'ct-slider',
'value' => [
'mobile' => '200px',
'tablet' => '300px',
'desktop' => '400px',
],
'units' => blocksy_units_config([
[
'unit' => 'px',
'min' => 200,
'max' => 1200,
],
[
'unit' => 'vw',
'min' => 20,
'max' => 100,
],
]),
'responsive' => true,
'divider' => 'top',
'sync' => 'live',
],
];

0
js/scripts.js Normal file
View File

View File

@ -1,4 +1,3 @@
/* Tainacan Items list customization */
.theme-items-list {
--tainacan-font-family: var(--fontFamily, inherit);
@ -65,6 +64,10 @@
}
}
}
&.tainacan-filter-list-fixed {
left: 14px;
}
}
/* Items list container */
@ -257,7 +260,7 @@ body:not(.tainacan-admin-page) {
}
}
.collection-thumbnail {
max-width: var(--tainacan-filter-menu-width-theme, 20%);
max-width: calc(var(--tainacan-filter-menu-width-theme, 20%) - 24px);
float: left;
margin-right: 24px;

View File

@ -67,14 +67,15 @@
}
}
.single-item-collection--document {
display: flex;
justify-content: center;
position: relative;
&:hover {
.tainacan-item-file-download {
opacity: 1;
transform: scale(1);
}
}
display: flex;
justify-content: center;
> iframe, img.attachment-large {
display: block;
@ -174,7 +175,7 @@
}
}
}
.s-item-collection--metadata {
.single-item-collection--metadata {
height: 100%;
div {
@ -192,24 +193,18 @@
}
}
@media only screen and (min-width: 768px) {
-moz-column-count: 2;
-moz-column-gap: 0;
-moz-column-rule: none;
-webkit-column-count: 2;
-webkit-column-gap: 0;
-webkit-column-rule: none;
column-count: 2;
column-gap: 4rem;;
column-rule: none;
}
@media only screen and (min-width: 1366px) {
-moz-column-count: 3;
-moz-column-gap: 7rem;
-moz-column-rule: none;
-webkit-column-count: 3;
-webkit-column-gap: 7rem;
-webkit-column-rule: none;
column-count: 3;
column-gap: 7rem;
column-rule: none;
}

View File

@ -86,6 +86,10 @@
margin-bottom: 24px;
}
.theme-items-list #filters-modal.tainacan-filter-list-fixed {
left: 14px;
}
.theme-items-list #items-list-area {
grid-area: itemslist;
justify-self: end;
@ -290,7 +294,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
}
.tainacan-collection-header .tainacan-collection-header__box .collection-thumbnail {
max-width: var(--tainacan-filter-menu-width-theme, 20%);
max-width: calc(var(--tainacan-filter-menu-width-theme, 20%) - 24px);
float: left;
margin-right: 24px;
}
@ -380,6 +384,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
.single-item-data-section .single-item-collection--document {
display: flex;
justify-content: center;
position: relative;
}
.single-item-data-section .single-item-collection--document:hover .tainacan-item-file-download {
@ -504,11 +509,11 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
object-fit: contain;
}
.single-item-data-section .s-item-collection--metadata {
.single-item-data-section .single-item-collection--metadata {
height: 100%;
}
.single-item-data-section .s-item-collection--metadata div {
.single-item-data-section .single-item-collection--metadata div {
-webkit-column-break-inside: avoid;
page-break-inside: avoid;
break-inside: avoid;
@ -516,7 +521,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
width: 100%;
}
.single-item-data-section .s-item-collection--metadata div:last-child {
.single-item-data-section .single-item-collection--metadata div:last-child {
-webkit-column-break-inside: auto;
page-break-inside: auto;
break-inside: auto;
@ -525,69 +530,63 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
}
@media only screen and (min-width: 768px) {
.single-item-data-section .s-item-collection--metadata {
-moz-column-count: 2;
.single-item-data-section .single-item-collection--metadata {
-moz-column-gap: 0;
-moz-column-rule: none;
-webkit-column-count: 2;
-webkit-column-gap: 0;
-webkit-column-rule: none;
column-count: 2;
column-gap: 4rem;
column-rule: none;
}
}
@media only screen and (min-width: 1366px) {
.single-item-data-section .s-item-collection--metadata {
-moz-column-count: 3;
.single-item-data-section .single-item-collection--metadata {
-moz-column-gap: 7rem;
-moz-column-rule: none;
-webkit-column-count: 3;
-webkit-column-gap: 7rem;
-webkit-column-rule: none;
column-count: 3;
column-gap: 7rem;
column-rule: none;
}
}
.single-item-data-section .s-item-collection--metadata h3 {
.single-item-data-section .single-item-collection--metadata h3 {
padding-right: 1rem;
margin-bottom: 0.25rem;
width: 100%;
}
.single-item-data-section .s-item-collection--metadata h3:first-of-type:last-of-type {
.single-item-data-section .single-item-collection--metadata h3:first-of-type:last-of-type {
display: inline-block;
}
.single-item-data-section .s-item-collection--metadata h4,
.single-item-data-section .s-item-collection--metadata label {
.single-item-data-section .single-item-collection--metadata h4,
.single-item-data-section .single-item-collection--metadata label {
padding-right: 0.875rem;
width: 100%;
}
.single-item-data-section .s-item-collection--metadata h4:first-of-type:last-of-type,
.single-item-data-section .s-item-collection--metadata label:first-of-type:last-of-type {
.single-item-data-section .single-item-collection--metadata h4:first-of-type:last-of-type,
.single-item-data-section .single-item-collection--metadata label:first-of-type:last-of-type {
display: inline-block;
}
.single-item-data-section .s-item-collection--metadata p {
.single-item-data-section .single-item-collection--metadata p {
word-wrap: break-word;
}
.single-item-data-section .s-item-collection--metadata .multivalue-separator {
.single-item-data-section .single-item-collection--metadata .multivalue-separator {
color: #cbcbcb;
margin: 0 8px;
}
.single-item-data-section .s-item-collection--metadata .hierarchy-separator {
.single-item-data-section .single-item-collection--metadata .hierarchy-separator {
color: #cbcbcb;
}
.single-item-data-section .s-item-collection--metadata .metadata-type-compound .multivalue-separator,
.single-item-data-section .s-item-collection--metadata .metadata-type-textarea .multivalue-separator {
.single-item-data-section .single-item-collection--metadata .metadata-type-compound .multivalue-separator,
.single-item-data-section .single-item-collection--metadata .metadata-type-textarea .multivalue-separator {
display: block;
max-height: 1px;
width: 35px;
@ -597,7 +596,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
margin: 0.875rem auto;
}
.single-item-data-section .s-item-collection--metadata .tainacan-compound-group {
.single-item-data-section .single-item-collection--metadata .tainacan-compound-group {
padding-left: 1.5rem;
border-left: 1px solid #f2f2f2;
}

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

@ -45,7 +45,6 @@ if (
the_post();
}
/**
* Note to code reviewers: This line doesn't need to be escaped.
* Function blocksy_output_hero_section() used here escapes the value properly.
@ -58,6 +57,25 @@ if (
$container_class = 'ct-container-narrow';
}
$content_area_class = 'content-area';
$post_content = get_the_content();
$content_style = blocksy_get_content_style();
if (
(
strpos($post_content, 'alignwide') !== false
||
strpos($post_content, 'alignfull') !== false
)
&&
blocksy_sidebar_position() === 'none'
&&
blocksy_get_content_style() !== 'boxed'
) {
$content_area_class .= ' content-area-wide';
}
?>
<div id="primary" class="content-area" <?php echo blocksy_get_v_spacing() ?>>
@ -67,6 +85,7 @@ if (
<?php
$post_options = blocksy_get_post_options();
$prefix = blocksy_manager()->screen->get_prefix();
$has_share_box = get_theme_mod(
@ -159,9 +178,10 @@ if (
$share_box2_location = get_theme_mod($prefix . '_share_box2_location', 'right');
$content_class = 'entry-content';
$content_editor = blocksy_get_entry_content_editor();
$content_class = 'entry-content';
if (
strpos($content_editor, 'classic') === false
&&

View File

@ -38,7 +38,7 @@
<div class="single-item-collection--document">
<?php
tainacan_the_document();
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
if ( get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'no' && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
}
?>
@ -52,7 +52,7 @@
if ( function_exists('tainacan_get_single_attachment_as_html') ) {
tainacan_get_single_attachment_as_html($attachment->ID);
}
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_attachment_download_link') && tainacan_the_item_attachment_download_link($attachment->ID) != '' ) {
if ( get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'no' && function_exists('tainacan_the_item_attachment_download_link') && tainacan_the_item_attachment_download_link($attachment->ID) != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_attachment_download_link($attachment->ID) . '</span>';
}
?>

View File

@ -12,12 +12,11 @@
<div class="single-item-collection--document">
<?php
tainacan_the_document();
if ( !get_theme_mod( 'tainacan_single_item_hide_download_document', false ) && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
if ( get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'no' && function_exists('tainacan_the_item_document_download_link') && tainacan_the_item_document_download_link() != '' ) {
echo '<span class="tainacan-item-file-download">' . tainacan_the_item_document_download_link() . '</span>';
}
?>
</div>
</section>
</div>
<?php endif; ?>

View File

@ -10,14 +10,12 @@
<section class="tainacan-content single-item-collection margin-two-column">
<div class="single-item-collection--information justify-content-center">
<div class="row">
<div class="col s-item-collection--metadata">
<div class="col single-item-collection--metadata" style="column-width: <?php echo get_theme_mod( $prefix . '_metadata_columns', ['mobile' => '200px', 'tablet' => '300px', 'desktop' => '400px' ] )['desktop'] ?>">
<?php if (has_post_thumbnail() && (get_theme_mod($prefix . '_show_thumbnail', 'no') === 'yes') ): ?>
<div class="tainacan-item-thumbnail-container card">
<div class="card-body">
<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')); ?>
</div>
</div>
<?php endif; ?>
<?php do_action( 'blocksy-tainacan-single-item-metadata-begin' ); ?>
<?php