Created
August 25, 2017 11:00
-
-
Save Gkiokan/026a68e6fbe42daffd6e8006d1892497 to your computer and use it in GitHub Desktop.
Custom File loader from Array of files with target Dir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Project: Autoload function files | |
Author: Gkiokan Sali | |
Date: 25.08.2017 | |
Comment: Allows you to include_once files from array only. | |
*/ | |
// Declare the function itself when it is not defined anywhere else | |
if(!is_callable('autoload_function_files')): | |
function autoload_function_files($files=[], $folder=''){ | |
$base_path = __DIR__ . '/' . $folder . '/%s.php'; | |
if(is_array($files)) | |
foreach($files as $file): | |
$path = sprintf($base_path, $file); | |
if(file_exists($path)) | |
include_once $path; | |
endforeach; | |
} | |
endif; | |
$basic_files = [ | |
'basics', | |
'remove-comments', | |
'theme-support', | |
'theme-setup', | |
'vc-container-extension', | |
'enqueue', | |
'navigation-extension', | |
'onepage-render', | |
'optimize', | |
]; | |
$navigation_files = [ | |
'Menus', | |
// 'ExtendsBodymovinIconFields', | |
// 'ExtendsBodymovinIconWalker', | |
// 'ExtendsInContactButtonWalker', | |
// 'SubMenuWalker', | |
]; | |
$vc_addon_files = [ | |
'buttons', | |
'extensions', | |
'footer_navigation', | |
]; | |
// Load them all | |
autoload_function_files($basic_files, 'basic'); | |
autoload_function_files($navigation_files, 'navigation'); | |
autoload_function_files($vc_addon_files, 'vc_addition'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment