| Conditions | 9 |
| Paths | 18 |
| Total Lines | 88 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 159 | static function cacheavail() { |
||
| 160 | if(!defined('AUTOPTIMIZE_CACHE_DIR')) { |
||
| 161 | // We didn't set a cache |
||
| 162 | return false; |
||
| 163 | } |
||
| 164 | |||
| 165 | foreach (array("","js","css") as $checkDir) { |
||
| 166 | if(!autoptimizeCache::checkCacheDir(AUTOPTIMIZE_CACHE_DIR.$checkDir)) { |
||
| 167 | return false; |
||
| 168 | } |
||
| 169 | } |
||
| 170 | |||
| 171 | /** write index.html here to avoid prying eyes */ |
||
| 172 | $indexFile=AUTOPTIMIZE_CACHE_DIR.'/index.html'; |
||
| 173 | if(!is_file($indexFile)) { |
||
| 174 | @file_put_contents($indexFile,'<html><head><meta name="robots" content="noindex, nofollow"></head><body>Generated by <a href="http://wordpress.org/extend/plugins/autoptimize/" rel="nofollow">Autoptimize</a></body></html>'); |
||
| 175 | } |
||
| 176 | |||
| 177 | /** write .htaccess here to overrule wp_super_cache */ |
||
| 178 | $htAccess=AUTOPTIMIZE_CACHE_DIR.'/.htaccess'; |
||
| 179 | if(!is_file($htAccess)) { |
||
| 180 | /** |
||
| 181 | * create wp-content/AO_htaccess_tmpl with |
||
| 182 | * whatever htaccess rules you might need |
||
| 183 | * if you want to override default AO htaccess |
||
| 184 | */ |
||
| 185 | $htaccess_tmpl=WP_CONTENT_DIR."/AO_htaccess_tmpl"; |
||
| 186 | if (is_file($htaccess_tmpl)) { |
||
| 187 | $htAccessContent=file_get_contents($htaccess_tmpl); |
||
| 188 | } else if (is_multisite() || AUTOPTIMIZE_CACHE_NOGZIP == false) { |
||
| 189 | $htAccessContent='<IfModule mod_expires.c> |
||
| 190 | ExpiresActive On |
||
| 191 | ExpiresByType text/css A30672000 |
||
| 192 | ExpiresByType text/javascript A30672000 |
||
| 193 | ExpiresByType application/javascript A30672000 |
||
| 194 | </IfModule> |
||
| 195 | <IfModule mod_headers.c> |
||
| 196 | Header append Cache-Control "public, immutable" |
||
| 197 | </IfModule> |
||
| 198 | <IfModule mod_deflate.c> |
||
| 199 | <FilesMatch "\.(js|css)$"> |
||
| 200 | SetOutputFilter DEFLATE |
||
| 201 | </FilesMatch> |
||
| 202 | </IfModule> |
||
| 203 | <IfModule mod_authz_core.c> |
||
| 204 | <Files *.php> |
||
| 205 | Require all granted |
||
| 206 | </Files> |
||
| 207 | </IfModule> |
||
| 208 | <IfModule !mod_authz_core.c> |
||
| 209 | <Files *.php> |
||
| 210 | Order allow,deny |
||
| 211 | Allow from all |
||
| 212 | </Files> |
||
| 213 | </IfModule>'; |
||
| 214 | } else { |
||
| 215 | $htAccessContent='<IfModule mod_expires.c> |
||
| 216 | ExpiresActive On |
||
| 217 | ExpiresByType text/css A30672000 |
||
| 218 | ExpiresByType text/javascript A30672000 |
||
| 219 | ExpiresByType application/javascript A30672000 |
||
| 220 | </IfModule> |
||
| 221 | <IfModule mod_headers.c> |
||
| 222 | Header append Cache-Control "public, immutable" |
||
| 223 | </IfModule> |
||
| 224 | <IfModule mod_deflate.c> |
||
| 225 | <FilesMatch "\.(js|css)$"> |
||
| 226 | SetOutputFilter DEFLATE |
||
| 227 | </FilesMatch> |
||
| 228 | </IfModule> |
||
| 229 | <IfModule mod_authz_core.c> |
||
| 230 | <Files *.php> |
||
| 231 | Require all denied |
||
| 232 | </Files> |
||
| 233 | </IfModule> |
||
| 234 | <IfModule !mod_authz_core.c> |
||
| 235 | <Files *.php> |
||
| 236 | Order deny,allow |
||
| 237 | Deny from all |
||
| 238 | </Files> |
||
| 239 | </IfModule>'; |
||
| 240 | } |
||
| 241 | @file_put_contents($htAccess,$htAccessContent); |
||
| 242 | } |
||
| 243 | |||
| 244 | // All OK |
||
| 245 | return true; |
||
| 246 | } |
||
| 247 | |||
| 271 |
This check marks private properties in classes that are never used. Those properties can be removed.