hesabixWpTheme/wedocs/shortcode.php
2026-05-22 13:52:15 +03:30

91 lines
5.7 KiB
PHP

<?php
$enable_doc_search = ! empty( $enable_search ) && $enable_search === 'on';
$hide_docs_list = ! empty( $hide_docs_list );
if ( $enable_doc_search || ( ! empty( $docs ) && ! $hide_docs_list ) ) {
?>
<div class="wedocs-shortcode-wrap">
<?php if ( $enable_doc_search ) { ?>
<div class="mb-10">
<?php wedocs_get_template_part( 'doc-search', 'form' ); ?>
</div>
<?php } ?>
<?php if ( ! empty( $docs ) && ! $hide_docs_list ) : ?>
<ul class="wedocs-docs-list grid grid-cols-1 md:grid-cols-2 lg:grid-cols-<?php echo (int) $col; ?> gap-6">
<?php foreach ( $docs as $main_doc ) { ?>
<li class="wedocs-docs-single bg-white rounded-3xl border border-slate-100 shadow-md hover:shadow-xl hover:border-brand-200 transition-all overflow-hidden group">
<div class="p-6 sm:p-8">
<h3 class="text-xl font-bold text-slate-800 mb-4 group-hover:text-brand-600 transition-colors">
<a class="block" href="<?php echo esc_url( get_permalink( $main_doc['doc']->ID ) ); ?>">
<?php echo esc_html( $main_doc['doc']->post_title ); ?>
</a>
</h3>
<div class="inside">
<?php if ( ! empty( $main_doc['sections'] ) ) : ?>
<ul class="wedocs-doc-sections space-y-2">
<?php
foreach ( $main_doc['sections'] as $section ) {
$article_args = array(
'post_type' => 'docs',
'posts_per_page' => '-1',
'orderby' => 'menu_order',
'order' => 'ASC'
);
$article_args = apply_filters( 'wedocs_shortcode_page_section_args', $article_args );
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query( $article_args );
$children_docs = get_page_children( $section->ID, $all_wp_pages );
$post_title = wedocs_apply_short_content(
__( $section->post_title, 'wedocs' ),
$col > 1 ? 60 : 160
);
$collapse_section_articles = wedocs_get_general_settings( 'collapse_articles', 'off' );
?>
<li>
<a class="icon-view font-medium text-slate-600 hover:text-brand-600 transition-colors" href="<?php echo esc_url( get_permalink( $section->ID ) ); ?>">
<?php echo esc_html( $post_title ); ?>
</a>
<?php if ( $children_docs ) : ?>
<svg fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="w-4 h-4 inline-block align-middle text-slate-400 <?php echo esc_attr( $collapse_section_articles !== 'on' ? 'active' : '' ); ?>"><path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>
<?php endif; ?>
</li>
<?php if ( $children_docs ) : ?>
<ul class="children has-icon mt-2 mr-4 pr-4 border-r-2 border-slate-100 space-y-1 <?php echo esc_attr( $collapse_section_articles !== 'on' ? 'active' : '' ); ?>">
<?php foreach ( $children_docs as $article ) : ?>
<li>
<a class="text-sm text-slate-500 hover:text-brand-600 transition-colors" href="<?php echo esc_url( get_permalink( $article->ID ) ); ?>">
<?php echo esc_html( wedocs_apply_short_content( $article->post_title, $col > 1 ? 60 : 160 ) ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php } ?>
</ul>
<?php else : ?>
<p class="flex items-start gap-2 text-sm text-slate-500">
<svg class="w-5 h-5 mt-0.5 text-slate-400 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<?php esc_html_e( 'هنوز بخشی برای این مستند اضافه نشده است.', 'wedocs' ); ?>
</p>
<?php endif; ?>
</div>
<div class="mt-6 pt-5 border-t border-slate-100 flex items-center justify-between">
<span class="text-xs text-slate-400"><?php echo esc_html__( 'ادامه مطلب', 'wedocs' ); ?></span>
<a class="inline-flex items-center gap-2 text-sm font-semibold text-brand-600 hover:text-brand-500 transition-colors" href="<?php echo esc_url( get_permalink( $main_doc['doc']->ID ) ); ?>">
<?php echo esc_html( $more ); ?>
<span aria-hidden="true">←</span>
</a>
</div>
</div>
</li>
<?php } ?>
</ul>
<?php endif; ?>
</div>
<?php }