forked from openfed/kiso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kiso.theme
52 lines (48 loc) · 1.63 KB
/
kiso.theme
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
<?php
/**
* @file
* Theme file.
*
* The Drupal "Kiso" (基礎) base theme provides a custom solution for keeping this file
* as clean as possible while the code grows. All [pre]process and hook functions live
* inside the `./includes` directory (rather than directly in this file).
*
* [THEMENAME]_page_attachments_alter() = ./includes/alter.page-attachments.inc
* [THEMENAME]_theme_suggestions_alter() = ./includes/alter.theme-suggestions.inc
* [THEMENAME]_[pre]process_html() = ./includes/[pre]process.html.inc
* [THEMENAME]_[pre]process_comment_wrapper() = ./includes/[pre]process.comment-wrapper.inc
* etc.
*/
// Define constant variable for the `./includes` directory.
define('INCLUDES_FOLDER', 'includes');
/**
* Includes a theme file.
*
* @param string $theme
* Name of the theme to use for base path.
* @param string $path
* Path relative to $theme.
*/
function kiso_include($theme, $path) {
static $themes = array();
if (!isset($themes[$theme])) {
$themes[$theme] = drupal_get_path('theme', $theme);
}
if ($themes[$theme] && ($file = DRUPAL_ROOT . '/' . $themes[$theme] . '/' . $path) && file_exists($file) && pathinfo($file, PATHINFO_EXTENSION) === 'inc') {
include_once $file;
}
}
/**
* Declare various [pre]process/hook functions.
*
* All [pre]process/hook functions must live (via include) inside this
* file so they are properly detected when drupal_alter() is invoked.
*/
if (is_dir(__DIR__ . '/' . INCLUDES_FOLDER)) {
$files = scandir(__DIR__ . '/' . INCLUDES_FOLDER);
if (!empty($files)) {
foreach ($files as $file) {
kiso_include('kiso', INCLUDES_FOLDER . '/' . $file);
}
}
}