| 1 |
<?php |
| 2 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. |
| 3 |
|
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
/** |
| 9 |
* Template archive docs |
| 10 |
* |
| 11 |
* @link https://wpdeveloper.com |
| 12 |
* @since 1.0.0 |
| 13 |
* |
| 14 |
* @package BetterDocs |
| 15 |
* @subpackage BetterDocs/public |
| 16 |
*/ |
| 17 |
|
| 18 |
get_header(); |
| 19 |
|
| 20 |
$view_object = betterdocs()->views; |
| 21 |
$layout = betterdocs()->customizer->defaults->get( 'betterdocs_archive_layout_select', 'layout-7' ); |
| 22 |
$title_tag = betterdocs()->customizer->defaults->get( 'betterdocs_archive_title_tag', 'h2' ); |
| 23 |
$title_tag = betterdocs()->template_helper->is_valid_tag( $title_tag ); |
| 24 |
$current_category = get_queried_object(); |
| 25 |
$content_area_classes = [ |
| 26 |
'betterdocs-content-wrapper betterdocs-display-flex', |
| 27 |
"doc-category-$layout" |
| 28 |
]; |
| 29 |
?> |
| 30 |
|
| 31 |
<div class="betterdocs-wrapper betterdocs-taxonomy-wrapper betterdocs-category-archive-wrapper betterdocs-wraper"> |
| 32 |
<?php betterdocs()->template_helper->search(); ?> |
| 33 |
|
| 34 |
<div class="<?php echo esc_attr( implode( ' ', $content_area_classes ) ); ?>"> |
| 35 |
<?php betterdocs()->template_helper->sidebar( $layout, 'template' ); ?> |
| 36 |
|
| 37 |
<div id="main" class="betterdocs-content-area"> |
| 38 |
<div class="betterdocs-content-inner-area"> |
| 39 |
<?php |
| 40 |
$view_object->get( |
| 41 |
'templates/parts/mobile-nav', |
| 42 |
[ |
| 43 |
'mobile_sidebar' => true, |
| 44 |
'mobile_toc' => false |
| 45 |
] |
| 46 |
); |
| 47 |
/** |
| 48 |
* Breadcrumbs |
| 49 |
*/ |
| 50 |
$view_object->get( 'templates/parts/breadcrumbs' ); |
| 51 |
?> |
| 52 |
|
| 53 |
<div class="betterdocs-entry-title"> |
| 54 |
<?php echo wp_sprintf( '<%1$s class="docs-cat-heading">%2$s</%1$s>', 'h3', $current_category->name ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> |
| 55 |
</div> |
| 56 |
|
| 57 |
<div class="betterdocs-entry-body betterdocs-taxonomy-doc-category"> |
| 58 |
<?php |
| 59 |
$_tax_query = [ |
| 60 |
[ |
| 61 |
'taxonomy' => 'doc_tag', |
| 62 |
'field' => 'slug', |
| 63 |
'terms' => isset( $current_category->slug ) ? $current_category->slug : '' |
| 64 |
] |
| 65 |
]; |
| 66 |
$post_query = betterdocs()->query->get_posts( |
| 67 |
[ |
| 68 |
'term_id' => isset( $current_category->term_id ) ? $current_category->term_id : '', |
| 69 |
'term_slug' => isset( $current_category->slug ) ? $current_category->slug : '', |
| 70 |
'posts_per_page' => -1, |
| 71 |
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- tag-archive listing requires tax filtering by design. |
| 72 |
'tax_query' => apply_filters( 'betterdocs_tag_tax_query', $_tax_query, $current_category ) |
| 73 |
] |
| 74 |
); |
| 75 |
|
| 76 |
$custom_icon = betterdocs()->customizer->defaults->get( 'betterdocs_archive_list_icon' ); |
| 77 |
$settings_list_icon = betterdocs()->settings->get( 'docs_list_icon' ); |
| 78 |
if ( ! $custom_icon && $settings_list_icon ) { |
| 79 |
$custom_icon = $settings_list_icon['url']; |
| 80 |
} |
| 81 |
|
| 82 |
if ( $post_query->have_posts() ) : |
| 83 |
?> |
| 84 |
<ul> |
| 85 |
<?php |
| 86 |
while ( $post_query->have_posts() ) : |
| 87 |
$post_query->the_post(); |
| 88 |
if ( $custom_icon ) { |
| 89 |
$icon = '<img src="' . esc_url( $custom_icon ) . '" />'; |
| 90 |
} else { |
| 91 |
$icon = betterdocs()->template_helper->icon(); |
| 92 |
} |
| 93 |
echo wp_sprintf( |
| 94 |
'<li>%s<a href="%s">%s</a></li>', |
| 95 |
$icon, //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 96 |
esc_attr( esc_url( get_the_permalink() ) ), |
| 97 |
betterdocs()->template_helper->kses( get_the_title() ) //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 98 |
); |
| 99 |
endwhile; |
| 100 |
wp_reset_postdata(); |
| 101 |
?> |
| 102 |
</ul> |
| 103 |
<?php |
| 104 |
else : |
| 105 |
echo '<p class="nothing-here">' . esc_html__( 'Sorry, no docs were found.', 'betterdocs' ) . '</p>'; |
| 106 |
endif; // $post_query->have_posts() |
| 107 |
?> |
| 108 |
</div> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
|
| 114 |
<?php |
| 115 |
get_footer(); |
| 116 |
|