mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06: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
|
||||
function rename_category_folder($string, $old_url)
|
||||
function rename_category_folder($new_name, $old_file)
|
||||
{
|
||||
|
||||
$old = str_replace('.md', '/', $old_url);
|
||||
$url = substr($old, 0, strrpos($old, '/'));
|
||||
$ostr = explode('/', $url);
|
||||
$url = '/blog/' . $ostr[count($ostr) - 1];
|
||||
|
||||
$old_name = str_replace('.md', '', basename($old_file));
|
||||
$dir = get_category_folder();
|
||||
|
||||
$file = array();
|
||||
|
||||
foreach ($dir as $index => $v) {
|
||||
if (stripos($v, $url) !== false) {
|
||||
if (stripos($v, '/' . $old_name . '/') !== false) {
|
||||
$str = explode('/', $v);
|
||||
$n = $str[count($ostr) - 4] . '/' . $str[count($ostr) - 3] .'/'. $str[count($ostr) - 2] .'/'. $string . '/';
|
||||
$file[] = array($v, $n);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($file as $f) {
|
||||
if(is_dir($f[0])) {
|
||||
rename($f[0], $f[1]);
|
||||
$old_folder = $str[0] . '/' . $str[1] . '/' . $str[2] . '/' . $old_name . '/';
|
||||
$new_folder = $str[0] . '/' . $str[1] . '/' . $str[2] . '/' . $new_name . '/';
|
||||
rename($old_folder, $new_folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue