autoloader( string $class_name )
Description #
Callback function for auto loading class on demand.
Parameters #
- $class_namestring (Required) Name of class.
Source #
File: loader.php
function autoloader( $class_name ) { if ( false === strpos( $class_name, 'AnsPress\\' ) ) { return; } // Replace AnsPress\Pro\ and change to lowercase to fix WPCS warning. $class_name = strtolower( str_replace( 'AnsPress\\', '', $class_name ) ); $filename = ANSPRESS_DIR . str_replace( '_', '-', str_replace( '\\', '/', $class_name ) ) . '.php'; // Check if file exists before including. if ( file_exists( $filename ) ) { require_once $filename; // Check class exists. if ( class_exists( $class_name ) ) { return true; } } return false; }
Expand full source code Collapse full source code View on GitHub: loader.php:25
Add your comment