-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautoload.php
56 lines (50 loc) · 1.65 KB
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Handles autoloading of the BoldGrid SEO class/interface structure.
*
* @since 1.3.1
* @package Boldgrid_Seo
* @subpackage Boldgrid_Seo/includes
* @author BoldGrid <[email protected]>
* @link https://boldgrid.com
*/
if ( ! function_exists( 'customizer_social_icons_autoload' ) ) {
/**
* The BoldGrid SEO class autoloader.
*
* Finds the path to a class that we're requiring and includes the file.
*
* @since 1.3.1
*/
function customizer_social_icons_autoload( $class_name ) {
$paths = array();
$our_class = ( 0 === stripos( $class_name, 'Customizer_Social_Icons' ) );
if ( $our_class ) {
$path = dirname( __FILE__ ) . '/includes/';
$is_interface = ( substr( $class_name, -strlen( 'Interface' ) ) == 'Interface' );
$filename = 'class-' . strtolower( str_replace( '_', '-', $class_name ) ) . '.php';
if ( $is_interface ) {
$interface = str_replace( '_Interface', '', $class_name );
$filename = 'interface-' . strtolower( str_replace( '_', '-', $interface ) ) . '.php';
}
$paths[] = $path . $filename;
$substr = str_replace( 'Customizer_Social_Icons_', '', $class_name );
$exploded = explode( '_', $substr );
$levels = count( $exploded );
$previous_path = '';
for ( $i = 0; $i < $levels; $i++ ) {
$paths[] = $path . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename;
$previous_path .= strtolower( $exploded[ $i ] ) . '/';
}
foreach ( $paths as $path ) {
$path = wp_normalize_path( $path );
if ( file_exists( $path ) ) {
include $path;
return;
}
}
}
}
// Run the autoloader.
spl_autoload_register( 'customizer_social_icons_autoload' );
}