HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux Droplet-NYC1-3 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: www-data (33)
PHP: 7.4.3-4ubuntu2.29
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/belairhomeloan.com/wp-content/plugins/wp-ses/classes/Autoloader.php
<?php
/**
 * Autoloader for WP Offload SES.
 *
 * @author  Delicious Brains
 * @package WP Offload SES
 */

namespace DeliciousBrains\WP_Offload_SES;

/**
 * Class Autoloader
 *
 * @since 1.0.0
 */
class Autoloader {

	/**
	 * Path to the main plugin file.
	 *
	 * @var string
	 */
	protected $abspath;

	/**
	 * Prefix to use in namespaces.
	 *
	 * @var string
	 */
	protected $prefix;

	/**
	 * Vendor to use in namespaces.
	 *
	 * @var string
	 */
	protected $vendor = 'DeliciousBrains';

	/**
	 * Autoloader constructor.
	 *
	 * @param string $prefix  Prefix to use in namespaces.
	 * @param string $abspath Path to the main plugin file.
	 *
	 * @throws \Exception
	 */
	public function __construct( $prefix, $abspath ) {
		$this->prefix  = $prefix;
		$this->abspath = trailingslashit( $abspath );

		$this->register_autoloader();
	}

	/**
	 * Registers the autoloader.
	 *
	 * @return bool
	 * @throws \Exception
	 */
	public function register_autoloader() {
		return spl_autoload_register( array( $this, 'autoloader' ) );
	}

	/**
	 * Load the classes.
	 *
	 * @param string $class_name The class to load.
	 */
	public function autoloader( $class_name ) {
		if ( ! $this->class_belongs_to_plugin( $class_name ) ) {
			return;
		}

		$class_path = $this->get_class_path( $class_name );
		$path       = $this->get_classes_directory() . $class_path;

		if ( file_exists( $path ) ) {
			require $path;
		} else {
			$path = $this->get_classes_directory( true ) . $class_path;

			if ( file_exists( $path ) ) {
				require $path;
			}
		}
	}

	/**
	 * Class belong to plugin.
	 *
	 * @param string $class_name The class name.
	 *
	 * @return bool
	 */
	protected function class_belongs_to_plugin( $class_name ) {
		if ( 0 !== strpos( $class_name, $this->vendor . '\\' . $this->prefix . '\\' ) ) {
			return false;
		}

		return true;
	}

	/**
	 * Get class path.
	 *
	 * @param string $class_name The class name.
	 *
	 * @return string
	 */
	protected function get_class_path( $class_name ) {
		$parts = explode( '\\', $class_name );
		$parts = array_slice( $parts, 2 );

		$filename = implode( DIRECTORY_SEPARATOR, $parts ) . '.php';

		return str_replace( '_', '-', $filename );
	}

	/**
	 * Get classes directory.
	 *
	 * @param bool $vendor If the path should include the vendor directory.
	 *
	 * @return string
	 */
	protected function get_classes_directory( $vendor = false ) {
		$dir = $vendor ? 'vendor' : 'classes';

		return trailingslashit( $this->abspath . $dir );
	}
}