| 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 |
if ( ! isset( $current_category ) || $current_category === null ) { |
| 8 |
return; |
| 9 |
} |
| 10 |
?> |
| 11 |
|
| 12 |
<div class="betterdocs-title-excerpt-lists betterdocs-title-excerpt-grid"> |
| 13 |
<?php |
| 14 |
$custom_icon = betterdocs()->customizer->defaults->get( 'betterdocs_archive_list_icon' ); |
| 15 |
$settings_list_icon = betterdocs()->settings->get( 'docs_list_icon' ); |
| 16 |
if ( ! $custom_icon && $settings_list_icon ) { |
| 17 |
$custom_icon = $settings_list_icon['url']; |
| 18 |
} |
| 19 |
|
| 20 |
if ( $post_query->have_posts() ) : |
| 21 |
while ( $post_query->have_posts() ) : |
| 22 |
$post_query->the_post(); |
| 23 |
$title_tag = isset( $docs_list_title_tag ) ? $docs_list_title_tag : 'h2'; |
| 24 |
$title_tag = betterdocs()->template_helper->is_valid_tag( $title_tag ); |
| 25 |
?> |
| 26 |
<div class="betterdocs-title-excerpt-list"> |
| 27 |
<?php echo wp_sprintf( '<span class="update-date">%s %s</span>', esc_html__( 'Last Updated:', 'betterdocs' ), get_the_modified_date() ); //phpcs:ignore ?> |
| 28 |
<<?php echo esc_attr( $title_tag ); ?> class="betterdocs-entry-title"> |
| 29 |
<a href="<?php echo esc_url( get_the_permalink() ); ?>"> |
| 30 |
<?php echo esc_html( get_the_title() ); ?> |
| 31 |
</a> |
| 32 |
</<?php echo esc_attr( $title_tag ); ?>> |
| 33 |
<?php |
| 34 |
// Set excerpt length to 14 words |
| 35 |
add_filter( |
| 36 |
'excerpt_length', |
| 37 |
function () { |
| 38 |
return 14; |
| 39 |
} |
| 40 |
); |
| 41 |
|
| 42 |
// Replace '[…]' with '...' |
| 43 |
add_filter( |
| 44 |
'excerpt_more', |
| 45 |
function () { |
| 46 |
return '...'; // Replace '[…]' with '...' |
| 47 |
} |
| 48 |
); |
| 49 |
|
| 50 |
echo '<p>' . esc_html( get_the_excerpt() ) . '</p>'; |
| 51 |
|
| 52 |
// Remove filters to avoid affecting other excerpts |
| 53 |
remove_filter( 'excerpt_length', '__return_empty_string' ); |
| 54 |
remove_filter( 'excerpt_more', '__return_empty_string' ); |
| 55 |
?> |
| 56 |
</div> |
| 57 |
<?php |
| 58 |
endwhile; |
| 59 |
wp_reset_postdata(); |
| 60 |
endif; |
| 61 |
?> |
| 62 |
</div> |
| 63 |
|