Skip to content

Commit 0ca53c8

Browse files
committed
Improve RTL styles, update settings and functions, update readme
- RTL CSS: add missing RTL rules for classic and vibrant themes - class-settings.php: additional settings fields - class-main.php: register new hooks - functions.php: additional helper functions - tom-select: update bundled JS to latest - readme.txt / README.md: content updates Fixes #75
1 parent 8f5147a commit 0ca53c8

14 files changed

Lines changed: 317 additions & 488 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Effortlessly create a powerful, multi-product knowledge base. Boost your support
3939
- 🧭 __Built-in Breadcrumbs__ — Improve UX and SEO with breadcrumb navigation.
4040
- 🧩 __Widgets Included__ — WZKB Articles, WZKB Sections, and WZKB Breadcrumbs widgets.
4141
-__Built-in Caching__ — Speed up your Knowledge Base without extra plugins.
42+
- 📋 __Auto Table of Contents__ — Automatically generate a linked Table of Contents from article headings, with configurable depth and minimum heading threshold.
4243

4344
### Pro features
4445

includes/admin/class-settings.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,46 @@ public static function settings_output() {
690690
'type' => 'checkbox',
691691
'default' => true,
692692
),
693+
'toc_header' => array(
694+
'id' => 'toc_header',
695+
'name' => '<h3>' . esc_html__( 'Table of Contents', 'knowledgebase' ) . '</h3>',
696+
'desc' => '',
697+
'type' => 'header',
698+
),
699+
'show_toc' => array(
700+
'id' => 'show_toc',
701+
'name' => esc_html__( 'Show table of contents', 'knowledgebase' ),
702+
'desc' => esc_html__( 'Auto-generate a table of contents from headings in article content. Only displays when there are sufficient headings.', 'knowledgebase' ),
703+
'type' => 'checkbox',
704+
'default' => false,
705+
),
706+
'toc_heading_depth' => array(
707+
'id' => 'toc_heading_depth',
708+
'name' => esc_html__( 'TOC heading depth', 'knowledgebase' ),
709+
'desc' => esc_html__( 'Maximum heading level to include in the table of contents. 2 includes only H2; 3 includes H2 and H3, and so on.', 'knowledgebase' ),
710+
'type' => 'number',
711+
'default' => 4,
712+
'size' => 'small',
713+
'min' => 2,
714+
'max' => 6,
715+
),
716+
'toc_min_headings' => array(
717+
'id' => 'toc_min_headings',
718+
'name' => esc_html__( 'Minimum headings for TOC', 'knowledgebase' ),
719+
'desc' => esc_html__( 'Minimum number of headings required before the table of contents is displayed.', 'knowledgebase' ),
720+
'type' => 'number',
721+
'default' => 3,
722+
'size' => 'small',
723+
'min' => 1,
724+
'max' => 20,
725+
),
726+
'toc_title' => array(
727+
'id' => 'toc_title',
728+
'name' => esc_html__( 'TOC title', 'knowledgebase' ),
729+
'desc' => esc_html__( 'Title displayed above the table of contents. Leave empty to hide the title.', 'knowledgebase' ),
730+
'type' => 'text',
731+
'default' => __( 'Table of Contents', 'knowledgebase' ),
732+
),
693733
);
694734

695735
/**

includes/admin/settings/js/tom-select.complete.min.js

Lines changed: 1 addition & 440 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-main.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,15 @@ final class Main {
155155
*/
156156
public Frontend\Related $related_articles;
157157

