PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.14.1
WpStream – Live Streaming, Video on Demand, Pay Per View v4.14.1
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / includes / class-wpstream-autoloader.php

class-wpstream-autoloader.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.14.1, at includes/class-wpstream-autoloader.php

126 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Classmap autoloader for the plugin's own classes and interfaces.
4 *
5 * Naming convention going forward: classes are prefixed `Wpstream_` and live
6 * in files named `class-wpstream-{dashed-lowercase-name}.php`. The map below
7 * is a static classmap rather than a name-to-path transform because several
8 * files deliberately hold multiple declarations (a module's interfaces and
9 * adapters live beside its main class) and a transform cannot express that.
10 *
11 * Adding a class to the plugin = declare it in its file + add one entry here.
12 *
13 * Deliberately NOT in the map (their existing require flows stay in charge):
14 * - WC_Product_Live_Stream / WC_Product_Video_On_Demand — they extend
15 * WC_Product, so loading them while WooCommerce is inactive fatals at
16 * class-link time; they load behind class_exists('WooCommerce') guards.
17 * - The Elementor widgets (ElementorWpStream\Widgets\*) — they extend
18 * Elementor\Widget_Base, so Wpstream_Elementor_Widgets (which IS mapped)
19 * requires them only after confirming Elementor is loaded.
20 * - Wpstream_Seo and Wpstream_Storage_Migration — both register hooks at
21 * include time, so they must be eagerly required; lazy-loading them would
22 * silently drop those hook registrations.
23 * - Function-only files (includes/Helpers/wpstream-*.php, the activation
24 * redirect, integrations/) — autoloaders only ever load class-likes.
25 *
26 * @package Wpstream
27 * @subpackage Wpstream/includes
28 */
29
30 /**
31 * Resolves the plugin's class and interface names to their defining files.
32 */
33 final class Wpstream_Autoloader {
34
35 /**
36 * Lowercased class/interface name => file path relative to the plugin root.
37 *
38 * Keys MUST be lowercase: PHP hands the autoloader the name exactly as
39 * typed at the call site, and class names are case-insensitive, so the
40 * lookup lowercases the incoming name before matching.
41 *
42 * @var array<string,string>
43 */
44 const CLASSMAP = array(
45 // Core orchestration.
46 'wpstream' => 'includes/class-wpstream.php',
47 'wpstream_loader' => 'includes/class-wpstream-loader.php',
48 'wpstream_activator' => 'includes/class-wpstream-activator.php',
49 'wpstream_elementor_widgets' => 'includes/class-wpstream-elementor-widgets.php',
50 'wpstream_deactivator' => 'includes/class-wpstream-deactivator.php',
51 'wpstream_admin' => 'admin/class-wpstream-admin.php',
52 'wpstream_onboarding' => 'admin/class-wpstream-onboarding.php',
53 'wpstream_live_channel_presentation' => 'includes/class-wpstream-live-channel-presentation.php',
54 'wpstream_public' => 'public/class-wpstream-public.php',
55 // Feature services.
56 'wpstream_ajax' => 'includes/class-wpstream-ajax.php',
57 'wpstream_chat_room_binding' => 'includes/class-wpstream-chat-room-binding.php',
58 'wpstream_live_api_connection' => 'includes/class-wpstream-live-api-connection.php',
59 'wpstream_player' => 'includes/class-wpstream-player.php',
60 'wpstream_quota_manager' => 'includes/class-wpstream-quota-manager.php',
61 'wpstream_template_loader' => 'includes/class-wpstream-templates.php',
62 'wpstream_theme_notice' => 'includes/class-wpstream-theme-notice.php',
63 'wpstream_product' => 'includes/class-wpstream-product.php',
64 'wpstream_playback_presentation' => 'includes/class-wpstream-playback-presentation.php',
65 // Player helpers.
66 'wpstream_playback_session' => 'includes/player/class-wpstream-playback-session.php',
67 'wpstream_channel_state' => 'includes/player/class-wpstream-channel-state.php',
68 // Baker API services.
69 'wpstream_user_quota_service' => 'includes/api/class-wpstream-user-quota-service.php',
70 'wpstream_channel_service' => 'includes/api/class-wpstream-channel-service.php',
71 // Logging.
72 'wpstream_log_entry' => 'includes/Helpers/class-wpstream-log-entry.php',
73 'wpstream_logger' => 'includes/Logger/class-wpstream-logger.php',
74 // Channel settings module (interfaces + adapters + main class share the file).
75 'wpstream_channel_settings_storage_port' => 'includes/class-wpstream-channel-settings.php',
76 'wpstream_channel_settings_baker_port' => 'includes/class-wpstream-channel-settings.php',
77 'wpstream_wordpress_channel_settings_storage' => 'includes/class-wpstream-channel-settings.php',
78 'wpstream_baker_channel_settings_adapter' => 'includes/class-wpstream-channel-settings.php',
79 'wpstream_channel_settings' => 'includes/class-wpstream-channel-settings.php',
80 // Streaming content creation module.
81 'wpstream_streaming_content_provisioning_port' => 'includes/class-wpstream-streaming-content-creation.php',
82 'wpstream_streaming_content_recording_catalog_port' => 'includes/class-wpstream-streaming-content-creation.php',
83 'wpstream_streaming_content_eligibility_port' => 'includes/class-wpstream-streaming-content-creation.php',
84 'wpstream_wordpress_streaming_content_eligibility' => 'includes/class-wpstream-streaming-content-creation.php',
85 'wpstream_streaming_content_creation_lock_port' => 'includes/class-wpstream-streaming-content-creation.php',
86 'wpstream_wordpress_streaming_content_creation_lock' => 'includes/class-wpstream-streaming-content-creation.php',
87 'wpstream_baker_streaming_content_provisioning' => 'includes/class-wpstream-streaming-content-creation.php',
88 'wpstream_baker_streaming_content_recording_catalog' => 'includes/class-wpstream-streaming-content-creation.php',
89 'wpstream_streaming_content_creation' => 'includes/class-wpstream-streaming-content-creation.php',
90 // DRM key delivery module.
91 'wpstream_drm_key_remote_fetch_port' => 'includes/class-wpstream-drm-key-delivery.php',
92 'wpstream_wordpress_drm_key_remote_fetch' => 'includes/class-wpstream-drm-key-delivery.php',
93 'wpstream_drm_key_delivery' => 'includes/class-wpstream-drm-key-delivery.php',
94 // Media list module.
95 'wpstream_media_list_active_catalog_port' => 'includes/class-wpstream-media-list.php',
96 'wpstream_baker_media_list_active_catalog' => 'includes/class-wpstream-media-list.php',
97 'wpstream_media_list' => 'includes/class-wpstream-media-list.php',
98 );
99
100 /**
101 * Register the autoloader with the spl autoload chain.
102 *
103 * @return void
104 */
105 public static function register() {
106 spl_autoload_register( array( __CLASS__, 'autoload' ) );
107 }
108
109 /**
110 * Load the file that defines $class when the classmap knows it.
111 *
112 * Names outside the map are left for the next autoloader in the chain.
113 *
114 * @param string $class Class or interface name as typed at the call site.
115 * @return void
116 */
117 public static function autoload( $class ) {
118 // Lowercase the incoming name: class names are case-insensitive.
119 $key = strtolower( $class );
120 if ( isset( self::CLASSMAP[ $key ] ) ) {
121 // The map is relative to the plugin root, one level above includes/.
122 require_once dirname( __DIR__ ) . '/' . self::CLASSMAP[ $key ];
123 }
124 }
125 }
126