PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.3.1
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.3.1
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 / utils.php

utils.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.3.1, at vendor/mrclay/minify/utils.php

79 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Utility functions for generating URIs in HTML files
4 *
5 * @warning These functions execute min/groupsConfig.php, sometimes multiple times.
6 * You must make sure that functions are not redefined, and if your use custom sources,
7 * you must require_once __DIR__ . '/lib/Minify/Source.php' so that
8 * class is available.
9 *
10 * @package Minify
11 */
12
13 require __DIR__ . '/bootstrap.php';
14
15 /*
16 * Get an HTML-escaped Minify URI for a group or set of files. By default, URIs
17 * will contain timestamps to allow far-future Expires headers.
18 *
19 * <code>
20 * <link rel="stylesheet" type="text/css" href="<?= Minify_getUri('css'); ?>" />
21 * <script src="<?= Minify_getUri('js'); ?>"></script>
22 * <script src="<?= Minify_getUri(array(
23 * '//scripts/file1.js'
24 * ,'//scripts/file2.js'
25 * )); ?>"></script>
26 * </code>
27 *
28 * @param mixed $keyOrFiles a group key or array of file paths/URIs
29 * @param array $opts options:
30 * 'farExpires' : (default true) append a modified timestamp for cache revving
31 * 'debug' : (default false) append debug flag
32 * 'charset' : (default 'UTF-8') for htmlspecialchars
33 * 'minAppUri' : (default '/min') URI of min directory
34 * 'rewriteWorks' : (default true) does mod_rewrite work in min app?
35 * 'groupsConfigFile' : specify if different
36 * @return string
37 */
38 function Minify_getUri($keyOrFiles, $opts = array())
39 {
40 return Minify_HTML_Helper::getUri($keyOrFiles, $opts);
41 }
42
43
44 /**
45 * Get the last modification time of several source js/css files. If you're
46 * caching the output of Minify_getUri(), you might want to know if one of the
47 * dependent source files has changed so you can update the HTML.
48 *
49 * Since this makes a bunch of stat() calls, you might not want to check this
50 * on every request.
51 *
52 * @param array $keysAndFiles group keys and/or file paths/URIs.
53 * @return int latest modification time of all given keys/files
54 */
55 function Minify_mtime($keysAndFiles, $groupsConfigFile = null)
56 {
57 $gc = null;
58 if (! $groupsConfigFile) {
59 $groupsConfigFile = Minify_HTML_Helper::app()->groupsConfigPath;
60 }
61 $sources = array();
62 foreach ($keysAndFiles as $keyOrFile) {
63 if (is_object($keyOrFile)
64 || 0 === strpos($keyOrFile, '/')
65 || 1 === strpos($keyOrFile, ':\\')) {
66 // a file/source obj
67 $sources[] = $keyOrFile;
68 } else {
69 if (! $gc) {
70 $gc = (require $groupsConfigFile);
71 }
72 foreach ($gc[$keyOrFile] as $source) {
73 $sources[] = $source;
74 }
75 }
76 }
77 return Minify_HTML_Helper::getLastModified($sources);
78 }
79