Version Description
Download this release
Release Info
Developer | wokamoto |
Plugin | Head Cleaner |
Version | 1.3.13 |
Comparing to | |
See all releases |
Code changes from version 1.3.12 to 1.3.13
- head-cleaner.php +333 -227
- readme.txt +5 -3
- readme_ja.txt +1 -1
head-cleaner.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Head Cleaner
|
4 |
-
Version: 1.3.
|
5 |
Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
|
6 |
Description: Cleaning tags from your WordPress header and footer.
|
7 |
Author: wokamoto
|
@@ -155,7 +155,7 @@ if (!class_exists('wokController') || !class_exists('wokScriptManager'))
|
|
155 |
//**************************************************************************************
|
156 |
class HeadCleaner extends wokController {
|
157 |
public $plugin_name = 'head-cleaner';
|
158 |
-
public $plugin_ver = '1.3.
|
159 |
|
160 |
// Deafault Options
|
161 |
private $options_default = array(
|
@@ -195,6 +195,7 @@ class HeadCleaner extends wokController {
|
|
195 |
);
|
196 |
|
197 |
private $wp_url = '';
|
|
|
198 |
private $self_url = '';
|
199 |
private $cache_path = '';
|
200 |
private $cache_url = '';
|
@@ -238,7 +239,8 @@ class HeadCleaner extends wokController {
|
|
238 |
$this->filters = $this->options['filters'];
|
239 |
$this->head_js = $this->options['head_js'];
|
240 |
|
241 |
-
$this->wp_url = trailingslashit(
|
|
|
242 |
$this->self_url = str_replace(ABSPATH, $this->wp_url, __FILE__);
|
243 |
$this->lang = (defined('WPLANG') ? WPLANG : 'ja');
|
244 |
$this->charset = get_option('blog_charset');
|
@@ -484,9 +486,19 @@ class HeadCleaner extends wokController {
|
|
484 |
|
485 |
$url = $this->_get_permalink();
|
486 |
|
487 |
-
|
488 |
-
|
489 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
$head_txt = trim($buffer);
|
491 |
|
492 |
$ret_val = '';
|
@@ -496,16 +508,158 @@ class HeadCleaner extends wokController {
|
|
496 |
$script_tag = ''; $inline_js = '';
|
497 |
|
498 |
// for IE conditional tag
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
$IE_conditional_tags = array();
|
500 |
-
$ie6 = false;
|
501 |
if ($this->options['ie_conditional']) {
|
502 |
-
$ua = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
|
503 |
-
$ie = (strpos($ua, 'msie') !== false)
|
504 |
-
&& (! preg_match('/(gecko|applewebkit|opera|sleipnir|chrome)/i', $ua));
|
505 |
-
$ie_ver = ($ie ? preg_replace('/^.*msie +([\d+\.]+);.*$/i', '$1', $ua) : false);
|
506 |
-
$ie6 = ($ie ? version_compare($ie_ver, '7.0', '<') : false);
|
507 |
if ($ie) {
|
508 |
-
$IE_conditional_tag_pattern = '/<\!-+[ \t]*\[if[ \t]+IE[ \t]*?\][ \t]*>(.*?)<\![ \t]*\[endif\][ \t]*-+>/
|
509 |
$head_txt = preg_replace($IE_conditional_tag_pattern, '$1', $head_txt);
|
510 |
|
511 |
$replace_patterns = array();
|
@@ -542,53 +696,27 @@ class HeadCleaner extends wokController {
|
|
542 |
unset($replace_patterns);
|
543 |
}
|
544 |
} else {
|
545 |
-
$IE_conditional_tag_pattern = '/<\!-+[ \t]*\[if[ \t]+([lg]te[ \t]*)?IE([ \t]+[056789\.]*)?[ \t]*?\][ \t]*>(.*?)<\![ \t]*\[endif\][ \t]*-+>/
|
546 |
preg_match_all($IE_conditional_tag_pattern, $head_txt, $IE_conditional_tags, PREG_SET_ORDER);
|
547 |
$head_txt = preg_replace($IE_conditional_tag_pattern, '', $head_txt);
|
548 |
}
|
549 |
|
550 |
-
|
551 |
-
|
552 |
-
$html_tag = trim($matches[2]) . "\n";
|
553 |
-
$head_tag = trim($matches[3]) . "\n";
|
554 |
-
$head_txt = trim($matches[4]) . "\n";
|
555 |
-
}
|
556 |
-
unset($matches);
|
557 |
-
$html_txt = $xml_head . $html_tag . $head_tag
|
558 |
-
. $head_txt
|
559 |
-
. '</head><body></body></html>';
|
560 |
-
|
561 |
-
// Get Simple DOM Object
|
562 |
-
$dom = str_get_html($html_txt);
|
563 |
-
if ($dom === false)
|
564 |
-
return (trim($buffer)."\n");
|
565 |
-
|
566 |
-
$xmlns = (defined('HC_XMLNS') ? HC_XMLNS : 'http://www.w3.org/1999/xhtml');
|
567 |
-
$xml_lang = $this->lang;
|
568 |
-
$lang = $this->lang;
|
569 |
-
if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $matches, PREG_SET_ORDER)) {
|
570 |
-
foreach ((array) $matches as $match) {
|
571 |
-
switch ($match[1]){
|
572 |
-
case 'xmlns': $xmlns = $match[2]; break;
|
573 |
-
case 'xml:lang': $xml_lang = $match[2]; break;
|
574 |
-
case 'lang': $lang = $match[2]; break;
|
575 |
-
}
|
576 |
-
}
|
577 |
-
unset($match);
|
578 |
-
}
|
579 |
-
unset($matches);
|
580 |
-
$html_tag = "<html xmlns=\"{$xmlns}\" xml:lang=\"{$xml_lang}\" lang=\"{$lang}\">\n";
|
581 |
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
|
|
|
|
|
|
|
|
588 |
|
589 |
-
|
590 |
-
$
|
591 |
-
foreach ((array) $elements as $element) {
|
592 |
$tag = trim($element->outertext);
|
593 |
if (strpos($css_tag, $tag) === FALSE) {
|
594 |
if (strpos($element->href, $this->wp_url) === FALSE) {
|
@@ -603,11 +731,10 @@ class HeadCleaner extends wokController {
|
|
603 |
}
|
604 |
}
|
605 |
}
|
606 |
-
unset($element);
|
607 |
|
608 |
-
|
609 |
-
$
|
610 |
-
foreach ((array) $elements as $element) {
|
611 |
$media = trim( isset($element->media) ? $element->media : $this->options['default_media'] );
|
612 |
$media = ( empty($media) || is_null($media) || $media === FALSE ? $this->options['default_media'] : $media );
|
613 |
$wk_text = $this->_remove_comment($element->innertext, 'css');
|
@@ -632,7 +759,6 @@ class HeadCleaner extends wokController {
|
|
632 |
$wk_inline_css[$media] .= trim($wk_text) . "\n";
|
633 |
}
|
634 |
}
|
635 |
-
$inline_css = '';
|
636 |
if ($this->options['cache_enabled']) {
|
637 |
if ($this->options['combined_css']) {
|
638 |
$css_tag = trim($css_tag) . "\n";
|
@@ -670,17 +796,26 @@ class HeadCleaner extends wokController {
|
|
670 |
}
|
671 |
}
|
672 |
}
|
|
|
|
|
|
|
673 |
$css_tag = trim($css_tag) . (!empty($css_tag) ? "\n" : '');
|
674 |
$inner_css = trim($inner_css) . (!empty($inner_css) ? "\n" : '');
|
675 |
$inline_css = trim($inline_css) . (!empty($inline_css) ? "\n" : '');
|
676 |
-
unset($wk_inline_css);
|
677 |
-
unset($element); unset($elements);
|
678 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
679 |
$inner_js = '';
|
680 |
$foot_js = '';
|
681 |
$js_src = array();
|
682 |
$js_libs = array();
|
683 |
-
|
684 |
foreach ((array) $elements as $element) {
|
685 |
if (!isset($element->src)) {
|
686 |
$inline_js .= $this->_remove_comment($element->innertext, 'js');
|
@@ -721,7 +856,7 @@ class HeadCleaner extends wokController {
|
|
721 |
}
|
722 |
}
|
723 |
}
|
724 |
-
unset($element);
|
725 |
|
726 |
// JavaScript FrameWork (Prototype.js > jQuery > mootools)
|
727 |
if (count($js_libs) > 0) {
|
@@ -733,7 +868,8 @@ class HeadCleaner extends wokController {
|
|
733 |
$script_tag = trim($script_tag) . "\n" . $wk_outer_js;
|
734 |
$inner_js = $wk_inner_js . $inner_js;
|
735 |
|
736 |
-
unset($js_libs_src);
|
|
|
737 |
}
|
738 |
|
739 |
$inline_js = trim($inline_js);
|
@@ -750,83 +886,13 @@ class HeadCleaner extends wokController {
|
|
750 |
$script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
|
751 |
$inline_js = (!empty($inline_js) ? "<script type=\"text/javascript\">//<![CDATA[\n{$inline_js}\n//]]></script>\n" : '');
|
752 |
}
|
|
|
753 |
$script_tag = trim($script_tag) . (!empty($script_tag) ? "\n" : '');
|
754 |
$inner_js = trim($inner_js) . (!empty($inner_js) ? "\n" : '');
|
755 |
$inline_js = trim($inline_js) . (!empty($inline_js) ? "\n" : '');
|
756 |
$foot_js = trim($foot_js) . (!empty($foot_js) ? "\n" : '');
|
757 |
|
758 |
-
$
|
759 |
-
|
760 |
-
$dom->clear(); unset($dom);
|
761 |
-
|
762 |
-
// for IE conditional tag
|
763 |
-
if (!$this->options['ie_conditional'] && count($IE_conditional_tags) > 0) {
|
764 |
-
$IE_conditional_tag_pattern = '/(<\!-+[ \t]*\[if[ \t]+.*IE.*[ \t]*?\][ \t]*>)[ \t\r\n]*(.*?)[ \t\r\n]*(<\![ \t]*\[endif\][ \t]*-+>)/i';
|
765 |
-
foreach ((array) $IE_conditional_tags as $IE_conditional_tag) {
|
766 |
-
if (isset($IE_conditional_tag[0])) {
|
767 |
-
$IE_tag = trim(preg_replace($IE_conditional_tag_pattern, "$1$2$3", $IE_conditional_tag[0]));
|
768 |
-
if ( strpos(strtolower($IE_tag), '<link') !== false )
|
769 |
-
$css_tag = trim($css_tag) . "\n" . $IE_tag . "\n";
|
770 |
-
elseif ( strpos(strtolower($IE_tag), '<style') !== false )
|
771 |
-
$inline_css = trim($inline_css) . "\n" . $IE_tag . "\n";
|
772 |
-
elseif ( strpos(strtolower($IE_tag), '<script') !== false )
|
773 |
-
$inline_js = trim($inline_js) . "\n" . $IE_tag . "\n";
|
774 |
-
elseif ( !empty($IE_tag) )
|
775 |
-
$object_tag = trim($object_tag) . "\n" . $IE_tag . "\n";
|
776 |
-
}
|
777 |
-
}
|
778 |
-
}
|
779 |
-
unset($IE_conditional_tag);
|
780 |
-
|
781 |
-
$ret_val .=
|
782 |
-
$html_tag
|
783 |
-
. $head_tag
|
784 |
-
. $meta_tag
|
785 |
-
. $title_tag
|
786 |
-
. $base_tag
|
787 |
-
. $link_tag
|
788 |
-
. $css_tag
|
789 |
-
. $inline_css
|
790 |
-
. (!$this->options['js_move_foot'] ? $script_tag : '')
|
791 |
-
. (!$this->options['js_move_foot'] ? $inline_js : '')
|
792 |
-
. $object_tag
|
793 |
-
;
|
794 |
-
//$ret_val = str_replace('\'', '"', $ret_val);
|
795 |
-
$ret_val = preg_replace(
|
796 |
-
array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
|
797 |
-
array( ' $1="$2"', "\n", "$1\n$2" ),
|
798 |
-
$ret_val
|
799 |
-
);
|
800 |
-
|
801 |
-
if ($this->options['js_move_foot'] || !empty($foot_js))
|
802 |
-
$this->foot_js_src = trim(
|
803 |
-
$foot_js
|
804 |
-
. ($this->options['js_move_foot'] ? $script_tag : '')
|
805 |
-
. ($this->options['js_move_foot'] ? $inline_js : '')
|
806 |
-
);
|
807 |
-
if (!empty($this->foot_js_src)) {
|
808 |
-
$this->foot_js_src .= "\n";
|
809 |
-
add_action('wp_footer', array(&$this, 'footer'), 9);
|
810 |
-
}
|
811 |
-
|
812 |
-
if ($this->options['dynamic']) {
|
813 |
-
$ret_val = preg_replace(
|
814 |
-
'/' . preg_quote($this->cache_url, '/') . '(js|css)\/([^\.]*)\.(js|css)/i' ,
|
815 |
-
$this->self_url . "?f=$2&t=$3" ,
|
816 |
-
$ret_val
|
817 |
-
);
|
818 |
-
}
|
819 |
-
|
820 |
-
$ret_val = ($ie6 || !$this->options['xml_declaration']
|
821 |
-
? preg_replace('/^<\?xml[^>]*>/i', '', $ret_val)
|
822 |
-
: (strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
|
823 |
-
);
|
824 |
-
$ret_val = trim($ret_val) . "\n";
|
825 |
-
|
826 |
-
if ($this->options['debug_mode'])
|
827 |
-
$ret_val .= $this->_get_debug_info($buffer);
|
828 |
-
|
829 |
-
return $ret_val;
|
830 |
}
|
831 |
|
832 |
//**************************************************************************************
|
@@ -917,12 +983,13 @@ class HeadCleaner extends wokController {
|
|
917 |
);
|
918 |
}
|
919 |
|
920 |
-
|
921 |
-
$ret_val =
|
922 |
array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
|
923 |
array( ' $1="$2"', "\n", "$1\n$2" ),
|
924 |
$ret_val
|
925 |
-
)
|
|
|
926 |
|
927 |
if ($this->options['debug_mode'])
|
928 |
$ret_val .= $this->_get_debug_info($buffer);
|
@@ -1715,88 +1782,8 @@ class HeadCleaner extends wokController {
|
|
1715 |
if ($this->wp25)
|
1716 |
check_admin_referer("update_options", "_wpnonce_update_options");
|
1717 |
|
1718 |
-
//
|
1719 |
-
$
|
1720 |
-
$remove_js = $this->stripArray(isset($_POST['remove_js']) ? $_POST['remove_js'] : array());
|
1721 |
-
$head_filters = $this->stripArray(isset($_POST['head_filters']) ? $_POST['head_filters'] : array());
|
1722 |
-
$head_remove = $this->stripArray(isset($_POST['head_remove']) ? $_POST['head_remove'] : array());
|
1723 |
-
$foot_filters = $this->stripArray(isset($_POST['foot_filters']) ? $_POST['foot_filters'] : array());
|
1724 |
-
$foot_remove = $this->stripArray(isset($_POST['foot_remove']) ? $_POST['foot_remove'] : array());
|
1725 |
-
$_POST = $this->stripArray($_POST);
|
1726 |
-
|
1727 |
-
// get options
|
1728 |
-
$this->options['xml_declaration'] = (isset($_POST['xml_declaration']) && $_POST['xml_declaration'] == 'on' ? true : false);
|
1729 |
-
$this->options['ie_conditional']= (isset($_POST['ie_conditional']) && $_POST['ie_conditional'] == 'on' ? true : false);
|
1730 |
-
$this->options['canonical_tag'] = (isset($_POST['canonical_tag']) && $_POST['canonical_tag'] == 'on' ? true : false);
|
1731 |
-
$this->options['foot_js'] = (isset($_POST['foot_js']) && $_POST['foot_js'] == 'on' ? true : false);
|
1732 |
-
$this->options['dynamic'] = (isset($_POST['dynamic']) && $_POST['dynamic'] == 'on' ? true : false);
|
1733 |
-
$this->options['js_move_foot'] = (isset($_POST['js_move_foot']) && $_POST['js_move_foot'] == 'on' ? true : false);
|
1734 |
-
$this->options['cache_enabled'] = (isset($_POST['cache_enabled']) && $_POST['cache_enabled'] == 'on' ? true : false);
|
1735 |
-
$this->options['combined_css'] = (isset($_POST['combined_css']) && $_POST['combined_css'] == 'on' ? true : false);
|
1736 |
-
$this->options['combined_js'] = (isset($_POST['combined_js']) && $_POST['combined_js'] == 'on' ? true : false);
|
1737 |
-
$this->options['js_minify'] = (isset($_POST['js_minify']) && $_POST['js_minify'] == 'on' ? true : false);
|
1738 |
-
$this->options['css_optimise'] = (isset($_POST['css_optimise']) && $_POST['css_optimise'] == 'on' ? true : false);
|
1739 |
-
$this->options['default_media'] = trim($_POST['default_media']);
|
1740 |
-
$this->options['gzip_on'] = (isset($_POST['gzip_on']) && $_POST['gzip_on'] == 'on' ? true : false);
|
1741 |
-
$this->options['use_ajax_libs'] = (isset($_POST['use_ajax_libs']) && $_POST['use_ajax_libs'] == 'on' ? true : false);
|
1742 |
-
$this->options['debug_mode'] = (isset($_POST['debug_mode']) && $_POST['debug_mode'] == 'on' ? true : false);
|
1743 |
-
$this->options['csstidy_option']['template'] = (int) $_POST['template'];
|
1744 |
-
$this->options['csstidy_option']['optimise_shorthands'] = (int) $_POST['optimise_shorthands'];
|
1745 |
-
$this->options['csstidy_option']['compress_colors'] = (isset($_POST['compress_colors']) && $_POST['compress_colors'] == 'on' ? true : false);
|
1746 |
-
$this->options['csstidy_option']['compress_font_weight'] = (isset($_POST['compress_font_weight']) && $_POST['compress_font_weight'] == 'on' ? true : false);
|
1747 |
-
$this->options['csstidy_option']['remove_bslash'] = (isset($_POST['remove_bslash']) && $_POST['remove_bslash'] == 'on' ? true : false);
|
1748 |
-
|
1749 |
-
$rm_generator = (isset($_POST['rm_generator']) && $_POST['rm_generator'] == 'on' ? true : false);
|
1750 |
-
$rm_rsd_link = (isset($_POST['rm_rsd_link']) && $_POST['rm_rsd_link'] == 'on' ? true : false);
|
1751 |
-
$rm_manifest = (isset($_POST['rm_manifest']) && $_POST['rm_manifest'] == 'on' ? true : false);
|
1752 |
-
|
1753 |
-
$this->options['remove_js'] = array();
|
1754 |
-
foreach ((array) $this->options['head_js'] as $javascript => $value) {
|
1755 |
-
if (count($head_js) > 0 && array_search($javascript, $head_js) !== FALSE)
|
1756 |
-
$this->options['head_js'][$javascript] = FALSE;
|
1757 |
-
else
|
1758 |
-
$this->options['head_js'][$javascript] = TRUE;
|
1759 |
-
if (array_search($javascript, (array) $remove_js) !== FALSE)
|
1760 |
-
$this->options['remove_js'][] = $javascript;
|
1761 |
-
}
|
1762 |
-
unset($head_js);
|
1763 |
-
unset($remove_js);
|
1764 |
-
|
1765 |
-
$tag = 'wp_head';
|
1766 |
-
|
1767 |
-
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
1768 |
-
if (count($head_filters) > 0 && array_search($function_name, $head_filters) !== FALSE)
|
1769 |
-
$this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
|
1770 |
-
elseif (count($head_remove) > 0 && array_search($function_name, $head_remove) !== FALSE)
|
1771 |
-
$this->options['priority'][$tag][$function_name] = -1;
|
1772 |
-
elseif (isset($this->options['priority'][$tag][$function_name]))
|
1773 |
-
$this->options['priority'][$tag][$function_name] = $priority;
|
1774 |
-
}
|
1775 |
-
$this->options['priority'][$tag]['wp_generator'] = ($rm_generator ? -1 : $this->options['filters'][$tag]['wp_generator']);
|
1776 |
-
$this->options['priority'][$tag]['rsd_link'] = ($rm_rsd_link ? -1 : $this->options['filters'][$tag]['rsd_link']);
|
1777 |
-
$this->options['priority'][$tag]['wlwmanifest_link'] = ($rm_manifest ? -1 : $this->options['filters'][$tag]['wlwmanifest_link']);
|
1778 |
-
unset($head_filters);
|
1779 |
-
|
1780 |
-
$tag = 'wp_footer';
|
1781 |
-
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
1782 |
-
if (count($foot_filters) > 0 && array_search($function_name, $foot_filters) !== FALSE)
|
1783 |
-
$this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
|
1784 |
-
elseif (count($foot_remove) > 0 && array_search($function_name, $foot_remove) !== FALSE)
|
1785 |
-
$this->options['priority'][$tag][$function_name] = -1;
|
1786 |
-
elseif (isset($this->options['priority'][$tag][$function_name]))
|
1787 |
-
$this->options['priority'][$tag][$function_name] = $priority;
|
1788 |
-
}
|
1789 |
-
unset($foot_filters);
|
1790 |
-
|
1791 |
-
// options update
|
1792 |
-
$this->updateOptions();
|
1793 |
-
|
1794 |
-
// create .htaccess file
|
1795 |
-
$cache_dir = $this->_create_cache_dir();
|
1796 |
-
if ( $cache_dir !== FALSE )
|
1797 |
-
$this->_create_htaccess($cache_dir);
|
1798 |
-
|
1799 |
-
// Done!
|
1800 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1801 |
|
1802 |
} elseif(isset($_POST['remove_cache'])) {
|
@@ -1805,8 +1792,6 @@ class HeadCleaner extends wokController {
|
|
1805 |
|
1806 |
// Remove all cache files
|
1807 |
$this->_remove_cache_file();
|
1808 |
-
|
1809 |
-
// Done!
|
1810 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1811 |
|
1812 |
} elseif(isset($_POST['options_delete'])) {
|
@@ -1815,8 +1800,6 @@ class HeadCleaner extends wokController {
|
|
1815 |
|
1816 |
// options delete
|
1817 |
$this->_delete_settings();
|
1818 |
-
|
1819 |
-
// Done!
|
1820 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1821 |
$this->error++;
|
1822 |
|
@@ -1830,7 +1813,8 @@ class HeadCleaner extends wokController {
|
|
1830 |
$out .= "<div class=\"wrap\">\n";
|
1831 |
$out .= "<form method=\"post\" id=\"update_options\" action=\"".$this->admin_action."\">\n";
|
1832 |
$out .= "<h2>".__('Head Cleaner Options', $this->textdomain_name)."</h2><br />\n";
|
1833 |
-
if ($this->wp25)
|
|
|
1834 |
|
1835 |
$out .= "<table class=\"optiontable form-table\" style=\"margin-top:0;\"><tbody>\n";
|
1836 |
|
@@ -2101,6 +2085,93 @@ class HeadCleaner extends wokController {
|
|
2101 |
|
2102 |
}
|
2103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2104 |
//**************************************************************************************
|
2105 |
// Delete Settings
|
2106 |
//**************************************************************************************
|
@@ -2204,10 +2275,45 @@ class HeadCleaner extends wokController {
|
|
2204 |
unset($active_filters);
|
2205 |
}
|
2206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2207 |
//**************************************************************************************
|
2208 |
// raw shortcode
|
2209 |
//**************************************************************************************
|
2210 |
-
function raw_formatter($content) {
|
2211 |
$new_content = '';
|
2212 |
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
|
2213 |
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Head Cleaner
|
4 |
+
Version: 1.3.13
|
5 |
Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
|
6 |
Description: Cleaning tags from your WordPress header and footer.
|
7 |
Author: wokamoto
|
155 |
//**************************************************************************************
|
156 |
class HeadCleaner extends wokController {
|
157 |
public $plugin_name = 'head-cleaner';
|
158 |
+
public $plugin_ver = '1.3.13';
|
159 |
|
160 |
// Deafault Options
|
161 |
private $options_default = array(
|
195 |
);
|
196 |
|
197 |
private $wp_url = '';
|
198 |
+
private $root_url = '';
|
199 |
private $self_url = '';
|
200 |
private $cache_path = '';
|
201 |
private $cache_url = '';
|
239 |
$this->filters = $this->options['filters'];
|
240 |
$this->head_js = $this->options['head_js'];
|
241 |
|
242 |
+
$this->wp_url = trailingslashit($this->_get_site_url());
|
243 |
+
$this->root_url = preg_replace('/^(https?:\/\/[^\/]*\/).*$/i', '$1', $this->wp_url);
|
244 |
$this->self_url = str_replace(ABSPATH, $this->wp_url, __FILE__);
|
245 |
$this->lang = (defined('WPLANG') ? WPLANG : 'ja');
|
246 |
$this->charset = get_option('blog_charset');
|
486 |
|
487 |
$url = $this->_get_permalink();
|
488 |
|
489 |
+
if (preg_match('/<!DOCTYPE [^>]* XHTML [^>]*>/i', $buffer)) {
|
490 |
+
// xhtml
|
491 |
+
$doctype = 'xhtml';
|
492 |
+
$xml_head = "<?xml version=\"1.0\" encoding=\"{$this->charset}\"?>\n";
|
493 |
+
$html_tag = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"{$this->lang}\" lang=\"{$this->lang}\">\n";
|
494 |
+
$head_tag = '<head profile="http://gmpg.org/xfn/11">'."\n";
|
495 |
+
} else {
|
496 |
+
// html
|
497 |
+
$doctype = 'html';
|
498 |
+
$xml_head = '';
|
499 |
+
$html_tag = "<html dir=\"ltr\" lang=\"{$this->lang}\">\n";
|
500 |
+
$head_tag = '<head>'."\n";
|
501 |
+
}
|
502 |
$head_txt = trim($buffer);
|
503 |
|
504 |
$ret_val = '';
|
508 |
$script_tag = ''; $inline_js = '';
|
509 |
|
510 |
// for IE conditional tag
|
511 |
+
list($head_txt, $IE_conditional_tags, $ie6) = $this->_parse_IE_conditional_tags($head_txt);
|
512 |
+
|
513 |
+
// Get Simple DOM Object
|
514 |
+
if (preg_match('/^(.*)(<html[^>]*>[^<]*)(<head[^>]*>[^<]*)(.*)$/ism', $head_txt, $matches)) {
|
515 |
+
$ret_val = trim($matches[1]) . "\n";
|
516 |
+
$html_tag = trim($matches[2]) . "\n";
|
517 |
+
$head_tag = trim($matches[3]) . "\n";
|
518 |
+
$head_txt = trim($matches[4]) . "\n";
|
519 |
+
}
|
520 |
+
unset($matches);
|
521 |
+
$html_txt = $xml_head . $html_tag . $head_tag
|
522 |
+
. $head_txt
|
523 |
+
. '</head><body></body></html>';
|
524 |
+
|
525 |
+
$dom = str_get_html($html_txt);
|
526 |
+
if ($dom === false)
|
527 |
+
return (trim($buffer)."\n");
|
528 |
+
|
529 |
+
// Parse Start!
|
530 |
+
if ( $doctype === 'xhtml' ) {
|
531 |
+
// xhtml
|
532 |
+
$xmlns = (defined('HC_XMLNS') ? HC_XMLNS : 'http://www.w3.org/1999/xhtml');
|
533 |
+
$xml_lang = $this->lang;
|
534 |
+
$lang = $this->lang;
|
535 |
+
if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $matches, PREG_SET_ORDER)) {
|
536 |
+
foreach ((array) $matches as $match) {
|
537 |
+
switch ($match[1]){
|
538 |
+
case 'xmlns': $xmlns = $match[2]; break;
|
539 |
+
case 'xml:lang': $xml_lang = $match[2]; break;
|
540 |
+
case 'lang': $lang = $match[2]; break;
|
541 |
+
}
|
542 |
+
}
|
543 |
+
unset($match);
|
544 |
+
}
|
545 |
+
unset($matches);
|
546 |
+
$html_tag = "<html xmlns=\"{$xmlns}\" xml:lang=\"{$xml_lang}\" lang=\"{$lang}\">\n";
|
547 |
+
} else {
|
548 |
+
// html
|
549 |
+
$dir = 'ltr';
|
550 |
+
$lang = $this->lang;
|
551 |
+
if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $matches, PREG_SET_ORDER)) {
|
552 |
+
foreach ((array) $matches as $match) {
|
553 |
+
switch ($match[1]){
|
554 |
+
case 'dir': $dir = $match[2]; break;
|
555 |
+
case 'lang': $lang = $match[2]; break;
|
556 |
+
}
|
557 |
+
}
|
558 |
+
unset($match);
|
559 |
+
}
|
560 |
+
unset($matches);
|
561 |
+
$html_tag = "<html dir=\"{$dir}\" lang=\"{$lang}\">\n";
|
562 |
+
}
|
563 |
+
|
564 |
+
$meta_tag = $this->_dom_to_html($dom->find("meta"));
|
565 |
+
$title_tag = $this->_dom_to_html($dom->find("title"), 1);
|
566 |
+
$base_tag = $this->_dom_to_html($dom->find("base"), 1);
|
567 |
+
$link_tag = $this->_dom_to_html($dom->find("link[rel!='stylesheet']"));
|
568 |
+
if (count($dom->find("link[rel='canonical']")) <= 0 && $this->options['canonical_tag'])
|
569 |
+
$link_tag .= '<link rel="canonical" href="' . htmlspecialchars($url, ENT_QUOTES) . '" />'."\n";
|
570 |
+
$object_tag = $this->_dom_to_html($dom->find("object"));
|
571 |
+
list($css_tag, $css_tag_with_id, $inner_css, $css_src, $inline_css) = $this->_parse_stylesheet_tag($dom->find("link[rel='stylesheet']"),$dom->find("style"));
|
572 |
+
list($script_tag, $inner_js, $inline_js, $foot_js) = $this->_parse_script_tag($dom->find("script"));
|
573 |
+
|
574 |
+
$dom->clear(); unset($dom);
|
575 |
+
|
576 |
+
// for IE conditional tag
|
577 |
+
if (!$this->options['ie_conditional'] && count($IE_conditional_tags) > 0) {
|
578 |
+
$IE_conditional_tag_pattern = '/(<\!-+[ \t]*\[if[ \t]+.*IE.*[ \t]*?\][ \t]*>)[ \t\r\n]*(.*?)[ \t\r\n]*(<\![ \t]*\[endif\][ \t]*-+>)/ims';
|
579 |
+
foreach ((array) $IE_conditional_tags as $IE_conditional_tag) {
|
580 |
+
if (isset($IE_conditional_tag[0])) {
|
581 |
+
$IE_tag = trim(preg_replace($IE_conditional_tag_pattern, "$1$2$3", $IE_conditional_tag[0]));
|
582 |
+
if ( strpos(strtolower($IE_tag), '<link') !== false )
|
583 |
+
$css_tag = trim($css_tag) . "\n" . $IE_tag . "\n";
|
584 |
+
elseif ( strpos(strtolower($IE_tag), '<style') !== false )
|
585 |
+
$inline_css = trim($inline_css) . "\n" . $IE_tag . "\n";
|
586 |
+
elseif ( strpos(strtolower($IE_tag), '<script') !== false )
|
587 |
+
$inline_js = trim($inline_js) . "\n" . $IE_tag . "\n";
|
588 |
+
elseif ( !empty($IE_tag) )
|
589 |
+
$object_tag = trim($object_tag) . "\n" . $IE_tag . "\n";
|
590 |
+
}
|
591 |
+
}
|
592 |
+
}
|
593 |
+
unset($IE_conditional_tag);
|
594 |
+
|
595 |
+
// Build!
|
596 |
+
$ret_val .=
|
597 |
+
$html_tag
|
598 |
+
. $head_tag
|
599 |
+
. $meta_tag
|
600 |
+
. $title_tag
|
601 |
+
. $base_tag
|
602 |
+
. $link_tag
|
603 |
+
. $css_tag
|
604 |
+
. $inline_css
|
605 |
+
. (!$this->options['js_move_foot'] ? $script_tag : '')
|
606 |
+
. (!$this->options['js_move_foot'] ? $inline_js : '')
|
607 |
+
. $object_tag
|
608 |
+
;
|
609 |
+
//$ret_val = str_replace('\'', '"', $ret_val);
|
610 |
+
$ret_val = preg_replace(
|
611 |
+
array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
|
612 |
+
array( ' $1="$2"', "\n", "$1\n$2" ),
|
613 |
+
$ret_val
|
614 |
+
);
|
615 |
+
|
616 |
+
if ($this->options['js_move_foot'] || !empty($foot_js))
|
617 |
+
$this->foot_js_src = trim(
|
618 |
+
$foot_js
|
619 |
+
. ($this->options['js_move_foot'] ? $script_tag : '')
|
620 |
+
. ($this->options['js_move_foot'] ? $inline_js : '')
|
621 |
+
);
|
622 |
+
if (!empty($this->foot_js_src)) {
|
623 |
+
$this->foot_js_src .= "\n";
|
624 |
+
add_action('wp_footer', array(&$this, 'footer'), 9);
|
625 |
+
}
|
626 |
+
|
627 |
+
if ($this->options['dynamic']) {
|
628 |
+
$ret_val = preg_replace(
|
629 |
+
'/' . preg_quote($this->cache_url, '/') . '(js|css)\/([^\.]*)\.(js|css)/i' ,
|
630 |
+
$this->self_url . "?f=$2&t=$3" ,
|
631 |
+
$ret_val
|
632 |
+
);
|
633 |
+
}
|
634 |
+
|
635 |
+
$ret_val = ($ie6 || !$this->options['xml_declaration']
|
636 |
+
? preg_replace('/^<\?xml[^>]*>/i', '', $ret_val)
|
637 |
+
: (strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
|
638 |
+
);
|
639 |
+
// $ret_val = str_replace($this->root_url, '/', $ret_val);
|
640 |
+
$ret_val = trim($ret_val) . "\n";
|
641 |
+
|
642 |
+
if ($this->options['debug_mode'])
|
643 |
+
$ret_val .= $this->_get_debug_info($buffer);
|
644 |
+
|
645 |
+
return $ret_val;
|
646 |
+
}
|
647 |
+
|
648 |
+
//**************************************************************************************
|
649 |
+
// Parse IE conditional tags
|
650 |
+
//**************************************************************************************
|
651 |
+
private function _parse_IE_conditional_tags($head_txt){
|
652 |
+
// Check USER AGENT
|
653 |
+
$ua = trim(strtolower($_SERVER['HTTP_USER_AGENT']));
|
654 |
+
$ie = (strpos($ua, 'msie') !== false)
|
655 |
+
&& (! preg_match('/(gecko|applewebkit|opera|sleipnir|chrome)/i', $ua));
|
656 |
+
$ie_ver = ($ie ? preg_replace('/^.*msie +([\d+\.]+);.*$/i', '$1', $ua) : false);
|
657 |
+
$ie6 = ($ie ? version_compare($ie_ver, '7.0', '<') : false);
|
658 |
+
|
659 |
$IE_conditional_tags = array();
|
|
|
660 |
if ($this->options['ie_conditional']) {
|
|
|
|
|
|
|
|
|
|
|
661 |
if ($ie) {
|
662 |
+
$IE_conditional_tag_pattern = '/<\!-+[ \t]*\[if[ \t]+IE[ \t]*?\][ \t]*>(.*?)<\![ \t]*\[endif\][ \t]*-+>/ims';
|
663 |
$head_txt = preg_replace($IE_conditional_tag_pattern, '$1', $head_txt);
|
664 |
|
665 |
$replace_patterns = array();
|
696 |
unset($replace_patterns);
|
697 |
}
|
698 |
} else {
|
699 |
+
$IE_conditional_tag_pattern = '/<\!-+[ \t]*\[if[ \t]+([lg]te[ \t]*)?IE([ \t]+[056789\.]*)?[ \t]*?\][ \t]*>(.*?)<\![ \t]*\[endif\][ \t]*-+>/ims';
|
700 |
preg_match_all($IE_conditional_tag_pattern, $head_txt, $IE_conditional_tags, PREG_SET_ORDER);
|
701 |
$head_txt = preg_replace($IE_conditional_tag_pattern, '', $head_txt);
|
702 |
}
|
703 |
|
704 |
+
return array($head_txt, $IE_conditional_tags, $ie6);
|
705 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
706 |
|
707 |
+
//**************************************************************************************
|
708 |
+
// parse stylesheet tag
|
709 |
+
//**************************************************************************************
|
710 |
+
private function _parse_stylesheet_tag($elements_linktag, $elements_styletag){
|
711 |
+
$css_tag = '';
|
712 |
+
$css_tag_with_id = '';
|
713 |
+
$inner_css = '';
|
714 |
+
$css_src = array();
|
715 |
+
$wk_inline_css = array();
|
716 |
+
$inline_css = '';
|
717 |
|
718 |
+
// css file
|
719 |
+
foreach ((array) $elements_linktag as $element) {
|
|
|
720 |
$tag = trim($element->outertext);
|
721 |
if (strpos($css_tag, $tag) === FALSE) {
|
722 |
if (strpos($element->href, $this->wp_url) === FALSE) {
|
731 |
}
|
732 |
}
|
733 |
}
|
734 |
+
unset($element);
|
735 |
|
736 |
+
// inline css
|
737 |
+
foreach ((array) $elements_styletag as $element) {
|
|
|
738 |
$media = trim( isset($element->media) ? $element->media : $this->options['default_media'] );
|
739 |
$media = ( empty($media) || is_null($media) || $media === FALSE ? $this->options['default_media'] : $media );
|
740 |
$wk_text = $this->_remove_comment($element->innertext, 'css');
|
759 |
$wk_inline_css[$media] .= trim($wk_text) . "\n";
|
760 |
}
|
761 |
}
|
|
|
762 |
if ($this->options['cache_enabled']) {
|
763 |
if ($this->options['combined_css']) {
|
764 |
$css_tag = trim($css_tag) . "\n";
|
796 |
}
|
797 |
}
|
798 |
}
|
799 |
+
unset($wk_inline_css);
|
800 |
+
unset($element);
|
801 |
+
|
802 |
$css_tag = trim($css_tag) . (!empty($css_tag) ? "\n" : '');
|
803 |
$inner_css = trim($inner_css) . (!empty($inner_css) ? "\n" : '');
|
804 |
$inline_css = trim($inline_css) . (!empty($inline_css) ? "\n" : '');
|
|
|
|
|
805 |
|
806 |
+
return array($css_tag, $css_tag_with_id, $inner_css, $css_src, $inline_css);
|
807 |
+
}
|
808 |
+
|
809 |
+
//**************************************************************************************
|
810 |
+
// parse scrip tag
|
811 |
+
//**************************************************************************************
|
812 |
+
private function _parse_script_tag($elements){
|
813 |
+
$script_tag = '';
|
814 |
$inner_js = '';
|
815 |
$foot_js = '';
|
816 |
$js_src = array();
|
817 |
$js_libs = array();
|
818 |
+
|
819 |
foreach ((array) $elements as $element) {
|
820 |
if (!isset($element->src)) {
|
821 |
$inline_js .= $this->_remove_comment($element->innertext, 'js');
|
856 |
}
|
857 |
}
|
858 |
}
|
859 |
+
unset($element);
|
860 |
|
861 |
// JavaScript FrameWork (Prototype.js > jQuery > mootools)
|
862 |
if (count($js_libs) > 0) {
|
868 |
$script_tag = trim($script_tag) . "\n" . $wk_outer_js;
|
869 |
$inner_js = $wk_inner_js . $inner_js;
|
870 |
|
871 |
+
unset($js_libs_src);
|
872 |
+
unset($js_libs);
|
873 |
}
|
874 |
|
875 |
$inline_js = trim($inline_js);
|
886 |
$script_tag = trim(trim($script_tag) . "\n" . $inner_js) . "\n";
|
887 |
$inline_js = (!empty($inline_js) ? "<script type=\"text/javascript\">//<![CDATA[\n{$inline_js}\n//]]></script>\n" : '');
|
888 |
}
|
889 |
+
|
890 |
$script_tag = trim($script_tag) . (!empty($script_tag) ? "\n" : '');
|
891 |
$inner_js = trim($inner_js) . (!empty($inner_js) ? "\n" : '');
|
892 |
$inline_js = trim($inline_js) . (!empty($inline_js) ? "\n" : '');
|
893 |
$foot_js = trim($foot_js) . (!empty($foot_js) ? "\n" : '');
|
894 |
|
895 |
+
return array($script_tag, $inner_js, $inline_js, $foot_js);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
896 |
}
|
897 |
|
898 |
//**************************************************************************************
|
983 |
);
|
984 |
}
|
985 |
|
986 |
+
// $ret_val = str_replace($this->root_url, '/', $ret_val);
|
987 |
+
$ret_val = preg_replace(
|
988 |
array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
|
989 |
array( ' $1="$2"', "\n", "$1\n$2" ),
|
990 |
$ret_val
|
991 |
+
);
|
992 |
+
$ret_val = trim($ret_val) . "\n";
|
993 |
|
994 |
if ($this->options['debug_mode'])
|
995 |
$ret_val .= $this->_get_debug_info($buffer);
|
1782 |
if ($this->wp25)
|
1783 |
check_admin_referer("update_options", "_wpnonce_update_options");
|
1784 |
|
1785 |
+
// Update options
|
1786 |
+
$this->_options_update($_POST);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1787 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1788 |
|
1789 |
} elseif(isset($_POST['remove_cache'])) {
|
1792 |
|
1793 |
// Remove all cache files
|
1794 |
$this->_remove_cache_file();
|
|
|
|
|
1795 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1796 |
|
1797 |
} elseif(isset($_POST['options_delete'])) {
|
1800 |
|
1801 |
// options delete
|
1802 |
$this->_delete_settings();
|
|
|
|
|
1803 |
$this->note .= "<strong>".__('Done!', $this->textdomain_name)."</strong>";
|
1804 |
$this->error++;
|
1805 |
|
1813 |
$out .= "<div class=\"wrap\">\n";
|
1814 |
$out .= "<form method=\"post\" id=\"update_options\" action=\"".$this->admin_action."\">\n";
|
1815 |
$out .= "<h2>".__('Head Cleaner Options', $this->textdomain_name)."</h2><br />\n";
|
1816 |
+
if ($this->wp25)
|
1817 |
+
$out .= $this->makeNonceField("update_options", "_wpnonce_update_options", true, false);
|
1818 |
|
1819 |
$out .= "<table class=\"optiontable form-table\" style=\"margin-top:0;\"><tbody>\n";
|
1820 |
|
2085 |
|
2086 |
}
|
2087 |
|
2088 |
+
//**************************************************************************************
|
2089 |
+
// options update
|
2090 |
+
//**************************************************************************************
|
2091 |
+
private function _options_update($recv_param) {
|
2092 |
+
// strip slashes array
|
2093 |
+
$head_js = $this->stripArray(isset($recv_param['head_js']) ? $recv_param['head_js'] : array());
|
2094 |
+
$remove_js = $this->stripArray(isset($recv_param['remove_js']) ? $recv_param['remove_js'] : array());
|
2095 |
+
$head_filters = $this->stripArray(isset($recv_param['head_filters']) ? $recv_param['head_filters'] : array());
|
2096 |
+
$head_remove = $this->stripArray(isset($recv_param['head_remove']) ? $recv_param['head_remove'] : array());
|
2097 |
+
$foot_filters = $this->stripArray(isset($recv_param['foot_filters']) ? $recv_param['foot_filters'] : array());
|
2098 |
+
$foot_remove = $this->stripArray(isset($recv_param['foot_remove']) ? $recv_param['foot_remove'] : array());
|
2099 |
+
$recv_param = $this->stripArray($recv_param);
|
2100 |
+
|
2101 |
+
// get options
|
2102 |
+
$this->options['xml_declaration'] = (isset($recv_param['xml_declaration']) && $recv_param['xml_declaration'] == 'on' ? true : false);
|
2103 |
+
$this->options['ie_conditional']= (isset($recv_param['ie_conditional']) && $recv_param['ie_conditional'] == 'on' ? true : false);
|
2104 |
+
$this->options['canonical_tag'] = (isset($recv_param['canonical_tag']) && $recv_param['canonical_tag'] == 'on' ? true : false);
|
2105 |
+
$this->options['foot_js'] = (isset($recv_param['foot_js']) && $recv_param['foot_js'] == 'on' ? true : false);
|
2106 |
+
$this->options['dynamic'] = (isset($recv_param['dynamic']) && $recv_param['dynamic'] == 'on' ? true : false);
|
2107 |
+
$this->options['js_move_foot'] = (isset($recv_param['js_move_foot']) && $recv_param['js_move_foot'] == 'on' ? true : false);
|
2108 |
+
$this->options['cache_enabled'] = (isset($recv_param['cache_enabled']) && $recv_param['cache_enabled'] == 'on' ? true : false);
|
2109 |
+
$this->options['combined_css'] = (isset($recv_param['combined_css']) && $recv_param['combined_css'] == 'on' ? true : false);
|
2110 |
+
$this->options['combined_js'] = (isset($recv_param['combined_js']) && $recv_param['combined_js'] == 'on' ? true : false);
|
2111 |
+
$this->options['js_minify'] = (isset($recv_param['js_minify']) && $recv_param['js_minify'] == 'on' ? true : false);
|
2112 |
+
$this->options['css_optimise'] = (isset($recv_param['css_optimise']) && $recv_param['css_optimise'] == 'on' ? true : false);
|
2113 |
+
$this->options['default_media'] = trim($recv_param['default_media']);
|
2114 |
+
$this->options['gzip_on'] = (isset($recv_param['gzip_on']) && $recv_param['gzip_on'] == 'on' ? true : false);
|
2115 |
+
$this->options['use_ajax_libs'] = (isset($recv_param['use_ajax_libs']) && $recv_param['use_ajax_libs'] == 'on' ? true : false);
|
2116 |
+
$this->options['debug_mode'] = (isset($recv_param['debug_mode']) && $recv_param['debug_mode'] == 'on' ? true : false);
|
2117 |
+
$this->options['csstidy_option']['template'] = (int) $recv_param['template'];
|
2118 |
+
$this->options['csstidy_option']['optimise_shorthands'] = (int) $recv_param['optimise_shorthands'];
|
2119 |
+
$this->options['csstidy_option']['compress_colors'] = (isset($recv_param['compress_colors']) && $recv_param['compress_colors'] == 'on' ? true : false);
|
2120 |
+
$this->options['csstidy_option']['compress_font_weight'] = (isset($recv_param['compress_font_weight']) && $recv_param['compress_font_weight'] == 'on' ? true : false);
|
2121 |
+
$this->options['csstidy_option']['remove_bslash'] = (isset($recv_param['remove_bslash']) && $recv_param['remove_bslash'] == 'on' ? true : false);
|
2122 |
+
|
2123 |
+
$rm_generator = (isset($recv_param['rm_generator']) && $recv_param['rm_generator'] == 'on' ? true : false);
|
2124 |
+
$rm_rsd_link = (isset($recv_param['rm_rsd_link']) && $recv_param['rm_rsd_link'] == 'on' ? true : false);
|
2125 |
+
$rm_manifest = (isset($recv_param['rm_manifest']) && $recv_param['rm_manifest'] == 'on' ? true : false);
|
2126 |
+
|
2127 |
+
$this->options['remove_js'] = array();
|
2128 |
+
foreach ((array) $this->options['head_js'] as $javascript => $value) {
|
2129 |
+
if (count($head_js) > 0 && array_search($javascript, $head_js) !== FALSE)
|
2130 |
+
$this->options['head_js'][$javascript] = FALSE;
|
2131 |
+
else
|
2132 |
+
$this->options['head_js'][$javascript] = TRUE;
|
2133 |
+
if (array_search($javascript, (array) $remove_js) !== FALSE)
|
2134 |
+
$this->options['remove_js'][] = $javascript;
|
2135 |
+
}
|
2136 |
+
unset($head_js);
|
2137 |
+
unset($remove_js);
|
2138 |
+
|
2139 |
+
// wp_head
|
2140 |
+
$tag = 'wp_head';
|
2141 |
+
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2142 |
+
if (count($head_filters) > 0 && array_search($function_name, $head_filters) !== FALSE)
|
2143 |
+
$this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
|
2144 |
+
elseif (count($head_remove) > 0 && array_search($function_name, $head_remove) !== FALSE)
|
2145 |
+
$this->options['priority'][$tag][$function_name] = -1;
|
2146 |
+
elseif (isset($this->options['priority'][$tag][$function_name]))
|
2147 |
+
$this->options['priority'][$tag][$function_name] = $priority;
|
2148 |
+
}
|
2149 |
+
$this->options['priority'][$tag]['wp_generator'] = ($rm_generator ? -1 : $this->options['filters'][$tag]['wp_generator']);
|
2150 |
+
$this->options['priority'][$tag]['rsd_link'] = ($rm_rsd_link ? -1 : $this->options['filters'][$tag]['rsd_link']);
|
2151 |
+
$this->options['priority'][$tag]['wlwmanifest_link'] = ($rm_manifest ? -1 : $this->options['filters'][$tag]['wlwmanifest_link']);
|
2152 |
+
unset($head_filters);
|
2153 |
+
|
2154 |
+
// wp_footer
|
2155 |
+
$tag = 'wp_footer';
|
2156 |
+
foreach ((array) $this->options['filters'][$tag] as $function_name => $priority) {
|
2157 |
+
if (count($foot_filters) > 0 && array_search($function_name, $foot_filters) !== FALSE)
|
2158 |
+
$this->options['priority'][$tag][$function_name] = HC_PRIORITY + 1;
|
2159 |
+
elseif (count($foot_remove) > 0 && array_search($function_name, $foot_remove) !== FALSE)
|
2160 |
+
$this->options['priority'][$tag][$function_name] = -1;
|
2161 |
+
elseif (isset($this->options['priority'][$tag][$function_name]))
|
2162 |
+
$this->options['priority'][$tag][$function_name] = $priority;
|
2163 |
+
}
|
2164 |
+
unset($foot_filters);
|
2165 |
+
|
2166 |
+
// options update
|
2167 |
+
$this->updateOptions();
|
2168 |
+
|
2169 |
+
// create .htaccess file
|
2170 |
+
$cache_dir = $this->_create_cache_dir();
|
2171 |
+
if ( $cache_dir !== FALSE )
|
2172 |
+
$this->_create_htaccess($cache_dir);
|
2173 |
+
}
|
2174 |
+
|
2175 |
//**************************************************************************************
|
2176 |
// Delete Settings
|
2177 |
//**************************************************************************************
|
2275 |
unset($active_filters);
|
2276 |
}
|
2277 |
|
2278 |
+
//**************************************************************************************
|
2279 |
+
// get site url
|
2280 |
+
//**************************************************************************************
|
2281 |
+
private function _get_site_url( $blog_id = null, $path = '', $scheme = null ) {
|
2282 |
+
if (function_exists('get_site_url'))
|
2283 |
+
return get_site_url($blog_id, $path, $scheme);
|
2284 |
+
|
2285 |
+
// should the list of allowed schemes be maintained elsewhere?
|
2286 |
+
$orig_scheme = $scheme;
|
2287 |
+
if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
|
2288 |
+
$force_ssl_login = function_exists('force_ssl_login') && force_ssl_login();
|
2289 |
+
$force_ssl_admin = function_exists('force_ssl_admin') && force_ssl_admin();
|
2290 |
+
if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( $force_ssl_login || $force_ssl_admin ) )
|
2291 |
+
$scheme = 'https';
|
2292 |
+
elseif ( ( 'login' == $scheme ) && $force_ssl_admin )
|
2293 |
+
$scheme = 'https';
|
2294 |
+
elseif ( ( 'admin' == $scheme ) && $force_ssl_admin )
|
2295 |
+
$scheme = 'https';
|
2296 |
+
else
|
2297 |
+
$scheme = ( function_exists('is_ssl') && is_ssl() ? 'https' : 'http' );
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
if ( empty( $blog_id ) || !( function_exists('is_multisite') && is_multisite() ) )
|
2301 |
+
$url = get_option( 'siteurl' );
|
2302 |
+
else
|
2303 |
+
$url = ( !function_exists('get_blog_option') ? get_option( 'siteurl' ) : get_blog_option( $blog_id, 'siteurl' ));
|
2304 |
+
|
2305 |
+
$url = str_replace( 'http://', "{$scheme}://", $url );
|
2306 |
+
|
2307 |
+
if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
|
2308 |
+
$url .= '/' . ltrim( $path, '/' );
|
2309 |
+
|
2310 |
+
return apply_filters( 'site_url', $url, $path, $orig_scheme, $blog_id );
|
2311 |
+
}
|
2312 |
+
|
2313 |
//**************************************************************************************
|
2314 |
// raw shortcode
|
2315 |
//**************************************************************************************
|
2316 |
+
public function raw_formatter($content) {
|
2317 |
$new_content = '';
|
2318 |
$pattern_full = '{(\[raw\].*?\[/raw\])}is';
|
2319 |
$pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
|
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.1
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Cleaning tags from your WordPress header and footer.
|
10 |
|
@@ -26,8 +26,7 @@ To speed up the loading of JavaScript and CSS.
|
|
26 |
* CSS, JavaScript, if your browser supports gzip compression transfer.
|
27 |
* Have multiple CSS files into the media and a binding for each attribute.
|
28 |
Of course, the file contains inline CSS.
|
29 |
-
* CSS
|
30 |
-
* The administrator can specify CSSTidy optimization.
|
31 |
* Have multiple JavaScript files into a binding and all.
|
32 |
Of course, the file also includes an inline JavaScript.
|
33 |
* JavaScript source code minified at [JSMin](http://code.google.com/p/jsmin-php/ "JSMin").
|
@@ -89,6 +88,9 @@ Head Cleaner Ver.1.1.5 includes 'php_browscap.ini' .
|
|
89 |
|
90 |
== Changelog ==
|
91 |
|
|
|
|
|
|
|
92 |
**1.3.12 - August 11, 2010**
|
93 |
Fixed a bug, IE Conditional tags.
|
94 |
|
4 |
Tags: head, header, footer, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 1.3.13
|
8 |
|
9 |
Cleaning tags from your WordPress header and footer.
|
10 |
|
26 |
* CSS, JavaScript, if your browser supports gzip compression transfer.
|
27 |
* Have multiple CSS files into the media and a binding for each attribute.
|
28 |
Of course, the file contains inline CSS.
|
29 |
+
* CSS minified.
|
|
|
30 |
* Have multiple JavaScript files into a binding and all.
|
31 |
Of course, the file also includes an inline JavaScript.
|
32 |
* JavaScript source code minified at [JSMin](http://code.google.com/p/jsmin-php/ "JSMin").
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
**1.3.13 - August 20, 2010**
|
92 |
+
Twenty Ten Themes support.
|
93 |
+
|
94 |
**1.3.12 - August 11, 2010**
|
95 |
Fixed a bug, IE Conditional tags.
|
96 |
|
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.1
|
7 |
-
Stable tag: 1.3.
|
8 |
|
9 |
Head �� footer �����|�����܂��B
|
10 |
|
4 |
Tags: head optimization, javascript, css, optimization, minified, performance
|
5 |
Requires at least: 2.5
|
6 |
Tested up to: 3.0.1
|
7 |
+
Stable tag: 1.3.13
|
8 |
|
9 |
Head �� footer �����|�����܂��B
|
10 |
|