Server IP : 213.176.29.180  /  Your IP : 3.133.159.116
Web Server : Apache
System : Linux 213.176.29.180.hostiran.name 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
User : webtaragh ( 1001)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0777) :  /proc/450/../124/../43/../422/../45/../19/../422/../12938/cwd/../elementskit/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //proc/450/../124/../43/../422/../45/../19/../422/../12938/cwd/../elementskit/autoloader.php
<?php
namespace ElementsKit;

defined( 'ABSPATH' ) || exit;

/**
 * ElementsKit autoloader.
 * Handles dynamically loading classes only when needed.
 *
 * @since 1.0.0
 */
if(!class_exists('\ElementsKit\Autoloader')):

    class Autoloader {
        
        /**
         * Run autoloader.
         * Register a function as `__autoload()` implementation.
         *
         * @since 1.0.0
         * @access public
         */
        public static function run() {
            spl_autoload_register( [ __CLASS__, 'autoload' ] );
        }
        
        /**
         * Autoload.
         * For a given class, check if it exist and load it.
         *
         * @since 1.0.0
         * @access private
         * @param string $class Class name.
         */
        private static function autoload( $class_name ) {

            // If the class being requested does not start with our prefix
            // we know it's not one in our project.
            if ( 0 !== strpos( $class_name, __NAMESPACE__ ) ) {
                return;
            }
            
            $file_name = strtolower(
                preg_replace(
                    [ '/\b'.__NAMESPACE__.'\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ],
                    [ '', '$1-$2', '-', DIRECTORY_SEPARATOR],
                    $class_name
                )
            );

            // Compile our path from the corosponding location.
            $file = trailingslashit(plugin_dir_path( __FILE__ )) . $file_name . '.php';

            // If a file is found.
            if ( file_exists( $file ) ) {
                // Then load it up!
                require_once( $file );
            }
        }
    }

endif;