set up layout information
This commit is contained in:
parent
7f4188929c
commit
fbec175cb8
@ -24,6 +24,7 @@ class ComicPress {
|
|||||||
var $category_tree = array();
|
var $category_tree = array();
|
||||||
|
|
||||||
var $partial_paths = array();
|
var $partial_paths = array();
|
||||||
|
var $layouts = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load ComicPress options.
|
* Load ComicPress options.
|
||||||
@ -360,14 +361,24 @@ class ComicPress {
|
|||||||
function _file_get_contents($file) { return file_get_contents($file); }
|
function _file_get_contents($file) { return file_get_contents($file); }
|
||||||
|
|
||||||
function get_layout_choices() {
|
function get_layout_choices() {
|
||||||
$layouts = array();
|
if (!is_array($this->layouts)) {
|
||||||
|
$this->layouts = array();
|
||||||
foreach ($this->_glob(get_template_directory() . '/layouts/*') as $file) {
|
foreach ($this->_glob(get_template_directory() . '/layouts/*') as $file) {
|
||||||
$content = $this->_file_get_contents($file);
|
$content = $this->_file_get_contents($file);
|
||||||
if (preg_match('#/\*.*Layout Name: ([^\n]+).*\*/#s', $content, $matches) > 0) {
|
$basename = pathinfo($file, PATHINFO_BASENAME);
|
||||||
$layouts[pathinfo($file, PATHINFO_BASENAME)] = $matches[1];
|
foreach (array(
|
||||||
|
"Layout Name", "Sidebars"
|
||||||
|
) as $field) {
|
||||||
|
if (preg_match('#/\*.*' . $field . ': ([^\n]+).*\*/#s', $content, $matches) > 0) {
|
||||||
|
if (!is_array($this->layouts[$basename])) {
|
||||||
|
$this->layouts[$basename] = array();
|
||||||
|
}
|
||||||
|
$this->layouts[$basename][$field] = $matches[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $layouts;
|
}
|
||||||
|
}
|
||||||
|
return $this->layouts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,10 +192,14 @@ FILE
|
|||||||
'layout.php' => <<<FILE
|
'layout.php' => <<<FILE
|
||||||
/*
|
/*
|
||||||
Layout Name: Test
|
Layout Name: Test
|
||||||
|
Sidebars: left,right
|
||||||
*/
|
*/
|
||||||
FILE
|
FILE
|
||||||
),
|
),
|
||||||
array('layout.php' => 'Test')
|
array('layout.php' => array(
|
||||||
|
'Layout Name' => 'Test',
|
||||||
|
'Sidebars' => 'left,right',
|
||||||
|
))
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user