[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  <?php
   2  /*
   3   This file should only ever be loaded on PHP 7+
   4   */
   5  if (PHP_VERSION_ID < 70000) {
   6      return;
   7  }
   8  
   9  spl_autoload_register(function ($class) {
  10      $namespace = 'ParagonIE_Sodium_';
  11      // Does the class use the namespace prefix?
  12      $len = strlen($namespace);
  13      if (strncmp($namespace, $class, $len) !== 0) {
  14          // no, move to the next registered autoloader
  15          return false;
  16      }
  17  
  18      // Get the relative class name
  19      $relative_class = substr($class, $len);
  20  
  21      // Replace the namespace prefix with the base directory, replace namespace
  22      // separators with directory separators in the relative class name, append
  23      // with .php
  24      $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php';
  25      // if the file exists, require it
  26      if (file_exists($file)) {
  27          require_once $file;
  28          return true;
  29      }
  30      return false;
  31  });


Generated: Thu Nov 21 01:00:03 2024 Cross-referenced by PHPXref 0.7.1