Skip to content

Commit cb192fe

Browse files
committed
New block: Breadcrumbs
* Features: * New block: Knowledge Base Breadcrumbs. * Modifications: * Enhanced breadcrumb navigation with semantic HTML5 markup and improved accessibility * Added Schema.org BreadcrumbList markup for better SEO * Added support for custom Unicode separators in breadcrumbs
1 parent b035623 commit cb192fe

File tree

18 files changed

+316
-196
lines changed

18 files changed

+316
-196
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"name": "knowledgebase/breadcrumb",
5+
"version": "2.3.0",
6+
"title": "Knowledge Base Breadcrumb",
7+
"category": "design",
8+
"icon": "menu",
9+
"keywords": [
10+
"knowledgebase",
11+
"breadcrumb",
12+
"kb",
13+
"navigation"
14+
],
15+
"description": "Display the Knowledge Base Breadcrumb navigation",
16+
"supports": {
17+
"html": false,
18+
"align": true
19+
},
20+
"attributes": {
21+
"className": {
22+
"type": "string",
23+
"default": ""
24+
},
25+
"separator": {
26+
"type": "string",
27+
"default": "»"
28+
}
29+
},
30+
"example": {},
31+
"textdomain": "knowledgebase",
32+
"editorScript": "file:./index.js",
33+
"editorStyle": "file:./index.css",
34+
"style": "file:./style-index.css"
35+
}

includes/blocks/build/breadcrumb/index-rtl.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-server-side-render'), 'version' => '209f3d829860668efee0');

includes/blocks/build/breadcrumb/index.css

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

includes/blocks/build/breadcrumb/index.js

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

includes/blocks/build/kb-articles/index-rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => 'af27dffe54569e88bed6');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-i18n', 'wp-server-side-render'), 'version' => 'fdd6590102694fbba66d');

includes/blocks/build/kb-articles/index.css

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

includes/blocks/class-blocks.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace WebberZone\Knowledge_Base\Blocks;
1010

1111
use WebberZone\Knowledge_Base\Frontend\Display;
12+
use WebberZone\Knowledge_Base\Frontend\Breadcrumbs;
1213

1314
// If this file is called directly, abort.
1415
if ( ! defined( 'WPINC' ) ) {
@@ -43,6 +44,7 @@ public function register_blocks() {
4344
'kb' => 'render_kb_block',
4445
'alerts' => 'render_alerts_block',
4546
'kb-articles' => 'render_articles_block',
47+
'breadcrumb' => 'render_breadcrumb_block',
4648
);
4749

4850
foreach ( $blocks as $block_name => $render_callback ) {
@@ -123,11 +125,10 @@ public function render_kb_block( $attributes ) {
123125
*
124126
* @param array $attributes The block attributes.
125127
* @param string $content The block content.
126-
* @param array $block The block object.
127128
*
128129
* @return string Returns the post content with latest posts added.
129130
*/
130-
public function render_alerts_block( $attributes, $content, $block ) {
131+
public function render_alerts_block( $attributes, $content ) {
131132
return wp_kses_post( $content );
132133
}
133134

@@ -177,4 +178,25 @@ public function render_articles_block( $attributes ) {
177178

178179
return $list_of_posts;
179180
}
181+
182+
/**
183+
* Render the block.
184+
*
185+
* @since 2.3.0
186+
*
187+
* @param array $attributes Block attributes.
188+
*
189+
* @return string Rendered block output.
190+
*/
191+
public static function render_breadcrumb_block( $attributes ) {
192+
$wrapper_attributes = get_block_wrapper_attributes();
193+
194+
$output = sprintf(
195+
'<div %1$s>%2$s</div>',
196+
$wrapper_attributes,
197+
wzkb_get_breadcrumb( $attributes )
198+
);
199+
200+
return $output;
201+
}
180202
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "https://schemas.wp.org/trunk/block.json",
3+
"apiVersion": 3,
4+
"name": "knowledgebase/breadcrumb",
5+
"version": "2.3.0",
6+
"title": "Knowledge Base Breadcrumb",
7+
"category": "design",
8+
"icon": "menu",
9+
"keywords": ["knowledgebase", "breadcrumb", "kb", "navigation"],
10+
"description": "Display the Knowledge Base Breadcrumb navigation",
11+
"supports": {
12+
"html": false,
13+
"align": true
14+
},
15+
"attributes": {
16+
"className": {
17+
"type": "string",
18+
"default": ""
19+
},
20+
"separator": {
21+
"type": "string",
22+
"default": "»"
23+
}
24+
},
25+
"example": {},
26+
"textdomain": "knowledgebase",
27+
"editorScript": "file:./index.js",
28+
"editorStyle": "file:./index.css"
29+
}

0 commit comments

Comments
 (0)