PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / mrclay / minify / min_extras / cli / rewrite-uris.php

rewrite-uris.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/mrclay/minify/min_extras/cli/rewrite-uris.php

62 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 #!/usr/bin/php
2 <?php
3
4 die('Must be rewritten for new API');
5
6 require __DIR__ . '/../../bootstrap.php';
7
8 $cli = new MrClay\Cli;
9
10 $cli->addRequiredArg('d')->assertDir()->setDescription('Your webserver\'s DOCUMENT_ROOT: Relative paths will be rewritten relative to this path.');
11
12 $cli->addOptionalArg('o')->useAsOutfile()->setDescription('Outfile: If given, output will be placed in this file.');
13
14 $cli->addOptionalArg('t')->setDescription('Test run: Return output followed by rewriting algorithm.');
15
16 if (! $cli->validate()) {
17 echo "USAGE: ./rewrite-uris.php [-t] -d DOC_ROOT [-o OUTFILE] file ...\n";
18 if ($cli->isHelpRequest) {
19 echo $cli->getArgumentsListing();
20 }
21 echo "EXAMPLE: ./rewrite-uris.php -v -d../.. ../../tests/_test_files/css/paths_rewrite.css ../../tests/_test_files/css/comments.css
22 \n";
23 exit(0);
24 }
25
26 $outfile = $cli->values['o'];
27 $testRun = $cli->values['t'];
28 $docRoot = $cli->values['d'];
29
30 $pathRewriter = function ($css, $options) {
31 return Minify_CSS_UriRewriter::rewrite($css, $options['currentDir'], $options['docRoot']);
32 };
33
34 $paths = $cli->getPathArgs();
35
36 $sources = array();
37 foreach ($paths as $path) {
38 if (is_file($path)) {
39 $sources[] = new Minify_Source(array(
40 'filepath' => $path,
41 'minifier' => $pathRewriter,
42 'minifyOptions' => array('docRoot' => $docRoot),
43 ));
44 } else {
45 $sources[] = new Minify_Source(array(
46 'id' => $path,
47 'content' => "/*** $path not found ***/\n",
48 'minifier' => 'Minify::nullMinifier',
49 ));
50 }
51 }
52 $combined = Minify::combine($sources) . "\n";
53
54 if ($testRun) {
55 echo $combined;
56 echo Minify_CSS_UriRewriter::$debugText . "\n";
57 } else {
58 $fp = $cli->openOutput();
59 fwrite($fp, $combined);
60 $cli->closeOutput();
61 }
62