Index: skinr.api.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr.api.php,v
retrieving revision 1.1
diff -u -p -r1.1 skinr.api.php
--- skinr.api.php	17 Dec 2010 22:15:24 -0000	1.1
+++ skinr.api.php	30 Dec 2010 22:29:44 -0000
@@ -100,8 +100,8 @@ function hook_skinr_config() {
  */
 function hook_skinr_api() {
   return array(
-    'api' => 1,
-    'path' => drupal_get_path('module', 'modulename'),
+    'api' => 2.0,
+    'directory' => 'skins',
   );
 }
 
Index: skinr.handlers.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr.handlers.inc,v
retrieving revision 1.9
diff -u -p -r1.9 skinr.handlers.inc
--- skinr.handlers.inc	20 Dec 2010 21:42:29 -0000	1.9
+++ skinr.handlers.inc	30 Dec 2010 22:29:44 -0000
@@ -149,8 +149,7 @@ function skinr_submit_handler(&$form, $f
  */
 function skinr_skinr_api() {
   return array(
-    'api' => 1,
-    'path' => drupal_get_path('module', 'skinr') . '/modules',
+    'api' => 2.0,
   );
 }
 
Index: skinr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skinr/skinr.module,v
retrieving revision 1.37
diff -u -p -r1.37 skinr.module
--- skinr.module	20 Dec 2010 21:42:29 -0000	1.37
+++ skinr.module	30 Dec 2010 22:29:44 -0000
@@ -39,7 +39,8 @@ function skinr_module_implements_alter(&
  */
 function skinr_init() {
   module_load_include('inc', 'skinr', 'skinr.handlers');
-  skinr_module_load_all_includes();
+  // Load module plugins, but make sure we only load *.skinr.inc files.
+  skinr_load_includes('modules', '\.skinr');
 }
 
 /**
@@ -421,38 +422,85 @@ function skinr_rule_visible($rid) {
 // Include file helpers.
 
 /**
- * Includes $module.skinr.inc files.
+ * Load include files for skinr implemented by all modules.
+ *
+ * @param $type
+ *   The type of a plugin; can be 'skins' or 'modules'.
+ * @param $filter
+ *   An optional include file name without .inc extension to limit the search to.
+ *
+ * @return
+ *   An array of hook details keyed by hook name. The hook details contain the
+ *   following keys:
+ *   - 'type': Available options are 'module' or 'theme'.
+ *   - 'name': The name of the owner module or theme of this plugin.
+ *   - 'plugin': The name of the skins plugin.
+ *   - 'path': This plugin's path.
+ *
+ * @see skinr_get_directories()
  */
-function skinr_module_load_all_includes() {
-  foreach (skinr_get_module_apis() as $module => $info) {
-    $file = DRUPAL_ROOT . "/$info[path]/$module.skinr.inc";
-    if (is_file($file)) {
-      require_once $file;
+function skinr_load_includes($type = 'skins', $filter = NULL) {
+  // Store hooks statically because the files can't be reincluded, so there's
+  // no use in being able to clear it.
+  static $hooks = array();
+
+  if (!isset($hooks[$type])) {
+    // Get a list of plugins.
+    $directories = skinr_get_plugins($type);
+    $file_list = array();
+    foreach ($directories as $module => $path) {
+      $file_list[$module] = drupal_system_listing("/{$filter}\.inc\$/", $path, 'name', 0);
+    }
+
+    // Load plugins.
+    $hooks[$type] = array();
+    foreach (array_filter($file_list) as $module => $files) {
+      foreach ($files as $file) {
+        // If $filter was provided, strip that part from $file->name.
+        if (!empty($filter)) {
+          list($file->name) = explode($filter, $file->name, 2);
+        }
+
+        include_once './' . $file->uri;
+        $hooks[$type][$module . '_' . $file->name] = array(
+          'type' => 'module',
+          'name' => $module,
+          'plugin' => $file->name,
+          'path' => dirname($file->uri),
+        );
+      }
     }
   }
+
+  return $hooks[$type];
 }
 
 /**
- * Get a list of modules that support skinr.
+ * Return a list of directories by modules implementing hook_skinr_api().
+ *
+ * @param $plugintype
+ *   The type of a plugin; can be 'skins' or 'modules'.
+ *
+ * @return
+ *   An array containing module names and the plugin directory.
+ *
+ * @see skinr_load_includes()
  */
-function skinr_get_module_apis() {
-  $cache = &drupal_static(__FUNCTION__);
-
-  if (!isset($cache)) {
-    $cache = array();
-    foreach (module_implements('skinr_api') as $module) {
-      $function = $module . '_skinr_api';
-      $info = $function();
-      if (isset($info['api']) && $info['api'] == 1.000) {
-        if (!isset($info['path'])) {
-          $info['path'] = drupal_get_path('module', $module);
-        }
-        $cache[$module] = $info;
-      }
+function skinr_get_plugins($plugintype) {
+  $directories = array();
+  foreach (module_implements('skinr_api') as $module) {
+    // Check if the module implements the correct api version.
+    $function = $module . '_skinr_api';
+    $info = $function();
+    if (!(isset($info['api']) || $info['api'] != 2.000)) {
+      // This module implements an older or newer version of skinr api.
+      continue;
     }
+    // Add the directory where skins are stored.
+    $directory = isset($info['directory']) ? $info['directory'] : $plugintype;
+    $directories[$module] = drupal_get_path('module', $module) . '/' . $directory;
   }
-
-  return $cache;
+  return $directories;
 }
 
 // -----------------------------------------------------------------------
@@ -758,24 +806,6 @@ function skinr_skin_info_status_default(
 }
 
 /**
- * Get a list of plugin hooks.
- *
- * @return
- *   An array of hook details keyed by hook name. The hook details contain the
- *   following keys:
- *   - 'type': Available options are 'module' or 'theme'.
- *   - 'name': The name of the owner module or theme of this plugin.
- *   - 'plugin': The name of the skins plugin.
- *   - 'path': This plugin's path.
- */
-function skinr_plugin_hooks() {
-  // @todo Load the include files and get an array of hooks; we need to
-  //   know which module and which plugin comprises the hook.
-  $hooks = array();
-  return $hooks;
-}
-
-/**
  * Helper function to prepend a path to an array of stylesheet or script filenames.
  *
  * If the url is absolute (e.g. the url start with 'http://' or 'https://')
@@ -881,19 +911,21 @@ function skinr_get_skin_info() {
     $skin_infos = array();
 
     // Load skins from hook_skinr_skins().
-    $hooks = skinr_plugin_hooks();
+    $hooks = skinr_load_includes('skins');
     foreach ($hooks as $hook => $source) {
       $function = $hook . '_skinr_skin_info';
-      $result = $function();
-      if (isset($result)) {
-        if (!is_array($result)) {
-          $result = array($result);
-        }
+      if (function_exists($function)) {
+        $result = $function();
+        if (isset($result)) {
+          if (!is_array($result)) {
+            $result = array($result);
+          }
 
-        // Make any programatic changes.
-        skinr_skin_info_process($result, $source);
+          // Make any programatic changes.
+          skinr_skin_info_process($result, $source);
 
-        $skin_infos = array_merge_recursive($skin_infos, $result);
+          $skin_infos = array_merge_recursive($skin_infos, $result);
+        }
       }
     }
 
@@ -919,22 +951,24 @@ function skinr_get_group_info() {
     $group_infos = array();
 
     // Load skins from hook_skinr_groups().
-    $hooks = skinr_plugin_hooks();
+    $hooks = skinr_load_includes('skins');
     foreach ($hooks as $hook => $source) {
       $function = $hook . '_skinr_group_info';
-      $result = $function();
-      if (isset($result)) {
-        if (!is_array($result)) {
-          $result = array($result);
-        }
+      if (function_exists($function)) {
+        $result = $function();
+        if (isset($result)) {
+          if (!is_array($result)) {
+            $result = array($result);
+          }
 
-        // Make any programatic changes.
-        // Merge in defaults.
-        foreach ($result as $group_name => $group_info) {
-          $result[$group_name] = array_merge(skinr_group_info_default(), $group_info);
-        }
+          // Make any programatic changes.
+          // Merge in defaults.
+          foreach ($result as $group_name => $group_info) {
+            $result[$group_name] = array_merge(skinr_group_info_default(), $group_info);
+          }
 
-        $group_infos = array_merge_recursive($group_infos, $result);
+          $group_infos = array_merge_recursive($group_infos, $result);
+        }
       }
     }
 
