Changeset 1688620
- Timestamp:
- 07/01/2017 06:44:58 AM (9 years ago)
- Location:
- optimality/trunk
- Files:
-
- 3 edited
-
index.php (modified) (6 diffs)
-
markup/html.php (modified) (3 diffs)
-
markup/sitemap.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
optimality/trunk/index.php
r1688504 r1688620 147 147 register_deactivation_hook(__FILE__, function() 148 148 { 149 wp_clear_scheduled_hook( __NAMESPACE__ ); 150 Style::cleanCache(); Script::cleanCache(); Html::cleanCache(); 149 wp_clear_scheduled_hook( __NAMESPACE__ ); $this->onReboot(); 151 150 }); 152 151 … … 164 163 }); 165 164 165 add_action('switch_theme', [$this, 'onReboot']); 166 166 167 if (isset($this->option[Image::MINIFY])) 167 168 { … … 169 170 } 170 171 171 call_user_func([ $this, '__construct' . 172 (is_admin() ? 'Admin' : 'Front') ]); 172 call_user_func([ $this, '__construct' . (is_admin() ? 'Admin' : 'Front') ]); 173 173 } 174 174 … … 263 263 } 264 264 265 $markup = new $markup(get_queried_object()); 266 267 if ($target = $markup(__TARGET__, $this->option)) 268 { 269 wp_redirect($target, 301); exit(); 270 } 271 265 272 $ishtml = preg_grep(Html::HEADER, headers_list()); 266 273 $method = strtoupper(@$_SERVER['REQUEST_METHOD']); … … 270 277 !is_user_logged_in() && !defined('DOING_CRON')) 271 278 { 272 Html::serve(@$_SERVER['HTTP_ACCEPT_ENCODING']); 273 } 274 275 $markup = new $markup(get_queried_object()); 276 277 if ($target = $markup(__TARGET__, $this->option)) 278 { 279 wp_redirect($target, 301); exit(); 279 $markup->serve(@$_SERVER['HTTP_ACCEPT_ENCODING']); 280 280 } 281 281 … … 675 675 return $option; 676 676 } 677 678 679 function onReboot() 680 { 681 Style::cleanCache(); 682 Script::cleanCache(); 683 Html::cleanCache(); 684 } 677 685 } 678 686 -
optimality/trunk/markup/html.php
r1688504 r1688620 219 219 { 220 220 $this->preserveWhiteSpace = !isset($option[static::MINIFY]); 221 @$this->loadHTML($string, LIBXML_COMPACT | LIBXML_NOBLANKS); 221 222 if (!@$this->loadHTML($string, LIBXML_COMPACT|LIBXML_NOBLANKS)) 223 { 224 return $string; 225 } 222 226 223 227 $schema = new \DOMXPath($this); $linked = [ ]; … … 469 473 if ($string = $this->build($string, $option)) 470 474 { 471 $handle = sprintf('~%s.html', md5( __TARGET__));475 $handle = sprintf('~%s.html', md5($this->route)); 472 476 473 477 file_put_contents($target = __CDNDIR__ . $handle, $string); … … 479 483 480 484 481 staticfunction serve($accept)482 { 483 $source = sprintf(__CDNDIR__ . '~%s.html', md5( __TARGET__));485 function serve($accept) 486 { 487 $source = sprintf(__CDNDIR__ . '~%s.html', md5($this->route)); 484 488 485 489 if ($encode = $accept && (strpos($accept, 'gzip') !== false)) -
optimality/trunk/markup/sitemap.php
r1688504 r1688620 112 112 113 113 114 function cache($string, $option) 115 { 116 return $this->build($string, $option); 117 } 118 119 120 function serve($accept) 121 { 122 return false; 123 } 124 125 114 126 static function ping() 115 127 {
Note: See TracChangeset
for help on using the changeset viewer.