Created
May 4, 2011 08:03
-
-
Save miya0001/954903 to your computer and use it in GitHub Desktop.
add_actionの使い方
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
以下はどちらの方法が良いのでしょう? | |
add_action()を条件式の中に入れるべき? 関数の中に条件式を入れるべき? | |
*/ | |
/* 書くのがちょっとだけ楽 */ | |
if (is_home()) { | |
add_acton('init', 'foo'); | |
add_acton('wp_head', 'bar'); | |
} | |
function foo(){ | |
// some action | |
} | |
function bar(){ | |
// some action | |
} | |
/* めんどくさい */ | |
add_acton('init', 'foo'); | |
add_acton('wp_head', 'bar'); | |
function foo(){ | |
if (is_home()) { | |
// some action | |
} | |
} | |
function bar(){ | |
if (is_home()) { | |
// some action | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment