Plugin Directory

Changeset 787383


Ignore:
Timestamp:
10/14/2013 05:21:09 AM (12 years ago)
Author:
takuword
Message:

Plugin mejer version upgrade.

Location:
wp-comcleaner/trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-comcleaner/trunk/readme.txt

    r637477 r787383  
    11=== WP ComCleaner ===
    22Contributors: takuword
    3 Donate link: No,Thanks.
     3Donate link: http://jre655.com/donation/
    44Tags: Speeding up,WP ComCleaner,PHP
    55Requires at least:3.4.1
    6 Tested up to: 3.5
    7 Stable tag: 4.3
     6Tested up to: 3.6.1
     7Stable tag: 2.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010==Description==
    11 This plug-in removes the unwanted string of symbols, such as extra blank WordPress site, and a newline.
     11This plugin is remove more link,stop self pingback,and header clean.
    1212In my environment had took 4 seconds to read when I was 1 second. It may be exaggerated.
    13 Videos you have verified is the following URL.
     13Videos you have verified is the following URL.(Japanese)
    1414http://www.youtube.com/watch?v=oC5YnOB-BPI
    1515Thank you.
     
    6161add footer function.
    6262
     63=2.0=
     643.5->3.6,and add some cleaner.
     65see source.
    6366== Arbitrary section ==
    6467Speeding up Plugin.
  • wp-comcleaner/trunk/wp-comcleaner.php

    r630056 r787383  
    44     Plugin URI: http://jre655.com/83
    55     Description: サイトの表示時、無駄な空白や記号を省きます。あと、他のプラグインも少し持ってきてます
    6      Version: 1.2
     6     Version: 2.0
    77     Author: 福田拓朗
    88     Author URI: http://jre655.com/
    99     */
    10      add_action ( 'admin_head', 'wp_comcleaner', 1 );
    11      add_action ( 'wp_head', 'wp_comcleaner', 1 );
    12      add_action ( 'wp_footer', 'wp_comcleaner', 1 );
    13     function wp_comcleaner() {
    14     {
    15 $source = str_replace('|/\*.*?\*/|sm', '', $source);
    16 $source = str_replace('/\/\/.*/', '', $source);
    17 $source = str_replace("/\x23.*/", '', $source);
    18 $source = str_replace('/\s+/', "\x20", $source);
    19 $source = str_replace('/\s?([\(\)\[\]\{\},\;:=<>\+\-\/\*\%\!\?&\|])\s?/', '$1', $source);
    20 $source = str_replace('/\?>$/s', '', $source);
    21 $source = str_replace('print', 'ehco', $source);
    22 $source = str_replace('require_once', 'require', $source);
    23 $source = str_replace(' ', '', $source);
    24 $source = str_replace('preg_replace', 'str_replace', $source);
    25 $source = str_replace('str_replace', 'str_replace', $source);
    26 $source = str_replace(array("\r\n","\r","\n"), '', $source);
    27 return $source;
    28 $buffer = str_replace(' ',"",$buffer);
    29 $buffer = str_replace('/\s?([\(\)\[\]\{\},\;:=<>\+\-\/\*\%\!\?&\|])\s?/',"",$buffer);
    30 $buffer = str_replace('|/\*.*?\*/|sm', '', $buffer);
    31 $buffer = str_replace('/\/\/.*/', '', $buffer);
    32 $buffer = str_replace("/\x23.*/", '', $buffer);
    33 $buffer = str_replace('/\s+/', "\x20", $buffer);
    34 $buffer = str_replace('/\?>$/s', '', $buffer);
    35 $buffer = str_replace('print', 'ehco', $buffer);
    36 $buffer = str_replace('require_once', 'require', $buffer);
    37 $buffer = str_replace('preg_replace', 'str_replace', $buffer);
    38 $buffer = str_replace('str_replace', 'str_replace', $buffer);
    39 $buffer = str_replace(array("\r\n","\r","\n"), '', $buffer);
    40 return $buffer;
    41 flush();
    42 if ( ! is_admin() ) {
    43 $headers['Vary'] = 'User-Agent';
    44 return $headers;
    45 }
    46 }
    47 if ( !class_exists( 'JCP_UseGoogleLibraries' ) ) {
    48 
    49     if ( ! defined( 'WP_CONTENT_URL' ) )
    50         define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
    51     if ( ! defined( 'WP_CONTENT_DIR' ) )
    52         define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
    53     if ( ! defined( 'WP_PLUGIN_URL' ) )
    54         define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
    55     if ( ! defined( 'WP_PLUGIN_DIR' ) )
    56         define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
    57 
    58     class JCP_UseGoogleLibraries {
    59 
    60         private static $instance;
    61         private static $version = '1.5';
    62         public static function get_instance() {
    63             if ( !isset( self::$instance ) ) {
    64                 self::$instance =  new JCP_UseGoogleLibraries();
    65             }
    66             return self::$instance;
    67         }
    68 protected $google_scripts;
    69         protected $noconflict_url;
    70         protected $noconflict_next;
    71         protected $is_ssl;
    72         protected static $cache_id = 'JCP_UseGoogleLibraries_cache';
    73         protected static $cache_len = 90000; // 25 hours
    74         protected static $script_before_init_notice =
    75             'Another plugin has registered or enqued a script before the "init" action.  Attempting to work around it.';
    76         function JCP_UseGoogleLibraries() {$this->__construct();}
    77         function __construct() {
    78             $this->google_scripts =
    79                 array(
    80 
    81                 // 'script-handle' => ( 'google-lib-path', 'google-file-name', 'google-combined-into'),
    82                 'jquery' => array( 'jquery', 'jquery.min', '' ),
    83                 'jquery-ui-core' => array( 'jqueryui', 'jquery-ui.min', '' ),
    84                 'jquery-ui-accordion' => array( '', '', 'jquery-ui-core' ),
    85                 'jquery-ui-autocomplete' => array( '', '', 'jquery-ui-core' ),
    86                 'jquery-ui-button' => array( '', '', 'jquery-ui-core' ),
    87                 'jquery-ui-datepicker' => array( '', '', 'jquery-ui-core' ),
    88                 'jquery-ui-dialog' => array( '', '', 'jquery-ui-core' ),
    89                 'jquery-ui-draggable' => array( '', '', 'jquery-ui-core' ),
    90                 'jquery-ui-droppable' => array( '', '', 'jquery-ui-core' ),
    91                 'jquery-ui-menu' => array( '', '', 'jquery-ui-core' ),
    92                 'jquery-ui-mouse' => array( '', '', 'jquery-ui-core' ),
    93                 'jquery-ui-position' => array( '', '', 'jquery-ui-core' ),
    94                 'jquery-ui-progressbar' => array( '', '', 'jquery-ui-core' ),
    95                 'jquery-ui-resizable' => array( '', '', 'jquery-ui-core' ),
    96                 'jquery-ui-selectable' => array( '', '', 'jquery-ui-core' ),
    97                 'jquery-ui-slider' => array( '', '', 'jquery-ui-core' ),
    98                 'jquery-ui-sortable' => array( '', '', 'jquery-ui-core' ),
    99                 'jquery-ui-tabs' => array( '', '', 'jquery-ui-core' ),
    100                 'jquery-ui-widget' => array( '', '', 'jquery-ui-core' ),
    101                 'jquery-effects-core' => array( '', '', 'jquery-ui-core' ),
    102                 'jquery-effects-blind' => array( '', '', 'jquery-ui-core' ),
    103                 'jquery-effects-bounce' => array( '', '', 'jquery-ui-core' ),
    104                 'jquery-effects-clip' => array( '', '', 'jquery-ui-core' ),
    105                 'jquery-effects-drop' => array( '', '', 'jquery-ui-core' ),
    106                 'jquery-effects-explode' => array( '', '', 'jquery-ui-core' ),
    107                 'jquery-effects-fade' => array( '', '', 'jquery-ui-core' ),  /* jQuery UI 1.8 */
    108                 'jquery-effects-fold' => array( '', '', 'jquery-ui-core' ),
    109                 'jquery-effects-highlight' => array( '', '', 'jquery-ui-core' ),
    110                 'jquery-effects-pulsate' => array( '', '', 'jquery-ui-core' ),
    111                 'jquery-effects-scale' => array( '', '', 'jquery-ui-core' ),
    112                 'jquery-effects-shake' => array( '', '', 'jquery-ui-core' ),
    113                 'jquery-effects-slide' => array( '', '', 'jquery-ui-core' ),
    114                 'jquery-effects-transfer' => array( '', '', 'jquery-ui-core' ),
    115                 'prototype' => array( 'prototype', 'prototype', '' ),
    116                 'scriptaculous-root' => array( 'scriptaculous', 'scriptaculous', '' ),
    117                 'scriptaculous-builder' => array( '', '', 'scriptaculous-root' ),
    118                 'scriptaculous-effects' => array( '', '', 'scriptaculous-root' ),
    119                 'scriptaculous-dragdrop' => array( '', '', 'scriptaculous-root' ),
    120                 'scriptaculous-controls' => array( '', '', 'scriptaculous-root' ),
    121                 'scriptaculous-slider' => array( '', '', 'scriptaculous-root' ),
    122                 'scriptaculous-sound' => array( '', '', 'scriptaculous-root' ),
    123                 'mootools' => array( 'mootools', 'mootools-yui-compressed', '' ),
    124                 'dojo' => array( 'dojo', 'dojo.xd', '' ),
    125                 'swfobject' => array( 'swfobject', 'swfobject', '' ),
    126                 'yui' => array( 'yui', 'build/yuiloader/yuiloader-min', '' ),
    127                 'ext-core' => array( 'ext-core', 'ext-core', '' )
    128 
    129             );
    130             $this->noconflict_url = WP_PLUGIN_URL . '/use-google-libraries/js/jQnc.js';
    131 
    132             $this->noconflict_next = FALSE;
    133             $is_ssl = false;
    134             if ( ( function_exists( 'getenv' ) and
    135                     ( ( getenv( 'HTTPS' ) != '' and getenv( 'HTTPS' ) != 'off' )
    136                         or
    137                         ( getenv( 'SERVER_PORT' ) == '433' ) ) )
    138                 or
    139                 ( isset( $_SERVER ) and
    140                     ( ( isset( $_SERVER['HTTPS'] ) and $_SERVER['HTTPS'] !='' and $_SERVER['HTTPS'] != 'off' )
    141                         or
    142                         ( isset( $_SERVER['SERVER_PORT'] ) and $_SERVER['SERVER_PORT'] == '443' ) ) ) ) {
    143                 $is_ssl = true;
    144             }
    145             $this->is_ssl = $is_ssl;
    146         }
    147 
    148         static function configure_plugin() {
    149             add_action( 'wp_default_scripts',
    150                 array( 'JCP_UseGoogleLibraries',
    151                     'replace_default_scripts_action' ),
    152                 1000 );
    153             add_filter( 'script_loader_src',
    154                 array( "JCP_UseGoogleLibraries", "remove_ver_query_filter" ),
    155                 1000 );
    156             add_filter( 'init', array( "JCP_UseGoogleLibraries", "setup_filter" ) );
    157             global $wp_scripts;
    158             if ( is_a( $wp_scripts, 'WP_Scripts' ) ) {
    159                 self::debug( self::$script_before_init_notice );
    160                 $ugl = self::get_instance();
    161                 $ugl->replace_default_scripts( $wp_scripts );
    162             }
    163         }
    164 static function script_before_init_admin_notice() {
    165             echo '<div class="error fade"><p>Use Google Libraries: ' . self::$script_before_init_notice . '</p></div>';
    166         }
    167 
    168         static function setup_filter() {
    169             $ugl = self::get_instance();
    170             $ugl->setup();
    171         }
    172         static function debug( $message ) {
    173             if ( WP_DEBUG !== false ) {
    174                 if ( is_array( $message ) || is_object( $message ) ) {
    175                     $message = print_r( $message, true );
    176                 }
    177                 error_log( "Use Google Libraries: " . $message );
    178             }
    179         }
    180         function setup() {
    181             global $concatenate_scripts;
    182             $concatenate_scripts = false;
    183 
    184         }
    185         static function replace_default_scripts_action( &$scripts ) {
    186             $ugl = self::get_instance();
    187             $ugl->replace_default_scripts( $scripts );
    188         }
    189         function build_newscripts( &$scripts ) {
    190             $newscripts = array();
    191             $combine_ok = array();
    192             foreach ( $this->google_scripts as $name => $values ) {
    193                 if ( $script = $scripts->query( $name ) ) {
    194                     $lib = $values[0];
    195                     $js = $values[1];
    196                     $combined = $values[2];
    197 
    198                     // default to requested ver
    199                     $ver = $script->ver;
    200 
    201                     if ( strpos( $ver, '-' ) !== false ) {
    202                         self::debug( "WordPress appears to be requesting a non-standard version of $name (version $ver). Using version provided by WordPress to ensure compatability." );
    203                         continue;
    204                     }
    205 
    206                     // TODO: replace with more flexible option
    207                     // quick and dirty work around for scriptaculous 1.8.0
    208                     if ( $name == 'scriptaculous-root' && $ver == '1.8.0' ) {
    209                         $ver = '1.8';
    210                     }
    211 
    212                     if ( $combined !== '' ) {
    213                         if ( ! in_array( $combined, $combine_ok ) ) {
    214                             self::debug( "Google servers not hosting combined library for $name (version $ver). Using version provided by WordPress to ensure compatability." );
    215                             continue;
    216                         }
    217                         if ( ! in_array( $combined, $script->deps ) ) {
    218                             // if this script has been combined into another script
    219                             // ensure this handle depends on the combined handle
    220                             $script->deps[] = $combined;
    221                         }
    222                     }
    223                     if ( $lib != '' ) {
    224                         // build new URL
    225                         $url = "http://ajax.googleapis.com/ajax/libs/$lib/$ver/$js.js";
    226                         if ( wp_remote_retrieve_response_code( wp_remote_head( $url ) ) !== 200 ) {
    227                             self::debug( "Google servers do not seem to be hosting requested version of $name (version $ver). Using version provided by WordPress." );
    228                             continue;
    229                         }
    230                         $script->src = $url;
    231                     } else {
    232                         $script->src = "";
    233                     }
    234                     $newscripts[] = $script;
    235                     $combine_ok[] = $name;
    236                 }
    237             }
    238             return $newscripts;
    239 
    240         }
    241         function get_newscripts( &$scripts ) {
    242             $wp_ver = get_bloginfo( 'version' );
    243             if ( false === ( $cache = get_transient( self::$cache_id ) ) ) {
    244                 $cache = array();
    245             }
    246             if ( ( ! isset( $cache['ugl_ver'] ) ) || ( $cache['ugl_ver'] !== self::$version ) ||
    247                 ( ! isset( $cache['wp_ver'] ) ) || ( $cache['wp_ver'] !== $wp_ver ) ||
    248                 ( ! isset( $cache['newscripts'] ) ) ) {
    249                 $newscripts = $this->build_newscripts( $scripts );
    250                 $cache = array(
    251                     'ugl_ver' => self::$version,
    252                     'wp_ver' => $wp_ver,
    253                     'newscripts' => $newscripts,
    254                 );
    255                 set_transient( self::$cache_id, $cache, self::$cache_len );
    256             } else {
    257                 $newscripts = $cache['newscripts'];
    258             }
    259             // need to handle ssl after cache load, because it may swap
    260             // back and forth depending on the site config/usage
    261             if ( $this->is_ssl === true ) {
    262                 foreach ( $newscripts as $script ) {
    263                     $script->src = preg_replace( '/^http:/', 'https:', $script->src );
    264                 }
    265             }
    266             return $newscripts;
    267         }
    268         function replace_default_scripts( &$scripts ) {
    269             $newscripts = $this->get_newscripts( $scripts );
    270             foreach ( $newscripts as $script ) {
    271                 $olddata = $this->WP_Dependency_get_data( $scripts, $script->handle );
    272                 $scripts->remove( $script->handle );
    273                 // re-register with original ver
    274                 $scripts->add( $script->handle, $script->src, $script->deps, $script->ver );
    275                 if ( $olddata )
    276                     foreach ( $olddata as $data_name => $data ) {
    277                         $scripts->add_data( $script->handle, $data_name, $data );
    278                     }
    279             }
    280         }
    281 
    282 
    283         function WP_Dependency_get_data( $dep_obj, $handle, $data_name = false ) {
    284 
    285             if ( !method_exists( $dep_obj, 'add_data' ) )
    286                 return false;
    287 
    288             if ( !isset( $dep_obj->registered[$handle] ) )
    289                 return false;
    290 
    291             if ( !$data_name )
    292                 return $dep_obj->registered[$handle]->extra;
    293 
    294             return $dep_obj->registered[$handle]->extra[$data_name];
    295         }
    296         function remove_ver_query( $src ) {
    297             if ( $this->noconflict_next ) {
    298                 $this->noconflict_next = FALSE;
    299                 echo "<script type='text/javascript'>try{jQuery.noConflict();}catch(e){};</script>\n";
    300             }
    301             if ( preg_match( '/ajax\.googleapis\.com\//', $src ) ) {
    302                 $src = remove_query_arg( 'ver', $src );
    303                 if ( strpos( $src, $this->google_scripts['jquery'][1] . ".js" ) ) {
    304                     $this->noconflict_next = TRUE;
    305                 }
    306             }
    307             return $src;
    308         }
    309 
    310         static function remove_ver_query_filter( $src ) {
    311             $ugl =  self::get_instance();
    312             return $ugl->remove_ver_query( $src );
    313         }
    314     }
    315 }
    316 if ( class_exists( 'JCP_UseGoogleLibraries' ) ) {
    317     JCP_UseGoogleLibraries::configure_plugin();
    318 class comcleaner {
    319     const VERSION = '1.0';
    320     const GROUP   = 'mo';
    321 public static function setup() {
    322         add_filter(
    323             'override_load_textdomain', array( new self, 'load' ), 10, 3 );
    324     }
    325 
    326     public function load( $override, $domain, $mofile ) {
    327         global $l10n;
    328 
    329         do_action( 'load_textdomain', $domain, $mofile );
    330         $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
    331         if ( !is_readable( $mofile ) ) return false;
    332 
    333         if ( function_exists( 'wp_cache_add_global_groups' ) ) {
    334             wp_cache_add_global_groups( self::GROUP );
    335         }
    336         $key = preg_replace('/[^-\w]/', '_',
    337             self::VERSION . "-${GLOBALS['wp_version']}-$mofile");
    338 
    339         $mo = new MO();
    340         if ( $cache = wp_cache_get( $key, self::GROUP ) ) {
    341             $mo->entries = $cache['entries'];
    342             $mo->set_headers( $cache['headers'] );
    343         } else {
    344             if ( !$mo->import_from_file( $mofile ) ) return false;
    345             $cache = array(
    346                 'entries' => $mo->entries,
    347                 'headers' => $mo->headers,
    348             );
    349             wp_cache_set( $key, $cache, self::GROUP );
    350         }
    351 
    352         if ( isset( $l10n[$domain] ) )
    353             $mo->merge_with( $l10n[$domain] );
    354         $l10n[$domain] = &$mo;
    355         return true;
    356     }
    357 }
    358 comcleaner::setup();
    359 }
    360 }
     10require_once('nopingback.php');
     11require_once('nomorelink.php');
     12require_once('headclean.php');
     13?>
Note: See TracChangeset for help on using the changeset viewer.