public function get_levels($args = array())
{
global $wpdb;
$defaults = array('status' => 'all', 'limit' => null, 'orderby' => 'list_order');
$args = wp_parse_args($args, $defaults);
if ($args['status'] == 'active') {
$where = "WHERE `status` !='inactive'";
} elseif ($args['status'] == 'inactive') {
$where = "WHERE `status` ='{$status}'";
} else {
$where = "";
}
if (!empty($args['limit'])) {
$limit = " LIMIT={$args['limit']}";
} else {
$limit = '';
}
$cache_key = md5(implode('|', $args) . $where);
$levels = wp_cache_get($cache_key, 'rcp');
if (false === $levels) {
$levels = $wpdb->get_results("SELECT * FROM {$this->db_name} {$where} ORDER BY {$args['orderby']}{$limit};");
wp_cache_set($cache_key, $levels, 'rcp');
}
$levels = apply_filters('rcp_get_levels', $levels);
if (!empty($levels)) {
return $levels;
}
return false;
}