dca134b5b6
- Delete the HPCT importer (no caller left after core dropped HPCT in PR-020c) and its bootstrap/alias/test-bootstrap entries - Conflict guard notice, log line and HivePress admin tab no longer point to the never-existing `wp wpdo hivepress migrate-from-hpct`; they say to deactivate the legacy plugins (their own tables are not imported) - Verify: ConflictGuardTest guard; HP unit 146 / integration 49 OK, bootstrap smoke OK - PR: PR-020d
130 lines
4.5 KiB
PHP
130 lines
4.5 KiB
PHP
<?php
|
|
/**
|
|
* Bootstrap for 2meet Data Optimizer HivePress AddOn.
|
|
*
|
|
* 載入 13 adapter + 補助組件 + admin tab + CLI namespace。
|
|
*
|
|
* 注意:HP 的 V3.0.0 family bootstrap 內部也有一個 class TMDO_HivePress_Bootstrap
|
|
* (在 includes/hivepress/class-tmdo-hivepress-bootstrap.php)。為避免衝突,本
|
|
* AddOn outer bootstrap 改名為 TMDO_HP_Bootstrap。
|
|
*
|
|
* @package TMDO_HIVEPRESS
|
|
* @since 0.1.0
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
final class TMDO_HP_Bootstrap {
|
|
|
|
public static function init(): void {
|
|
if ( ! class_exists( 'TMDO_API' ) && ! class_exists( 'WPDO_API' ) ) {
|
|
add_action( 'admin_notices', array( __CLASS__, 'missing_core_notice' ) );
|
|
return;
|
|
}
|
|
|
|
load_plugin_textdomain(
|
|
'tmdo-hivepress',
|
|
false,
|
|
dirname( plugin_basename( TMDO_HIVEPRESS_FILE ) ) . '/languages'
|
|
);
|
|
|
|
self::require_files();
|
|
self::register_hooks();
|
|
}
|
|
|
|
private static function require_files(): void {
|
|
$base = TMDO_HIVEPRESS_PATH;
|
|
|
|
// HivePress family bootstrap framework
|
|
require_once $base . 'includes/hivepress/interface-tmdo-hp-adapter.php';
|
|
require_once $base . 'includes/hivepress/trait-tmdo-hp-adapter.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-detector.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-conflict-guard.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-bootstrap.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-cron-optimizer.php';
|
|
|
|
// 13 adapters
|
|
foreach ( array(
|
|
'core', 'reviews', 'favorites', 'messages', 'memberships',
|
|
'requests', 'tags', 'seo', 'social-links', 'blocks',
|
|
'bookings', 'marketplace', 'statistics',
|
|
) as $adapter_slug ) {
|
|
$file = $base . "includes/hivepress/adapters/class-tmdo-hivepress-{$adapter_slug}-adapter.php";
|
|
if ( file_exists( $file ) ) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
|
|
// HP misc components
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-attribute-bridge.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-suitability-scorer.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-benchmark.php';
|
|
require_once $base . 'includes/hivepress/class-tmdo-hivepress-rest.php';
|
|
|
|
// Misc HP integration files
|
|
require_once $base . 'includes/class-tmdo-hivepress.php';
|
|
require_once $base . 'includes/class-tmdo-hivepress-transient-filter.php';
|
|
require_once $base . 'includes/class-tmdo-hivepress-term-comment-fields.php';
|
|
require_once $base . 'includes/class-tmdo-hivepress-entity-groups.php';
|
|
require_once $base . 'includes/class-tmdo-listing-stats.php';
|
|
}
|
|
|
|
private static function register_hooks(): void {
|
|
// HP family v3.0.0 per-addon adapter bootstrap
|
|
// (TMDO_HivePress_Bootstrap is the inner family bootstrap class
|
|
// from includes/hivepress/class-tmdo-hivepress-bootstrap.php)
|
|
if ( class_exists( 'TMDO_HivePress_Bootstrap' )
|
|
&& method_exists( 'TMDO_HivePress_Bootstrap', 'boot' ) ) {
|
|
TMDO_HivePress_Bootstrap::boot();
|
|
}
|
|
|
|
// HP transient filter (init:5)
|
|
if ( class_exists( 'TMDO_Hivepress_Transient_Filter' ) ) {
|
|
add_action( 'init', array( 'TMDO_Hivepress_Transient_Filter', 'init' ), 5 );
|
|
}
|
|
|
|
// Listing Stats hooks + cron
|
|
if ( class_exists( 'TMDO_Listing_Stats' ) ) {
|
|
TMDO_Listing_Stats::register_hooks();
|
|
TMDO_Listing_Stats::schedule_cron();
|
|
}
|
|
|
|
// Term/Comment fields
|
|
if ( class_exists( 'TMDO_Hivepress_Term_Comment_Fields' )
|
|
&& method_exists( 'TMDO_Hivepress_Term_Comment_Fields', 'register' ) ) {
|
|
TMDO_Hivepress_Term_Comment_Fields::register();
|
|
}
|
|
|
|
// Post + user entity groups (hp_listing_core / hp_request_core / hp_vendor_core / hp_user).
|
|
TMDO_HivePress_Entity_Groups::register();
|
|
|
|
// Admin tab
|
|
if ( is_admin() ) {
|
|
$admin_file = TMDO_HIVEPRESS_PATH . 'admin/class-tmdo-admin-hivepress.php';
|
|
if ( file_exists( $admin_file ) ) {
|
|
require_once $admin_file;
|
|
}
|
|
}
|
|
|
|
// CLI namespace
|
|
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
|
$cli_file = TMDO_HIVEPRESS_PATH . 'cli/class-tmdo-cli-hivepress.php';
|
|
if ( file_exists( $cli_file ) ) {
|
|
require_once $cli_file;
|
|
if ( class_exists( 'TMDO_CLI_HivePress' ) ) {
|
|
\WP_CLI::add_command( 'tmdo hivepress', 'TMDO_CLI_HivePress' );
|
|
\WP_CLI::add_command( 'wpdo hivepress', 'TMDO_CLI_HivePress' );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static function missing_core_notice(): void {
|
|
echo '<div class="notice notice-error"><p>';
|
|
echo esc_html__( '2meet Data Optimizer HivePress AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-hivepress' );
|
|
echo '</p></div>';
|
|
}
|
|
}
|