Skip to content

Commit 77a2c1c

Browse files
committed
Support for plugin themes in menus.php
1 parent e918591 commit 77a2c1c

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

admin/pages/menus.php

+20-5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use MyAAC\Cache\Cache;
1212
use MyAAC\Models\Menu;
13+
use MyAAC\Plugins;
1314

1415
defined('MYAAC') or die('Direct access not allowed!');
1516
$title = 'Menus';
@@ -21,6 +22,8 @@
2122
return;
2223
}
2324

25+
$pluginThemes = Plugins::getThemes();
26+
2427
if (isset($_POST['template'])) {
2528
$template = $_POST['template'];
2629

@@ -64,9 +67,16 @@
6467
success('Saved at ' . date('H:i'));
6568
}
6669

67-
$file = TEMPLATES . $template . '/config.php';
68-
if (file_exists($file)) {
69-
require_once $file;
70+
$path = TEMPLATES . $template;
71+
72+
if (isset($pluginThemes[$template])) {
73+
$path = BASE . $pluginThemes[$template];
74+
}
75+
76+
$path .= '/config.php';
77+
78+
if (file_exists($path)) {
79+
require_once $path;
7080
} else {
7181
echo 'Cannot find template config.php file.';
7282
return;
@@ -169,8 +179,13 @@
169179
} else {
170180
$templates = Menu::select('template')->distinct()->get()->toArray();
171181
foreach ($templates as $key => $value) {
172-
$file = TEMPLATES . $value['template'] . '/config.php';
173-
if (!file_exists($file)) {
182+
$path = TEMPLATES . $value['template'];
183+
184+
if (isset($pluginThemes[$value['template']])) {
185+
$path = BASE . $pluginThemes[$value['template']];
186+
}
187+
188+
if (!file_exists($path . '/config.php')) {
174189
unset($templates[$key]);
175190
}
176191
}

0 commit comments

Comments
 (0)