[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/sodium_compat/ -> autoload.php (source)

   1  <?php
   2  
   3  if (!is_callable('sodiumCompatAutoloader')) {
   4      /**
   5       * Sodium_Compat autoloader.
   6       *
   7       * @param string $class Class name to be autoloaded.
   8       *
   9       * @return bool         Stop autoloading?
  10       */
  11      function sodiumCompatAutoloader($class)
  12      {
  13          $namespace = 'ParagonIE_Sodium_';
  14          // Does the class use the namespace prefix?
  15          $len = strlen($namespace);
  16          if (strncmp($namespace, $class, $len) !== 0) {
  17              // no, move to the next registered autoloader
  18              return false;
  19          }
  20  
  21          // Get the relative class name
  22          $relative_class = substr($class, $len);
  23  
  24          // Replace the namespace prefix with the base directory, replace namespace
  25          // separators with directory separators in the relative class name, append
  26          // with .php
  27          $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
  28          // if the file exists, require it
  29          if (file_exists($file)) {
  30              require_once $file;
  31              return true;
  32          }
  33          return false;
  34      }
  35  
  36      // Now that we have an autoloader, let's register it!
  37      spl_autoload_register('sodiumCompatAutoloader');
  38  }
  39  
  40  require_once dirname(__FILE__) . '/src/SodiumException.php';
  41  if (PHP_VERSION_ID >= 50300) {
  42      // Namespaces didn't exist before 5.3.0, so don't even try to use this
  43      // unless PHP >= 5.3.0
  44      require_once dirname(__FILE__) . '/lib/namespaced.php';
  45      require_once dirname(__FILE__) . '/lib/sodium_compat.php';
  46  } else {
  47      require_once dirname(__FILE__) . '/src/PHP52/SplFixedArray.php';
  48  }
  49  if (PHP_VERSION_ID < 70200 || !extension_loaded('sodium')) {
  50      if (PHP_VERSION_ID >= 50300 && !defined('SODIUM_CRYPTO_SCALARMULT_BYTES')) {
  51          require_once dirname(__FILE__) . '/lib/php72compat_const.php';
  52      }
  53      if (PHP_VERSION_ID >= 70000) {
  54          assert(class_exists('ParagonIE_Sodium_Compat'), 'Possible filesystem/autoloader bug?');
  55      } else {
  56          assert(class_exists('ParagonIE_Sodium_Compat'));
  57      }
  58      require_once (dirname(__FILE__) . '/lib/php72compat.php');
  59  }


Generated: Fri Jul 10 01:00:03 2020 Cross-referenced by PHPXref 0.7.1