Version Description
Download this release
Release Info
Developer | wokamoto |
Plugin | Head Cleaner |
Version | 1.4.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.0.4 to 1.4.0.5
- head-cleaner.php +27 -15
- readme.txt +1 -1
- readme_ja.txt +1 -1
head-cleaner.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Head Cleaner
|
4 |
-
Version: 1.4.0.
|
5 |
Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
|
6 |
Description: Cleaning tags from your WordPress header and footer.
|
7 |
Author: wokamoto
|
@@ -213,7 +213,7 @@ class HeadCleaner extends wokController {
|
|
213 |
$priority = $this->options_default['priority'];
|
214 |
foreach ($wk_options['priority'] as $tag => $filters) {
|
215 |
foreach ((array) $filters as $key => $val) {
|
216 |
-
if ($val <= 0 || $val >
|
217 |
$priority[$tag][$key] = $val;
|
218 |
}
|
219 |
}
|
@@ -228,7 +228,7 @@ class HeadCleaner extends wokController {
|
|
228 |
$wk_options['filters'] = $filters;
|
229 |
$wk_options['priority'] = $priority;
|
230 |
$wk_options['head_js'] = $head_js;
|
231 |
-
$wk_options['analyze_expired'] = time() +
|
232 |
}
|
233 |
|
234 |
return $wk_options;
|
@@ -298,7 +298,7 @@ class HeadCleaner extends wokController {
|
|
298 |
if ( function_exists('rel_canonical') && !$this->options['canonical_tag'] )
|
299 |
remove_action( 'wp_head', 'rel_canonical' );
|
300 |
|
301 |
-
add_action('wp_head', array(&$this, 'end'),
|
302 |
$this->_get_filters('wp_head');
|
303 |
$this->_change_filters_priority('wp_head');
|
304 |
|
@@ -325,7 +325,7 @@ class HeadCleaner extends wokController {
|
|
325 |
ob_start(array(&$this, 'footer_cleaner'));
|
326 |
$this->mtime_start = microtime();
|
327 |
|
328 |
-
add_action('wp_footer', array(&$this, 'end'),
|
329 |
$this->_get_filters('wp_footer');
|
330 |
$this->_change_filters_priority('wp_footer');
|
331 |
}
|
@@ -374,7 +374,7 @@ class HeadCleaner extends wokController {
|
|
374 |
if ( $this->options['filters'] != $this->filters || $this->options['head_js'] != $this->head_js ) {
|
375 |
$this->options['filters'] = $this->filters;
|
376 |
$this->options['head_js'] = $this->head_js;
|
377 |
-
$this->options['analyze_expired'] = time() +
|
378 |
$this->updateOptions();
|
379 |
}
|
380 |
}
|
@@ -453,6 +453,12 @@ class HeadCleaner extends wokController {
|
|
453 |
}
|
454 |
unset($matches);
|
455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
$dom = str_get_html(
|
457 |
$xml_head . $html_tag . $head_tag . $head_txt .
|
458 |
'</head><body></body></html>'
|
@@ -466,7 +472,7 @@ class HeadCleaner extends wokController {
|
|
466 |
if ( empty($html_tag) ) {
|
467 |
if ( $doctype === 'xhtml' ) {
|
468 |
// xhtml
|
469 |
-
$xmlns =
|
470 |
$xml_lang = $this->lang;
|
471 |
} else {
|
472 |
// html
|
@@ -572,6 +578,7 @@ class HeadCleaner extends wokController {
|
|
572 |
: $this->_tag_trim(strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
|
573 |
);
|
574 |
$ret_val = $this->_tag_normalize($ret_val);
|
|
|
575 |
|
576 |
// add debug information
|
577 |
if ($this->options['debug_mode'])
|
@@ -586,6 +593,11 @@ class HeadCleaner extends wokController {
|
|
586 |
return $ret_val;
|
587 |
}
|
588 |
|
|
|
|
|
|
|
|
|
|
|
589 |
//**************************************************************************************
|
590 |
// Parse IE conditional tags
|
591 |
//**************************************************************************************
|
@@ -1778,7 +1790,7 @@ class HeadCleaner extends wokController {
|
|
1778 |
: $img_url
|
1779 |
);
|
1780 |
$img_enc = (
|
1781 |
-
$img_enc != $img_url && strlen($img_enc) <=
|
1782 |
? $img_enc
|
1783 |
: $img_url
|
1784 |
);
|
@@ -2130,7 +2142,7 @@ E__O__T;
|
|
2130 |
$out .= '</tr>'."\n";
|
2131 |
$head_filters = array();
|
2132 |
foreach ((array) $this->options['filters']['wp_head'] as $function_name => $priority) {
|
2133 |
-
if ($priority <
|
2134 |
if (isset($this->options['priority']['wp_head'][$function_name]))
|
2135 |
$priority = (int) $this->options['priority']['wp_head'][$function_name];
|
2136 |
if (!isset($head_filters[$priority]))
|
@@ -2144,7 +2156,7 @@ E__O__T;
|
|
2144 |
foreach ($filters as $function_name){
|
2145 |
if ( ! preg_match('/^(' . implode('|', $this->default_head_filters) . ')$/i', $function_name)) {
|
2146 |
$out .= '<tr>';
|
2147 |
-
$out .= '<th><input type="checkbox" name="head_filters['.$i.']" value="'.$function_name.'"'.($priority >
|
2148 |
$out .= '<th><input type="checkbox" name="head_remove['.$i.']" value="'.$function_name.'"'.($priority <= 0 ? ' checked="true"' : '').' /></th>';
|
2149 |
$out .= '<td>'.$function_name.'</td>';
|
2150 |
if ($this->options['debug_mode'])
|
@@ -2168,7 +2180,7 @@ E__O__T;
|
|
2168 |
$out .= '</tr>'."\n";
|
2169 |
$footer_filters = array();
|
2170 |
foreach ((array) $this->options['filters']['wp_footer'] as $function_name => $priority) {
|
2171 |
-
if ($priority <
|
2172 |
if (isset($this->options['priority']['wp_footer'][$function_name]))
|
2173 |
$priority = (int) $this->options['priority']['wp_footer'][$function_name];
|
2174 |
if (!isset($footer_filters[$priority]))
|
@@ -2182,7 +2194,7 @@ E__O__T;
|
|
2182 |
foreach ($filters as $function_name){
|
2183 |
if ( ! preg_match('/^(' . implode('|', $this->default_head_filters) . ')$/i', $function_name)) {
|
2184 |
$out .= '<tr>';
|
2185 |
-
$out .= '<th><input type="checkbox" name="foot_filters['.$i.']" value="'.$function_name.'"'.($priority >
|
2186 |
$out .= '<th><input type="checkbox" name="foot_remove['.$i.']" value="'.$function_name.'"'.($priority <= 0 ? ' checked="true"' : '').' /></th>';
|
2187 |
$out .= '<td>'.$function_name.'</td>';
|
2188 |
if ($this->options['debug_mode'])
|
@@ -2306,7 +2318,7 @@ E__O__T;
|
|
2306 |
$tag = 'wp_head';
|
2307 |
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2308 |
if (count($head_filters) > 0 && array_search($function_name, $head_filters) !== FALSE)
|
2309 |
-
$this->options['priority'][$tag][$function_name] =
|
2310 |
elseif (count($head_remove) > 0 && array_search($function_name, $head_remove) !== FALSE)
|
2311 |
$this->options['priority'][$tag][$function_name] = -1;
|
2312 |
elseif (isset($this->options['priority'][$tag][$function_name]))
|
@@ -2321,7 +2333,7 @@ E__O__T;
|
|
2321 |
$tag = 'wp_footer';
|
2322 |
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2323 |
if (count($foot_filters) > 0 && array_search($function_name, $foot_filters) !== FALSE)
|
2324 |
-
$this->options['priority'][$tag][$function_name] =
|
2325 |
elseif (count($foot_remove) > 0 && array_search($function_name, $foot_remove) !== FALSE)
|
2326 |
$this->options['priority'][$tag][$function_name] = -1;
|
2327 |
elseif (isset($this->options['priority'][$tag][$function_name]))
|
@@ -2436,7 +2448,7 @@ E__O__T;
|
|
2436 |
? $this->options['priority'][$tag]
|
2437 |
: array() );
|
2438 |
foreach ($this->no_conflict as $function_name) {
|
2439 |
-
$custom_priority[$function_name] =
|
2440 |
}
|
2441 |
foreach ($active_filters as $priority => $filters) {
|
2442 |
foreach ($filters as $filter) {
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Head Cleaner
|
4 |
+
Version: 1.4.0.5
|
5 |
Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
|
6 |
Description: Cleaning tags from your WordPress header and footer.
|
7 |
Author: wokamoto
|
213 |
$priority = $this->options_default['priority'];
|
214 |
foreach ($wk_options['priority'] as $tag => $filters) {
|
215 |
foreach ((array) $filters as $key => $val) {
|
216 |
+
if ($val <= 0 || $val > self::PRIORITY)
|
217 |
$priority[$tag][$key] = $val;
|
218 |
}
|
219 |
}
|
228 |
$wk_options['filters'] = $filters;
|
229 |
$wk_options['priority'] = $priority;
|
230 |
$wk_options['head_js'] = $head_js;
|
231 |
+
$wk_options['analyze_expired'] = time() + self::ANALYZE_EXPIRED;
|
232 |
}
|
233 |
|
234 |
return $wk_options;
|
298 |
if ( function_exists('rel_canonical') && !$this->options['canonical_tag'] )
|
299 |
remove_action( 'wp_head', 'rel_canonical' );
|
300 |
|
301 |
+
add_action('wp_head', array(&$this, 'end'), self::PRIORITY);
|
302 |
$this->_get_filters('wp_head');
|
303 |
$this->_change_filters_priority('wp_head');
|
304 |
|
325 |
ob_start(array(&$this, 'footer_cleaner'));
|
326 |
$this->mtime_start = microtime();
|
327 |
|
328 |
+
add_action('wp_footer', array(&$this, 'end'), self::PRIORITY);
|
329 |
$this->_get_filters('wp_footer');
|
330 |
$this->_change_filters_priority('wp_footer');
|
331 |
}
|
374 |
if ( $this->options['filters'] != $this->filters || $this->options['head_js'] != $this->head_js ) {
|
375 |
$this->options['filters'] = $this->filters;
|
376 |
$this->options['head_js'] = $this->head_js;
|
377 |
+
$this->options['analyze_expired'] = time() + self::ANALYZE_EXPIRED;
|
378 |
$this->updateOptions();
|
379 |
}
|
380 |
}
|
453 |
}
|
454 |
unset($matches);
|
455 |
|
456 |
+
$head_txt = preg_replace_callback(
|
457 |
+
array('/(content=)(")([^"]*)(")/i', '/(content=)(\')([^\']*)(\')/i'),
|
458 |
+
array(&$this, '_tag_replace'),
|
459 |
+
$head_txt
|
460 |
+
);
|
461 |
+
|
462 |
$dom = str_get_html(
|
463 |
$xml_head . $html_tag . $head_tag . $head_txt .
|
464 |
'</head><body></body></html>'
|
472 |
if ( empty($html_tag) ) {
|
473 |
if ( $doctype === 'xhtml' ) {
|
474 |
// xhtml
|
475 |
+
$xmlns = self::XMLNS;
|
476 |
$xml_lang = $this->lang;
|
477 |
} else {
|
478 |
// html
|
578 |
: $this->_tag_trim(strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
|
579 |
);
|
580 |
$ret_val = $this->_tag_normalize($ret_val);
|
581 |
+
$ret_val = str_replace(''', "'", $ret_val);
|
582 |
|
583 |
// add debug information
|
584 |
if ($this->options['debug_mode'])
|
593 |
return $ret_val;
|
594 |
}
|
595 |
|
596 |
+
private function _tag_replace($matches) {
|
597 |
+
$content = $matches[2] . esc_attr($matches[3]) . $matches[4];
|
598 |
+
return $matches[1] . $content;
|
599 |
+
}
|
600 |
+
|
601 |
//**************************************************************************************
|
602 |
// Parse IE conditional tags
|
603 |
//**************************************************************************************
|
1790 |
: $img_url
|
1791 |
);
|
1792 |
$img_enc = (
|
1793 |
+
$img_enc != $img_url && strlen($img_enc) <= self::IMG_BASE64_MAX_SIZE
|
1794 |
? $img_enc
|
1795 |
: $img_url
|
1796 |
);
|
2142 |
$out .= '</tr>'."\n";
|
2143 |
$head_filters = array();
|
2144 |
foreach ((array) $this->options['filters']['wp_head'] as $function_name => $priority) {
|
2145 |
+
if ($priority < self::PRIORITY) {
|
2146 |
if (isset($this->options['priority']['wp_head'][$function_name]))
|
2147 |
$priority = (int) $this->options['priority']['wp_head'][$function_name];
|
2148 |
if (!isset($head_filters[$priority]))
|
2156 |
foreach ($filters as $function_name){
|
2157 |
if ( ! preg_match('/^(' . implode('|', $this->default_head_filters) . ')$/i', $function_name)) {
|
2158 |
$out .= '<tr>';
|
2159 |
+
$out .= '<th><input type="checkbox" name="head_filters['.$i.']" value="'.$function_name.'"'.($priority > self::PRIORITY ? ' checked="true"' : '').' /></th>';
|
2160 |
$out .= '<th><input type="checkbox" name="head_remove['.$i.']" value="'.$function_name.'"'.($priority <= 0 ? ' checked="true"' : '').' /></th>';
|
2161 |
$out .= '<td>'.$function_name.'</td>';
|
2162 |
if ($this->options['debug_mode'])
|
2180 |
$out .= '</tr>'."\n";
|
2181 |
$footer_filters = array();
|
2182 |
foreach ((array) $this->options['filters']['wp_footer'] as $function_name => $priority) {
|
2183 |
+
if ($priority < self::PRIORITY) {
|
2184 |
if (isset($this->options['priority']['wp_footer'][$function_name]))
|
2185 |
$priority = (int) $this->options['priority']['wp_footer'][$function_name];
|
2186 |
if (!isset($footer_filters[$priority]))
|
2194 |
foreach ($filters as $function_name){
|
2195 |
if ( ! preg_match('/^(' . implode('|', $this->default_head_filters) . ')$/i', $function_name)) {
|
2196 |
$out .= '<tr>';
|
2197 |
+
$out .= '<th><input type="checkbox" name="foot_filters['.$i.']" value="'.$function_name.'"'.($priority > self::PRIORITY ? ' checked="true"' : '').' /></th>';
|
2198 |
$out .= '<th><input type="checkbox" name="foot_remove['.$i.']" value="'.$function_name.'"'.($priority <= 0 ? ' checked="true"' : '').' /></th>';
|
2199 |
$out .= '<td>'.$function_name.'</td>';
|
2200 |
if ($this->options['debug_mode'])
|
2318 |
$tag = 'wp_head';
|
2319 |
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2320 |
if (count($head_filters) > 0 && array_search($function_name, $head_filters) !== FALSE)
|
2321 |
+
$this->options['priority'][$tag][$function_name] = self::PRIORITY + 1;
|
2322 |
elseif (count($head_remove) > 0 && array_search($function_name, $head_remove) !== FALSE)
|
2323 |
$this->options['priority'][$tag][$function_name] = -1;
|
2324 |
elseif (isset($this->options['priority'][$tag][$function_name]))
|
2333 |
$tag = 'wp_footer';
|
2334 |
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2335 |
if (count($foot_filters) > 0 && array_search($function_name, $foot_filters) !== FALSE)
|
2336 |
+
$this->options['priority'][$tag][$function_name] = self::PRIORITY + 1;
|
2337 |
elseif (count($foot_remove) > 0 && array_search($function_name, $foot_remove) !== FALSE)
|
2338 |
$this->options['priority'][$tag][$function_name] = -1;
|
2339 |
elseif (isset($this->options['priority'][$tag][$function_name]))
|
2448 |
? $this->options['priority'][$tag]
|
2449 |
: array() );
|
2450 |
foreach ($this->no_conflict as $function_name) {
|
2451 |
+
$custom_priority[$function_name] = self::PRIORITY + 1;
|
2452 |
}
|
2453 |
foreach ($active_filters as $priority => $filters) {
|
2454 |
foreach ($filters as $filter) {
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJ
|
|
4 |
Tags: head, header, footer, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.2
|
7 |
-
Stable tag: 1.4.0.
|
8 |
|
9 |
Cleaning tags from your WordPress header and footer.
|
10 |
|
4 |
Tags: head, header, footer, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.2
|
7 |
+
Stable tag: 1.4.0.5
|
8 |
|
9 |
Cleaning tags from your WordPress header and footer.
|
10 |
|
readme_ja.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJ
|
|
4 |
Tags: head optimization, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.2
|
7 |
-
Stable tag: 1.4.0.
|
8 |
|
9 |
Head と footer をお掃除します。
|
10 |
|
4 |
Tags: head optimization, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.2
|
7 |
+
Stable tag: 1.4.0.5
|
8 |
|
9 |
Head と footer をお掃除します。
|
10 |
|