public function get_fees_for_category($catid) { $fees = array(); if (wpbdp_payments_api()->payments_possible()) { $parent_categories = wpbdp_get_parent_categories($catid); array_walk($parent_categories, create_function('&$x', '$x = intval($x->term_id);')); foreach ($this->get_fees() as $fee) { if ($fee->categories['all']) { $fees[] = $fee; } else { foreach ($fee->categories['categories'] as $fee_catid) { if (in_array($fee_catid, $parent_categories)) { $fees[] = $fee; break; } } } } } if (!$fees) { $fees[] = $this->get_free_fee(); } return $fees; }
function wpbdp_get_parent_catids($catid) { $parent_categories = wpbdp_get_parent_categories($catid); array_walk($parent_categories, create_function('&$x', '$x = intval($x->term_id);')); return $parent_categories; }