From 993e20671b8622a82c43c8a4a87ed739f39b137d Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Mon, 21 Mar 2022 15:31:34 -0300 Subject: [PATCH] Adds new options to lightbox view. --- tainacan-blocksy/inc/enqueues.php | 2 +- .../single-elements/document-attachments.php | 36 ++++- .../hide-files-caption-lightbox.php | 20 +++ .../hide-files-description-lightbox.php | 21 +++ .../hide-files-name-lightbox.php | 21 +++ .../tainacan-item-single-attachments.php | 146 ++---------------- .../tainacan-item-single-attachments_new.php | 55 +++++++ .../tainacan-item-single-attachments_old.php | 135 ++++++++++++++++ 8 files changed, 297 insertions(+), 139 deletions(-) create mode 100644 tainacan-blocksy/inc/options/single-elements/hide-files-caption-lightbox.php create mode 100644 tainacan-blocksy/inc/options/single-elements/hide-files-description-lightbox.php create mode 100644 tainacan-blocksy/inc/options/single-elements/hide-files-name-lightbox.php create mode 100644 tainacan-blocksy/template-parts/tainacan-item-single-attachments_new.php create mode 100644 tainacan-blocksy/template-parts/tainacan-item-single-attachments_old.php diff --git a/tainacan-blocksy/inc/enqueues.php b/tainacan-blocksy/inc/enqueues.php index 11cad3f..3a448ab 100644 --- a/tainacan-blocksy/inc/enqueues.php +++ b/tainacan-blocksy/inc/enqueues.php @@ -107,7 +107,7 @@ if ( !function_exists('tainacan_blocksy_gallery_light_color_scheme') ) { $has_light_dark_color_scheme = get_theme_mod( $prefix . '_gallery_color_scheme', 'dark' ) == 'light'; - if (!$has_light_dark_color_scheme) + if (!$has_light_dark_color_scheme || function_exists('tainacan_the_item_gallery')) return; $css = ' diff --git a/tainacan-blocksy/inc/options/single-elements/document-attachments.php b/tainacan-blocksy/inc/options/single-elements/document-attachments.php index d7017c5..cff9f2b 100644 --- a/tainacan-blocksy/inc/options/single-elements/document-attachments.php +++ b/tainacan-blocksy/inc/options/single-elements/document-attachments.php @@ -48,7 +48,27 @@ $options = [ blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/hide-files-description-main.php', [ 'prefix' => $prefix, 'enabled' => 'yes' - ], false) + ], false), + blocksy_rand_md5() => [ + 'type' => 'ct-condition', + 'condition' => [ + $prefix . 'disable_gallery_lightbox' => 'no' + ], + 'options' => [ + blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/hide-files-caption-lightbox.php', [ + 'prefix' => $prefix, + 'enabled' => 'no' + ], false), + blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/hide-files-name-lightbox.php', [ + 'prefix' => $prefix, + 'enabled' => 'no' + ], false), + blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/hide-files-description-lightbox.php', [ + 'prefix' => $prefix, + 'enabled' => 'no' + ], false) + ] + ] ] ], @@ -77,9 +97,17 @@ $options = [ blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/attachments-typography.php', [ 'prefix' => $prefix ], false), - blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/gallery-color-scheme.php', [ - 'prefix' => $prefix - ], false) + blocksy_rand_md5() => [ + 'type' => 'ct-condition', + 'condition' => [ + $prefix . 'disable_gallery_lightbox' => 'no' + ], + 'options' => [ + blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/gallery-color-scheme.php', [ + 'prefix' => $prefix + ], false) + ] + ] ], ] ] diff --git a/tainacan-blocksy/inc/options/single-elements/hide-files-caption-lightbox.php b/tainacan-blocksy/inc/options/single-elements/hide-files-caption-lightbox.php new file mode 100644 index 0000000..077bff6 --- /dev/null +++ b/tainacan-blocksy/inc/options/single-elements/hide-files-caption-lightbox.php @@ -0,0 +1,20 @@ + [ + 'label' => __( 'Hide files caption', 'tainacan-blocksy' ), + 'type' => 'ct-switch', + 'value' => $enabled, + 'setting' => [ 'transport' => 'postMessage' ], + 'desc' => __( 'Toggle to hide the attachments and document caption on the lightbox.', 'tainacan-blocksy' ), + 'sync' => blocksy_sync_single_post_container([ + 'prefix' => $prefix, + ]), + ] +]; \ No newline at end of file diff --git a/tainacan-blocksy/inc/options/single-elements/hide-files-description-lightbox.php b/tainacan-blocksy/inc/options/single-elements/hide-files-description-lightbox.php new file mode 100644 index 0000000..8d367f9 --- /dev/null +++ b/tainacan-blocksy/inc/options/single-elements/hide-files-description-lightbox.php @@ -0,0 +1,21 @@ + [ + 'label' => __( 'Hide files description', 'tainacan-blocksy' ), + 'type' => 'ct-switch', + 'value' => $enabled, + 'setting' => [ 'transport' => 'postMessage' ], + 'desc' => __( 'Toggle to hide the attachments and document description on the lightbox.', 'tainacan-blocksy' ), + 'sync' => blocksy_sync_single_post_container([ + 'prefix' => $prefix, + ]), + ] +]; \ No newline at end of file diff --git a/tainacan-blocksy/inc/options/single-elements/hide-files-name-lightbox.php b/tainacan-blocksy/inc/options/single-elements/hide-files-name-lightbox.php new file mode 100644 index 0000000..3909bea --- /dev/null +++ b/tainacan-blocksy/inc/options/single-elements/hide-files-name-lightbox.php @@ -0,0 +1,21 @@ + [ + 'label' => __( 'Hide files name', 'tainacan-blocksy' ), + 'type' => 'ct-switch', + 'value' => $enabled, + 'setting' => [ 'transport' => 'postMessage' ], + 'desc' => __( 'Toggle to hide the attachments and document name on the lightbox view.', 'tainacan-blocksy' ), + 'sync' => blocksy_sync_single_post_container([ + 'prefix' => $prefix, + ]), + ] +]; \ No newline at end of file diff --git a/tainacan-blocksy/template-parts/tainacan-item-single-attachments.php b/tainacan-blocksy/template-parts/tainacan-item-single-attachments.php index 0a1fdaa..2cc112c 100644 --- a/tainacan-blocksy/template-parts/tainacan-item-single-attachments.php +++ b/tainacan-blocksy/template-parts/tainacan-item-single-attachments.php @@ -1,135 +1,13 @@ screen->get_prefix(); - - // Galley mode is a shortname for when documents and attachments are displayed merged in the same list - $is_gallery_mode = get_theme_mod( $prefix . '_document_attachments_structure', 'gallery-type-1' ) == 'gallery-type-2'; - $hide_file_name = get_theme_mod( $prefix . '_hide_files_name', 'no') == 'yes'; - $hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes'; - $hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes'; - $hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes'; - $hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes'; - $disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes'; - - global $post; - - if ( function_exists('tainacan_the_media_component') && ( !empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) ) { - ?> - - \ No newline at end of file + if ( function_exists('tainacan_the_item_gallery') ) { //if (version_compare(TAINACAN_VERSION, '0.19RC') >= 0) { + tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-attachments_new' ); + } else if ( function_exists('tainacan_get_the_media_component') ) { //if (version_compare(TAINACAN_VERSION, '0.18RC') >= 0) { + tainacan_blocksy_get_template_part( 'template-parts/tainacan-item-single-attachments_old' ); + } else { + ?> +
+

