- 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>
75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
final class VC_Plugin {
|
|
private static $instance = null;
|
|
|
|
public static function instance() {
|
|
if ( null === self::$instance ) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
private function __construct() {}
|
|
|
|
public function init() {
|
|
$this->load_files();
|
|
|
|
VC_CPT::init();
|
|
VC_Taxonomies::init();
|
|
VC_Settings::init();
|
|
VC_Structure_Admin::init();
|
|
VC_Routing::init();
|
|
VC_Menu::init();
|
|
VC_Cron::init();
|
|
VC_Display::init();
|
|
VC_Sections::init();
|
|
}
|
|
|
|
private function load_files() {
|
|
$files = array(
|
|
'includes/helpers.php',
|
|
'includes/class-vc-logger.php',
|
|
'includes/class-vc-cpt.php',
|
|
'includes/class-vc-taxonomies.php',
|
|
'includes/class-vc-structure.php',
|
|
'includes/class-vc-api.php',
|
|
'includes/class-vc-importer.php',
|
|
'includes/class-vc-cron.php',
|
|
'includes/class-vc-settings.php',
|
|
'includes/class-vc-structure-admin.php',
|
|
'includes/class-vc-routing.php',
|
|
'includes/class-vc-menu.php',
|
|
'includes/class-vc-display.php',
|
|
'includes/class-vc-sections.php',
|
|
);
|
|
|
|
foreach ( $files as $file ) {
|
|
require_once VC_PLUGIN_DIR . $file;
|
|
}
|
|
}
|
|
|
|
public static function activate() {
|
|
require_once VC_PLUGIN_DIR . 'includes/helpers.php';
|
|
require_once VC_PLUGIN_DIR . 'includes/class-vc-cpt.php';
|
|
require_once VC_PLUGIN_DIR . 'includes/class-vc-taxonomies.php';
|
|
require_once VC_PLUGIN_DIR . 'includes/class-vc-cron.php';
|
|
|
|
VC_CPT::register();
|
|
VC_Taxonomies::register();
|
|
VC_Cron::maybe_schedule();
|
|
flush_rewrite_rules();
|
|
// Structure routes are added on init, which has not run for this
|
|
// request; flush again on the next one so they are included.
|
|
update_option( 'vc_flush_rewrite', 1 );
|
|
}
|
|
|
|
public static function deactivate() {
|
|
require_once VC_PLUGIN_DIR . 'includes/class-vc-cron.php';
|
|
VC_Cron::unschedule();
|
|
delete_transient( 'vc_sync_lock' );
|
|
flush_rewrite_rules();
|
|
}
|
|
}
|