我想知道下面的逻辑是否正确,是否应该在某些情况下让它工作,因为在某些情况下它似乎不工作。
下面的例子很简单。假设我想使用一个函数,它是在主题相关文件的其他地方定义的parent_theme_hooks.php
, 通过我的孩子主题中的动作钩functions.php
.
parent_theme_hooks.php
function is_enabled(){
return true;
}
function check_if_enabled(){
do_action( \'my_hook\', $some, $args );
}
然后在儿童主题中functions.phpfunction my_function($some, $args) {
if ( is_enabled() ) {
$message = \'yes\';
} else {
$message = \'no\';
}
echo $message;
}
add_action( \'my_hook\', \'my_function\', 11, 2 );
Question所以我的问题是我是否可以使用这个函数is_enabled()
在子主题中functions.php
何时在父主题的其他地方定义?谢谢