PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 3.8.9
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v3.8.9
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Core/Rewrite.php +4 -27 4.4.13.8.9 View file →
@@ -141,13 +141,8 @@
141 141
142 142 return $structure;
143 143 }
144 144
145 - public function hierarchy_based_slug_switch() {
146 - $hierarchy_slug = $this->settings->get( 'enable_category_hierarchy_slugs', false );
147 - return $hierarchy_slug;
148 - }
149 -
150 145 public function get_base_slug() {
151 146 $docs_slug = $this->settings->get( 'docs_slug', 'docs' );
152 147 $docs_page = $this->settings->get( 'docs_page', 0 );
153 148 $builtin_doc_page = $this->settings->get( 'builtin_doc_page', true );
@@ -201,9 +196,9 @@
201 196 function ( $carry, $item ) {
202 197 $carry .= ( strpos( $item, '%' ) !== false ? '([^/]+)' : $item ) . '/';
203 198 return $carry;
204 199 },
205 - '^'
200 + ''
206 201 ) . '?$';
207 202 }
208 203
209 204 public function make_query( $segments ) {
@@ -236,23 +231,17 @@
236 231 * https://url/docs/(kb-slug)/(cat-slug)/(docs-slug)
237 232 * https://url/docs/(cat-slug)/(kb-slug)/(docs-slug)
238 233 */
239 234
240 - $base = $this->get_base_slug();
241 - $hierarchy_slug = $this->hierarchy_based_slug_switch();
235 + $base = $this->get_base_slug();
242 236
243 237 // Add rule to handle pagination attempts
244 238 $this->add_rewrite_rule(
245 - '^' . $base . '/page/([0-9]+)/?$',
239 + $base . '/page/([0-9]+)/?$',
246 240 'index.php?post_type=docs',
247 241 'top'
248 242 );
249 243
250 - $base = $this->get_base_slug();
251 - $this->add_rewrite_rule( '^' . $base . '/(feed|rdf|rss|rss2|atom)/?$', 'index.php?post_type=docs&feed=$matches[1]' );
252 - $this->add_rewrite_rule( '^' . $base . '/authors/([0-9]+)/?$', 'index.php?post_type=docs&author=$matches[1]' );
253 - $this->add_rewrite_rule( '^' . $base . '/authors/([0-9]+)/page/([0-9]+)/?$', 'index.php?post_type=docs&author=$matches[1]&page=$matches[2]' );
254 -
255 244 /**
256 245 * This code of blocks used to determine single docs permalink.
257 246 */
258 247 $_docs_perma_struct = betterdocs()->settings->get( 'permalink_structure', 'docs' );
@@ -257,20 +246,8 @@
257 246 */
258 247 $_docs_perma_struct = betterdocs()->settings->get( 'permalink_structure', 'docs' );
259 248 $_normalized_structure = $this->normalzie_doc_perma_structure( $_docs_perma_struct );
260 249
261 - if( $hierarchy_slug ) { // register hierarchy based slug rewrite rule, for single doc permalink
262 - // When MKB or WPML is used, the actual base for single docs might differ from the generic $base
263 - $perma_base = isset( $_normalized_structure['raw'][0] ) && strpos( $_normalized_structure['raw'][0], '%' ) === false
264 - ? $_normalized_structure['raw'][0]
265 - : $base;
266 -
267 - $this->add_rewrite_rule( '^' . $perma_base . '/(.+?)/([^/]+)(?:/([0-9]+))?/?$', 'index.php?doc_category=$matches[1]&docs=$matches[2]&post_type=docs', 'top' );
268 -
269 - // Removed flush_rewrite_rules() from here. Calling flush_rewrite_rules() on the 'init' hook causes
270 - // infinite database updates and destroys custom rules when WPML or MKB dynamically filters keys.
271 - }
272 -
273 250 $_feed_regex = $_normalized_structure['raw'];
274 251 $_feed_regex[] = '(feed|rdf|rss|rss2|atom)';
275 252 $_feed_group = $_normalized_structure['group'];
276 253 $_feed_group[] = '%feed%';
@@ -281,9 +258,9 @@
281 258 $this->make_regex( $_normalized_structure['raw'] ),
282 259 $this->make_query( $_normalized_structure['group'] )
283 260 );
284 261
285 - $this->add_rewrite_rule( '^' . $base . '/(feed|rdf|rss|rss2|atom)/?$', 'index.php?post_type=docs&feed=$matches[1]' );
262 + $this->add_rewrite_rule( $base . '/(feed|rdf|rss|rss2|atom)/?$', 'index.php?post_type=docs&feed=$matches[1]' );
286 263 }
287 264
288 265 public function add_rewrite_rule( $regex, $query, $after = 'top' ) {
289 266 add_rewrite_rule( $regex, $query, $after );