| 1 |
<?php |
| 2 |
|
| 3 |
abstract class autoptimizeBase |
| 4 |
{ |
| 5 |
protected $content = ''; |
| 6 |
|
| 7 |
public function __construct($content) |
| 8 |
{ |
| 9 |
$this->content = $content; |
| 10 |
//Best place to catch errors |
| 11 |
} |
| 12 |
|
| 13 |
//Reads the page and collects tags |
| 14 |
abstract public function read($justhead); |
| 15 |
|
| 16 |
//Joins and optimizes collected things |
| 17 |
abstract public function minify(); |
| 18 |
|
| 19 |
//Caches the things |
| 20 |
abstract public function cache(); |
| 21 |
|
| 22 |
//Returns the content |
| 23 |
abstract public function getcontent(); |
| 24 |
|
| 25 |
//Converts an URL to a full path |
| 26 |
protected function getpath($url) |
| 27 |
{ |
| 28 |
$siteurl = site_url(); |
| 29 |
if ((strpos($url,'//')===false) && (strpos($url,parse_url($siteurl,PHP_URL_HOST))===false)) { |
| 30 |
$url = $siteurl.$url; |
| 31 |
} |
| 32 |
$path = str_replace(WP_ROOT_URL,'',$url); |
| 33 |
if(preg_match('#^(https?|ftp)://#i',$path)) |
| 34 |
{ |
| 35 |
/** External script/css (adsense, etc) */ |
| 36 |
return false; |
| 37 |
} |
| 38 |
$path = str_replace('//','/',WP_ROOT_PATH.$path); |
| 39 |
return $path; |
| 40 |
} |
| 41 |
|
| 42 |
// coz I'm a crappy developer and I need easy access to whatever I want to log |
| 43 |
protected function ao_logger($logmsg) { |
| 44 |
$logfile=WP_CONTENT_DIR.'/ao_log.txt'; |
| 45 |
$logmsg.="\n"; |
| 46 |
file_put_contents($logfile,$logmsg,FILE_APPEND); |
| 47 |
} |
| 48 |
} |
| 49 |
|