Skip to content

Commit

Permalink
zip.php: Avoid deprecated create_function (removed in PHP 8.0)
Browse files Browse the repository at this point in the history
Anonymous functions literals have been supported for 10+ years
since PHP 5.3.0.
  • Loading branch information
Krinkle committed Jul 21, 2023
1 parent 279197a commit e8b104c
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,21 @@
$theme_name = $_POST["theme_name"];
$uncompressed = $_POST["file"];

/*
//no longer using alternate image paths - keep this here in case we do later on
//this preg_replace went from url(jqm/1.1.0-rc.1/images/....) to url(images/....)
//replace image paths with appropriate ones
$uncompressed = preg_replace_callback('/url\(\.\.\/jqm\/[^\/]*\//sim',
create_function(
'$matches',
'return "url(";'
), $uncompressed);
*/

//minifying CSS file
$comment_pos = strpos($uncompressed, "\n/* Swatches");
$comment = substr($uncompressed, 0, $comment_pos);
$css = substr($uncompressed, $comment_pos, strlen($uncompressed) - $comment_pos);

$compressed = preg_replace_callback('/(\/\*.*?\*\/|\n|\t)/sim',
create_function(
'$matches',
'return "";'
), $css);
function($matches) {
return "";
}, $css);

// remove all around in ",", ":" and "{"
$compressed = preg_replace_callback('/\s?(,|{|:){1}\s?/sim',
create_function(
'$matches',
'return $matches[1];'
), $compressed);
function($matches) {
return $matches[1];
}, $compressed);

$compressed = $comment . $compressed;

Expand Down

0 comments on commit e8b104c

Please sign in to comment.