PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / trunk
Forumax – AI Powered Advanced Community Forum Plugin vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 2.0.0 2.1.0 All 29 releases
bbp-core / autoloader.php

autoloader.php in Forumax – AI Powered Advanced Community Forum Plugin trunk, at autoloader.php

48 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 spl_autoload_register( 'forumax_autoloader' );
3
4 /**
5 * Autoload files for the Forumax plugin.
6 *
7 * SCOPED: Only handles classes that belong to Forumax.
8 * This prevents conflicts with other plugins' autoloaders and namespaces.
9 *
10 * @param string $class The fully-qualified class name.
11 * @return void
12 */
13 function forumax_autoloader( $class ) {
14 // Define the namespace/class prefixes that belong to Forumax.
15 $forumax_prefixes = array(
16 'admin\\', // admin\Menu, admin\Elementor\*, admin\Blocks\*, admin\menu\*
17 'Admin\\', // Admin\Admin_Assets
18 'Frontend\\', // Frontend\Frontend_Assets
19 'features\\', // features\bbp_voting, features\bbp_attachments, etc.
20 );
21
22 // Check if this class belongs to Forumax.
23 $is_forumax_class = false;
24
25 // Check for exact global class name (no namespace).
26 if ( 'Admin' === $class ) {
27 $is_forumax_class = true;
28 } else {
29 // Check for namespace prefixes.
30 foreach ( $forumax_prefixes as $prefix ) {
31 if ( strpos( $class, $prefix ) === 0 ) {
32 $is_forumax_class = true;
33 break;
34 }
35 }
36 }
37
38 // Bail early if this class doesn't belong to Forumax.
39 if ( ! $is_forumax_class ) {
40 return;
41 }
42
43 $path = __DIR__ . '/includes/' . str_replace( '\\', '/', $class ) . '.php';
44
45 if ( file_exists( $path ) ) {
46 include_once $path;
47 }
48 }