PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
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 / views / templates / authors / author.php

author.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.2, at views/templates/authors/author.php

77 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- view template receives variables via extract(); prefixing is impractical.
3
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8 wp_enqueue_style('betterdocs-pagination');
9
10 $author_id = get_query_var( 'author' );
11 $page = get_query_var( 'page' );
12 $enable_pagination = false;
13
14 $default_args = [
15 'post_type' => 'docs',
16 'author' => $author_id,
17 'posts_per_page' => -1
18 ];
19
20 if ( ! empty( $page ) ) { // if page is found enable pagination
21 $default_args['paged'] = $page;
22 $default_args['posts_per_page'] = 10;
23 $enable_pagination = true;
24 }
25
26 $post_query = new WP_Query( $default_args );
27
28 $author_docs_count = count_user_posts( $author_id, 'docs' );
29 $author_name = get_the_author_meta( 'nicename', $author_id );
30 $author_avatar_tag = get_avatar( $author_id, 40 );
31
32
33 get_header();
34
35 ?>
36 <div class="betterdocs-wrapper betterdocs-taxonomy-wrapper betterdocs-archive-layout-7 betterdocs-category-archive-wrapper betterdocs-wraper">
37 <div class="betterdocs-content-wrapper betterdocs-display-flex doc-category-layout-7">
38 <div id="main" class="betterdocs-content-area">
39 <div class="betterdocs-content-inner-area">
40 <?php
41
42 betterdocs()->views->get( 'template-parts/author-header', [
43 'author_name' => $author_name,
44 'author_docs_count' => $author_docs_count,
45 'avatar_tag' => $author_avatar_tag
46 ] );
47
48 betterdocs()->views->get( 'template-parts/author-archive-doc-list', [
49 'post_query' => $post_query
50 ] );
51
52 if ( $enable_pagination ) {
53 global $wp;
54 $remove_the_last_two_vars = explode( '/', $wp->request );
55 $new_link = home_url() .'/'. implode( '/', array_slice( $remove_the_last_two_vars, 0, ( count( $remove_the_last_two_vars ) - 2 ) ) ) . '/';
56 $total_pages = ceil( ( isset( $post_query->found_posts ) ? $post_query->found_posts : 0 ) / 10 );
57
58 betterdocs()->views->get(
59 'template-parts/pagination',
60 [
61 'total_pages' => $total_pages,
62 'link' => $new_link,
63 'current_page' => isset( $page ) ? $page : 1,
64 'template' => 'doc_category' //bypass the template to be used in authors template
65 ]
66 );
67 }
68 ?>
69 </div>
70 </div>
71 </div>
72 </div>
73
74 <?php
75 get_footer();
76 ?>
77