Adds option to separate default section from others layout. #9.

This commit is contained in:
mateuswetah 2022-10-05 11:36:04 -03:00
parent 30f6d2f6f2
commit f3869b9155
9 changed files with 100 additions and 2028 deletions

View File

@ -42,7 +42,19 @@ if ( function_exists('tainacan_get_the_metadata_sections') ) {
[ [
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-sections.php', [ blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-sections.php', [
'prefix' => $prefix 'prefix' => $prefix
], false) ], false),
blocksy_rand_md5() => [
'type' => 'ct-condition',
'condition' => [
$prefix . 'metadata_sections_layout_type' => 'metadata-section-type-2|metadata-section-type-3|metadata-section-type-4',
],
'options' => [
blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/single-elements/metadata-sections-default.php', [
'prefix' => $prefix,
'enabled' => 'no'
], false)
]
]
] ]
); );
} }

View File

@ -0,0 +1,22 @@
<?php
if (! isset($prefix)) {
$prefix = '';
}
if (! isset($enabled)) {
$enabled = 'no';
}
$options = [
$prefix . 'metadata_sections_separate_default_section' => [
'label' => __( 'Separate default section', 'tainacan-blocksy' ),
'type' => 'ct-switch',
'value' => $enabled,
'setting' => [ 'transport' => 'postMessage' ],
'desc' => __( 'Toggle to show or not the default section separated from the other sections layout.', 'tainacan-blocksy' ),
'sync' => blocksy_sync_single_post_container([
'prefix' => $prefix
])
]
];

File diff suppressed because it is too large Load Diff

View File

