Skip to content

Commit 271cf9b

Browse files
committed
Sync from pro: TOC improvements, CSS updates, settings; update readme for Pro TOC features
1 parent 62eee44 commit 271cf9b

13 files changed

Lines changed: 122 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ Effortlessly create a powerful, multi-product knowledge base. Boost your support
4343

4444
### Pro features
4545

46-
[Knowledge Base Pro](https://webberzone.com/plugins/knowledgebase/#pro) enhances the plugin with advanced features for larger documentation sites, including ratings and feedback, a help widget, a powerful custom permalinks engine, premium layouts, and additional admin tools.
46+
[Knowledge Base Pro](https://webberzone.com/plugins/knowledgebase/#pro) enhances the plugin with advanced features for larger documentation sites, including ratings and feedback, a help widget, a powerful custom permalinks engine, premium layouts, enhanced TOC surfaces, and additional admin tools.
4747

4848
-__Article Rating & Feedback System__ — Collect binary or 5-star feedback with optional follow-up questions, admin alerts, Bayesian sorting, and GDPR-friendly tracking modes.
4949
- 💬 __Help Widget__ — Offer an in-app support hub with live search, suggested articles, and a contact form inside a floating assistant.
5050
- 🧭 __Custom Permalinks Engine__ — Craft advanced URL structures for articles, sections, tags, and products using dynamic placeholders.
5151
- 🎨 __Premium Layout Pack__ — Unlock seven additional frontend styles (Card, Minimal, Boxed, Gradient, Compact, Magazine, Professional).
52+
- 📑 __Enhanced Table of Contents__ — Three Pro TOC delivery surfaces: a sidebar widget that renders the TOC for the current article, a Gutenberg block for inline insertion, and a floating/sticky panel that follows the reader down the page.
5253
- 🛠️ __Advanced Admin Tools__ — Control knowledge base caching with expiry settings, on-demand cache clearing, and other productivity enhancements.
5354

5455
### Key Concepts

includes/admin/class-settings.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,26 @@ public static function settings_output() {
730730
'type' => 'text',
731731
'default' => __( 'Table of Contents', 'knowledgebase' ),
732732
),
733+
'show_floating_toc' => array(
734+
'id' => 'show_floating_toc',
735+
'name' => esc_html__( 'Show floating table of contents', 'knowledgebase' ),
736+
'desc' => esc_html__( 'Display a sticky/floating TOC panel that follows the reader as they scroll through a KB article. Highlights the active section automatically.', 'knowledgebase' ),
737+
'type' => 'checkbox',
738+
'default' => false,
739+
'pro' => true,
740+
),
741+
'floating_toc_position' => array(
742+
'id' => 'floating_toc_position',
743+
'name' => esc_html__( 'Floating TOC position', 'knowledgebase' ),
744+
'desc' => esc_html__( 'Side of the viewport where the floating TOC panel is anchored.', 'knowledgebase' ),
745+
'type' => 'radio',
746+
'default' => 'right',
747+
'options' => array(
748+
'right' => esc_html__( 'Right', 'knowledgebase' ),
749+
'left' => esc_html__( 'Left', 'knowledgebase' ),
750+
),
751+
'pro' => true,
752+
),
733753
);
734754

735755
/**

includes/blocks/src/components/icons.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
1+
export const tocIcon = (props) => (
2+
<svg
3+
xmlns="http://www.w3.org/2000/svg"
4+
viewBox="-76.8 -76.8 665.6 665.6"
5+
{...props}
6+
>
7+
<rect
8+
width={665.6}
9+
height={665.6}
10+
x={-76.8}
11+
y={-76.8}
12+
fill="#FFBD59"
13+
rx={332.8}
14+
/>
15+
{ /* Bullet dots */}
16+
<circle cx="80" cy="120" r="32" fill="#792a18" />
17+
<circle cx="80" cy="256" r="32" fill="#792a18" />
18+
<circle cx="80" cy="392" r="32" fill="#792a18" />
19+
{ /* Lines */}
20+
<rect x="152" y="100" width="240" height="40" rx="20" fill="#fff" />
21+
<rect x="152" y="236" width="200" height="40" rx="20" fill="#fff" />
22+
<rect x="152" y="372" width="220" height="40" rx="20" fill="#fff" />
23+
{ /* Indented sub-items */}
24+
<rect x="192" y="168" width="160" height="32" rx="16" fill="#f0ebea" />
25+
<rect x="192" y="304" width="140" height="32" rx="16" fill="#f0ebea" />
26+
</svg>
27+
);
28+
29+
export const ratingIcon = (props) => (
30+
<svg
31+
xmlns="http://www.w3.org/2000/svg"
32+
viewBox="-76.8 -76.8 665.6 665.6"
33+
{...props}
34+
>
35+
<rect
36+
width={665.6}
37+
height={665.6}
38+
x={-76.8}
39+
y={-76.8}
40+
fill="#FFBD59"
41+
rx={332.8}
42+
/>
43+
<path
44+
fill="#792a18"
45+
d="M256 60l48.6 148.6H460l-126.3 91.8 48.2 148.4L256 357l-125.9 91.8 48.2-148.4L52 208.6h155.4z"
46+
/>
47+
</svg>
48+
);
49+
150
export const bookIcon = (props) => (
251
<svg
352
xmlns="http://www.w3.org/2000/svg"

includes/frontend/class-toc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function inject_toc( string $content ): string {
5252
return $content;
5353
}
5454

55-
$result = self::process_content( $content );
55+
$result = self::process_content( $content, array( 'extra_class' => 'wzkb-toc--inline' ) );
5656

5757
if ( empty( $result['toc'] ) ) {
5858
return $content;
@@ -75,6 +75,7 @@ public function inject_toc( string $content ): string {
7575
* @type int $heading_depth Max heading level to include (2–6). Default from setting.
7676
* @type int $min_headings Minimum headings required to show TOC. Default from setting.
7777
* @type string $title TOC title text. Default from setting.
78+
* @type string $extra_class Additional CSS class added to the TOC nav element. Default empty.
7879
* }
7980
* @return array {
8081
* @type string $toc TOC HTML, or empty string if below minimum headings.
@@ -86,6 +87,7 @@ public static function process_content( string $content, array $args = array() )
8687
'heading_depth' => (int) \wzkb_get_option( 'toc_heading_depth', 4 ),
8788
'min_headings' => (int) \wzkb_get_option( 'toc_min_headings', 3 ),
8889
'title' => (string) \wzkb_get_option( 'toc_title', __( 'Table of Contents', 'knowledgebase' ) ),
90+
'extra_class' => '',
8991
);
9092
$args = wp_parse_args( $args, $defaults );
9193

@@ -158,8 +160,9 @@ private static function build_toc_html( array $headings, array $args ): string {
158160
return '';
159161
}
160162

161-
$title = isset( $args['title'] ) ? (string) $args['title'] : '';
162-
$output = '<nav class="wzkb-toc" aria-label="' . esc_attr__( 'Table of Contents', 'knowledgebase' ) . '">';
163+
$title = isset( $args['title'] ) ? (string) $args['title'] : '';
164+
$extra_class = isset( $args['extra_class'] ) && '' !== $args['extra_class'] ? ' ' . esc_attr( $args['extra_class'] ) : '';
165+
$output = '<nav class="wzkb-toc' . $extra_class . '" aria-label="' . esc_attr__( 'Table of Contents', 'knowledgebase' ) . '">';
163166

164167
if ( '' !== $title ) {
165168
$output .= '<p class="wzkb-toc-title">' . esc_html( $title ) . '</p>';
@@ -186,9 +189,6 @@ private static function build_toc_html( array $headings, array $args ): string {
186189
}
187190
if ( ! empty( $stack ) && end( $stack ) === $level ) {
188191
$output .= '</li>';
189-
} elseif ( ! empty( $stack ) ) {
190-
$output .= '<ul>';
191-
$stack[] = $level;
192192
} else {
193193
$stack[] = $level;
194194
}

includes/frontend/css/styles/classic-rtl.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,11 +922,14 @@ nav.pagination {
922922

923923
/* Table of Contents */
924924
.wzkb-toc {
925+
margin-bottom: 2rem;
926+
}
927+
928+
.wzkb-toc--inline {
925929
background: var(--wzkb-bg-light);
926930
border: 1px solid var(--wzkb-border-light);
927931
border-radius: 6px;
928932
padding: 1rem 1.5rem;
929-
margin-bottom: 2rem;
930933
display: inline-block;
931934
min-width: 200px;
932935
max-width: 100%;
@@ -941,6 +944,11 @@ nav.pagination {
941944
font-size: 15px;
942945
}
943946

947+
.wzkb-toc--widget .wzkb-toc-title {
948+
color: inherit;
949+
font-size: inherit;
950+
}
951+
944952
.wzkb-toc-list,
945953
.wzkb-toc-list ul {
946954
margin: 0;

0 commit comments

Comments
 (0)