PHP头条
热点:

各位php高手帮小弟我看看这段代码是什么意思


各位php高手帮我看看这段代码是什么意思


function apply_filters($tag, $value) {
global $wp_filter, $merged_filters, $wp_current_filter;

$args = array();

if ( isset($wp_filter['all']) ) {
$wp_current_filter[] = $tag;
$args = func_get_args();
_wp_call_all_hook($args);
}

if ( !isset($wp_filter[$tag]) ) {
if ( isset($wp_filter['all']) )
array_pop($wp_current_filter);
return $value;
}

if ( !isset($wp_filter['all']) )
$wp_current_filter[] = $tag;

if ( !isset( $merged_filters[ $tag ] ) ) {
ksort($wp_filter[$tag]);
$merged_filters[ $tag ] = true;
}

reset( $wp_filter[ $tag ] );

if ( empty($args) )
$args = func_get_args();

do {
foreach( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) ){
$args[1] = $value;
$value = call_user_func_array($the_['function'], array_slice($args, 1, (int) $the_['accepted_args']));
}

} while ( next($wp_filter[$tag]) !== false );

array_pop( $wp_current_filter );

return $value;
}



function the_permalink() {
echo apply_filters('the_permalink', get_permalink());
}
分享到:
------解决方案--------------------
常用函数-apply_filters()
说明
调用添加到过滤器hook上的函数。在Plugin API上查看过滤器hook列表。
通过调用该函数,可以调用附着在过滤器hook $tag上的回调函数。用$tag参数所指定的新hook的名称调用该函数,可创建一个新的过滤器hook。
用法
 
参数
$tag
(字符串)(必需)过滤器hook的名称
默认值:None
$value
(混合)(必需)连接到$tag上的过滤器可能修改的值
默认值:None
返回的值
(混合)所有连接函数都应用到该函数后,返回$value的结果。
注意:返回值的类型应与$value类型一致,如字符串或数组。
使用方法:

$tag:可以自定义任意值
$value:可以自定义任意值

------解决方案--------------------
引用:
Quote: 引用:

常用函数-apply_filters()
说明
调用添加到过滤器hook上的函数。在Plugin API上查看过滤器hook列表。
通过调用该函数,可以调用附着在过滤器hook $tag上的回调函数。用$tag参数所指定的新hook的名称调用该函数,可创建一个新的过滤器hook。
用法
 
参数
$tag
(字符串)(必需)过滤器hook的名称
默认值:None
$value
(混合)(必需)连接到$tag上的过滤器可能修改的值
默认值:None
返回的值
(混合)所有连接函数都应用到该函数后,返回$value的结果。
注意:返回值的类型应与$value类型一致,如字符串或数组。
使用方法:

$tag:可以自定义任意值
$value:可以自定义任意值


过滤器hook? 是什么东西?
我选择用wordpress做一个博客,先在blog.php页面中显示全部博文(分页),然后点击标题进入完整博文内容。
为什么当我点击博文标题, 就跳转到了index.php页面, 如果是别人写好的模板,在index.php中显示全部博文,点击标题后在index.php中显示完整博文,为什么换了个页面就不可以了?代码大概如下:

//检查是否有日志
    //当博文有日志时 就循环
        " title="">

www.phpzy.comtrue/phprm/6251.htmlTechArticle各位php高手帮小弟我看看这段代码是什么意思 各位php高手帮我看看这段代码是什么意思 functionapply_filters($tag,$value){ global$wp_filter,$merged_filters,$wp_current_filter; $args=array(); if(isset($wp_filter[...

相关文章

相关频道:

PHP之友评论

今天推荐