/** * Add all the screen option columns * * @access public * @param mixed $columns The original columns. * @return array $columns The modified columns. */ function msa_all_audits_add_column($columns) { /** * Conditions */ $condition_categories = msa_get_condition_categories(); foreach ($condition_categories as $key => $condition_category) { $conditions = msa_get_conditions_from_category($key); foreach ($conditions as $key => $condition) { $columns[$key] = $condition['name']; } } /** * Attributes */ $attributes = msa_get_attributes(); foreach ($attributes as $slug => $attribute) { if (isset($attribute['name'])) { $columns[$slug] = $attribute['name']; } } return $columns; }
/** * Get all the columns that we want to display * * @access public */ function get_columns() { $columns['score'] = __('Score', 'msa'); $condition_categories = msa_get_condition_categories(); foreach ($condition_categories as $key => $condition_category) { $columns[$key] = $condition_category['name']; $conditions = msa_get_conditions_from_category($key); foreach ($conditions as $key => $condition) { $columns[$key] = $condition['name']; } } $attributes = msa_get_attributes(); foreach ($attributes as $key => $attribute) { $columns[$key] = $attribute['name']; } return $columns; }
/** * Get the score value for a condition category * * @access public * @param mixed $category The condition category. * @param mixed $score The score of the category. * @return float $score The relative weight of the category score. */ function msa_get_condition_catergory_score($category, $score) { $cat_conditions = msa_get_conditions_from_category($category); $cat_score = 0; $cat_weight = 0; foreach ($cat_conditions as $key => $cat_condition) { $cat_score += $score[$key] * $cat_condition['weight']; $cat_weight += $cat_condition['weight']; } return $cat_score / $cat_weight; }