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 / lib / Minify / Controller / Groups.php

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

76 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class Minify_Controller_Groups
4 * @package Minify
5 */
6
7 /**
8 * Controller class for serving predetermined groups of minimized sets, selected
9 * by PATH_INFO
10 *
11 * <code>
12 * Minify::serve('Groups', array(
13 * 'groups' => array(
14 * 'css' => array('//css/type.css', '//css/layout.css')
15 * ,'js' => array('//js/jquery.js', '//js/site.js')
16 * )
17 * ));
18 * </code>
19 *
20 * If the above code were placed in /serve.php, it would enable the URLs
21 * /serve.php/js and /serve.php/css
22 *
23 * @package Minify
24 * @author Stephen Clay <[email protected]>
25 */
26 class Minify_Controller_Groups extends Minify_Controller_Files
27 {
28
29 /**
30 * Set up groups of files as sources
31 *
32 * @param array $options controller and Minify options
33 *
34 * 'groups': (required) array mapping PATH_INFO strings to arrays
35 * of complete file paths. @see Minify_Controller_Groups
36 *
37 * @return array Minify options
38 */
39 public function createConfiguration(array $options)
40 {
41 // strip controller options
42 $groups = $options['groups'];
43 unset($options['groups']);
44
45 $server = $this->env->server();
46
47 // mod_fcgid places PATH_INFO in ORIG_PATH_INFO
48 if (isset($server['ORIG_PATH_INFO'])) {
49 $pathInfo = substr($server['ORIG_PATH_INFO'], 1);
50 } elseif (isset($server['PATH_INFO'])) {
51 $pathInfo = substr($server['PATH_INFO'], 1);
52 } else {
53 $pathInfo = false;
54 }
55
56 if (false === $pathInfo || ! isset($groups[$pathInfo])) {
57 // no PATH_INFO or not a valid group
58 $this->logger->info("Missing PATH_INFO or no group set for \"$pathInfo\"");
59
60 return new Minify_ServeConfiguration($options);
61 }
62
63 $files = $groups[$pathInfo];
64 // if $files is a single object, casting will break it
65 if (is_object($files)) {
66 $files = array($files);
67 } elseif (! is_array($files)) {
68 $files = (array)$files;
69 }
70
71 $options['files'] = $files;
72
73 return parent::createConfiguration($options);
74 }
75 }
76