158+
/**
159+
* Table of contents.
160+
*
161+
* @since 3.0.0
162+
*
163+
* @var Frontend\TOC TOC handler.
164+
*/
165+
public Frontend\TOC $toc;
166+
158167
/**
159168
* Block patterns.
160169
*
@@ -201,6 +210,7 @@ private function init() {
201210
$this->styles = new Frontend\Styles_Handler();
202211
$this->display = new Frontend\Display();
203212
$this->related_articles = new Frontend\Related();
213+
$this->toc = new Frontend\TOC();
204214
$this->search = new Frontend\Search();
205215
$this->shortcodes = new Frontend\Shortcodes();
206216
$this->feed = new Frontend\Feed();

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

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
--wzkb-color-text: #333;
1515
--wzkb-color-text-medium: #666;
1616
--wzkb-color-white: #fff;
17-
--wzkb-color-orange: orange;
17+
--wzkb-color-orange: #f97316;
1818

1919
/* Background colors */
2020
--wzkb-bg-white: #fff;
2121
--wzkb-bg-light: #f8f9fa;
22-
--wzkb-bg-ghostwhite: ghostwhite;
22+
--wzkb-bg-ghostwhite: #f8f8ff;
2323

2424
/* Border colors */
2525
--wzkb-border-light: #e0e0e0;
@@ -189,11 +189,11 @@
189189
}
190190

191191
.wzkb-section-name-level-1 {
192-
border-bottom: 1px black dotted;
193-
border-top: 1px black dotted;
194-
padding: 5px 1px;
195-
background-color: var(--wzkb-bg-ghostwhite);
196-
margin-top: 30px;
192+
border-bottom: 2px solid var(--wzkb-border-light);
193+
border-top: none;
194+
padding: 8px 0 10px;
195+
background-color: transparent;
196+
margin-top: 24px;
197197
margin-bottom: 0;
198198
grid-column: 1 / -1;
199199
}
@@ -242,25 +242,17 @@
242242
}
243243

244244
.wzkb-articles-list li:before {
245-
content: "\f123";
245+
content: "";
246246
display: inline-block;
247-
width: 20px;
248-
height: 20px;
249-
font-size: 20px;
250-
line-height: 1;
251-
font-family: dashicons;
252-
text-decoration: inherit;
247+
width: 16px;
248+
font-size: 18px;
249+
line-height: 1.4;
253250
font-weight: 400;
254-
font-style: normal;
255-
vertical-align: top;
256-
text-align: center;
257-
-webkit-transition: color 0.1s ease-in 0;
258-
transition: color 0.1s ease-in 0;
251+
font-family: inherit;
259252
-webkit-font-smoothing: antialiased;
260253
-moz-osx-font-smoothing: grayscale;
261-
margin-left: 10px;
262-
word-wrap: break-word;
263-
color: var(--wzkb-color-text-medium);
254+
margin-left: 8px;
255+
color: var(--wzkb-color-primary);
264256
}
265257

266258
.wzkb-articles-list li a {
@@ -927,3 +919,51 @@ nav.pagination {
927919
margin: 0;
928920
line-height: 1.55;
929921
}
922+
923+
/* Table of Contents */
924+
.wzkb-toc {
925+
background: var(--wzkb-bg-light);
926+
border: 1px solid var(--wzkb-border-light);
927+
border-radius: 6px;
928+
padding: 1rem 1.5rem;
929+
margin-bottom: 2rem;
930+
display: inline-block;
931+
min-width: 200px;
932+
max-width: 100%;
933+
box-sizing: border-box;
934+
box-shadow: 0 1px 4px var(--wzkb-shadow-color);
935+
}
936+
937+
.wzkb-toc-title {
938+
font-weight: 700;
939+
margin: 0 0 0.5rem;
940+
color: var(--wzkb-color-text-dark);
941+
font-size: 15px;
942+
}
943+
944+
.wzkb-toc-list,
945+
.wzkb-toc-list ul {
946+
margin: 0;
947+
padding-right: 1.25rem;
948+
list-style: disc;
949+
}
950+
951+
.wzkb-toc-list ul {
952+
padding-right: 1.5rem;
953+
}
954+
955+
.wzkb-toc-list li {
956+
margin: 0.2rem 0;
957+
line-height: 1.5;
958+
}
959+
960+
.wzkb-toc-list a {
961+
color: var(--wzkb-color-primary);
962+
text-decoration: none;
963+
transition: color 0.2s ease;
964+
}
965+
966+
.wzkb-toc-list a:hover {
967+
color: var(--wzkb-color-dark);
968+
text-decoration: underline;
969+
}

0 commit comments

Comments
 (0)