我需要从插件中删除内容过滤器的帮助:
add_filter( \'the_content\', array( &$this, \'addContentAds\' ), 8 );
有人能帮我吗?谢谢并致以最良好的问候
我需要从插件中删除内容过滤器的帮助:
add_filter( \'the_content\', array( &$this, \'addContentAds\' ), 8 );
有人能帮我吗?谢谢并致以最良好的问候
由于筛选器出现在类中,因此必须通过替换$this
(由于您没有在类上运行remove\\u筛选器,$此选项不可用)以及声明它的类的名称。
以一个名为:Wecba的类为例,您将按如下方式删除它:
remove_filter(\'the_content\', array(\'Wecba\', \'add_Content_Ads\'), 8);
否仅取决于类名。希望有帮助
WordPress 4.7简介WP_Hook
班全局变量$wp_filter
现在是WP_Hook
对象,每个“钩子”对应一个,钩子上附加了过滤器。这使得移除过滤器非常容易。
您仍然可以使用remove_filter
函数,以处理回调函数未在类中声明的筛选器。
下面的代码,您可以粘贴到其中functions.php
将允许删除任何筛选器:
function remove_the_content_filter() {
global $wp_filter;
$hook = \'the_content\';
$callback = \'addContentAds\';
$priority = 8;
if ( !is_object( $wp_filter[ $hook ] ) )
// no filters for this $hook
return;
$prts = $wp_filter[ $hook ]->callbacks; // array
$prts_cnt = count( $prts );
$prty = $wp_filter[ $hook ]->callbacks[ $priority ]; // array
if ( !is_array( $prty ) )
// no filters with this $priority
return;
$prty_cnt = count( $prty );
foreach ( $prty as $key => $val ) {
if ( false != stripos( $key, $callback ) ) {
if ( ( 1 == $prts_cnt ) && ( 1 == $prty_cnt ) ) {
// our filter the one only
unset( $wp_filter[ $hook ] );
return;
} else {
if ( 1 == $prty_cnt ) {
// our filter the only one with this $priority
unset( $wp_filter[ $hook ]->callbacks[ $priority ] );
return;
} else {
// there are more filters with this $priority, remove our filter
unset( $wp_filter[ $hook ]->callbacks[ $priority ][ $key ] );
return;
}
}
}
}
}
add_action( \'wp_head\', \'remove_the_content_filter\' );
我在WP\\U查询中编写了一段代码,用于将字符串(内容)转换为数组(选项)。但这似乎是错误的!事实上,每次循环后,choices数组都是空的。但是str string不为null。如何将此数组处理为nutnull?任何帮助都将不胜感激。$first_query = new WP_Query( $args ); while ($first_query->have_posts()) : $first_query->the_post(); the_title(