- Update enqueue-scripts.php: /Assets/css/ → /Assets/Css/, /Assets/js/ → /Assets/Js/ - Update related-posts.php, performance.php, minify-css.php, CSSConflictValidator.php - Fix 404 errors for CSS/JS/Fonts on production 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.7 KiB
PHP
61 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Simple CSS Minifier Script
|
|
* Run from command line: php minify-css.php
|
|
*/
|
|
|
|
function minify_css($css) {
|
|
// Remove comments
|
|
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
|
|
|
|
// Remove space after colons
|
|
$css = str_replace(': ', ':', $css);
|
|
|
|
// Remove whitespace
|
|
$css = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $css);
|
|
|
|
// Remove space before and after specific characters
|
|
$css = preg_replace('/\s*([{};,>+~])\s*/', '$1', $css);
|
|
|
|
// Remove last semicolon before closing brace
|
|
$css = str_replace(';}', '}', $css);
|
|
|
|
// Trim
|
|
$css = trim($css);
|
|
|
|
return $css;
|
|
}
|
|
|
|
$files = [
|
|
'Assets/Css/css-global-accessibility.css' => 'Assets/Css/css-global-accessibility.min.css',
|
|
'Assets/Css/style.css' => 'Assets/Css/style.min.css',
|
|
];
|
|
|
|
$base_path = __DIR__ . '/';
|
|
|
|
foreach ($files as $source => $dest) {
|
|
$source_path = $base_path . $source;
|
|
$dest_path = $base_path . $dest;
|
|
|
|
if (file_exists($source_path)) {
|
|
$css = file_get_contents($source_path);
|
|
$minified = minify_css($css);
|
|
|
|
file_put_contents($dest_path, $minified);
|
|
|
|
$original_size = strlen($css);
|
|
$minified_size = strlen($minified);
|
|
$savings = $original_size - $minified_size;
|
|
$percent = round(($savings / $original_size) * 100, 1);
|
|
|
|
echo "Minified: $source\n";
|
|
echo " Original: " . number_format($original_size) . " bytes\n";
|
|
echo " Minified: " . number_format($minified_size) . " bytes\n";
|
|
echo " Savings: " . number_format($savings) . " bytes ($percent%)\n\n";
|
|
} else {
|
|
echo "File not found: $source\n";
|
|
}
|
|
}
|
|
|
|
echo "Done!\n";
|