Skip to content

Commit a8a46a7

Browse files
author
Smart Cloud Solutions Inc.
committed
feat(ai-kit): allow title, URL, and metadata editing for KB section-based documents
1 parent 486cfc0 commit a8a46a7

14 files changed

Lines changed: 74 additions & 8 deletions

File tree

ai-kit-admin/dist/chunks/330.828d35e6.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

ai-kit-admin/dist/chunks/330.9e81af7e.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.

ai-kit-admin/dist/index.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('jquery', 'react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => 'fb86e5d1fe3b40905744');
1+
<?php return array('dependencies' => array('jquery', 'react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '62ae99f41fce601125a5');

ai-kit-admin/dist/index.js

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

ai-kit-admin/php/kb/admin.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ private function getEffectiveSectionMetadata(object $section, ?object $override)
11461146
if (is_array($extra_meta) && !empty($extra_meta['description']) && is_string($extra_meta['description'])) {
11471147
$metadata['description'] = $extra_meta['description'];
11481148
}
1149+
if (is_array($extra_meta) && !empty($extra_meta['postUrl']) && is_string($extra_meta['postUrl'])) {
1150+
$metadata['postUrl'] = $extra_meta['postUrl'];
1151+
}
11491152
if ($section->category) {
11501153
$metadata['category'] = $section->category;
11511154
}

ai-kit-admin/php/kb/parser.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ private function parseGutenbergWithSections(\WP_Post $post, array $blocks): arra
315315
'md' => $this->converter->blocksToMarkdown($base_content_blocks),
316316
'generated_at' => current_time('mysql'),
317317
'source_updated_at' => $post->post_modified,
318+
'extra_meta' => [
319+
'description' => $this->getPostDescription($post),
320+
'postUrl' => $this->getPostUrl($post),
321+
],
318322
];
319323

320324
$base_section['origin_hash'] = $this->calculateOriginHash($base_section);
@@ -343,6 +347,7 @@ private function parseKbSectionBlock(\WP_Post $post, array $block, int $sort_ord
343347
$doc_key = $attrs['docKey'] ?? null;
344348
$title = $attrs['title'] ?? null;
345349
$description = $attrs['description'] ?? null;
350+
$post_url = $attrs['postUrl'] ?? null;
346351
$tags = $attrs['tags'] ?? null;
347352
$category = $attrs['category'] ?? null;
348353
$subcategory = $attrs['subcategory'] ?? null;
@@ -381,6 +386,7 @@ private function parseKbSectionBlock(\WP_Post $post, array $block, int $sort_ord
381386
'extra_meta' => [
382387
'block_type' => 'gutenberg',
383388
'description' => $description,
389+
'postUrl' => $post_url,
384390
'priority' => $priority,
385391
],
386392
];
@@ -416,6 +422,7 @@ private function parseGutenbergSimple(\WP_Post $post, array $blocks): array
416422
'source_updated_at' => $post->post_modified,
417423
'extra_meta' => [
418424
'description' => $this->getPostDescription($post),
425+
'postUrl' => $this->getPostUrl($post),
419426
],
420427
];
421428

@@ -588,6 +595,7 @@ private function parseElementorWithSections(\WP_Post $post, array $elements): ar
588595
'source_updated_at' => $post->post_modified,
589596
'extra_meta' => [
590597
'description' => $this->getPostDescription($post),
598+
'postUrl' => $this->getPostUrl($post),
591599
'source_type' => 'elementor',
592600
],
593601
];
@@ -679,6 +687,7 @@ private function parseElementorKbSection(\WP_Post $post, array $element, int $so
679687
$doc_key = $settings['kb_doc_key'] ?? null;
680688
$doc_title = $settings['kb_doc_title'] ?? null;
681689
$doc_description = $settings['kb_doc_description'] ?? null;
690+
$doc_post_url = $settings['kb_post_url']['url'] ?? null;
682691
$title = $settings['kb_title'] ?? null;
683692
$category = $settings['kb_category'] ?? null;
684693
$subcategory = $settings['kb_subcategory'] ?? null;
@@ -733,6 +742,7 @@ private function parseElementorKbSection(\WP_Post $post, array $element, int $so
733742
'source_updated_at' => $post->post_modified,
734743
'extra_meta' => [
735744
'description' => $doc_description,
745+
'postUrl' => $doc_post_url,
736746
'source_type' => 'elementor',
737747
'priority' => $priority,
738748
],
@@ -853,6 +863,7 @@ private function parseElementorSimple(\WP_Post $post, array $elements): array
853863
'source_updated_at' => $post->post_modified,
854864
'extra_meta' => [
855865
'description' => $this->getPostDescription($post),
866+
'postUrl' => $this->getPostUrl($post),
856867
'source_type' => 'elementor',
857868
],
858869
];
@@ -900,6 +911,7 @@ private function parseClassicPost(\WP_Post $post): array
900911
'source_updated_at' => $post->post_modified,
901912
'extra_meta' => [
902913
'description' => $this->getPostDescription($post),
914+
'postUrl' => $this->getPostUrl($post),
903915
],
904916
];
905917

@@ -968,6 +980,16 @@ private function getPostDescription(\WP_Post $post): ?string
968980
return $description !== '' ? $description : null;
969981
}
970982

983+
/**
984+
* Get the canonical post URL when available.
985+
*/
986+
private function getPostUrl(\WP_Post $post): ?string
987+
{
988+
$url = get_permalink($post);
989+
990+
return is_string($url) && $url !== '' ? $url : null;
991+
}
992+
971993
/**
972994
* Generate a stable section ID from block data
973995
*/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ce7a317b779454e7ef4a');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '8ffe613288822cef7625');

ai-kit-blocks/dist/editor.js

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

ai-kit-blocks/dist/kb-section/block.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"description": {
2828
"type": "string"
2929
},
30+
"postUrl": {
31+
"type": "string"
32+
},
3033
"tags": {
3134
"type": "array",
3235
"default": [],

ai-kit-blocks/src/kb-section/block.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"description": {
2828
"type": "string"
2929
},
30+
"postUrl": {
31+
"type": "string"
32+
},
3033
"tags": {
3134
"type": "array",
3235
"default": [],

0 commit comments

Comments
 (0)