forked from kadimi/bootswatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
35 lines (32 loc) · 1.1 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
<?php
/**
* Bootswatch functions and definitions.
*
* @package Bootswatch
*/
define( 'BOOTSWATCH_DIR', get_template_directory() );
define( 'BOOTSWATCH_MINIMAL_PHP_VERSION', '7.3.0' );
define( 'BOOTSWATCH_MINIMAL_PHP_VERSION_ID', 70300 );
/**
* Loads Bootswatch translated strings.
*/
function bootswatch_load_textdomain() {
load_theme_textdomain( 'bootswatch', BOOTSWATCH_DIR . '/languages' );
}
add_action( 'after_setup_theme', 'bootswatch_load_textdomain' );
/**
* Load all extras from ./inc/ using `get_template_part()` to allow overriding.
*/
if ( PHP_VERSION_ID > BOOTSWATCH_MINIMAL_PHP_VERSION_ID ) {
$bootswatch_extras = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( BOOTSWATCH_DIR . '/inc' ), RecursiveIteratorIterator::SELF_FIRST );
( function() use ( $bootswatch_extras ) {
foreach ( $bootswatch_extras as $extra => $unused ) {
$extra = str_replace( '\\', '/', $extra );
if ( preg_match( '/\/[\w-]+\.php$/', $extra ) ) {
get_template_part( substr( $extra, strlen( BOOTSWATCH_DIR ), -4 ) );
}
}
} )();
} else {
get_template_part( 'inc/compatibility/php-version' );
}