| 1 |
<?php |
| 2 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
use WPDeveloper\BetterDocs\Utils\Helper; |
| 8 |
|
| 9 |
$posts = betterdocs()->query->get_posts( $query_args, true ); |
| 10 |
|
| 11 |
if ( ! $posts->have_posts() ) { |
| 12 |
wp_reset_postdata(); |
| 13 |
} |
| 14 |
|
| 15 |
$_page_id = null; |
| 16 |
|
| 17 |
if ( is_single() ) { |
| 18 |
$_page_id = get_the_ID(); |
| 19 |
} |
| 20 |
?> |
| 21 |
|
| 22 |
<ul class="betterdocs-articles-list"> |
| 23 |
<?php |
| 24 |
|
| 25 |
if ( '' === $query_args[ 'posts_per_page' ] ) { |
| 26 |
$query_args[ 'posts_per_page' ] = get_option( 'posts_per_page' ); |
| 27 |
} |
| 28 |
|
| 29 |
if ( -1 == $query_args[ 'posts_per_page' ] || $query_args[ 'posts_per_page' ] > 0 ) { |
| 30 |
while ( $posts->have_posts() ): |
| 31 |
$posts->the_post(); |
| 32 |
$_link_attributes = array( |
| 33 |
'href' => esc_url( get_the_permalink() ) |
| 34 |
); |
| 35 |
|
| 36 |
if ( get_the_ID() === $_page_id && Helper::get_tax() != 'doc_category' ) { |
| 37 |
$_link_attributes[ 'class' ] = 'active'; |
| 38 |
} |
| 39 |
|
| 40 |
$_link_attributes = betterdocs()->template_helper->get_html_attributes( $_link_attributes ); |
| 41 |
|
| 42 |
echo wp_sprintf( |
| 43 |
'<li><a %1$s>%2$s</a></li>', |
| 44 |
$_link_attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 45 |
// Same per-item filter as category-list.php (API method badges etc.). |
| 46 |
apply_filters( 'betterdocs_docs_list_item_title', betterdocs()->template_helper->kses( get_the_title() ), get_the_ID() ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 47 |
); |
| 48 |
endwhile; |
| 49 |
|
| 50 |
wp_reset_postdata(); |
| 51 |
} |
| 52 |
?> |
| 53 |
</ul> |
| 54 |
|