| @@ -1,27 +1,70 @@ | ||
| 1 | 1 | <?php |
| 2 | - $current_category = get_queried_object(); | |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical. | |
| 3 | 3 | |
| 4 | - if ( $current_category != null ): | |
| 5 | -?> | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | +$current_category = get_queried_object(); | |
| 6 | 8 | |
| 7 | -<div class='betterdocs-content-area block-archive-list <?php echo $blockId; ?>'> | |
| 8 | - <div class="betterdocs-content-inner-area"> | |
| 9 | - <div class="betterdocs-entry-title"> | |
| 10 | - <?php | |
| 11 | - echo wp_sprintf( | |
| 12 | - '<%1$s class="betterdocs-entry-heading">%2$s</%1$s>', | |
| 13 | - $title_tag, | |
| 14 | - $current_category->name | |
| 15 | - ); | |
| 16 | - echo wp_sprintf( '<p>%s</p>', wp_kses_post( $current_category->description ) ); | |
| 17 | - ?> | |
| 18 | - </div> | |
| 19 | - <div class="betterdocs-entry-body betterdocs-taxonomy-doc-category"> | |
| 20 | - <?php $view_object->get( 'widgets/archive-list' );?> | |
| 21 | - </div> | |
| 22 | - </div> | |
| 23 | -</div> | |
| 9 | +if ( $current_category != null && $layout == 'layout-1' ) : | |
| 24 | 10 | |
| 25 | -<?php | |
| 26 | - endif; | |
| 27 | -?> | |
| 11 | + ?> | |
| 12 | + <div class='betterdocs-content-area block-archive-list <?php echo esc_attr( $blockId ); ?>'> | |
| 13 | + <div class="betterdocs-content-inner-area"> | |
| 14 | + <div class="betterdocs-entry-title"> | |
| 15 | + <?php | |
| 16 | + $title_tag = tag_escape( betterdocs()->template_helper->is_valid_tag( isset( $title_tag ) ? $title_tag : 'h2' ) ); | |
| 17 | + echo wp_sprintf( | |
| 18 | + '<%1$s class="betterdocs-entry-heading">%2$s</%1$s>', | |
| 19 | + $title_tag, //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 20 | + esc_html( $current_category->name ) | |
| 21 | + ); | |
| 22 | + echo wp_sprintf( '<p>%s</p>', wp_kses_post( $current_category->description ) ); | |
| 23 | + ?> | |
| 24 | + </div> | |
| 25 | + <div class="betterdocs-entry-body betterdocs-taxonomy-doc-category"> | |
| 26 | + <?php $view_object->get( 'widgets/archive-list' ); ?> | |
| 27 | + </div> | |
| 28 | + </div> | |
| 29 | + </div> | |
| 30 | + <?php | |
| 31 | + elseif ( $current_category != null && $layout == 'layout-2' ) : | |
| 32 | + // Public action name predates the prefix convention; renaming would break third-party integrations. | |
| 33 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 34 | + do_action( 'archive_handbook_list' ); | |
| 35 | + elseif ( $current_category != null && ( $layout == 'layout-3' || $layout == 'layout-4' ) ) : | |
| 36 | + $post_query = new WP_Query( $query_args ); | |
| 37 | + | |
| 38 | + | |
| 39 | + // Determine CSS class and template based on layout | |
| 40 | + $css_class = $layout == 'layout-3' ? 'doc-category-layout-7' : 'doc-category-layout-4'; | |
| 41 | + $template = $layout == 'layout-3' ? 'template-parts/archive-doc-list' : 'template-parts/archive-doc-list-2'; | |
| 42 | + | |
| 43 | + echo '<div class="' . esc_attr( $blockId ) . ' ' . esc_attr( $css_class ) . '">'; | |
| 44 | + betterdocs()->views->get( | |
| 45 | + $template, | |
| 46 | + [ | |
| 47 | + 'current_category' => $current_category, | |
| 48 | + 'post_query' => $post_query, | |
| 49 | + 'docs_list_title_tag' => isset( $docs_list_title_tag ) ? $docs_list_title_tag : 'h2' | |
| 50 | + ] | |
| 51 | + ); | |
| 52 | + | |
| 53 | + // Common pagination logic for both layout-3 and layout-4 | |
| 54 | + if ( $pagination ) { | |
| 55 | + $current_page = isset( $page ) ? $page : ( get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1 ); | |
| 56 | + $posts_per_page = isset( $posts_per_page ) && $posts_per_page > 0 ? $posts_per_page : 10; | |
| 57 | + $total_pages = ceil( ( isset( $post_query->found_posts ) ? $post_query->found_posts : 0 ) / $posts_per_page ); | |
| 58 | + betterdocs()->views->get( | |
| 59 | + 'template-parts/pagination', | |
| 60 | + [ | |
| 61 | + 'total_pages' => $total_pages, | |
| 62 | + 'link' => ( $current_category instanceof \WP_Term ) ? get_term_link( $current_category, 'doc_category' ) : get_permalink(get_the_ID()), | |
| 63 | + 'current_page' => $current_page, | |
| 64 | + 'template' => 'doc_category' | |
| 65 | + ] | |
| 66 | + ); | |
| 67 | + } | |
| 68 | + echo '</div>'; | |
| 69 | + endif; | |
| 70 | + ?> | |