@ -467,7 +467,7 @@
.tainacan-item-section { .tainacan-item-section {
width: 100%; width: 100%;
display: none; display: none;
padding: 2rem 4.16667vw 1rem 4.16667vw; padding: 2rem 42px 1rem 42px;
border-top: 1px solid var(--formBorderInitialColor, #e0e5eb); border-top: 1px solid var(--formBorderInitialColor, #e0e5eb);
} }
label { label {
@ -514,7 +514,7 @@
.tainacan-item-section { .tainacan-item-section {
width: 100%; width: 100%;
display: none; display: none;
padding: 2rem 4.16667vw 1rem 4.16667vw; padding: 2rem 42px 1rem 42px;
border-bottom: 1px solid var(--formBorderInitialColor, #e0e5eb); border-bottom: 1px solid var(--formBorderInitialColor, #e0e5eb);
margin-bottom: 0; margin-bottom: 0;
} }

View File

@ -851,7 +851,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
.tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--tabs .tainacan-item-section { .tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--tabs .tainacan-item-section {
width: 100%; width: 100%;
display: none; display: none;
padding: 2rem 4.16667vw 1rem 4.16667vw; padding: 2rem 42px 1rem 42px;
border-top: 1px solid var(--formBorderInitialColor, #e0e5eb); border-top: 1px solid var(--formBorderInitialColor, #e0e5eb);
} }
@ -903,7 +903,7 @@ body:not(.tainacan-admin-page) .tainacan-modal-content .modal-card-body {
.tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--collapses .tainacan-item-section, .tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--accordion .tainacan-item-section { .tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--collapses .tainacan-item-section, .tainacan-item-single-page .tainacan-metadata-sections-container.metadata-section-layout--accordion .tainacan-item-section {
width: 100%; width: 100%;
display: none; display: none;
padding: 2rem 4.16667vw 1rem 4.16667vw; padding: 2rem 42px 1rem 42px;
border-bottom: 1px solid var(--formBorderInitialColor, #e0e5eb); border-bottom: 1px solid var(--formBorderInitialColor, #e0e5eb);
margin-bottom: 0; margin-bottom: 0;
} }

File diff suppressed because one or more lines are too long

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,5 +1,14 @@
<?php <?php
$prefix = blocksy_manager()->screen->get_prefix(); $prefix = blocksy_manager()->screen->get_prefix();
$section_layout = get_theme_mod($prefix . '_metadata_sections_layout_type', 'metadata-section-type-1');
$exclude_title_metadata = get_theme_mod($prefix . '_show_title_metadata', 'yes') === 'no';
$show_thumbnail_with_metadata = get_theme_mod($prefix . '_show_thumbnail', 'no') === 'yes';
$metadata_list_structure_type = get_theme_mod($prefix . '_metadata_list_structure_type', 'metadata-type-1');
$display_section_labels = get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes';
$show_default_section_separated =
in_array($section_layout, ['metadata-section-type-2', 'metadata-section-type-3', 'metadata-section-type-4']) &&
get_theme_mod($prefix . '_metadata_sections_separate_default_section', 'no') === 'yes';
/** /**
* The new metadata sections function makes it a bit more complicated to add * The new metadata sections function makes it a bit more complicated to add
@ -8,7 +17,7 @@
* The following uses a filter to add it right above the first metadatum in the first section. * The following uses a filter to add it right above the first metadatum in the first section.
**/ **/
if ( has_post_thumbnail() && (get_theme_mod($prefix . '_show_thumbnail', 'no') === 'yes') ) { if ( has_post_thumbnail() && $show_thumbnail_with_metadata ) {
// Gets collection so we can obtain firtst metadatum // Gets collection so we can obtain firtst metadatum
$collection = tainacan_get_collection(); $collection = tainacan_get_collection();
@ -29,7 +38,7 @@
$first_metadatum_id = $metadatum['id']; $first_metadatum_id = $metadatum['id'];
// IF we are not displaying the title here, we must look for the second metadata // IF we are not displaying the title here, we must look for the second metadata
if ( get_theme_mod($prefix . '_show_title_metadata', 'yes') === 'no' ) { if ( $exclude_title_metadata ) {
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance(); $Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
$metadatum_object = $Tainacan_Metadata->fetch($first_metadatum_id); $metadatum_object = $Tainacan_Metadata->fetch($first_metadatum_id);
@ -75,11 +84,26 @@
'after_title' => '</h3>', 'after_title' => '</h3>',
'before_value' => '<p class="tainacan-metadata-value">', 'before_value' => '<p class="tainacan-metadata-value">',
'after_value' => '</p>', 'after_value' => '</p>',
'exclude_title' => (get_theme_mod($prefix . '_show_title_metadata', 'yes') === 'no') 'exclude_title' => $exclude_title_metadata
); );
if ( $show_default_section_separated ) {
$section_layout = get_theme_mod($prefix . '_metadata_sections_layout_type', 'metadata-section-type-1'); $sections_args = array(
'metadata_sections__in' => [ \Tainacan\Entities\Metadata_Section::$default_section_slug ],
'before' => '<section class="tainacan-item-section tainacan-item-section--metadata">',
'after' => '</section>',
'before_name' => '<h2 class="tainacan-single-item-section" id="metadata-section-$slug">',
'after_name' => '</h2>',
'hide_name' => !$display_section_labels,
'before_metadata_list' => do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '<div class="tainacan-item-section__metadata ' . $metadata_list_structure_type . '">',
'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ),
'metadata_list_args' => $metadata_args
);
echo '<div class="tainacan-metadata-sections-container">';
tainacan_the_metadata_sections( $sections_args );
echo '</div>';
}
if ( $section_layout == 'metadata-section-type-2') { if ( $section_layout == 'metadata-section-type-2') {
@ -87,7 +111,8 @@
return str_replace('<input', '<input checked="checked"', $before); return str_replace('<input', '<input checked="checked"', $before);
}, 10, 2); }, 10, 2);
$args = array( $sections_args = array(
'metadata_sections__not_in' => $show_default_section_separated ? [ \Tainacan\Entities\Metadata_Section::$default_section_slug ] : [],
'before' => '', 'before' => '',
'after' => '', 'after' => '',
'before_name' => '<input name="tabs" type="radio" id="tab-section-$id" /> 'before_name' => '<input name="tabs" type="radio" id="tab-section-$id" />
@ -96,13 +121,13 @@
'after_name' => '</h2> 'after_name' => '</h2>
</label>', </label>',
'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . ' 'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '
<div class="tainacan-item-section__metadata ' . get_theme_mod($prefix . '_metadata_list_structure_type', 'metadata-type-1') . '" aria-labelledby="metadata-section-$slug">', <div class="tainacan-item-section__metadata ' . $metadata_list_structure_type . '" aria-labelledby="metadata-section-$slug">',
'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>', 'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>',
'metadata_list_args' => $metadata_args 'metadata_list_args' => $metadata_args
); );
echo '<div class="tainacan-metadata-sections-container metadata-section-layout--tabs">'; echo '<div class="tainacan-metadata-sections-container metadata-section-layout--tabs">';
tainacan_the_metadata_sections( $args ); tainacan_the_metadata_sections( $sections_args );
echo '</div>'; echo '</div>';
} else if ( $section_layout == 'metadata-section-type-3') { } else if ( $section_layout == 'metadata-section-type-3') {
@ -111,7 +136,8 @@
return str_replace('<input', '<input checked="checked"', $before); return str_replace('<input', '<input checked="checked"', $before);
}, 10, 2); }, 10, 2);
$args = array( $sections_args = array(
'metadata_sections__not_in' => $show_default_section_separated ? [ \Tainacan\Entities\Metadata_Section::$default_section_slug ] : [],
'before' => '', 'before' => '',
'after' => '', 'after' => '',
'before_name' => '<input name="collapses" type="checkbox" id="collapse-section-$id"/> 'before_name' => '<input name="collapses" type="checkbox" id="collapse-section-$id"/>
@ -121,13 +147,13 @@
'after_name' => '</h2> 'after_name' => '</h2>
</label>', </label>',
'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . ' 'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '
<div class="tainacan-item-section__metadata ' . get_theme_mod($prefix . '_metadata_list_structure_type', 'metadata-type-1') . '" aria-labelledby="metadata-section-$slug">', <div class="tainacan-item-section__metadata ' . $metadata_list_structure_type . '" aria-labelledby="metadata-section-$slug">',
'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>', 'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>',
'metadata_list_args' => $metadata_args 'metadata_list_args' => $metadata_args
); );
echo '<div class="tainacan-metadata-sections-container metadata-section-layout--collapses">'; echo '<div class="tainacan-metadata-sections-container metadata-section-layout--collapses">';
tainacan_the_metadata_sections( $args ); tainacan_the_metadata_sections( $sections_args );
echo '</div>'; echo '</div>';
} else if ( $section_layout == 'metadata-section-type-4') { } else if ( $section_layout == 'metadata-section-type-4') {
@ -136,7 +162,8 @@
return str_replace('<input', '<input checked="checked"', $before); return str_replace('<input', '<input checked="checked"', $before);
}, 10, 2); }, 10, 2);
$args = array( $sections_args = array(
'metadata_sections__not_in' => $show_default_section_separated ? [ \Tainacan\Entities\Metadata_Section::$default_section_slug ] : [],
'before' => '', 'before' => '',
'after' => '', 'after' => '',
'before_name' => '<input name="accordion" type="radio" id="accordion-section-$id"/> 'before_name' => '<input name="accordion" type="radio" id="accordion-section-$id"/>
@ -146,29 +173,30 @@
'after_name' => '</h2> 'after_name' => '</h2>
</label>', </label>',
'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . ' 'before_metadata_list' => '<section class="tainacan-item-section tainacan-item-section--metadata">' . do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '
<div class="tainacan-item-section__metadata ' . get_theme_mod($prefix . '_metadata_list_structure_type', 'metadata-type-1') . '" aria-labelledby="metadata-section-$slug">', <div class="tainacan-item-section__metadata ' . $metadata_list_structure_type . '" aria-labelledby="metadata-section-$slug">',
'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>', 'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ) . '</section>',
'metadata_list_args' => $metadata_args 'metadata_list_args' => $metadata_args
); );
echo '<div class="tainacan-metadata-sections-container metadata-section-layout--accordion">'; echo '<div class="tainacan-metadata-sections-container metadata-section-layout--accordion">';
tainacan_the_metadata_sections( $args ); tainacan_the_metadata_sections( $sections_args );
echo '</div>'; echo '</div>';
} else { } else {
$args = array( $sections_args = array(
'metadata_sections__not_in' => $show_default_section_separated ? [ \Tainacan\Entities\Metadata_Section::$default_section_slug ] : [],
'before' => '<section class="tainacan-item-section tainacan-item-section--metadata">', 'before' => '<section class="tainacan-item-section tainacan-item-section--metadata">',
'after' => '</section>', 'after' => '</section>',
'before_name' => '<h2 class="tainacan-single-item-section" id="metadata-section-$slug">', 'before_name' => '<h2 class="tainacan-single-item-section" id="metadata-section-$slug">',
'after_name' => '</h2>', 'after_name' => '</h2>',
'hide_name' => !get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes', 'hide_name' => !$display_section_labels,
'before_metadata_list' => do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '<div class="tainacan-item-section__metadata ' . get_theme_mod($prefix . '_metadata_list_structure_type', 'metadata-type-1') . '">', 'before_metadata_list' => do_action( 'tainacan-blocksy-single-item-metadata-begin' ) . '<div class="tainacan-item-section__metadata ' . $metadata_list_structure_type . '">',
'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ), 'after_metadata_list' => '</div>' . do_action( 'tainacan-blocksy-single-item-metadata-end' ),
'metadata_list_args' => $metadata_args 'metadata_list_args' => $metadata_args
); );
echo '<div class="tainacan-metadata-sections-container">'; echo '<div class="tainacan-metadata-sections-container">';
tainacan_the_metadata_sections( $args ); tainacan_the_metadata_sections( $sections_args );
echo '</div>'; echo '</div>';
} }
?> ?>