Skip to content

Instantly share code, notes, and snippets.

@miya0001
Created May 4, 2011 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miya0001/954903 to your computer and use it in GitHub Desktop.
Save miya0001/954903 to your computer and use it in GitHub Desktop.
add_actionの使い方
<?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