+
+ \ No newline at end of file diff --git a/tainacan-blocksy/template-parts/tainacan-item-single-attachments_new.php b/tainacan-blocksy/template-parts/tainacan-item-single-attachments_new.php new file mode 100644 index 0000000..af897e0 --- /dev/null +++ b/tainacan-blocksy/template-parts/tainacan-item-single-attachments_new.php @@ -0,0 +1,55 @@ +screen->get_prefix(); + + // Galley mode is a shortname for when documents and attachments are displayed merged in the same list + $is_gallery_mode = get_theme_mod( $prefix . '_document_attachments_structure', 'gallery-type-1' ) == 'gallery-type-2'; + $hide_file_name = get_theme_mod( $prefix . '_hide_files_name', 'no') == 'yes'; + $hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes'; + $hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes'; + $hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes'; + $hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes'; + $disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes'; + $hide_file_name_lightbox = get_theme_mod( $prefix . '_hide_files_name_lightbox', 'no') == 'yes'; + $hide_file_caption_lightbox = get_theme_mod( $prefix . '_hide_files_caption_lightbox', 'no') == 'yes'; + $hide_file_description_lightbox = get_theme_mod( $prefix . '_hide_files_description_lightbox', 'no') == 'yes'; + $has_light_dark_color_scheme = get_theme_mod( $prefix . '_gallery_color_scheme', 'dark' ) == 'light'; + + global $post; + + if ( function_exists('tainacan_the_media_component') && ( !empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) ) { + ?> + + \ No newline at end of file diff --git a/tainacan-blocksy/template-parts/tainacan-item-single-attachments_old.php b/tainacan-blocksy/template-parts/tainacan-item-single-attachments_old.php new file mode 100644 index 0000000..0a1fdaa --- /dev/null +++ b/tainacan-blocksy/template-parts/tainacan-item-single-attachments_old.php @@ -0,0 +1,135 @@ +screen->get_prefix(); + + // Galley mode is a shortname for when documents and attachments are displayed merged in the same list + $is_gallery_mode = get_theme_mod( $prefix . '_document_attachments_structure', 'gallery-type-1' ) == 'gallery-type-2'; + $hide_file_name = get_theme_mod( $prefix . '_hide_files_name', 'no') == 'yes'; + $hide_file_name_main = get_theme_mod( $prefix . '_hide_files_name_main', 'yes') == 'yes'; + $hide_file_caption_main = get_theme_mod( $prefix . '_hide_files_caption_main', 'yes') == 'yes'; + $hide_file_description_main = get_theme_mod( $prefix . '_hide_files_description_main', 'yes') == 'yes'; + $hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes'; + $disable_gallery_lightbox = get_theme_mod( $prefix . '_disable_gallery_lightbox', 'no') == 'yes'; + + global $post; + + if ( function_exists('tainacan_the_media_component') && ( !empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) ) { + ?> + + \ No newline at end of file