PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.8.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.8.0
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 3.5.2 All 199 releases
betterdocs / includes / Editors / BlockEditor / Blocks / ArchiveHeader.php

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

59 lines 1.5 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 [
33 'term_id' => isset( $current_category->term_id ) ? $current_category->term_id : '',
34 'term_slug' => isset( $current_category->slug ) ? $current_category->slug : '',
35 'posts_per_page' => -1
36 ]
37 );
38
39 $post_query = new \WP_Query( $args );
40
41 $_nested_categories = betterdocs()->query->get_child_term_ids_by_parent_id( 'doc_category', ( isset( $current_category->term_id ) ? $current_category->term_id : '' ) );
42
43 if ( $_nested_categories ) {
44 $sub_terms_count = count( explode( ',', $_nested_categories ) );
45 } else {
46 $sub_terms_count = 0;
47 }
48
49 return [
50 'current_category' => $current_category,
51 'found_posts' => $post_query->found_posts,
52 'show_count' => true,
53 'title_tag' => $this->attributes['titleTag'],
54 'show_icon' => true,
55 'sub_terms_count' => $sub_terms_count,
56 ];
57 }
58 }
59