Head Cleaner - Version 1.3.3

Version Description

Download this release

Release Info

Developer wokamoto
Plugin Icon wp plugin Head Cleaner
Version 1.3.3
Comparing to
See all releases

Code changes from version 1.3.2 to 1.3.3

Files changed (3) hide show
  1. head-cleaner.php +63 -39
  2. readme.txt +43 -1
  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.2
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
@@ -109,7 +109,7 @@ if (!class_exists('wokController') || !class_exists('wokScriptManager'))
109
  //**************************************************************************************
110
  class HeadCleanerController extends wokController {
111
  public $plugin_name = 'head-cleaner';
112
- public $plugin_ver = '1.3.2';
113
 
114
  // Deafault Options
115
  private $options_default = array(
@@ -133,6 +133,7 @@ class HeadCleanerController extends wokController {
133
  'filters' => array('wp_head' => array(), 'wp_footer' => array()) ,
134
  'priority' => array('wp_head' => array(), 'wp_footer' => array()) ,
135
  'head_js' => array() ,
 
136
  'analyze_expired'=> 0 ,
137
  'xml_declaration'=> false ,
138
  'ie_conditional' => false ,
@@ -302,9 +303,14 @@ class HeadCleanerController extends wokController {
302
  if (! $this->_is_ktai() ) {
303
  ob_start(array(&$this, 'head_cleaner'));
304
  $this->mtime_start = microtime();
 
 
 
 
305
  add_action('wp_head', array(&$this, 'end'), HC_PRIORITY);
306
  $this->_get_filters('wp_head');
307
  $this->_change_filters_priority('wp_head');
 
308
  if ($this->options['foot_js'])
309
  add_action('wp_footer', array(&$this, 'footer_start'), 1);
310
  }
@@ -520,9 +526,10 @@ class HeadCleanerController extends wokController {
520
  foreach ($wk_inline_css as $key => $val) {
521
  $val = trim($val);
522
  if (!empty($val)) {
523
- $inline_css .= "<style type=\"text/css\" media=\"{$media}\">/*<![CDATA[ */\n"
524
- . $val
525
- . "\n/* ]]>*/</style>\n";
 
526
  }
527
  }
528
  }
@@ -545,33 +552,35 @@ class HeadCleanerController extends wokController {
545
  if (!isset($this->head_js[$src]))
546
  $this->head_js[$src] = true;
547
 
548
- $find = FALSE;
549
- if (preg_match('/\/((prototype|jquery|mootools)\.js)\?ver=([\.\d]+)[^\?]*$/i', $src, $matches)) {
550
- list($find, $filename, $product, $version) = $matches;
551
- } elseif (preg_match('/\/((prototype|jquery|mootools)[\-\.](min|[\.\d]+)[^\/]*\.js)\?[^\?]*$/i', $src, $matches)) {
552
- list($find, $filename, $product, $version) = $matches;
553
- } elseif (preg_match('/\/scriptaculous\/((builder|controls|dragdrop|effects|wp\-scriptaculous|scriptaculous|slider|sound|unittest)\.js)\?ver\=([\.\d]+)[^\?]*$/i', $src, $matches)) {
554
- list($find, $filename, $product, $version) = $matches;
555
- $product = (strpos($product, 'scriptaculous') === FALSE
556
- ? 'scriptaculous/' . $product
557
- : 'scriptaculous/scriptaculous');
558
- }
559
- unset($matches);
560
-
561
- if ($find !== FALSE) {
562
- $version = trim(substr($version, -1) === '.' ? substr($version, 0, -1) : $version);
563
- if (empty($version))
564
- $version = preg_replace('/^.*\/([\.\d]+)\/.*$/', '$1', $src);
565
- if (!preg_match('/^[\.\d]*\d$/', $version))
566
- $version = '1';
567
- $js_libs[$product][$version] = $src;
568
- } elseif ($this->head_js[$src] === FALSE) {
569
- $foot_js .= trim($element->outertext) . "\n";
570
- } elseif (strpos($src, $this->wp_url) === FALSE) {
571
- $script_tag .= trim($element->outertext) . "\n";
572
- } else {
573
- $inner_js .= trim($element->outertext) . "\n";
574
- $js_src[] = $element->src;
 
 
575
  }
576
  }
577
  }
@@ -710,11 +719,14 @@ class HeadCleanerController extends wokController {
710
  if (!isset($element->src)) {
711
  $inline_js .= $this->_remove_comment($element->innertext, 'js');
712
  } else {
713
- if (strpos($element->src, $this->wp_url) === FALSE) {
714
- $script_tag .= trim($element->outertext) . "\n";
715
- } else {
716
- $inner_js .= trim($element->outertext) . "\n";
717
- $js_src[] = preg_replace('/\.gz$/i', '', $element->src);
 
 
 
718
  }
719
  }
720
  break;
@@ -749,8 +761,12 @@ class HeadCleanerController extends wokController {
749
  . $script_tag
750
  . $inline_js
751
  ;
752
- $ret_val = str_replace('\'', '"', $ret_val);
753
- $ret_val = trim($ret_val) . "\n";
 
 
 
 
754
 
755
  if ($this->options['debug_mode'])
756
  $ret_val .= $this->_get_debug_info($buffer);
@@ -1472,6 +1488,7 @@ class HeadCleanerController extends wokController {
1472
 
1473
  // strip slashes array
1474
  $head_js = $this->stripArray(isset($_POST['head_js']) ? $_POST['head_js'] : array());
 
1475
  $head_filters = $this->stripArray(isset($_POST['head_filters']) ? $_POST['head_filters'] : array());
1476
  $head_remove = $this->stripArray(isset($_POST['head_remove']) ? $_POST['head_remove'] : array());
1477
  $foot_filters = $this->stripArray(isset($_POST['foot_filters']) ? $_POST['foot_filters'] : array());
@@ -1504,13 +1521,17 @@ class HeadCleanerController extends wokController {
1504
  $rm_rsd_link = (isset($_POST['rm_rsd_link']) && $_POST['rm_rsd_link'] == 'on' ? true : false);
1505
  $rm_manifest = (isset($_POST['rm_manifest']) && $_POST['rm_manifest'] == 'on' ? true : false);
1506
 
 
1507
  foreach ((array) $this->options['head_js'] as $javascript => $value) {
1508
  if (count($head_js) > 0 && array_search($javascript, $head_js) !== FALSE)
1509
  $this->options['head_js'][$javascript] = FALSE;
1510
  else
1511
  $this->options['head_js'][$javascript] = TRUE;
 
 
1512
  }
1513
  unset($head_js);
 
1514
 
1515
  $tag = 'wp_head';
1516
 
@@ -1806,10 +1827,13 @@ class HeadCleanerController extends wokController {
1806
  $out .= "<table><tbody>\n";
1807
  $out .= "<tr>";
1808
  $out .= "<th>" . __('Move to footer', $this->textdomain_name) . "</th>\n";
 
1809
  $out .= "<th>" . __('JavaScripts', $this->textdomain_name) . "</th>\n";
1810
  foreach ($this->options['head_js'] as $javascript => $value) {
 
1811
  $out .= "<tr>";
1812
  $out .= "<th><input type=\"checkbox\" name=\"head_js[$i]\" value=\"$javascript\"".($value === FALSE ? " checked=\"true\"" : "")." /></th>";
 
1813
  $out .= "<td>$javascript</td>";
1814
  $i++;
1815
  }
1
  <?php
2
  /*
3
  Plugin Name: Head Cleaner
4
+ Version: 1.3.3
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
109
  //**************************************************************************************
110
  class HeadCleanerController extends wokController {
111
  public $plugin_name = 'head-cleaner';
112
+ public $plugin_ver = '1.3.3';
113
 
114
  // Deafault Options
115
  private $options_default = array(
133
  'filters' => array('wp_head' => array(), 'wp_footer' => array()) ,
134
  'priority' => array('wp_head' => array(), 'wp_footer' => array()) ,
135
  'head_js' => array() ,
136
+ 'remove_js' => array() ,
137
  'analyze_expired'=> 0 ,
138
  'xml_declaration'=> false ,
139
  'ie_conditional' => false ,
303
  if (! $this->_is_ktai() ) {
304
  ob_start(array(&$this, 'head_cleaner'));
305
  $this->mtime_start = microtime();
306
+
307
+ if ( function_exists('rel_canonical') && !$this->options['canonical_tag'] )
308
+ remove_action( 'wp_head', 'rel_canonical' );
309
+
310
  add_action('wp_head', array(&$this, 'end'), HC_PRIORITY);
311
  $this->_get_filters('wp_head');
312
  $this->_change_filters_priority('wp_head');
313
+
314
  if ($this->options['foot_js'])
315
  add_action('wp_footer', array(&$this, 'footer_start'), 1);
316
  }
526
  foreach ($wk_inline_css as $key => $val) {
527
  $val = trim($val);
528
  if (!empty($val)) {
529
+ $inline_css .=
530
+ '<style type="text/css"' . (!empty($media) ? " media=\"{$media}\"" : '') . ">/*<![CDATA[ */\n" .
531
+ $val .
532
+ "\n/* ]]>*/</style>\n";
533
  }
534
  }
535
  }
552
  if (!isset($this->head_js[$src]))
553
  $this->head_js[$src] = true;
554
 
555
+ if (array_search( $src, (array) $this->options['remove_js']) === FALSE) {
556
+ $find = FALSE;
557
+ if (preg_match('/\/((prototype|jquery|mootools)\.js)\?ver=([\.\d]+)[^\?]*$/i', $src, $matches)) {
558
+ list($find, $filename, $product, $version) = $matches;
559
+ } elseif (preg_match('/\/((prototype|jquery|mootools)[\-\.](min|[\.\d]+)[^\/]*\.js)\?[^\?]*$/i', $src, $matches)) {
560
+ list($find, $filename, $product, $version) = $matches;
561
+ } elseif (preg_match('/\/scriptaculous\/((builder|controls|dragdrop|effects|wp\-scriptaculous|scriptaculous|slider|sound|unittest)\.js)\?ver\=([\.\d]+)[^\?]*$/i', $src, $matches)) {
562
+ list($find, $filename, $product, $version) = $matches;
563
+ $product = (strpos($product, 'scriptaculous') === FALSE
564
+ ? 'scriptaculous/' . $product
565
+ : 'scriptaculous/scriptaculous');
566
+ }
567
+ unset($matches);
568
+
569
+ if ($find !== FALSE) {
570
+ $version = trim(substr($version, -1) === '.' ? substr($version, 0, -1) : $version);
571
+ if (empty($version))
572
+ $version = preg_replace('/^.*\/([\.\d]+)\/.*$/', '$1', $src);
573
+ if (!preg_match('/^[\.\d]*\d$/', $version))
574
+ $version = '1';
575
+ $js_libs[$product][$version] = $src;
576
+ } elseif ($this->head_js[$src] === FALSE) {
577
+ $foot_js .= trim($element->outertext) . "\n";
578
+ } elseif (strpos($src, $this->wp_url) === FALSE) {
579
+ $script_tag .= trim($element->outertext) . "\n";
580
+ } else {
581
+ $inner_js .= trim($element->outertext) . "\n";
582
+ $js_src[] = $element->src;
583
+ }
584
  }
585
  }
586
  }
719
  if (!isset($element->src)) {
720
  $inline_js .= $this->_remove_comment($element->innertext, 'js');
721
  } else {
722
+ $src = $element->src;
723
+ if (array_search( $src, (array) $this->options['remove_js']) === FALSE) {
724
+ if (strpos($src, $this->wp_url) === FALSE) {
725
+ $script_tag .= trim($element->outertext) . "\n";
726
+ } else {
727
+ $inner_js .= trim($element->outertext) . "\n";
728
+ $js_src[] = preg_replace('/\.gz$/i', '', $src);
729
+ }
730
  }
731
  }
732
  break;
761
  . $script_tag
762
  . $inline_js
763
  ;
764
+ //$ret_val = str_replace('\'', '"', $ret_val);
765
+ $ret_val = trim(preg_replace(
766
+ array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
767
+ array( ' $1="$2"', "\n", "$1\n$2" ),
768
+ $ret_val
769
+ )) . "\n";
770
 
771
  if ($this->options['debug_mode'])
772
  $ret_val .= $this->_get_debug_info($buffer);
1488
 
1489
  // strip slashes array
1490
  $head_js = $this->stripArray(isset($_POST['head_js']) ? $_POST['head_js'] : array());
1491
+ $remove_js = $this->stripArray(isset($_POST['remove_js']) ? $_POST['remove_js'] : array());
1492
  $head_filters = $this->stripArray(isset($_POST['head_filters']) ? $_POST['head_filters'] : array());
1493
  $head_remove = $this->stripArray(isset($_POST['head_remove']) ? $_POST['head_remove'] : array());
1494
  $foot_filters = $this->stripArray(isset($_POST['foot_filters']) ? $_POST['foot_filters'] : array());
1521
  $rm_rsd_link = (isset($_POST['rm_rsd_link']) && $_POST['rm_rsd_link'] == 'on' ? true : false);
1522
  $rm_manifest = (isset($_POST['rm_manifest']) && $_POST['rm_manifest'] == 'on' ? true : false);
1523
 
1524
+ $this->options['remove_js'] = array();
1525
  foreach ((array) $this->options['head_js'] as $javascript => $value) {
1526
  if (count($head_js) > 0 && array_search($javascript, $head_js) !== FALSE)
1527
  $this->options['head_js'][$javascript] = FALSE;
1528
  else
1529
  $this->options['head_js'][$javascript] = TRUE;
1530
+ if (array_search($javascript, (array) $remove_js) !== FALSE)
1531
+ $this->options['remove_js'][] = $javascript;
1532
  }
1533
  unset($head_js);
1534
+ unset($remove_js);
1535
 
1536
  $tag = 'wp_head';
1537
 
1827
  $out .= "<table><tbody>\n";
1828
  $out .= "<tr>";
1829
  $out .= "<th>" . __('Move to footer', $this->textdomain_name) . "</th>\n";
1830
+ $out .= "<th>" . __('Remove', $this->textdomain_name) . "</th>\n";
1831
  $out .= "<th>" . __('JavaScripts', $this->textdomain_name) . "</th>\n";
1832
  foreach ($this->options['head_js'] as $javascript => $value) {
1833
+ $remove = (array_search( $javascript, (array)$this->options["remove_js"] ) !== FALSE);
1834
  $out .= "<tr>";
1835
  $out .= "<th><input type=\"checkbox\" name=\"head_js[$i]\" value=\"$javascript\"".($value === FALSE ? " checked=\"true\"" : "")." /></th>";
1836
+ $out .= "<th><input type=\"checkbox\" name=\"remove_js[$i]\" value=\"$javascript\"".($remove !== FALSE ? " checked=\"true\"" : "")." /></th>";
1837
  $out .= "<td>$javascript</td>";
1838
  $i++;
1839
  }
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: 2.9.1
7
- Stable tag: 1.3.2
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
@@ -85,3 +85,45 @@ Head Cleaner Ver.1.1.5 includes 'php_browscap.ini' .
85
 
86
  1. The admin page
87
  2. YSlow Result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  Tags: head, header, footer, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
  Tested up to: 2.9.1
7
+ Stable tag: 1.3.3
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
85
 
86
  1. The admin page
87
  2. YSlow Result
88
+
89
+ == Changelog ==
90
+
91
+ **1.3.3 - January 27, 2010**
92
+ Add an item to the Options page set.
93
+ (Added the option to remove the JavaScript)
94
+
95
+ **1.3.2 - January 25, 2010**
96
+ In the inline CSS "@import", &lt;link rel=&quot;stylesheet&quot;&gt; was modified to convert the tag.
97
+
98
+ **1.3.1 - September 8, 2009**
99
+ Minor bug fixes.
100
+
101
+ **1.3.0 - July 5, 2009**
102
+ Google AJAX Libraries support
103
+
104
+ **1.2.0 - April 5, 2009**
105
+ Add an item to the Options page set.
106
+
107
+ **1.1.3 - March 19, 2009**
108
+ Adjust the filter to display the active filters.
109
+
110
+ **1.1.2 - March 17, 2009**
111
+ Minor bug fixes.
112
+
113
+ **1.1.1 - March 10, 2009**
114
+ JavaScript, filter set an expiration date of the analysis.
115
+
116
+ **1.1.0 - March 9, 2009**
117
+ JavaScript has to be moved to the footer.
118
+
119
+ **1.0.3 - March 7, 2009**
120
+ Fixed a bug in IE conditional tags Decision.
121
+
122
+ **1.0.2 - March 7, 2009**
123
+ Fixed a conflict with "[WordPress.com Stats](http://wordpress.org/extend/plugins/stats/)" and "[Ultimate Google Analytics](http://wordpress.org/extend/plugins/ultimate-google-analytics/)".
124
+
125
+ **1.0.1 - March 6, 2009**
126
+ script.aculo.us was to correct the load order.
127
+
128
+ **1.0.0 - March 5, 2009**
129
+ Initial release.
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: 2.9.1
7
- Stable tag: 1.3.2
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: 2.9.1
7
+ Stable tag: 1.3.3
8
 
9
  Head �� footer �����|�����܂��B
10