-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathload.php
executable file
·65 lines (55 loc) · 1.67 KB
/
load.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
57
58
59
60
61
62
63
64
65
<?php
/**
* InStockNotifier
*
* @author Govind Kumar <gkprmr@gmail.com>
* @version 1.0.0
* @package InStockNotifier
*/
namespace InStockNotifier;
/**
* In-Stock Notifier - WooCommerce Plugin
* Copyright (C) 2017 Govind Kumar <gkprmr@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Auto load the plugin's classes.
*/
spl_autoload_register( __NAMESPACE__ . '\\wsn_autoload_classes' );
/**
* Auto load the plugin classes.
*
* @param string $class Name of the class.
*
* @return bool|mixed
* @since 1.0
*
*/
function wsn_autoload_classes( $class ) {
// Get the name of the namespace and check if it is what we are looking for?
if ( 0 !== strpos( $class, 'InStockNotifier\\', 0 ) ) {
return false;
}
static $loaded = array();
if ( isset( $loaded[ $class ] ) ) {
return $loaded[ $class ];
}
$extension = '.php';
$_class = strtolower( str_replace( 'InStockNotifier\\', '', $class ) );
$_class = str_replace( '_', '-', $_class );
$_class = 'class-' . $_class;
if ( file_exists( WSN_CLASS_PATH . $_class . $extension ) ) {
return $loaded[ $class ] = (bool) require_once( WSN_CLASS_PATH . $_class . $extension );
}
}