cmb2_autoload_classes

Autoloads files with CMB2 classes when needed.

Description

cmb2_autoload_classes( (string) $class_name ); 

Parameters (1)

0. $class_name (string)
Name of the class being requested

Usage

  1. if ( !function_exists( 'cmb2_autoload_classes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'cmb2/includes/helper-functions.php'; 
  3.  
  4. // Name of the class being requested 
  5. $class_name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = cmb2_autoload_classes($class_name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/helper-functions.php  
  1. function cmb2_autoload_classes( $class_name ) { 
  2. if ( 0 !== strpos( $class_name, 'CMB2' ) ) { 
  3. return; 
  4.  
  5. $path = 'includes'; 
  6.  
  7. if ( 'CMB2_Type' === $class_name || 0 === strpos( $class_name, 'CMB2_Type_' ) ) { 
  8. $path .= '/types'; 
  9.  
  10. include_once( cmb2_dir( "$path/{$class_name}.php" ) );