Head Cleaner - Version 1.1.2

Version Description

Download this release

Release Info

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

Code changes from version 1.1.1 to 1.1.2

head-cleaner.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Head Cleaner
4
- Version: 1.1.1
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
@@ -106,7 +106,7 @@ if (!class_exists('wokController') || !class_exists('wokScriptManager'))
106
  //**************************************************************************************
107
  class HeadCleanerController extends wokController {
108
  public $plugin_name = 'head-cleaner';
109
- public $plugin_ver = '1.1.1';
110
 
111
  // Deafault Options
112
  private $options_default = array(
@@ -214,7 +214,7 @@ class HeadCleanerController extends wokController {
214
 
215
  $priority = $this->options_default['priority'];
216
  foreach ($wk_options['priority'] as $tag => $filters) {
217
- foreach ($filters as $key => $val) {
218
  if ($val <= 0 || $val > HC_PRIORITY)
219
  $priority[$tag][$key] = $val;
220
  }
@@ -222,7 +222,7 @@ class HeadCleanerController extends wokController {
222
  unset($filters);
223
 
224
  $head_js = $this->options_default['head_js'];
225
- foreach ($wk_options['head_js'] as $key => $val) {
226
  if ($val === FALSE)
227
  $head_js[$key] = $val;
228
  }
@@ -401,7 +401,7 @@ class HeadCleanerController extends wokController {
401
  $xml_lang = $this->lang;
402
  $lang = $this->lang;
403
  if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $mathes, PREG_SET_ORDER)) {
404
- foreach ($matches as $match) {
405
  switch ($match[1]){
406
  case 'xmlns': $xmlns = $match[2]; break;
407
  case 'xml:lang': $xml_lang = $match[2]; break;
@@ -422,7 +422,7 @@ class HeadCleanerController extends wokController {
422
 
423
  $css_tag = ''; $inner_css = ''; $css_src = array();
424
  $elements = $dom->find("link[rel='stylesheet']");
425
- foreach ((array)$elements as $element) {
426
  $tag = trim($element);
427
  if (isset($element->href)) {
428
  $src = str_replace($this->wp_url, ABSPATH, trim(preg_replace('/\.css\?.*$/i', '.css', $element->href)));
@@ -444,7 +444,7 @@ class HeadCleanerController extends wokController {
444
 
445
  $elements = $dom->find("style");
446
  $wk_inline_css = array();
447
- foreach ((array)$elements as $element) {
448
  $media = trim(isset($element->media) ? $element->media : $this->options['default_media']);
449
  $media = (empty($media) ? $this->options['default_media'] : $media);
450
  $wk_inline_css[$media] .= $this->_remove_comment($element->innertext, 'css');
@@ -495,7 +495,7 @@ class HeadCleanerController extends wokController {
495
  $js_src = array();
496
  $js_libs = array();
497
  $elements = $dom->find("script");
498
- foreach ((array)$elements as $element) {
499
  if (!isset($element->src)) {
500
  $inline_js .= $this->_remove_comment($element->innertext, 'js');
501
  } else {
@@ -639,7 +639,7 @@ class HeadCleanerController extends wokController {
639
 
640
  $inner_js = ''; $js_src = array();
641
  $elements = $dom->find("div#footer *");
642
- foreach ((array)$elements as $element) {
643
  switch ($element->tag) {
644
  case 'script':
645
  if ($this->_is_javascript()) {
@@ -863,7 +863,7 @@ class HeadCleanerController extends wokController {
863
  foreach ((array) $tags as $tag_types) {
864
  foreach ((array) $tag_types as $tag) {
865
  $html .= "<$type";
866
- foreach((array)$tag as $key => $val) {
867
  $html .= " $key=\"$val\"";
868
  }
869
  $html .= " />\n";
@@ -895,7 +895,7 @@ class HeadCleanerController extends wokController {
895
  if (preg_match_all('/url[ \t]*\([\'"]?([^\)]*)[\'"]?\)/i', $content, $matches, PREG_SET_ORDER)) {
896
  $base_path = dirname($filename);
897
  $search = array(); $replace = array();
898
- foreach ($matches as $match) {
899
  if (! preg_match('/^https?:\/\//i', trim($match[1]))) {
900
  $abs_url = $this->_abs_url(trim($match[1]), $base_path);
901
  $search[] = $match[0];
@@ -933,7 +933,7 @@ class HeadCleanerController extends wokController {
933
  //**************************************************************************************
934
  private function _files_read($files, $type = 'js') {
935
  $text = '';
936
- foreach ($files as $filename) {
937
  $content = trim($this->_file_read($filename));
938
  switch ($type) {
939
  case 'css':
@@ -1107,7 +1107,7 @@ class HeadCleanerController extends wokController {
1107
  $html = '';
1108
  $longfilename = ''; $files = array();
1109
 
1110
- foreach ((array)$styles as $style) {
1111
  $src = trim(preg_replace('/(\.css|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $style)));
1112
  if (file_exists($src)) {
1113
  $filename = (preg_match('/\.css$/i', $src) ? $src : $style);
@@ -1177,7 +1177,7 @@ class HeadCleanerController extends wokController {
1177
  $html = '';
1178
  $longfilename = ''; $files = array();
1179
 
1180
- foreach ((array)$javascripts as $javascript) {
1181
  $src = trim(preg_replace('/(\.js|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $javascript)));
1182
  if (file_exists($src)) {
1183
  $filename = (preg_match('/\.js$/i', $src) ? $src : $javascript);
@@ -1278,7 +1278,7 @@ class HeadCleanerController extends wokController {
1278
  //**************************************************************************************
1279
  private function _newer_version_src($js_libs, $limit_ver = '') {
1280
  $src = ''; $ver = '0.0';
1281
- foreach ((array)$js_libs as $key => $val) {
1282
  if ( version_compare( $key, $ver, '>') ) {
1283
  $src = $val; $ver = $key;
1284
  }
@@ -1306,7 +1306,7 @@ class HeadCleanerController extends wokController {
1306
  private function _css_import($css) {
1307
  if (preg_match_all('/@import[ \t]*url[ \t]*\([\'"]?([^\)]*)[\'"]?\);?/i', $css, $matches, PREG_SET_ORDER)) {
1308
  $search = array(); $replace = array();
1309
- foreach ($matches as $match) {
1310
  $filename = str_replace($this->wp_url, ABSPATH, trim($match[1]));
1311
  $content = $this->_file_read($filename);
1312
  $content = $this->_css_url_edit($content, $filename);
@@ -1380,7 +1380,7 @@ class HeadCleanerController extends wokController {
1380
  private function _remove_all_file($dir, $rmdir = false) {
1381
  if(file_exists($dir)) {
1382
  if($objs = glob($dir."/*")) {
1383
- foreach($objs as $obj) {
1384
  is_dir($obj)
1385
  ? $this->_remove_all_file($obj, true)
1386
  : @unlink($obj);
@@ -1440,7 +1440,7 @@ class HeadCleanerController extends wokController {
1440
  } else {
1441
  $this_plugin = plugin_basename(__FILE__);
1442
  if ($file == $this_plugin) {
1443
- $settings_link = '<a href="options-general.php?page=' . $this->plugin_file . '">' . __('Settings') . '</a>';
1444
  array_unshift($links, $settings_link); // before other links
1445
  }
1446
  }
@@ -1806,6 +1806,16 @@ class HeadCleanerController extends wokController {
1806
  $this->options = $this->_init_options();
1807
  }
1808
 
 
 
 
 
 
 
 
 
 
 
1809
  //**************************************************************************************
1810
  // Get Filters
1811
  //**************************************************************************************
@@ -1819,14 +1829,11 @@ class HeadCleanerController extends wokController {
1819
  $this->filters[$tag] = array();
1820
 
1821
  $active_filters = (isset($wp_filter[$tag])
1822
- ? $wp_filter[$tag]
1823
  : array());
1824
  foreach ($active_filters as $priority => $filters) {
1825
  foreach ($filters as $filter) {
1826
- $function_name = (is_array($filter['function'])
1827
- ? (get_class($filter['function'][0]) !== FALSE ? get_class($filter['function'][0]) : $filter['function'][0]) . '::' . $filter['function'][1]
1828
- : $filter['function']
1829
- );
1830
  $this->filters[$tag][$function_name] = $priority;
1831
  }
1832
  }
@@ -1881,10 +1888,7 @@ class HeadCleanerController extends wokController {
1881
  }
1882
  foreach ($active_filters as $priority => $filters) {
1883
  foreach ($filters as $filter) {
1884
- $function_name = (is_array($filter['function'])
1885
- ? (get_class($filter['function'][0]) !== FALSE ? get_class($filter['function'][0]) : $filter['function'][0]) . '::' . $filter['function'][1]
1886
- : $filter['function']
1887
- );
1888
  if ( isset($custom_priority[$function_name]) && $custom_priority[$function_name] != $priority) {
1889
  remove_filter( $tag, $filter['function'], $priority);
1890
  if ($custom_priority[$function_name] > 0)
1
  <?php
2
  /*
3
  Plugin Name: Head Cleaner
4
+ Version: 1.1.2
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
106
  //**************************************************************************************
107
  class HeadCleanerController extends wokController {
108
  public $plugin_name = 'head-cleaner';
109
+ public $plugin_ver = '1.1.2';
110
 
111
  // Deafault Options
112
  private $options_default = array(
214
 
215
  $priority = $this->options_default['priority'];
216
  foreach ($wk_options['priority'] as $tag => $filters) {
217
+ foreach ((array) $filters as $key => $val) {
218
  if ($val <= 0 || $val > HC_PRIORITY)
219
  $priority[$tag][$key] = $val;
220
  }
222
  unset($filters);
223
 
224
  $head_js = $this->options_default['head_js'];
225
+ foreach ((array) $wk_options['head_js'] as $key => $val) {
226
  if ($val === FALSE)
227
  $head_js[$key] = $val;
228
  }
401
  $xml_lang = $this->lang;
402
  $lang = $this->lang;
403
  if (preg_match_all('/ +([^ ]*)=[\'"]([^\'"]*)[\'"]/', $html_tag, $mathes, PREG_SET_ORDER)) {
404
+ foreach ((array) $matches as $match) {
405
  switch ($match[1]){
406
  case 'xmlns': $xmlns = $match[2]; break;
407
  case 'xml:lang': $xml_lang = $match[2]; break;
422
 
423
  $css_tag = ''; $inner_css = ''; $css_src = array();
424
  $elements = $dom->find("link[rel='stylesheet']");
425
+ foreach ((array) $elements as $element) {
426
  $tag = trim($element);
427
  if (isset($element->href)) {
428
  $src = str_replace($this->wp_url, ABSPATH, trim(preg_replace('/\.css\?.*$/i', '.css', $element->href)));
444
 
445
  $elements = $dom->find("style");
446
  $wk_inline_css = array();
447
+ foreach ((array) $elements as $element) {
448
  $media = trim(isset($element->media) ? $element->media : $this->options['default_media']);
449
  $media = (empty($media) ? $this->options['default_media'] : $media);
450
  $wk_inline_css[$media] .= $this->_remove_comment($element->innertext, 'css');
495
  $js_src = array();
496
  $js_libs = array();
497
  $elements = $dom->find("script");
498
+ foreach ((array) $elements as $element) {
499
  if (!isset($element->src)) {
500
  $inline_js .= $this->_remove_comment($element->innertext, 'js');
501
  } else {
639
 
640
  $inner_js = ''; $js_src = array();
641
  $elements = $dom->find("div#footer *");
642
+ foreach ((array) $elements as $element) {
643
  switch ($element->tag) {
644
  case 'script':
645
  if ($this->_is_javascript()) {
863
  foreach ((array) $tags as $tag_types) {
864
  foreach ((array) $tag_types as $tag) {
865
  $html .= "<$type";
866
+ foreach((array) $tag as $key => $val) {
867
  $html .= " $key=\"$val\"";
868
  }
869
  $html .= " />\n";
895
  if (preg_match_all('/url[ \t]*\([\'"]?([^\)]*)[\'"]?\)/i', $content, $matches, PREG_SET_ORDER)) {
896
  $base_path = dirname($filename);
897
  $search = array(); $replace = array();
898
+ foreach ((array) $matches as $match) {
899
  if (! preg_match('/^https?:\/\//i', trim($match[1]))) {
900
  $abs_url = $this->_abs_url(trim($match[1]), $base_path);
901
  $search[] = $match[0];
933
  //**************************************************************************************
934
  private function _files_read($files, $type = 'js') {
935
  $text = '';
936
+ foreach ((array) $files as $filename) {
937
  $content = trim($this->_file_read($filename));
938
  switch ($type) {
939
  case 'css':
1107
  $html = '';
1108
  $longfilename = ''; $files = array();
1109
 
1110
+ foreach ((array) $styles as $style) {
1111
  $src = trim(preg_replace('/(\.css|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $style)));
1112
  if (file_exists($src)) {
1113
  $filename = (preg_match('/\.css$/i', $src) ? $src : $style);
1177
  $html = '';
1178
  $longfilename = ''; $files = array();
1179
 
1180
+ foreach ((array) $javascripts as $javascript) {
1181
  $src = trim(preg_replace('/(\.js|\.php)(\?[^\?]*)$/i', '$1', str_replace($this->wp_url, ABSPATH, $javascript)));
1182
  if (file_exists($src)) {
1183
  $filename = (preg_match('/\.js$/i', $src) ? $src : $javascript);
1278
  //**************************************************************************************
1279
  private function _newer_version_src($js_libs, $limit_ver = '') {
1280
  $src = ''; $ver = '0.0';
1281
+ foreach ((array) $js_libs as $key => $val) {
1282
  if ( version_compare( $key, $ver, '>') ) {
1283
  $src = $val; $ver = $key;
1284
  }
1306
  private function _css_import($css) {
1307
  if (preg_match_all('/@import[ \t]*url[ \t]*\([\'"]?([^\)]*)[\'"]?\);?/i', $css, $matches, PREG_SET_ORDER)) {
1308
  $search = array(); $replace = array();
1309
+ foreach ((array) $matches as $match) {
1310
  $filename = str_replace($this->wp_url, ABSPATH, trim($match[1]));
1311
  $content = $this->_file_read($filename);
1312
  $content = $this->_css_url_edit($content, $filename);
1380
  private function _remove_all_file($dir, $rmdir = false) {
1381
  if(file_exists($dir)) {
1382
  if($objs = glob($dir."/*")) {
1383
+ foreach((array) $objs as $obj) {
1384
  is_dir($obj)
1385
  ? $this->_remove_all_file($obj, true)
1386
  : @unlink($obj);
1440
  } else {
1441
  $this_plugin = plugin_basename(__FILE__);
1442
  if ($file == $this_plugin) {
1443
+ $settings_link = '<a href="' . $this->admin_action . '">' . __('Settings') . '</a>';
1444
  array_unshift($links, $settings_link); // before other links
1445
  }
1446
  }
1806
  $this->options = $this->_init_options();
1807
  }
1808
 
1809
+ //**************************************************************************************
1810
+ // Get function name
1811
+ //**************************************************************************************
1812
+ private function _get_function_name($function) {
1813
+ return (is_array($function)
1814
+ ? (get_class($function[0]) !== FALSE ? get_class($function[0]) : $function[0]) . '::' . $function[1]
1815
+ : $function
1816
+ );
1817
+ }
1818
+
1819
  //**************************************************************************************
1820
  // Get Filters
1821
  //**************************************************************************************
1829
  $this->filters[$tag] = array();
1830
 
1831
  $active_filters = (isset($wp_filter[$tag])
1832
+ ? (array) $wp_filter[$tag]
1833
  : array());
1834
  foreach ($active_filters as $priority => $filters) {
1835
  foreach ($filters as $filter) {
1836
+ $function_name = $this->_get_function_name($filter['function']);
 
 
 
1837
  $this->filters[$tag][$function_name] = $priority;
1838
  }
1839
  }
1888
  }
1889
  foreach ($active_filters as $priority => $filters) {
1890
  foreach ($filters as $filter) {
1891
+ $function_name = $this->_get_function_name($filter['function']);
 
 
 
1892
  if ( isset($custom_priority[$function_name]) && $custom_priority[$function_name] != $priority) {
1893
  remove_filter( $tag, $filter['function'], $priority);
1894
  if ($custom_priority[$function_name] > 0)
includes/common-controller.php CHANGED
@@ -163,7 +163,7 @@ class wokController {
163
  function addPluginSettingLinks($links, $file) {
164
  $this_plugin = plugin_basename($this->file_path);
165
  if ($file == $this_plugin) {
166
- $settings_link = '<a href="options-general.php?page=' . $this->plugin_file . '">' . __('Settings') . '</a>';
167
  array_unshift($links, $settings_link); // before other links
168
  }
169
  return $links;
163
  function addPluginSettingLinks($links, $file) {
164
  $this_plugin = plugin_basename($this->file_path);
165
  if ($file == $this_plugin) {
166
+ $settings_link = '<a href="' . $this->admin_action . '">' . __('Settings') . '</a>';
167
  array_unshift($links, $settings_link); // before other links
168
  }
169
  return $links;
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.7.1
7
- Stable tag: 1.1.1
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
@@ -13,6 +13,8 @@ Cleaning tags from your WordPress header and footer.
13
  Cleaning tags from your WordPress header and footer.
14
  To speed up the loading of JavaScript and CSS.
15
 
 
 
16
  = Features =
17
 
18
  * IE6 at the top of the non-grant xml declaration.
@@ -42,7 +44,7 @@ To speed up the loading of JavaScript and CSS.
42
 
43
  The control panel of Head Cleaner is in 'Settings > Head Cleaner'.
44
 
45
- **PHP libraries are using [Simple HTML DOM Parser](http://simplehtmldom.sourceforge.net/ "Simple HTML DOM Parser") and [JSMin](http://code.google.com/p/jsmin-php/ "JSMin") upper limit, PHP5 is only later.**
46
 
47
  == Frequently Asked Questions ==
48
 
4
  Tags: head, header, footer, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
  Tested up to: 2.7.1
7
+ Stable tag: 1.1.2
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
13
  Cleaning tags from your WordPress header and footer.
14
  To speed up the loading of JavaScript and CSS.
15
 
16
+ **PHP5 Required.**
17
+
18
  = Features =
19
 
20
  * IE6 at the top of the non-grant xml declaration.
44
 
45
  The control panel of Head Cleaner is in 'Settings > Head Cleaner'.
46
 
47
+ **PHP libraries are using [Simple HTML DOM Parser](http://simplehtmldom.sourceforge.net/ "Simple HTML DOM Parser") and [JSMin](http://code.google.com/p/jsmin-php/ "JSMin"). PHP5 Required.**
48
 
49
  == Frequently Asked Questions ==
50
 
readme_ja.txt CHANGED
@@ -4,13 +4,14 @@ 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.7.1
7
- Stable tag: 1.1.1
8
 
9
  Head �� footer �����|�����܂��B
10
 
11
  == Description ==
12
 
13
  WordPress �T�C�g�� `<head>` �̒��g�ƁA�t�b�^�̈�𐮌`���Ȃ����܂��B
 
14
 
15
  = Features =
16
 
4
  Tags: head optimization, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
  Tested up to: 2.7.1
7
+ Stable tag: 1.1.2
8
 
9
  Head �� footer �����|�����܂��B
10
 
11
  == Description ==
12
 
13
  WordPress �T�C�g�� `<head>` �̒��g�ƁA�t�b�^�̈�𐮌`���Ȃ����܂��B
14
+ **PHP5 �ȍ~�̂ݑΉ��ł��B**
15
 
16
  = Features =
17
 
screenshot-1.png CHANGED
Binary file