久々のハックネタです。
ハックといっても大袈裟なものではなく、ただ余計なPHPの呼び出しを止めましょうって話です。
といっても、それほど効果があるわけではないかもしれませんが、サーバーには優しいので興味があれば試されてはいかがでしょうか?
出来るだけ少ない変更で効果がある箇所を修正したいので、まずはヘッダーと、フッターの呼び出しを少なくしましょう。
では一番簡単で、一度決めると変更されない タイトルの呼び出しを中止します。
ちなみに、ここから先は、うちで使用しているテーマ「K2]を例にしてカスタマイズしてみます。
Blogのアドレスとタイトル
CODE:
-
<h1><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
こちらを、うちのBlogのアドレスとタイトル「orioa]に置き換えます。
CODE:
-
<h1><a href="http://www.orioa.com/">orioa</a></h1>
テーマのスタイルシートの呼び出し。
CODE:
-
<link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_url'); ?>" />
こちらを
CODE:
-
<link rel="stylesheet" type="text/css" media="screen" href="http://www.orioa.com/wp-content/themes/K2/style.css" />
meta情報をまとめて変更
CODE:
-
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
-
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
-
<meta name="template" content="K2 <?php k2info('version'); ?>" />
-
<meta name="description" content="<?php bloginfo('description'); ?>" />
これを必要なのか分からないが・・・とりあえず変更
CODE:
RSSのアドレスも変更
CODE:
-
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
-
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
-
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
CODE:
-
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.orioa.com/feed/" />
-
<link rel="alternate" type="text/xml" title="RSS .92" href="http://www.orioa.com/feed/rss/" />
-
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://www.orioa.com/feed/atom/" />
ヘッダーはこのぐらいにして、つぎはフッターを変更したいと思います。
CODE:
-
<p class="footerpoweredby"><?php printf( __('Powered by %1$s and %2$s','k2_domain'),
-
sprintf('<a href="http://wordpress.org/">%1$s<!-- %2$s--></a>',
-
get_bloginfo('version')
-
),
-
sprintf('<a href="http://getk2.com/" title="%1$s">K2<!-- %2$s--></a>',
-
__('Loves you like a kitten.','k2_domain'),
-
get_k2info('version')
-
)
-
); ?></p>
こちらを
CODE:
RSSへのリンクを
CODE:
-
<p class="footerfeedlinks"><?php printf(__('<a href="%1$s">Entries Feed</a> and <a href="%2$s">Comments Feed</a>','k2_domain'), get_bloginfo('rss2_url'), get_bloginfo('comments_rss2_url')) ?></p>
こちらに
CODE:
-
<p class="footerfeedlinks"><a href="http://www.orioa.com/feed/">Entries Feed</a> and <a href="http://www.orioa.com/comments/feed/">Comments Feed</a></p>
と、なかなかの量ですが、体感的に変化があったような感じがします。
オリジナルテーマを使ってる方、もしくはテーマを変更する予定のない方は有効な手段ではないでしょうか?









0 Responses to “WP Hack : PHPの不要な呼び出しを少なくして高速化する!”