LLMS_Loader::autoload( string $class )
Auto-load LLMS classes.
Parameters Parameters
- $class
-
(string) (Required) Class name being called.
Return Return
(void)
Source Source
File: includes/class-llms-loader.php
public function autoload( $class ) { $class = strtolower( $class ); if ( 0 !== strpos( $class, 'llms_' ) && 'lifterlms' !== $class && 'meta_box_field_interface' !== $class ) { return; } $path = null; $fileize = str_replace( '_', '-', $class ); $file = 'class-' . $fileize . '.php'; if ( array_key_exists( $class, $this->non_standard_classes ) ) { $path = LLMS_PLUGIN_DIR . $this->non_standard_classes[ $class ]; $file = null; } elseif ( 0 === strpos( $class, 'llms_abstract_' ) ) { $path = LLMS_PLUGIN_DIR . 'includes/abstracts/'; $file = $fileize . '.php'; } elseif ( 0 === strpos( $class, 'llms_analytics_' ) && false !== strrpos( $class, '_widget', - 7 ) ) { $path = LLMS_PLUGIN_DIR . 'includes/admin/reporting/widgets/'; $file = 'class.llms.analytics.widget.' . substr( $class, 15, - 7 ) . '.php'; } elseif ( 0 === strpos( $class, 'llms_interface_' ) ) { $path = LLMS_PLUGIN_DIR . 'includes/interfaces/'; $file = $fileize . '.php'; } elseif ( 0 === strpos( $class, 'llms_metabox_' ) && false !== strrpos( $class, '_field', - 6 ) ) { $path = LLMS_PLUGIN_DIR . 'includes/admin/post-types/meta-boxes/fields/'; $file = 'llms-class-meta-box-' . substr( $fileize, 13, - 6 ) . '.php'; } elseif ( 0 === strpos( $class, 'llms_table_' ) ) { /** @todo Prefix file names with 'class-' */ $path = LLMS_PLUGIN_DIR . 'includes/admin/reporting/tables/'; $file = $fileize . '.php'; } elseif ( 0 === strpos( $class, 'llms_trait_' ) ) { $path = LLMS_PLUGIN_DIR . 'includes/traits/'; $file = $fileize . '.php'; } if ( is_null( $path ) ) { foreach ( $this->class_paths as $class_path => $class_name_starts_with ) { if ( 0 === strpos( $class, $class_name_starts_with ) ) { $path = LLMS_PLUGIN_DIR . $class_path; break; } } } if ( $path ) { if ( is_readable( $path . $file ) ) { require_once $path . $file; return; } $file = str_replace( '-', '.', $file ); if ( is_readable( $path . $file ) ) { require_once $path . $file; return; } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.0.0 | Increased the number of files that are autoloaded instead of manually loaded on every request. Return early if not a LifterLMS core class. |
5.3.0 | Add traits. |
4.0.0 | Moved from LifterLMS class. |
3.15.0 | Unknown. |
1.0.0 | Introduced. |