PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.3
Yatra – Travel Booking & Tour Operator Software v3.0.3
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / app / Compatibility / Compatibility.php

Compatibility.php in Yatra – Travel Booking & Tour Operator Software 3.0.3, at app/Compatibility/Compatibility.php

83 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Compatibility;
6
7 /**
8 * Compatibility Manager (Loader)
9 *
10 * This file is intentionally small: it conditionally loads and registers
11 * compatibility handlers (Elementor, etc.) from subfolders.
12 *
13 * Folder convention:
14 * - app/Compatibility/Elementor/Assets.php
15 * - app/Compatibility/SomePlugin/Assets.php
16 */
17 final class Compatibility
18 {
19 /**
20 * Register all compatibility handlers.
21 */
22 public static function register(): void
23 {
24 if (is_admin()) {
25 return;
26 }
27
28 foreach (self::handlers() as $handler) {
29 $file = $handler['file'] ?? '';
30 $class = $handler['class'] ?? '';
31
32 if (!is_string($file) || $file === '' || !is_string($class) || $class === '') {
33 continue;
34 }
35
36 if (file_exists($file)) {
37 require_once $file;
38 }
39
40 if (!class_exists($class)) {
41 continue;
42 }
43
44 // Handlers expose register(): void (and can self-check plugin presence)
45 if (is_callable([$class, 'register'])) {
46 try {
47 $class::register();
48 } catch (\Throwable $e) {
49 // Never break frontend due to optional integrations.
50 continue;
51 }
52 }
53 }
54 }
55
56 /**
57 * @return array<int,array{file:string,class:string}>
58 */
59 private static function handlers(): array
60 {
61 $base = defined('YATRA_PLUGIN_PATH') ? rtrim((string) YATRA_PLUGIN_PATH, '/\\') . '/app/Compatibility/' : '';
62 if ($base === '') {
63 return [];
64 }
65
66 return [
67 [
68 'file' => $base . 'Elementor/Assets.php',
69 'class' => 'Yatra\\Compatibility\\Elementor\\Assets',
70 ],
71 [
72 'file' => $base . 'LiteSpeed/Assets.php',
73 'class' => 'Yatra\\Compatibility\\LiteSpeed\\Assets',
74 ],
75 [
76 'file' => $base . 'Wanderland/Header.php',
77 'class' => 'Yatra\\Compatibility\\Wanderland\\Header',
78 ],
79 ];
80 }
81 }
82
83