2012-02-22 63 views
0

我需要覆蓋WordPress插件中包含的小部件中的設置(插件是woocommerce)。我在插件的小部件代碼中找到了需要進行更改的地方(對於product_categories小部件,我想添加$ cat_args ['depth'] = 1;這樣我只能看到父類別),並且一切正常,但我希望能夠做到這一點,以便如果插件更新,它不會消除變化。我有一個我已經開發的自定義主題...有什麼方法可以在該主題中進行更改,以便我仍然可以安全地更新woocommerce?在WordPress插件小部件中覆蓋函數

回答

1

這樣做會問的Widget開發商這樣做的唯一方法:

$cat_args_depth = 1; 
$cat_args_depth = apply_filters('woocommerce_cat_args_depth', $cat_args_depth); 
$cat_args['depth'] = $cat_args_depth; 

,然後你可以只使用

add_filter('woocommerce_cat_args_depth', function($cat_args_depth) { 
    $cat_args_depth = 2; // your value 
    return $cat_args_depth ; 
}); 
+0

嗯,我害怕這一點。感謝您的迴應! – 2012-02-22 19:23:15