Head Cleaner - Version 1.3.9

Version Description

Download this release

Release Info

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

Code changes from version 1.3.8 to 1.3.9

Files changed (4) hide show
  1. head-cleaner.php +103 -39
  2. includes/regist_ajax_libs.php +8 -8
  3. readme.txt +2 -2
  4. readme_ja.txt +2 -2
head-cleaner.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Head Cleaner
4
- Version: 1.3.8
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
@@ -50,11 +50,14 @@ if (version_compare(phpversion(), "5.0.0", "<"))
50
  //**************************************************************************************
51
  // Defines
52
  //**************************************************************************************
53
- define('HC_PRIORITY', 10000);
54
- define('HC_ANALYZE_EXPIRED', 604800); // 60 * 60 * 24 * 7 [sec.]
55
- define('HC_XMLNS', 'http://www.w3.org/1999/xhtml');
56
- define('HC_CACHE_DIR', 'cache/head-cleaner');
57
-
 
 
 
58
 
59
  //**************************************************************************************
60
  if (!defined('ABSPATH') && strstr($_SERVER['PHP_SELF'], '/head-cleaner.php')) {
@@ -67,8 +70,15 @@ if (!defined('ABSPATH') && strstr($_SERVER['PHP_SELF'], '/head-cleaner.php')) {
67
  $type = trim(stripslashes($_GET['t']));
68
 
69
  if (strlen($filename_hash) == 32 && ($type == 'js' || $type == 'css')) {
70
- $is_gzip = (strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== FALSE);
71
- $filename = "{$cache_dir}{$type}/{$filename_hash}.{$type}" . ($is_gzip ? '.gz' : '');
 
 
 
 
 
 
 
72
  if (file_exists($filename)) {
73
  $offset = (!defined('HC_EXPIRED_JS_CSS') ? HC_EXPIRED_JS_CSS : 60 * 60 * 24 * 30);
74
  $content_type = 'text/' . ($type == 'js' ? 'javascript' : $type);
@@ -80,7 +90,14 @@ if (!defined('ABSPATH') && strstr($_SERVER['PHP_SELF'], '/head-cleaner.php')) {
80
  if ($is_gzip)
81
  header('Content-Encoding: gzip');
82
 
 
 
 
83
  readfile($filename);
 
 
 
 
84
  $error = false;
85
  } else {
86
  $error = 404;
@@ -134,7 +151,7 @@ if (!class_exists('wokController') || !class_exists('wokScriptManager'))
134
  //**************************************************************************************
135
  class HeadCleaner extends wokController {
136
  public $plugin_name = 'head-cleaner';
137
- public $plugin_ver = '1.3.8';
138
 
139
  // Deafault Options
140
  private $options_default = array(
@@ -243,9 +260,25 @@ class HeadCleaner extends wokController {
243
  }
244
  }
245
 
246
- // Require PHP Libraries
247
- if (!is_admin())
 
 
 
 
248
  $this->_require_libraries();
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
 
251
  /**********************************************************
@@ -426,11 +459,13 @@ class HeadCleaner extends wokController {
426
  //**************************************************************************************
427
  public function filters_save(){
428
  if ($this->_chk_filters_update()) {
429
- $this->options['filters'] = $this->filters;
430
- $this->options['head_js'] = $this->head_js;
431
- if (time() > $this->options['analyze_expired'])
432
- $this->options['analyze_expired'] = time() + HC_ANALYZE_EXPIRED;
433
- $this->updateOptions();
 
 
434
  }
435
  }
436
 
@@ -761,6 +796,14 @@ class HeadCleaner extends wokController {
761
  add_action('wp_footer', array(&$this, 'footer'), 9);
762
  }
763
 
 
 
 
 
 
 
 
 
764
  $ret_val = ($ie6 || !$this->options['xml_declaration']
765
  ? preg_replace('/^<\?xml[^>]*>/i', '', $ret_val)
766
  : (strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
@@ -852,6 +895,15 @@ class HeadCleaner extends wokController {
852
  . $script_tag
853
  . $inline_js
854
  ;
 
 
 
 
 
 
 
 
 
855
  //$ret_val = str_replace('\'', '"', $ret_val);
856
  $ret_val = trim(preg_replace(
857
  array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
@@ -1348,10 +1400,11 @@ class HeadCleaner extends wokController {
1348
  $this->_file_write($filename, $script, $this->options['gzip_on']);
1349
  }
1350
 
1351
- $fileurl = ($this->options['dynamic']
1352
- ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1353
- : $this->cache_url . $longfilename
1354
- );
 
1355
  if (file_exists($filename))
1356
  $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1357
 
@@ -1376,10 +1429,11 @@ class HeadCleaner extends wokController {
1376
  if (!file_exists($filename) && !empty($script) )
1377
  $this->_file_write($filename, $script, $this->options['gzip_on']);
1378
 
1379
- $fileurl = ($this->options['dynamic']
1380
- ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1381
- : $this->cache_url . $longfilename
1382
- );
 
1383
  if (file_exists($filename))
1384
  $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1385
 
@@ -2129,6 +2183,26 @@ class HeadCleaner extends wokController {
2129
  unset($active_filters);
2130
  }
2131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2132
  //**************************************************************************************
2133
  // Debug Information
2134
  //**************************************************************************************
@@ -2186,18 +2260,8 @@ global $head_cleaner;
2186
 
2187
  $head_cleaner = new HeadCleaner();
2188
 
2189
- if (is_admin()) {
2190
- add_action('admin_menu', array(&$head_cleaner, 'admin_menu'));
2191
- add_filter('plugin_action_links', array(&$head_cleaner, 'plugin_setting_links'), 10, 2 );
2192
-
2193
- if (function_exists('register_activation_hook'))
2194
- register_activation_hook(__FILE__, array(&$head_cleaner, 'activation'));
2195
- if (function_exists('register_deactivation_hook'))
2196
- register_deactivation_hook(__FILE__, array(&$head_cleaner, 'deactivation'));
2197
-
2198
- } else {
2199
- add_action('get_header', array(&$head_cleaner, 'head_start'));
2200
- add_action('wp_footer', array(&$head_cleaner, 'filters_save'), 11);
2201
-
2202
- }
2203
- ?>
1
  <?php
2
  /*
3
  Plugin Name: Head Cleaner
4
+ Version: 1.3.9
5
  Plugin URI: http://wppluginsj.sourceforge.jp/head-cleaner/
6
  Description: Cleaning tags from your WordPress header and footer.
7
  Author: wokamoto
50
  //**************************************************************************************
51
  // Defines
52
  //**************************************************************************************
53
+ if (!defined('HC_PRIORITY'))
54
+ define('HC_PRIORITY', 10000);
55
+ if (!define('HC_ANALYZE_EXPIRED'))
56
+ define('HC_ANALYZE_EXPIRED', 604800); // 60 * 60 * 24 * 7 [sec.]
57
+ if (!define('HC_XMLNS'))
58
+ define('HC_XMLNS', 'http://www.w3.org/1999/xhtml');
59
+ if (!define('HC_CACHE_DIR'))
60
+ define('HC_CACHE_DIR', 'cache/head-cleaner');
61
 
62
  //**************************************************************************************
63
  if (!defined('ABSPATH') && strstr($_SERVER['PHP_SELF'], '/head-cleaner.php')) {
70
  $type = trim(stripslashes($_GET['t']));
71
 
72
  if (strlen($filename_hash) == 32 && ($type == 'js' || $type == 'css')) {
73
+ $is_gzip = (strpos(strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== FALSE);
74
+ $ob_gzip = false;
75
+
76
+ $filename = "{$cache_dir}{$type}/{$filename_hash}.{$type}";
77
+ if ($is_gzip && file_exists($filename.'.gz'))
78
+ $filename .= '.gz';
79
+ else
80
+ $ob_gzip = $is_gzip;
81
+
82
  if (file_exists($filename)) {
83
  $offset = (!defined('HC_EXPIRED_JS_CSS') ? HC_EXPIRED_JS_CSS : 60 * 60 * 24 * 30);
84
  $content_type = 'text/' . ($type == 'js' ? 'javascript' : $type);
90
  if ($is_gzip)
91
  header('Content-Encoding: gzip');
92
 
93
+ if ($ob_gzip)
94
+ ob_start("ob_gzhandler");
95
+
96
  readfile($filename);
97
+
98
+ if ($ob_gzip)
99
+ ob_end_flush();
100
+
101
  $error = false;
102
  } else {
103
  $error = 404;
151
  //**************************************************************************************
152
  class HeadCleaner extends wokController {
153
  public $plugin_name = 'head-cleaner';
154
+ public $plugin_ver = '1.3.9';
155
 
156
  // Deafault Options
157
  private $options_default = array(
260
  }
261
  }
262
 
263
+ if (is_admin()) {
264
+ add_action('admin_menu', array(&$this, 'admin_menu'));
265
+ add_filter('plugin_action_links', array(&$this, 'plugin_setting_links'), 10, 2 );
266
+
267
+ } else {
268
+ // Require PHP Libraries
269
  $this->_require_libraries();
270
+
271
+ add_action('get_header', array(&$this, 'head_start'));
272
+ add_action('wp_footer', array(&$this, 'filters_save'), 11);
273
+
274
+ // remove_filter('the_content', 'wpautop');
275
+ // remove_filter('the_content', 'wptexturize');
276
+ // add_filter('the_content', array(&$head_cleaner, 'raw_formatter'), 99);
277
+
278
+ // remove_filter('the_excerpt', 'wpautop');
279
+ // remove_filter('the_excerpt', 'wptexturize');
280
+ // add_filter('the_excerpt', array(&$head_cleaner, 'raw_formatter'), 99);
281
+ }
282
  }
283
 
284
  /**********************************************************
459
  //**************************************************************************************
460
  public function filters_save(){
461
  if ($this->_chk_filters_update()) {
462
+ if ( $this->options['filters'] != $this->filters || $this->options['head_js'] != $this->head_js ) {
463
+ $this->options['filters'] = $this->filters;
464
+ $this->options['head_js'] = $this->head_js;
465
+ if (time() > $this->options['analyze_expired'])
466
+ $this->options['analyze_expired'] = time() + HC_ANALYZE_EXPIRED;
467
+ $this->updateOptions();
468
+ }
469
  }
470
  }
471
 
796
  add_action('wp_footer', array(&$this, 'footer'), 9);
797
  }
798
 
799
+ if ($this->options['dynamic']) {
800
+ $ret_val = preg_replace(
801
+ '/' . preg_quote($this->cache_url, '/') . '(js|css)\/([^\.]*)\.(js|css)/i' ,
802
+ $this->self_url . "?f=$2&amp;t=$3" ,
803
+ $ret_val
804
+ );
805
+ }
806
+
807
  $ret_val = ($ie6 || !$this->options['xml_declaration']
808
  ? preg_replace('/^<\?xml[^>]*>/i', '', $ret_val)
809
  : (strpos($ret_val, '<?xml') === false ? $xml_head : '') . $ret_val
895
  . $script_tag
896
  . $inline_js
897
  ;
898
+
899
+ if ($this->options['dynamic']) {
900
+ $ret_val = preg_replace(
901
+ '/' . preg_quote($this->cache_url, '/') . '(js|css)\/([^\.]*)\.(js|css)/i' ,
902
+ $this->self_url . "?f=$2&amp;t=$3" ,
903
+ $ret_val
904
+ );
905
+ }
906
+
907
  //$ret_val = str_replace('\'', '"', $ret_val);
908
  $ret_val = trim(preg_replace(
909
  array( "/[\s]+([^\=]+)\='([^']*)'/i", '/[\n\r]+/i', '/(<\/[^>]+>)[ \t]*(<[^>]+)/i' ) ,
1400
  $this->_file_write($filename, $script, $this->options['gzip_on']);
1401
  }
1402
 
1403
+ $fileurl = $this->cache_url . $longfilename;
1404
+ // $fileurl = ($this->options['dynamic']
1405
+ // ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1406
+ // : $this->cache_url . $longfilename
1407
+ // );
1408
  if (file_exists($filename))
1409
  $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1410
 
1429
  if (!file_exists($filename) && !empty($script) )
1430
  $this->_file_write($filename, $script, $this->options['gzip_on']);
1431
 
1432
+ $fileurl = $this->cache_url . $longfilename;
1433
+ // $fileurl = ($this->options['dynamic']
1434
+ // ? $this->self_url . '?f=' . $md5_filename . '&amp;t=js'
1435
+ // : $this->cache_url . $longfilename
1436
+ // );
1437
  if (file_exists($filename))
1438
  $html .= "<script type=\"text/javascript\" src=\"{$fileurl}\"></script>\n";
1439
 
2183
  unset($active_filters);
2184
  }
2185
 
2186
+ //**************************************************************************************
2187
+ // raw shortcode
2188
+ //**************************************************************************************
2189
+ function raw_formatter($content) {
2190
+ $new_content = '';
2191
+ $pattern_full = '{(\[raw\].*?\[/raw\])}is';
2192
+ $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
2193
+ $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
2194
+
2195
+ foreach ($pieces as $piece) {
2196
+ if (preg_match($pattern_contents, $piece, $matches)) {
2197
+ $new_content .= $matches[1];
2198
+ } else {
2199
+ $new_content .= wptexturize(wpautop($piece));
2200
+ }
2201
+ }
2202
+
2203
+ return $new_content;
2204
+ }
2205
+
2206
  //**************************************************************************************
2207
  // Debug Information
2208
  //**************************************************************************************
2260
 
2261
  $head_cleaner = new HeadCleaner();
2262
 
2263
+ if (function_exists('register_activation_hook'))
2264
+ register_activation_hook(__FILE__, array(&$head_cleaner, 'activation'));
2265
+ if (function_exists('register_deactivation_hook'))
2266
+ register_deactivation_hook(__FILE__, array(&$head_cleaner, 'deactivation'));
2267
+ ?>
 
 
 
 
 
 
 
 
 
 
includes/regist_ajax_libs.php CHANGED
@@ -6,7 +6,7 @@ License:
6
  Released under the GPL license
7
  http://www.gnu.org/copyleft/gpl.html
8
 
9
- Copyright 2009 wokamoto (email : wokamoto1973@gmail.com)
10
 
11
  This program is free software; you can redistribute it and/or modify
12
  it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ if (AJAX_LIBS_GOOGLE) {
30
  define('AJAX_LIBS_GOOGLE_URL', 'http://ajax.googleapis.com/ajax/libs/');
31
  define('AJAX_LIBS_PROTOTYPE_JS_VER', '1.6.0.3');
32
  define('AJAX_LIBS_SCRIPTACULOUS_VER', '1.8.2');
33
- define('AJAX_LIBS_JQUERY_VER', '1.3.2');
34
  define('AJAX_LIBS_JQUERY_UI_VER', '1.7');
35
  define('AJAX_LIBS_MOOTOOLS_VER', '1.11');
36
  define('AJAX_LIBS_DOJO_VER', '1.1.1');
@@ -171,11 +171,11 @@ register_script('scriptaculous', '', array('scriptaculous-dragdrop', 'scriptacul
171
 
172
  // jQuery
173
  // name: jquery
174
- // versions: 1.3.2
175
- // load request: google.load("jquery", "1.3.2");
176
- // extras: uncompressed:true, e.g., google.load("jquery", "1.3", {uncompressed:true});
177
- // path: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
178
- // path(u): http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
179
  // site: http://jquery.com/
180
  register_script('jquery', AJAX_LIBS_JQUERY, false, AJAX_LIBS_JQUERY_VER);
181
  register_script('jquery.ui', AJAX_LIBS_JQUERY_UI, array('jquery'), AJAX_LIBS_JQUERY_UI_VER);
@@ -284,4 +284,4 @@ if (function_exists('wp_register_style')) {
284
  }
285
 
286
  endif;
287
- ?>
6
  Released under the GPL license
7
  http://www.gnu.org/copyleft/gpl.html
8
 
9
+ Copyright 2009 - 2010 wokamoto (email : wokamoto1973@gmail.com)
10
 
11
  This program is free software; you can redistribute it and/or modify
12
  it under the terms of the GNU General Public License as published by
30
  define('AJAX_LIBS_GOOGLE_URL', 'http://ajax.googleapis.com/ajax/libs/');
31
  define('AJAX_LIBS_PROTOTYPE_JS_VER', '1.6.0.3');
32
  define('AJAX_LIBS_SCRIPTACULOUS_VER', '1.8.2');
33
+ define('AJAX_LIBS_JQUERY_VER', '1.4.2');
34
  define('AJAX_LIBS_JQUERY_UI_VER', '1.7');
35
  define('AJAX_LIBS_MOOTOOLS_VER', '1.11');
36
  define('AJAX_LIBS_DOJO_VER', '1.1.1');
171
 
172
  // jQuery
173
  // name: jquery
174
+ // versions: 1.4.2
175
+ // load request: google.load("jquery", "1.4.2");
176
+ // extras: uncompressed:true, e.g., google.load("jquery", "1.4", {uncompressed:true});
177
+ // path: http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
178
+ // path(u): http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
179
  // site: http://jquery.com/
180
  register_script('jquery', AJAX_LIBS_JQUERY, false, AJAX_LIBS_JQUERY_VER);
181
  register_script('jquery.ui', AJAX_LIBS_JQUERY_UI, array('jquery'), AJAX_LIBS_JQUERY_UI_VER);
284
  }
285
 
286
  endif;
287
+ ?>
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wokamoto
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: head, header, footer, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
- Tested up to: 2.9.2
7
- Stable tag: 1.3.8
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: head, header, footer, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
+ Tested up to: 3.0
7
+ Stable tag: 1.3.9
8
 
9
  Cleaning tags from your WordPress header and footer.
10
 
readme_ja.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wokamoto
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: head optimization, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
- Tested up to: 2.9.2
7
- Stable tag: 1.3.8
8
 
9
  Head �� footer �����|�����܂��B
10
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=9S8AJCY7XB8F4&lc=JP&item_name=WordPress%20Plugins&item_number=wp%2dplugins&currency_code=JPY&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
4
  Tags: head optimization, javascript, css, optimization, minified, performance
5
  Requires at least: 2.5
6
+ Tested up to: 3.0
7
+ Stable tag: 1.3.9
8
 
9
  Head �� footer �����|�����܂��B
10