.+)\\\\(?P[^\\\\]+)$/', $class_name, $matches ) ) { return; } static $reflection; if ( empty( $reflection ) ) { $reflection = new \ReflectionObject( $this ); } if ( $reflection->getNamespaceName() !== $matches['namespace'] ) { return; } $autoload_name = $matches['autoload']; $autoload_dir = static::get_location_path(); $load_dirs = array( 'classes' => 'class', ); foreach ( $load_dirs as $dir => $prefix ) { $dir = $dir . DIRECTORY_SEPARATOR; $autoload_path = sprintf( '%s%s%s-%s.php', $autoload_dir, $dir, $prefix, strtolower( str_replace( '_', '-', $autoload_name ) ) ); if ( is_readable( $autoload_path ) ) { require_once $autoload_path; // NOSONAR - WP compatible. return; } } } /** * Method get_location(). * * @param string $path what to get path/url. * * @return string value. */ public static function get_location_path( $path = 'dir' ) { $location = array( 'dir' => MAINWP_MODULES_DIR . 'api-backups' . DIRECTORY_SEPARATOR, 'url' => MAINWP_MODULES_URL . 'api-backups/', ); return isset( $location[ $path ] ) ? $location[ $path ] : ''; } }