从codex中,关于过滤器挂钩:
bloginfo_url
applied to the the output of bloginfo("url"), bloginfo("directory") and bloginfo("home") before returning the information.
我有没有办法更精确地说明这一点?这样我就可以在bloginfo("url")
例如从codex中,关于过滤器挂钩:
bloginfo_url
applied to the the output of bloginfo("url"), bloginfo("directory") and bloginfo("home") before returning the information.
我有没有办法更精确地说明这一点?这样我就可以在bloginfo("url")
例如您可以使用过滤器函数中的附加变量来访问它。
过滤器bloginfo_url
使用$show
参数(调用时使用的参数bloginfo
) 并将其传递给apply_filters
.
所以我开始bloginfo_url
应该没问题,您只需在函数内部进行切换,它仅适用于。url
.
这将是您的代码:
add_filter(\'bloginfo_url\', \'f711_bloginfo_url_filter\', 10, 2 );
它告诉您挂接的位置、回调函数、与其他过滤器相比应用回调函数的优先级,以及可以传递给函数的参数数。这是您的重要部分,因为1是标准值。在回调函数中:
function f711_bloginfo_url_filter( $output, $show ) {
if ( $show == \'url\' ) {
$output = "this";//whatever you want to do with it
}
return $output;
}
我是updating the codex page example for action hooks, 在游戏中完成一些可重用的功能(最初是针对这里的一些Q@WA)。但后来我遇到了一个以前没有意识到的问题:在挂接到一个函数以修改变量的输出后,我再也无法决定是要回显输出还是只返回它。The Problem: 我可以修改传递给do_action 用回调函数钩住。使用变量修改/添加的所有内容仅在回调函数中可用,但在do_action 在原始函数内部调用。很高兴:我将其修改为一个工作示例,因此您可以将其复制/粘贴