chore: initial snapshot of 2meet-data-optimizer-hivepress-addon v0.1.0

Baseline before backporting wp-data-optimizer v3.0.1-v3.4.6.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
2026-07-31 05:06:36 +08:00
commit b4400a68e5
56 changed files with 10395 additions and 0 deletions
@@ -0,0 +1,159 @@
<?php
/**
* Bookings adapter — `hivepress-bookings` (DETECT-ONLY in v3.0.0).
*
* The bookings plugin is not installed in the dev environment, so this
* adapter ships pre-built but only activates when the addon is detected
* by `TMDO_HivePress_Detector`. Schema is based on HivePress' published
* Booking model (post_type=hp_booking) — fields are best-effort from the
* addon's documented field aliases:
*
* start_time / end_time → unix timestamp range queries (hot)
* status → enum filter (hot)
* guests → numeric count (hot for slot-availability)
* listing → post_parent (already a posts column)
*
* Hot-zone target: `wp_wpdo_hot_hp_booking` with covering indexes on
* `(listing_id, start_time)` for slot-availability queries and
* `(status, start_time)` for vendor dashboard listings.
*
* The schema MAY drift from real Booking model when the addon is finally
* installed; reconcile with `wp wpdo doctor` then.
*
* @package WP_Data_Optimizer
* @since 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'TMDO_HivePress_Bookings_Adapter' ) ) {
/**
* Bookings addon adapter (detect-only — schema reserved for future install).
*/
final class TMDO_HivePress_Bookings_Adapter implements TMDO_HivePress_Adapter {
use TMDO_HivePress_Adapter_Trait;
/**
* Constructor — bind register hooks via inherited trait.
*/
public function __construct() {
$this->bind_anti_eav_hooks();
}
/** Adapter slug (matches wp.org plugin slug). */
public function plugin_slug(): string {
return 'hivepress-bookings';
}
/** Class probed for addon presence. */
public function detection_class(): string {
return 'HivePress\\Bookings\\Plugin';
}
/** Version constant probed for addon presence. */
public function detection_const(): string {
return 'HIVEPRESS_BOOKINGS_VERSION';
}
/** Minimum addon version supported. */
public function minimum_addon_version(): string {
return '1.0.0';
}
/**
* Register hot fields for hp_booking post type.
*
* @param TMDO_Schema_Registry $registry Schema registry singleton.
*/
public function on_register_fields( TMDO_Schema_Registry $registry ): void {
$registry->register_many(
$this->plugin_slug(),
array(
array(
'post_type' => 'hp_booking',
'meta_key' => 'hp_start_time',
'zone' => 'hot',
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
'column' => 'hp_start_time',
'indexed' => true,
),
array(
'post_type' => 'hp_booking',
'meta_key' => 'hp_end_time',
'zone' => 'hot',
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
'column' => 'hp_end_time',
'indexed' => true,
),
array(
'post_type' => 'hp_booking',
'meta_key' => 'hp_guests',
'zone' => 'hot',
'data_type' => 'int(11) NOT NULL DEFAULT 0',
'column' => 'hp_guests',
'indexed' => false,
),
)
);
}
/**
* Doctor probe — verify hot table when addon is active.
*
* @return array{ok:bool, message:string}
*/
public function doctor_check(): array {
global $wpdb;
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) {
return array(
'ok' => false,
'message' => 'wpdb global not available',
);
}
$table = $wpdb->prefix . 'wpdo_hot_hp_booking';
try {
$exists = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );
return array(
'ok' => $exists,
'message' => $exists
? sprintf( 'hivepress-bookings: %s present', $table )
: sprintf( 'hivepress-bookings: %s missing (addon installed but not migrated)', $table ),
);
} catch ( \Throwable $e ) {
return array(
'ok' => false,
'message' => sprintf( 'hivepress-bookings doctor failed: %s', $e->getMessage() ),
);
}
}
/**
* 8-D self-score.
*
* D8 (perf) reduced to 0.9 because the schema is best-effort from
* documentation; once the addon is installed and EXPLAIN can verify
* index usage, raise to 1.0.
*/
public function suitability_score(): array {
return $this->compose_score(
array(
'd8_perf' => 0.9,
)
);
}
/**
* FSM modules this adapter contributes.
*
* @return array<int,string>
*/
public function migrations(): array {
return array( 'hot_hp_booking' );
}
}
} // end if ( ! class_exists )