Wordpress-应用我可以使用的过滤器';无法连接到任何添加过滤器

Wordpress-应用我可以使用的过滤器';无法连接到任何添加过滤器,wordpress,add-filter,Wordpress,Add Filter,我正在尝试编辑WoodPress(woocommerce)的插件,我经常发现一些行使用了apply\u filter功能,例如: return apply_filters ( 'woocommerce_get_variation_sale_price', $price, $this, $min_or_max, $display ); 不幸的是,我无法理解这个过滤器的作用,因为我无法追踪标签的使用位置。我扫描了(在eclipse中搜索)工作区,没有任何运气,我找不到任何add\u filter“

我正在尝试编辑WoodPress(woocommerce)的插件,我经常发现一些行使用了
apply\u filter
功能,例如:

return apply_filters ( 'woocommerce_get_variation_sale_price', $price, $this, $min_or_max, $display );
不幸的是,我无法理解这个过滤器的作用,因为我无法追踪标签的使用位置。我扫描了(在eclipse中搜索)工作区,没有任何运气,我找不到任何
add\u filter
“woocmerc\u get\u variation\u sale\u price”

这怎么可能?正在阅读两个函数的文档,它们应该连接在一起

我被卡住了

应用过滤器()
函数将执行使用
添加过滤器($hook,$function\u name,$priority,$num\u arguments)钩住的任何函数
,剩余值作为参数传递给函数。这通常是WordPress操作和过滤器挂钩如何扩展核心WordPress或插件的功能的——在本例中是WooCommerce

这意味着示例中的代码可以选择性地用于让您或其他插件更改插件返回的
$price
的值。它为您提供父对象(
$this
)以及有关用于计算价格的变量的其他信息

如果您找不到该字符串的任何其他引用(您的示例在筛选器名称中缺少一个“e”),则表示没有任何内容连接到该筛选器并修改
$price
的值

如果您想在返回
$price
之前添加一个钩子来过滤它的值,它将如下所示

// the name of the filter, the hooked function, the priority, and the # of args
add_filter( 'woocommerce_get_variation_sale_price', 'my_woocommerce_get_variation_sale_price', 10, 4 ); 
function my_woocommerce_get_variation_sale_price( $price, $product, $min_or_max, $display ){
    // Use the arguments to do whatever you want to 
    // the $price before it is returned.
    return $price;
}
apply\u filters()
函数将使用
add\u filter($hook,$function\u name,$priority,$num\u arguments)
执行已连接到它的任何函数,剩余值作为参数传递给函数。这通常是WordPress操作和过滤器挂钩如何扩展核心WordPress或插件的功能的——在本例中是WooCommerce

这意味着示例中的代码可以选择性地用于让您或其他插件更改插件返回的
$price
的值。它为您提供父对象(
$this
)以及有关用于计算价格的变量的其他信息

如果您找不到该字符串的任何其他引用(您的示例在筛选器名称中缺少一个“e”),则表示没有任何内容连接到该筛选器并修改
$price
的值

如果您想在返回
$price
之前添加一个钩子来过滤它的值,它将如下所示

// the name of the filter, the hooked function, the priority, and the # of args
add_filter( 'woocommerce_get_variation_sale_price', 'my_woocommerce_get_variation_sale_price', 10, 4 ); 
function my_woocommerce_get_variation_sale_price( $price, $product, $min_or_max, $display ){
    // Use the arguments to do whatever you want to 
    // the $price before it is returned.
    return $price;
}
apply\u filters()
函数将使用
add\u filter($hook,$function\u name,$priority,$num\u arguments)
执行已连接到它的任何函数,剩余值作为参数传递给函数。这通常是WordPress操作和过滤器挂钩如何扩展核心WordPress或插件的功能的——在本例中是WooCommerce

这意味着示例中的代码可以选择性地用于让您或其他插件更改插件返回的
$price
的值。它为您提供父对象(
$this
)以及有关用于计算价格的变量的其他信息

如果您找不到该字符串的任何其他引用(您的示例在筛选器名称中缺少一个“e”),则表示没有任何内容连接到该筛选器并修改
$price
的值

如果您想在返回
$price
之前添加一个钩子来过滤它的值,它将如下所示

// the name of the filter, the hooked function, the priority, and the # of args
add_filter( 'woocommerce_get_variation_sale_price', 'my_woocommerce_get_variation_sale_price', 10, 4 ); 
function my_woocommerce_get_variation_sale_price( $price, $product, $min_or_max, $display ){
    // Use the arguments to do whatever you want to 
    // the $price before it is returned.
    return $price;
}
apply\u filters()
函数将使用
add\u filter($hook,$function\u name,$priority,$num\u arguments)
执行已连接到它的任何函数,剩余值作为参数传递给函数。这通常是WordPress操作和过滤器挂钩如何扩展核心WordPress或插件的功能的——在本例中是WooCommerce

这意味着示例中的代码可以选择性地用于让您或其他插件更改插件返回的
$price
的值。它为您提供父对象(
$this
)以及有关用于计算价格的变量的其他信息

如果您找不到该字符串的任何其他引用(您的示例在筛选器名称中缺少一个“e”),则表示没有任何内容连接到该筛选器并修改
$price
的值

如果您想在返回
$price
之前添加一个钩子来过滤它的值,它将如下所示

// the name of the filter, the hooked function, the priority, and the # of args
add_filter( 'woocommerce_get_variation_sale_price', 'my_woocommerce_get_variation_sale_price', 10, 4 ); 
function my_woocommerce_get_variation_sale_price( $price, $product, $min_or_max, $display ){
    // Use the arguments to do whatever you want to 
    // the $price before it is returned.
    return $price;
}

我不明白你为什么说过滤器名称缺少一个“e”,我检查了(复制粘贴)该行是正确的,实际上我找不到该特定过滤器名称的任何其他引用。这意味着我在文件中看到的每个apply_过滤器都是无用的?那他们为什么要放呢?这对我来说没有太大意义,尽管你所说的如何添加和应用工作是正确的。。。我在这里也检查了,我关于这个钩子从来没有有效地钩住一个函数的理论是正确的……我不明白为什么你说过滤器名称缺少一个“e”,我检查了(复制粘贴)这行是正确的,事实上我找不到任何其他关于特定过滤器名称的引用。这意味着我在文件中看到的每个apply_过滤器都是无用的?那他们为什么要放呢?这对我来说没有太大意义,尽管你所说的如何添加和应用工作是正确的。。。我在这里也检查过,我的理论是关于这个钩子永远不会有效地钩住一个函数的事实是正确的…我不明白为什么你说