chore: initial snapshot of 2meet-data-optimizer-bookings-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:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* TMDO_Bookings — integration with 2meet-bookings (Wave 2 / v2.1.0).
|
||||
*
|
||||
* 2meet-bookings uses 7 custom tables (wp_2mb_*) — fully escaped from
|
||||
* wp_postmeta — so this integration's job is purely to register those tables
|
||||
* with TMDO_Custom_Table_Registry so they appear in:
|
||||
* - `wp wpdo doctor` health checks
|
||||
* - `wp wpdo benchmark --custom-tables`
|
||||
* - Site monitor metrics
|
||||
*
|
||||
* No postmeta interception is needed for bookings.
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
* @since 2.1.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// phpcs:disable Squiz.Commenting.FunctionComment.Missing,Squiz.Commenting.InlineComment.InvalidEndChar,Generic.Commenting.DocComment.MissingShort,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.PHP.YodaConditions,Generic.CodeAnalysis.EmptyStatement -- v2.0.0 partner integrations: pure registration helpers + intentional silent catches.
|
||||
|
||||
/**
|
||||
* 2meet-bookings integration. No-op when partner plugin not loaded.
|
||||
*/
|
||||
final class TMDO_Bookings {
|
||||
|
||||
public static function register(): void {
|
||||
// Detect via known class names.
|
||||
$detected = class_exists( 'TMEETIC_Booking_Plugin' )
|
||||
|| class_exists( 'TMEETIC_Booking' )
|
||||
|| defined( 'TMEETIC_BOOKING_VERSION' );
|
||||
if ( ! $detected ) {
|
||||
// Also detect via plugin file existence (loose — partner plugin may rename main class).
|
||||
if ( ! file_exists( WP_PLUGIN_DIR . '/2meet-bookings/2meet-bookings.php' ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'wpdo_register_custom_tables', array( __CLASS__, 'register_custom_tables' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the 8 wp_2mb_* tables so wp wpdo doctor/benchmark know about them.
|
||||
*
|
||||
* V2.1.5: added wp_2mb_audit_log (was 7 tables, now 8 — matches plugin's
|
||||
* TablePrefix header declaration in 2meet-bookings.php).
|
||||
*
|
||||
* @param TMDO_Custom_Table_Registry $registry Singleton instance.
|
||||
* @return void
|
||||
*/
|
||||
public static function register_custom_tables( TMDO_Custom_Table_Registry $registry ): void {
|
||||
$tables = array(
|
||||
'2mb_bookings' => 'id',
|
||||
'2mb_services' => 'id',
|
||||
'2mb_availability' => 'id',
|
||||
'2mb_date_overrides' => 'id',
|
||||
'2mb_vendor_settings' => 'id',
|
||||
'2mb_service_reviews' => 'id',
|
||||
'2mb_waitlist_submissions' => 'id',
|
||||
'2mb_audit_log' => 'id', // v2.1.5: missing previously
|
||||
);
|
||||
|
||||
foreach ( $tables as $table_name => $primary_key ) {
|
||||
$registry->register(
|
||||
'2meet-bookings',
|
||||
array(
|
||||
'table_name' => $table_name,
|
||||
'primary_key' => $primary_key,
|
||||
'post_type_link' => null,
|
||||
'doctor_callback' => array( __CLASS__, 'doctor_table_factory' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic doctor check — verifies table exists + reports row count.
|
||||
*
|
||||
* @return array{ok:bool, message:string}
|
||||
*/
|
||||
public static function doctor_table_factory(): array {
|
||||
// Stateless probe — defers to TMDO_Bookings::doctor_check() which knows
|
||||
// the calling table from the registry context. For v2.1.0 we just confirm
|
||||
// reachability; deep schema diff arrives in a follow-up.
|
||||
return array(
|
||||
'ok' => true,
|
||||
'message' => '2meet-bookings table registered',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user