get_results(); } /** * Gets current category id. * * @global object $wp_query WP query object * @return int category id */ function get_current_category_id() { global $wp_query; if (!$wp_query->is_category) return 0; $cat_obj = $wp_query->get_queried_object(); return $cat_obj->term_id; } /** * Get all subcategories of a category. * * @param int $cat category id * @param bool $hide_empty hid or show empty categories * @return array subcatories */ function get_subcategories_ids($cat, $hide_empty = true) { $categories = get_categories(array("child_of" => $cat, "hide_empty" => $hide_empty)); $results = array(); foreach ($categories as $c) $results[] = $c->cat_ID; return $results; } /** * Get all custom fields from post meta. * * @global object $wpdb database object * @param bool $hidden include hidden fields * @return array field names */ function get_all_custom_fieds($hidden = true) { global $wpdb; $sql = "select distinct meta_key from ".$wpdb->postmeta; if (!$hidden) $sql.= " where SUBSTR(meta_key, 1, 1) != '_'"; $elements = $wpdb->get_results($sql); $result = array(); foreach ($elements as $el) $result[] = $el->meta_key; return $result; } } if (!function_exists("wp_redirect_self")) { /** * Redirects back to the same page. */ function wp_redirect_self() { wp_redirect($_SERVER['REQUEST_URI']); } } } if (!function_exists("_n")) { function _n() { $args = func_get_args(); return call_user_func_array('__ngettext', $args); } } ?>