Skip to content

Commit fe5ca73

Browse files
committed
refactor: improve CPT registration with proper name and front-end URL structure
1 parent eb35faf commit fe5ca73

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

includes/class-cpt.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function register_post_type() {
8282
$ptlabels = apply_filters( 'wzkb_post_type_labels', $ptlabels );
8383

8484
$ptargs = array(
85-
'label' => __( 'wz_knowledgebase', 'knowledgebase' ),
85+
'name' => 'wz_knowledgebase',
8686
'description' => __( 'Knowledge Base', 'knowledgebase' ),
8787
'labels' => $ptlabels,
8888
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'author', 'custom-fields', 'comments' ),
@@ -95,6 +95,7 @@ public static function register_post_type() {
9595
'map_meta_cap' => true,
9696
'has_archive' => $archives,
9797
'rewrite' => $rewrite,
98+
'query_var' => true,
9899
);
99100

100101
/**
@@ -127,7 +128,7 @@ private static function get_taxonomy_base_args( string $slug, bool $is_hierarchi
127128
'show_tagcloud' => ! $is_hierarchical,
128129
'rewrite' => array(
129130
'slug' => $slug,
130-
'with_front' => true,
131+
'with_front' => false,
131132
'hierarchical' => $is_hierarchical,
132133
),
133134
);

includes/class-main.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
namespace WebberZone\Knowledge_Base;
99

1010
use WebberZone\Knowledge_Base\Admin\Admin;
11-
use WebberZone\Knowledge_Base\Pro\Pro;
1211
use WebberZone\Knowledge_Base\Util\Hook_Registry;
1312

1413
if ( ! defined( 'WPINC' ) ) {
@@ -42,9 +41,9 @@ final class Main {
4241
*
4342
* @since 3.0.0
4443
*
45-
* @var Pro|null Pro instance.
44+
* @var Pro\Pro|null Pro instance.
4645
*/
47-
public ?Pro $pro = null;
46+
public ?Pro\Pro $pro = null;
4847

4948
/**
5049
* Shortcodes.
@@ -182,7 +181,7 @@ private function init() {
182181

183182
// Conditionally load Pro if available.
184183
if ( class_exists( 'WebberZone\\Knowledge_Base\\Pro\\Pro' ) ) {
185-
$this->pro = new Pro();
184+
$this->pro = new Pro\Pro();
186185
}
187186

188187
if ( is_admin() ) {
@@ -210,7 +209,7 @@ public function initiate_plugin() {
210209
}
211210

212211
/**
213-
* Initialise the Better Search widgets.
212+
* Initialise the Knowledge Base widgets.
214213
*
215214
* @since 2.3.0
216215
*/

0 commit comments

Comments
 (0)