search-regex
Last commit date
build
5 days ago
includes
5 days ago
changelog.txt
1 year ago
license.txt
18 years ago
readme.txt
5 days ago
search-regex-loader.php
6 months ago
search-regex.php
5 days ago
search-regex-loader.php
53 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Legacy autoloader - retained for backward compatibility. |
| 4 | * |
| 5 | * This file was used in version 3.3.0 to load the plugin, but in retrospect it is better |
| 6 | * to have it in the main plugin file. |
| 7 | * |
| 8 | * This file can safely be removed in a future major version (3.5+) after sufficient time |
| 9 | * has passed for caches to be cleared. |
| 10 | * |
| 11 | * @deprecated 3.5.0 Use the autoloader in search-regex.php instead. |
| 12 | * @package Search_Regex |
| 13 | */ |
| 14 | |
| 15 | spl_autoload_register( |
| 16 | function ( $requested_class ) { |
| 17 | $prefix = 'SearchRegex\\'; |
| 18 | |
| 19 | if ( strncmp( $prefix, $requested_class, strlen( $prefix ) ) !== 0 ) { |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | $relative_class = substr( $requested_class, strlen( $prefix ) ); |
| 24 | if ( $relative_class === '' ) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | $normalize = static function ( string $value ): string { |
| 29 | return str_replace( '_', '-', strtolower( $value ) ); |
| 30 | }; |
| 31 | |
| 32 | $segments = explode( '\\', $relative_class ); |
| 33 | $class_name = array_pop( $segments ); |
| 34 | $normalized_segments = array_filter( |
| 35 | array_map( $normalize, $segments ), |
| 36 | static fn ( $value ) => $value !== '' |
| 37 | ); |
| 38 | |
| 39 | $base_dir = __DIR__ . '/includes/'; |
| 40 | if ( count( $normalized_segments ) > 0 ) { |
| 41 | $base_dir .= implode( '/', $normalized_segments ) . '/'; |
| 42 | } |
| 43 | |
| 44 | $path = $base_dir . 'class-' . $normalize( $class_name ) . '.php'; |
| 45 | |
| 46 | if ( file_exists( $path ) ) { |
| 47 | require_once $path; |
| 48 | } |
| 49 | } |
| 50 | ); |
| 51 | |
| 52 | require_once __DIR__ . '/build/search-regex-version.php'; |
| 53 |