From b03106c736d23a19b0e04186e727ed21aec53571 Mon Sep 17 00:00:00 2001 From: danpros Date: Mon, 4 Dec 2023 16:55:58 +0700 Subject: [PATCH] Revert changes --- system/includes/functions.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/system/includes/functions.php b/system/includes/functions.php index b2fde80..808a070 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -53,7 +53,7 @@ function get_static_pages() } // Get static page path. Unsorted. -function get_static_sub_pages() +function get_static_sub_pages($static = null) { static $_sub_page = array(); @@ -64,7 +64,16 @@ function get_static_sub_pages() } $_sub_page = unserialize(file_get_contents($url)); } - + if ($static != null) { + $stringLen = strlen($static); + return array_filter($_sub_page, function ($sub_page) use ($static, $stringLen) { + $x = explode("/", $sub_page); + if ($x[count($x) - 2] == $static) { + return true; + } + return false; + }); + } return $_sub_page; } @@ -970,14 +979,14 @@ function get_static_post($static) // Return static page. function get_static_sub_post($static, $sub_static) { - $posts = get_static_sub_pages(); + $posts = get_static_sub_pages($static); $tmp = array(); if (!empty($posts)) { - foreach ($posts as $index => $v) { - if (stripos($v, $sub_static . '.md') !== false && stripos($v, $static) !== false) { + foreach ($posts as $index => $v) { + if (stripos($v, $sub_static . '.md') !== false) { $post = new stdClass; @@ -986,7 +995,6 @@ function get_static_sub_post($static, $sub_static) // The static page URL $url = str_replace($replaced, '', $v); - $post->url = site_url() . $static . "/" . str_replace('.md', '', $url); $post->file = $v; @@ -2339,7 +2347,7 @@ function get_menu($custom) $active = ''; } - $subPages = get_static_sub_pages(); + $subPages = get_static_sub_pages(str_replace('.md', '', $base)); if (!empty($subPages)) { asort($subPages); echo '