Skip to content

Commit 38a60a4

Browse files
author
Akshay Paghdar
committed
Fixed Directory Tree.
1 parent 357831b commit 38a60a4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

includes/post-types/contentsView.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ function listFolderFiles($dir, $url = '') {
125125
$output = '';
126126
foreach ($ffs as $ff) {
127127
$output .= '<li>';
128-
129128
$file_path = str_replace(ABSPATH, '', $dir);
130129
$file_url = site_url('/') . $file_path . '/' . $ff;
131130
if (is_dir($dir . '/' . $ff)) {
@@ -166,11 +165,17 @@ function showFileList($id) {
166165
if ($file) {
167166
mbstring_binary_safe_encoding();
168167

169-
//get the url
168+
$site_url = site_url('/');
169+
$parsed_site_url = parse_url($site_url);
170170
$url = $file['url'];
171+
if ($parsed_site_url['scheme'] == 'https') {
172+
$url = str_replace("http://", "https://", $url);
173+
} else {
174+
$url = str_replace("https://", "http://", $url);
175+
}
171176

172177
//Replace url to directory path
173-
$path = str_replace(site_url('/'), ABSPATH, esc_url($url));
178+
$path = str_replace($site_url, ABSPATH, esc_url($url));
174179

175180
if (is_file($path)) {
176181
$filesize = size_format(filesize($path));

0 commit comments

Comments
 (0)