Open hungud opened 3 years ago
I send you bugsfix
/**
@return mixed */ public function the_content_filter($content) {
if ($upload_data = wp_upload_dir()) {
if (!empty($upload_data['url']) && !empty($content)) {
$url = preg_replace('/https?:\/\//', '', $upload_data['url']);
$root_dir = trim($this->get('sm.root_dir'), '/ '); // Remove any forward slash and empty space.
$root_dir = apply_filters("wp_stateless_handle_root_dir", $root_dir);
$root_dir = !empty($root_dir) ? $root_dir . '/' : false;
/*
print_r("==========DEBUG============");
echo '<br/>';
print_r($image_host);
echo '<br/>';
print_r($url);
echo '<br/>';
print_r($root_dir);
echo '<br/>';
$root_dir= rtrim($root_dir, "/");
print_r($root_dir);
echo '<br/>';
print_r($file_ext);
echo '<br/>';
print_r("==========DEBUG============");
*/
/* Bugsfix by hungud */
$root_dir= rtrim($root_dir, "/");
$url = str_replace($root_dir, "", $url);
$root_dir = "";
/* Bugsfix by hungud */
$image_host = $this->get_gs_host();
$file_ext = $this->replaceable_file_types();
/*
$content = preg_replace(
'/(href|src)=(\'|")(https?:\/\/' . str_replace('/', '\/', $url) . ')\/(.+?)(' . $file_ext . ')(\'|")/i',
'$1=$2' . $image_host . '/' . ($root_dir ? $root_dir : '') . '$4$5$6',
$content
);
*/
/* Bugsfix by hungud */
$content = preg_replace(
'/(href|src)=(\'|")(https?:\/\/' . str_replace('/', '\/', $url) . ')(.*?)(' . $file_ext . ')(\'|")/i',
'$1=$2' . $image_host . '/' . ($root_dir ? $root_dir : '') . '$4$5$6',
$content
);
/* Bugsfix by hungud */
}
}
return $content;
}
Please, create a Pull Request so we can review your fix.
`
public function the_content_filter($content) {
`
wp_upload_dir() => return with current date => /wp-content/uploads/2021/01
=> so, it do wrong, it should show by current post date!
Please correct it!