mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 20:16:22 +05:30
Update functions.php
This commit is contained in:
parent
6db06e112b
commit
7cbbf00392
1 changed files with 6 additions and 18 deletions
|
|
@ -3307,29 +3307,17 @@ function safe_tag($string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rename category folder
|
// rename category folder
|
||||||
function rename_category_folder($string, $old_url)
|
function rename_category_folder($new_name, $old_file)
|
||||||
{
|
{
|
||||||
|
|
||||||
$old = str_replace('.md', '/', $old_url);
|
$old_name = str_replace('.md', '', basename($old_file));
|
||||||
$url = substr($old, 0, strrpos($old, '/'));
|
|
||||||
$ostr = explode('/', $url);
|
|
||||||
$url = '/blog/' . $ostr[count($ostr) - 1];
|
|
||||||
|
|
||||||
$dir = get_category_folder();
|
$dir = get_category_folder();
|
||||||
|
|
||||||
$file = array();
|
|
||||||
|
|
||||||
foreach ($dir as $index => $v) {
|
foreach ($dir as $index => $v) {
|
||||||
if (stripos($v, $url) !== false) {
|
if (stripos($v, '/' . $old_name . '/') !== false) {
|
||||||
$str = explode('/', $v);
|
$str = explode('/', $v);
|
||||||
$n = $str[count($ostr) - 4] . '/' . $str[count($ostr) - 3] .'/'. $str[count($ostr) - 2] .'/'. $string . '/';
|
$old_folder = $str[0] . '/' . $str[1] . '/' . $str[2] . '/' . $old_name . '/';
|
||||||
$file[] = array($v, $n);
|
$new_folder = $str[0] . '/' . $str[1] . '/' . $str[2] . '/' . $new_name . '/';
|
||||||
}
|
rename($old_folder, $new_folder);
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($file as $f) {
|
|
||||||
if(is_dir($f[0])) {
|
|
||||||
rename($f[0], $f[1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue