From d779571840bb33d55df480861915842395df26f2 Mon Sep 17 00:00:00 2001 From: mariez Date: Wed, 21 Dec 2016 21:09:33 -0300 Subject: [PATCH] add theme_info function to manage relative path and split dir/name --- functions.php | 22 +++++++++++++++++++++- theme_info | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 theme_info diff --git a/functions.php b/functions.php index f9d446e..7a1b715 100644 --- a/functions.php +++ b/functions.php @@ -113,4 +113,24 @@ function _topMenu() $topmenu .= ''; return $topmenu; -} \ No newline at end of file +} + + +## pick up theme_info (name or dir) +function theme_info($data = "dir"){ + $thinfo = dirname(__FILE__) . '/theme_info'; + if ( is_file($thinfo) ) { + $theme_info = file_get_contents($thinfo); + $lines = explode("\n", $theme_info); + $info = array(); + foreach ($lines as $line) { + if (preg_match('/(\w+)=([\p{L}\p{N}&\#; \-\(\)]+)/u', $line, $regs)) { + $info[$regs[1]] = $regs[2]; + } + } + $dir = ( !empty($info['dir']) ) ? 'ui/'.$info['dir'] : 'ui/phplist-ui-bootlist'; + $return = ($data == 'name') ? $info['name'] : $dir; + + return $return; + } +} diff --git a/theme_info b/theme_info new file mode 100644 index 0000000..a23746e --- /dev/null +++ b/theme_info @@ -0,0 +1,2 @@ +name=Bootlist +dir=phplist-ui-bootlist \ No newline at end of file