如何应用此 WordPress 过滤器? [英] How do I apply this WordPress filter?

查看:22
本文介绍了如何应用此 WordPress 过滤器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助来应用这个 WordPress 过滤器...

I need help to apply this WordPress filter...

apply_filters( ‘wcmp_widget_vendor_product_sales_report_days_range’, 7, $requestData, $vendor );

这个过滤器是插件制造商(WC Marketplace)提供给我的——他们只是说为了显示销售超过 60 天的产品,你必须做自定义代码.为此使用这个过滤器 apply_filters('wcmp_widget_vendor_product_sales_report_days_range', 7, $requestData, $vendor ); 并将值更改为 7 到 60."

This filter is what has been provided to me by the plugin makers (WC Marketplace) - all they said was "in order to display product sold over 60 days, you have to do custom code. For this use this filter apply_filters( ‘wcmp_widget_vendor_product_sales_report_days_range’, 7, $requestData, $vendor ); and change the value change 7 to 60."

我是 WordPress 编码新手,不确定如何应用此过滤器.在他们的插件代码中对这个过滤器的唯一引用是在这个文件中 https://github.com/dualcube/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-ajax.php 在线 2905.

I am new to WordPress coding and am not sure how to go about applying this filter. The only reference to this filter in their plugins code is in this file https://github.com/dualcube/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-ajax.php on line 2905.

任何帮助都会很棒.我已经查看了 WordPress 参考资料,但我一无所知.

Any help would be great. I have already looked in the WordPress references but I am clueless.

推荐答案

在您主题的 functions.php 文件中使用此代码:

Use this code in your theme's functions.php file:

// To change the default value of `$days_range` from 7 days to 60 days
function lh_wcmp_vendor_custom_sales_report( $days_range ) {
    $days_range = 60; // you can adjust days here as you needed
    return $days_range;
}
add_filter( 'wcmp_widget_vendor_product_sales_report_days_range', 'lh_wcmp_vendor_custom_sales_report', 10 );

虽然我没有数据来测试它,但我相信它对你有用.

Though I don't have data to test it, but I am sure it will work for you.

这篇关于如何应用此 WordPress 过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