PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.1
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.1
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
betterdocs / includes / Editors / BlockEditor / Blocks / ArchiveHeader.php

ArchiveHeader.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 3.8.1, at includes/Editors/BlockEditor/Blocks/ArchiveHeader.php

57 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDeveloper\BetterDocs\Editors\BlockEditor\Blocks;
4
5 use WPDeveloper\BetterDocs\Editors\BlockEditor\Block;
6
7 class ArchiveHeader extends Block {
8
9 protected $editor_styles = ['betterdocs-category-archive-header'];
10
11 protected $frontend_styles = ['betterdocs-category-archive-header', 'betterdocs-doc_category'];
12
13 public function get_name() {
14 return 'archive-header';
15 }
16
17 public function get_default_attributes() {
18 return [
19 'blockId' => '',
20 'titleTag' => 'h2'
21 ];
22 }
23
24 public function render( $attributes, $content ) {
25 $this->views( 'widgets/archive-header' );
26 }
27
28 public function view_params() {
29 $current_category = get_queried_object();
30
31 $args = betterdocs()->query->docs_query_args( [
32 'term_id' => isset( $current_category->term_id ) ? $current_category->term_id : '',
33 'term_slug' => isset( $current_category->slug ) ? $current_category->slug : '',
34 'posts_per_page' => -1
35 ] );
36
37 $post_query = new \WP_Query( $args );
38
39 $_nested_categories = betterdocs()->query->get_child_term_ids_by_parent_id( 'doc_category', (isset( $current_category->term_id ) ? $current_category->term_id : '') );
40
41 if ( $_nested_categories ) {
42 $sub_terms_count = count( explode( ',', $_nested_categories ) );
43 } else {
44 $sub_terms_count = 0;
45 }
46
47 return [
48 'current_category' => $current_category,
49 'found_posts' => $post_query->found_posts,
50 'show_count' => true,
51 'title_tag' => $this->attributes['titleTag'],
52 'show_icon' => true,
53 'sub_terms_count' => $sub_terms_count,
54 ];
55 }
56 }
57