Better check boolean values on the save function #674.
This commit is contained in:
parent
a7be880952
commit
aa40c5fb87
|
@ -53,7 +53,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
|
|||
label={__('Document', 'tainacan')}
|
||||
checked={ mediaSources['document'] === true }
|
||||
onChange={ ( isChecked ) => {
|
||||
let updatedSources = JSON.parse(JSON.stringify(mediaSources));
|
||||
let updatedSources = Object.assign({},mediaSources);
|
||||
updatedSources['document'] = isChecked;
|
||||
setAttributes({ mediaSources: updatedSources });
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
|
|||
label={__('Attachments', 'tainacan')}
|
||||
checked={ mediaSources['attachments'] === true }
|
||||
onChange={ ( isChecked ) => {
|
||||
let updatedSources = JSON.parse(JSON.stringify(mediaSources));
|
||||
let updatedSources = Object.assign({},mediaSources);
|
||||
updatedSources['attachments'] = isChecked;
|
||||
setAttributes({ mediaSources: updatedSources });
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
|
|||
label={__('Metadata', 'tainacan')}
|
||||
checked={ mediaSources['metadata'] === true }
|
||||
onChange={ ( isChecked ) => {
|
||||
let updatedSources = JSON.parse(JSON.stringify(mediaSources));
|
||||
let updatedSources = Object.assign({},mediaSources);
|
||||
updatedSources['metadata'] = isChecked;
|
||||
setAttributes({ mediaSources: updatedSources });
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
|
|||
label={__('Main slider', 'tainacan')}
|
||||
checked={ layoutElements['main'] === true }
|
||||
onChange={ ( isChecked ) => {
|
||||
let updatedElements = JSON.parse(JSON.stringify(layoutElements));
|
||||
let updatedElements = Object.assign({},layoutElements);
|
||||
updatedElements['main'] = isChecked;
|
||||
setAttributes({ layoutElements: updatedElements });
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ export default function ({ attributes, setAttributes, className, isSelected, cli
|
|||
label={__('Thumbnails carousel', 'tainacan')}
|
||||
checked={ layoutElements['thumbnails'] === true }
|
||||
onChange={ (isChecked) => {
|
||||
let updatedElements = JSON.parse(JSON.stringify(layoutElements));
|
||||
console.log(typeof layoutElements['thumbnails'])
|
||||
let updatedElements = Object.assign({},layoutElements);
|
||||
updatedElements['thumbnails'] = isChecked;
|
||||
setAttributes({ layoutElements: updatedElements });
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
$media_items_main = array();
|
||||
$media_items_thumbnails = array();
|
||||
|
||||
if ( isset($media_sources['attachments']) && $media_sources['attachments'] )
|
||||
if ( isset($media_sources['attachments']) && ($media_sources['attachments'] === true || $media_sources['attachments'] == 'true') )
|
||||
$attachments = tainacan_get_the_attachments(null, $item_id);
|
||||
|
||||
if ( isset($layout_elements['main']) && $layout_elements['main'] ) {
|
||||
if ( isset($layout_elements['main']) && ($layout_elements['main'] === true || $layout_elements['main'] == 'true') ) {
|
||||
|
||||
$class_slide_metadata = '';
|
||||
if ($hide_file_name_main)
|
||||
|
@ -43,7 +43,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
if ($hide_file_caption_main)
|
||||
$class_slide_metadata .= ' hide-caption';
|
||||
|
||||
if ( isset($media_sources['document']) && $media_sources['document'] && !empty(tainacan_get_the_document($item_id)) ) {
|
||||
if ( isset($media_sources['document']) && ($media_sources['document'] === true || $media_sources['document'] == 'true') && !empty(tainacan_get_the_document($item_id)) ) {
|
||||
$is_document_type_attachment = tainacan_get_the_document_type($item_id) === 'attachment';
|
||||
$media_items_main[] =
|
||||
tainacan_get_the_media_component_slide(array(
|
||||
|
@ -60,7 +60,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
));
|
||||
}
|
||||
|
||||
if ( isset($media_sources['attachments']) && $media_sources['attachments'] ) {
|
||||
if ( isset($media_sources['attachments']) && ($media_sources['attachments'] === true || $media_sources['attachments'] == 'true') ) {
|
||||
foreach ( $attachments as $attachment ) {
|
||||
$media_items_main[] =
|
||||
tainacan_get_the_media_component_slide(array(
|
||||
|
@ -79,7 +79,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( isset($layout_elements['thumbnails']) && $layout_elements['thumbnails'] ) {
|
||||
if ( isset($layout_elements['thumbnails']) && ($layout_elements['thumbnails'] === true || $layout_elements['thumbnails'] == 'true') ) {
|
||||
|
||||
$class_slide_metadata = '';
|
||||
if ($hide_file_name_thumbnails)
|
||||
|
@ -89,7 +89,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
if ($hide_file_caption_thumbnails)
|
||||
$class_slide_metadata .= ' hide-caption';
|
||||
|
||||
if ( isset($media_sources['document']) && $media_sources['document'] && !empty(tainacan_get_the_document($item_id)) ) {
|
||||
if ( isset($media_sources['document']) && ($media_sources['document'] === true && $media_sources['document'] == 'true') && !empty(tainacan_get_the_document($item_id)) ) {
|
||||
$is_document_type_attachment = tainacan_get_the_document_type($item_id) === 'attachment';
|
||||
$media_items_thumbnails[] =
|
||||
tainacan_get_the_media_component_slide(array(
|
||||
|
@ -103,7 +103,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
));
|
||||
}
|
||||
|
||||
if ( isset($media_sources['attachments']) && $media_sources['attachments'] ) {
|
||||
if ( isset($media_sources['attachments']) && ($media_sources['attachments'] === true || $media_sources['attachments'] == 'true') ) {
|
||||
foreach ( $attachments as $attachment ) {
|
||||
$media_items_thumbnails[] =
|
||||
tainacan_get_the_media_component_slide(array(
|
||||
|
@ -126,12 +126,12 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
$wrapper_attributes,
|
||||
tainacan_get_the_media_component(
|
||||
'tainacan-item-gallery-block_id-' . $block_id,
|
||||
(isset($layout_elements['thumbnails']) && $layout_elements['thumbnails']) ? $media_items_thumbnails : null,
|
||||
(isset($layout_elements['main']) && $layout_elements['main']) ? $media_items_main : null,
|
||||
(isset($layout_elements['thumbnails']) && ($layout_elements['thumbnails'] === true || $layout_elements['thumbnails'] == 'true')) ? $media_items_thumbnails : null,
|
||||
(isset($layout_elements['main']) && ($layout_elements['main'] === true || $layout_elements['main'] == 'true')) ? $media_items_main : null,
|
||||
array(
|
||||
'class_main_div' => '',
|
||||
'class_thumbs_div' => '',
|
||||
'swiper_main_options' => (isset($layout_elements['main']) && $layout_elements['main']) ? array(
|
||||
'swiper_main_options' => (isset($layout_elements['main']) && ($layout_elements['main'] === true || $layout_elements['main'] == 'true')) ? array(
|
||||
'navigation' => array(
|
||||
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-gallery-block_id-' . $block_id . '-main',
|
||||
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-gallery-block_id-' . $block_id . '-main',
|
||||
|
@ -139,7 +139,7 @@ function tainacan_blocks_render_items_gallery( $block_attributes, $content ) {
|
|||
'lazy' => true
|
||||
)
|
||||
) : '',
|
||||
'swiper_thumbs_options' => (isset($layout_elements['thumbnails']) && $layout_elements['thumbnails'] && (!isset($layout_elements['main']) || !$layout_elements['main']) ) ? array(
|
||||
'swiper_thumbs_options' => (isset($layout_elements['thumbnails']) && ($layout_elements['thumbnails'] === true || $layout_elements['thumbnails'] == 'true') && (!isset($layout_elements['main']) || !($layout_elements['main'] === true || $layout_elements['main'] == 'true')) ) ? array(
|
||||
'navigation' => array(
|
||||
'nextEl' => '.swiper-navigation-next_' . 'tainacan-item-gallery-block_id-' . $block_id . '-thumbs',
|
||||
'prevEl' => '.swiper-navigation-prev_' . 'tainacan-item-gallery-block_id-' . $block_id . '-thumbs',
|
||||
|
|
Loading…
Reference in New Issue