-
Notifications
You must be signed in to change notification settings - Fork 13
Fix CSS URL for all plugins storing assets in uploads folder #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix CSS URL for all plugins storing assets in uploads folder #446
Conversation
|
Claude finished @arpit-instawp's task —— View job Code Review for Elementor Hardcoded CSS Issue FixTodo List:
Review SummaryThis PR adds functionality to fix hardcoded CSS URLs in Elementor files after WordPress site migration. The implementation addresses a legitimate issue where Elementor CSS files retain old domain URLs that break after migration. ✅ Positive Aspects
|
|
Claude finished @arpit-instawp's task —— View job Code Review for Elementor Hardcoded CSS Issue FixTodo List:
Review SummaryThis PR adds functionality to fix hardcoded CSS URLs in Elementor files after WordPress site migration. The implementation addresses a legitimate issue where Elementor CSS files retain old domain URLs that break after migration. ✅ Positive Aspects
|
randhirinsta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take all .css files under upload folder for search and replace domain. remove file size check and strictly check for css type file
|
Claude finished @arpit-instawp's task —— View job Code Review for Elementor Hardcoded CSS Issue FixTodo List:
Review SummaryThis PR implements CSS URL fixing functionality for Elementor after WordPress site migration. The latest version addresses the review feedback from randhirinsta by processing all .css files under the uploads folder and removing file size checks, while maintaining strict CSS file type validation. ✅ Positive Aspects
|
|
Claude finished @arpit-instawp's task —— View job Code Review for Elementor Hardcoded CSS Issue FixTodo List:
Review SummaryThis PR implements CSS URL fixing functionality for Elementor after WordPress site migration. The latest version addresses the review feedback from randhirinsta by processing all .css files under the uploads folder and removing file size checks, while maintaining strict CSS file type validation. ✅ Positive Aspects
|
randhirinsta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is slow and has high memory usage. Please review and test the optimized version below, which is up to 50× faster.
$old_domain = null;
foreach ($iterator as $file) {
if ('css' !== strtolower($file->getExtension())) {
continue;
}
$real_css_file = $file->getRealPath();
if (false === $real_css_file || 0 !== strpos($real_css_file, $real_root_path)) {
continue;
}
if (!is_file($real_css_file) || !is_writable($real_css_file)) {
continue;
}
$content = file_get_contents($real_css_file);
if (false === $content || false === stripos($content, 'url(')) {
continue;
}
// If we haven't found the old domain yet, search for it
if (null === $old_domain) {
if (preg_match('#url\(\s*[\'"]?https?://([^/]+)/wp-content/uploads/#i', $content, $match)) {
if ($match[1] !== $current_domain && filter_var('https://' . $match[1], FILTER_VALIDATE_URL)) {
$old_domain = $match[1];
file_put_contents($log_file_path, "Found old domain: {$old_domain}\n", FILE_APPEND);
}
}
}
// If old domain is found, do replacement
if ($old_domain) {
$updated = str_replace(
["https://{$old_domain}/", "http://{$old_domain}/"],
["https://{$current_domain}/", "https://{$current_domain}/"],
$content
);
if ($updated !== $content) {
file_put_contents($real_css_file, $updated);
file_put_contents($log_file_path, 'Fixed CSS URL: ' . basename($real_css_file) . "\n", FILE_APPEND);
}
}
}
https://app.clickup.com/t/86d0ce002