Changeset 49056 for trunk/src/wp-includes/sodium_compat/autoload.php
- Timestamp:
- 09/27/2020 04:44:01 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/sodium_compat/autoload.php
r46858 r49056 1 1 <?php 2 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 3 if (PHP_VERSION_ID < 70000) { 4 if (!is_callable('sodiumCompatAutoloader')) { 5 /** 6 * Sodium_Compat autoloader. 7 * 8 * @param string $class Class name to be autoloaded. 9 * 10 * @return bool Stop autoloading? 11 */ 12 function sodiumCompatAutoloader($class) 13 { 14 $namespace = 'ParagonIE_Sodium_'; 15 // Does the class use the namespace prefix? 16 $len = strlen($namespace); 17 if (strncmp($namespace, $class, $len) !== 0) { 18 // no, move to the next registered autoloader 19 return false; 20 } 21 22 // Get the relative class name 23 $relative_class = substr($class, $len); 24 25 // Replace the namespace prefix with the base directory, replace namespace 26 // separators with directory separators in the relative class name, append 27 // with .php 28 $file = dirname(__FILE__) . '/src/' . str_replace('_', '/', $relative_class) . '.php'; 29 // if the file exists, require it 30 if (file_exists($file)) { 31 require_once $file; 32 return true; 33 } 18 34 return false; 19 35 } 20 36 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; 37 // Now that we have an autoloader, let's register it! 38 spl_autoload_register('sodiumCompatAutoloader'); 34 39 } 35 36 // Now that we have an autoloader, let's register it! 37 spl_autoload_register('sodiumCompatAutoloader'); 40 } else { 41 require_once dirname(__FILE__) . '/autoload-php7.php'; 38 42 } 39 43 40 require_once dirname(__FILE__) . '/src/SodiumException.php'; 44 if (!class_exists('SodiumException', false)) { 45 require_once dirname(__FILE__) . '/src/SodiumException.php'; 46 } 41 47 if (PHP_VERSION_ID >= 50300) { 42 48 // Namespaces didn't exist before 5.3.0, so don't even try to use this
Note: See TracChangeset
for help on using the changeset viewer.