forked from wprig/wprig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
66 lines (54 loc) · 1.67 KB
/
functions.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
66
<?php
/**
* WP Rig functions and definitions
*
* This file must be parseable by PHP 5.2.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package wp_rig
*/
define( 'WP_RIG_MINIMUM_WP_VERSION', '4.5' );
define( 'WP_RIG_MINIMUM_PHP_VERSION', '7.0' );
// Bail if requirements are not met.
if ( version_compare( $GLOBALS['wp_version'], WP_RIG_MINIMUM_WP_VERSION, '<' ) || version_compare( phpversion(), WP_RIG_MINIMUM_PHP_VERSION, '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
return;
}
// Include WordPress shims.
require get_template_directory() . '/inc/wordpress-shims.php';
// Setup autoloader (via Composer or custom).
if ( file_exists( get_template_directory() . '/vendor/autoload.php' ) ) {
require get_template_directory() . '/vendor/autoload.php';
} else {
/**
* Custom autoloader function for theme classes.
*
* @access private
*
* @param string $class_name Class name to load.
* @return bool True if the class was loaded, false otherwise.
*/
function _wp_rig_autoload( $class_name ) {
$namespace = 'WP_Rig\WP_Rig';
if ( strpos( $class_name, $namespace . '\\' ) !== 0 ) {
return false;
}
$parts = explode( '\\', substr( $class_name, strlen( $namespace . '\\' ) ) );
$path = get_template_directory() . '/inc';
foreach ( $parts as $part ) {
$path .= '/' . $part;
}
$path .= '.php';
if ( ! file_exists( $path ) ) {
return false;
}
require_once $path;
return true;
}
spl_autoload_register( '_wp_rig_autoload' );
}
// Load the `wp_rig()` entry point function.
require get_template_directory() . '/inc/functions.php';
// Initialize the theme.
call_user_func( 'WP_Rig\WP_Rig\wp_rig' );