-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
32 lines (26 loc) · 919 Bytes
/
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
<?php
/**
* Automatically require_once all php files within ./library/ and ./vc-elemets/.
* - Don't add functions/code here, give the code context in it's own file within /library
*
* @package salient-child
*/
// Get all library files from cache (or re-cache).
$cache_key = 'GLOB/LIBRARY';
$cache_expire = ( 60 * 60 ) * 1; // 1hr
// wp_cache_delete( $cache_key ); // For debugging @codingStandardsIgnoreLine
$files = wp_cache_get( $cache_key, '' );
if ( false === $files ) {
$files = glob( dirname( __FILE__ ) . '/{library,vc-elements}/*.php', GLOB_BRACE );
wp_cache_set( $cache_key, $files, '', $cache_expire );
}
foreach ( $files as $file ) {
if ( ! file_exists( $file ) ) {
wp_cache_delete( $cache_key );
continue; // File now doesn't exist for whatever reason.
}
require_once $file;
}
// Remember:
// Don't add functions/code here,
// give the code context in it's own file within /library/.