| 1 |
<?php |
| 2 |
/** |
| 3 |
* Side-effect-free Booking Modes V3 preflight boundary. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
* @since 11.8.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Verify the complete V3 production manifest and all declarations before bootstrap. |
| 15 |
* |
| 16 |
* Loading validator classes is intentionally allowed here; hooks, assets, and |
| 17 |
* public compatibility functions are registered only after this returns true. |
| 18 |
* |
| 19 |
* @return array<string,mixed> Result with ready and errors keys. |
| 20 |
*/ |
| 21 |
function wpbc_booking_modes_v3_preflight() { |
| 22 |
static $result = null; |
| 23 |
|
| 24 |
if ( null !== $result ) { |
| 25 |
return $result; |
| 26 |
} |
| 27 |
|
| 28 |
$base_directory = __DIR__; |
| 29 |
$required_files = array( |
| 30 |
$base_directory . '/class-wpbc-booking-modes-v3-definition-validator.php', |
| 31 |
$base_directory . '/class-wpbc-booking-modes-v3-definition-registry.php', |
| 32 |
$base_directory . '/class-wpbc-booking-modes-v3-definition-translator.php', |
| 33 |
$base_directory . '/class-wpbc-booking-modes-v3-page-registry.php', |
| 34 |
$base_directory . '/class-wpbc-booking-modes-v3-compatibility-registry.php', |
| 35 |
$base_directory . '/class-wpbc-booking-modes-v3-context.php', |
| 36 |
$base_directory . '/class-wpbc-booking-modes-v3-storage.php', |
| 37 |
$base_directory . '/class-wpbc-booking-modes-v3-source-index.php', |
| 38 |
$base_directory . '/class-wpbc-booking-modes-v3-compiler.php', |
| 39 |
$base_directory . '/class-wpbc-booking-modes-v3-switch-intent.php', |
| 40 |
$base_directory . '/canonical-pages.php', |
| 41 |
$base_directory . '/booking_modes-api.php', |
| 42 |
$base_directory . '/booking_modes-navigation.php', |
| 43 |
$base_directory . '/booking_modes-services.php', |
| 44 |
$base_directory . '/booking_modes-setup.php', |
| 45 |
$base_directory . '/booking_modes-toolbar.php', |
| 46 |
$base_directory . '/booking_modes-landing.php', |
| 47 |
$base_directory . '/ajax/booking_mode_switch.php', |
| 48 |
$base_directory . '/ajax/booking_mode_quickstart.php', |
| 49 |
$base_directory . '/quickstart/booking_modes-quickstart.php', |
| 50 |
$base_directory . '/quickstart/appointment.php', |
| 51 |
$base_directory . '/quickstart/rental.php', |
| 52 |
$base_directory . '/_out/booking_modes.js', |
| 53 |
$base_directory . '/_out/booking_modes.css', |
| 54 |
$base_directory . '/_out/booking_modes-native-menu.css', |
| 55 |
$base_directory . '/booking_modes.php', |
| 56 |
$base_directory . '/modes/classic.php', |
| 57 |
$base_directory . '/modes/appointment.php', |
| 58 |
$base_directory . '/modes/rental.php', |
| 59 |
); |
| 60 |
|
| 61 |
$errors = array(); |
| 62 |
foreach ( $required_files as $required_file ) { |
| 63 |
if ( ! is_readable( $required_file ) ) { |
| 64 |
$errors[] = 'Missing or unreadable V3 component: ' . basename( $required_file ); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
if ( ! empty( $errors ) ) { |
| 69 |
$result = array( 'ready' => false, 'errors' => $errors ); |
| 70 |
return $result; |
| 71 |
} |
| 72 |
|
| 73 |
require_once $base_directory . '/class-wpbc-booking-modes-v3-definition-validator.php'; |
| 74 |
require_once $base_directory . '/class-wpbc-booking-modes-v3-definition-registry.php'; |
| 75 |
|
| 76 |
$registry = WPBC_Booking_Modes_V3_Definition_Registry::get_instance(); |
| 77 |
$is_valid = $registry->load( $base_directory ); |
| 78 |
$result = array( |
| 79 |
'ready' => $is_valid, |
| 80 |
'errors' => $registry->get_errors(), |
| 81 |
); |
| 82 |
|
| 83 |
return $result; |
| 84 |
} |
| 85 |
|