HEX
Server: Apache/2.4.38 (Debian)
System: Linux host457 5.14.0-4-amd64 #1 SMP Debian 5.14.16-1 (2021-11-03) x86_64
User: www-data (33)
PHP: 7.4.21
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: /home/vhosts/harpoeditore.it/httpdocs/wp-content/themes/dt-the7/inc/class-the7-autoloader.php
<?php
/**
 * @since   7.5.0
 *
 * @package The7
 */

defined( 'ABSPATH' ) || exit;

/**
 * Class The7_Autoloader
 */
class The7_Autoloader {

	/**
	 * Path to the includes directory.
	 *
	 * @var string
	 */
	protected $include_path = '';

	/**
	 * The7_Aoutoloader constructor.
	 *
	 * @throws Exception
	 */
	public function __construct() {
		spl_autoload_register( array( $this, 'autoload' ) );

		$this->include_path = trailingslashit( PRESSCORE_DIR );
	}

	/**
	 * Take a class name and turn it into a file name.
	 *
	 * @param string $class Class name.
	 *
	 * @return string
	 */
	private function get_file_name_from_class( $class ) {
		return 'class-' . str_replace( '_', '-', $class ) . '.php';
	}

	/**
	 * Include a class file.
	 *
	 * @param string $path File path.
	 *
	 * @return bool Successful or not.
	 */
	private function load_file( $path ) {
		if ( $path && is_readable( $path ) ) {
			include_once $path;

			return true;
		}

		return false;
	}

	/**
	 * Auto-load The7 classes on demand to reduce memory consumption.
	 *
	 * @param string $class Class name.
	 */
	public function autoload( $class ) {
		$class = strtolower( $class );

		if ( 0 === strpos( $class, 'presscore_' ) || 0 === strpos( $class, 'dt_' ) ) {
			$this->load_deprecated_class( $class );
		}

		if ( 0 === strpos( $class, 'the7\\' ) ) {
			$this->load_namespaced_classes( $class );
		}

		if ( 0 !== strpos( $class, 'the7_' ) ) {
			return;
		}

		$file = $this->get_file_name_from_class( $class );
		$path = $this->include_path;

		if ( 0 === strpos( $class, 'the7_options' ) ) {
			$path = $this->include_path . 'extensions/options-framework/';
		} elseif ( 0 === strpos( $class, 'the7_option_field' ) ) {
			$path = $this->include_path . 'extensions/options-framework/fields/';
		} elseif ( 0 === strpos( $class, 'the7_admin' ) ) {
			$path = $this->include_path . 'admin/';
		} elseif ( 0 === strpos( $class, 'the7_less_vars' ) ) {
			$path = $this->include_path . 'extensions/less-vars/';
		}

		if ( ! $this->load_file( $path . $file ) && function_exists( 'mb_strtolower' ) ) {
			$file = $this->get_file_name_from_class( mb_strtolower( $class ) );
			$this->load_file( $path . $file );
		}
	}

	/**
	 * Load deprecated class.
	 *
	 * @param string $class Class name in lowercase.
	 */
	protected function load_deprecated_class( $class ) {
		$file = $this->get_file_name_from_class( $class );
		$path = $this->include_path . 'deprecated/';
		$this->load_file( $path . $file );
	}

	/**
	 * Load namespaced class.
	 *
	 * @param string $class Class name in lowercase.
	 */
	protected function load_namespaced_classes( $class ) {
		$class = str_replace( [ 'the7\\', '\\', '_' ], [ '', DIRECTORY_SEPARATOR, '-' ], $class );
		$this->load_file( $this->include_path . $class . '.php' );
	}
}