PluginProbe
Autoptimize / 0.2
Autoptimize v0.2
2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 All 107 releases
autoptimize / classes / autoptimizeCache.php

autoptimizeCache.php in Autoptimize 0.2, at classes/autoptimizeCache.php

41 lines 977 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class autopimizeCache
4 {
5 private $filename;
6 private $mime;
7 private $cachedir;
8
9 public function __construct($cachedir,$md5)
10 {
11 $this->cachedir = $cachedir;
12 $this->filename = 'autoptimize_'.$md5.'.php';
13 }
14
15 public function check()
16 {
17 if(!file_exists($this->cachedir.$this->filename))
18 {
19 //No cached file, sorry
20 return false;
21 }
22 //Cache exists!
23 return true;
24 }
25
26 public function cache($code,$mime)
27 {
28 $phpcode = file_get_contents(WP_PLUGIN_DIR.'/autoptimize/config/default.php');
29 $phpcode = str_replace(array('%%CONTENT%%','exit;'),array($mime,''),$phpcode);
30 file_put_contents($this->cachedir.$this->filename,$phpcode);
31 file_put_contents($this->cachedir.$this->filename.'.deflate',gzencode($code,9,FORCE_DEFLATE));
32 file_put_contents($this->cachedir.$this->filename.'.gzip',gzencode($code,9,FORCE_GZIP));
33 file_put_contents($this->cachedir.$this->filename.'.none',$code);
34 }
35
36 public function getname()
37 {
38 return $this->filename;
39 }
40 }
41