Index: wp-includes/capabilities.php
===================================================================
--- wp-includes/capabilities.php	(revision 3614)
+++ wp-includes/capabilities.php	(working copy)
@@ -393,6 +393,107 @@
 	return $caps;
 }
 
+// Third party registration of additional capabilities, without assignment to a particular role
+function register_cap($cap) {
+	$caplist = get_settings('caplist');
+	if ( !in_array($cap, (array) $caplist) ) {
+		$caplist[] = $cap;
+		$caplist = array_unique($caplist);
+		sort($caplist);
+		update_option('caplist', $caplist);
+	}
+}
+
+// Third party unregistration of additional capabilities
+// This will NOT remove the capability from any roles that have it
+function unregister_cap($cap) {
+	$caplist = get_settings('caplist');
+	if ( in_array($cap, (array) $caplist) ) {
+		$caplist = array_unique($caplist);
+		sort($caplist);
+		$caplist = array_diff((array) $caplist, array($cap));
+		update_option('caplist', $caplist);
+	}
+}
+
+// Third party fetching of all possible capabilities (WP default + third party)
+// Mostly taken from Owen Winkler's Role Manager plugin
+function get_all_caps() {
+	global $wp_roles;
+
+	// Get Role List
+	foreach ( $wp_roles->role_objects as $key => $role ) {
+		foreach ( $role->capabilities as $cap => $grant ) {
+			$capnames[$cap] = $cap;
+		}
+	}
+
+	// Get third party caps
+	$other_caps = get_option('caplist');
+
+	// Get default WP caps
+	$default_caps = array(
+		'activate_plugins',
+		'delete_others_pages',
+		'delete_others_posts',
+		'delete_pages',
+		'delete_posts',
+		'delete_published_pages',
+		'delete_published_posts',
+		'edit_files',
+		'edit_others_pages',
+		'edit_others_posts',
+		'edit_pages',
+		'edit_plugins',
+		'edit_posts',
+		'edit_published_pages',
+		'edit_published_posts',
+		'edit_themes',
+		'edit_users',
+		'import',
+		'level_0',
+		'level_1',
+		'level_10',
+		'level_2',
+		'level_3',
+		'level_4',
+		'level_5',
+		'level_6',
+		'level_7',
+		'level_8',
+		'level_9',
+		'manage_categories',
+		'manage_links',
+		'manage_options',
+		'moderate_comments',
+		'publish_pages',
+		'publish_posts',
+		'read',
+		'switch_themes',
+		'unfiltered_html',
+		'upload_files'
+	);
+
+	if ( !is_array($capnames) )
+		$capnames = array();
+	if ( !is_array($other_caps) )
+		$other_caps = array();
+
+	// Cleanup
+	$capnames = array_merge($capnames, $other_caps, $default_caps);
+	$capnames = array_unique($capnames);
+	sort($capnames);
+
+	// Remove roles, we just want capabilities
+	foreach ( $wp_roles->get_names() as $role ) {
+		$key = array_search($role, $capnames);
+		if ( $key !== false && $key !== null ) //array_search() returns null if not found in PHP 4.1
+			unset($capnames[$key]);
+	}
+
+	return apply_filters('get_all_caps', $capnames);
+}
+
 // Capability checking wrapper around the global $current_user object.
 function current_user_can($capability) {
 	$current_user = wp_get_current_user();
