fix: paginated region/city pages, no routes before first save, safer structure save

- Add /{slug}/page/N/ rules and keep the page number through 301s
- Route only regions synced to a term, so unsaved presets never claim /europe/ etc.
- Flush rewrites on the request after activation so structure routes survive
- Suggest the existing term slug for new cities (keeps live /tour-destination/ URLs)
- Refuse saves without the editor sentinel; confirm before saving an empty structure
- Show term-sync failures to the admin instead of reporting success

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 15:33:01 +03:30
parent f5c4c89f1a
commit 930b7e0534
8 changed files with 161 additions and 28 deletions

View File

@@ -99,6 +99,13 @@ class VC_Routing {
$term = get_queried_object();
if ( self::is_configured_term( $term ) ) {
$canonical = get_term_link( $term );
// Keep the page: /tour-destination/x/page/2/ and /x/?paged=2
// both land on /x/page/2/ (the form core's redirect_canonical
// would produce anyway).
$paged = (int) get_query_var( 'paged' );
if ( $paged > 1 && ! is_wp_error( $canonical ) ) {
$canonical = trailingslashit( $canonical ) . 'page/' . $paged . '/';
}
}
}
if ( ! $canonical || is_wp_error( $canonical ) ) {
@@ -114,6 +121,7 @@ class VC_Routing {
}
if ( isset( $parts[1] ) && '' !== $parts[1] ) {
$canonical .= '?' . $parts[1];
$canonical = remove_query_arg( 'paged', $canonical );
}
wp_safe_redirect( $canonical, 301 );
exit;