Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.971
diff -u -r1.971 common.inc
--- includes/common.inc	24 Aug 2009 00:14:18 -0000	1.971
+++ includes/common.inc	24 Aug 2009 15:55:40 -0000
@@ -4257,7 +4257,7 @@
       'arguments' => array('display' => NULL),
     ),
     'links' => array(
-      'arguments' => array('links' => NULL, 'attributes' => array('class' => array('links'))),
+      'arguments' => array('links' => NULL, 'attributes' => array('class' => array('links')), 'heading' => array()),
     ),
     'image' => array(
       'arguments' => array('path' => NULL, 'alt' => '', 'title' => '', 'attributes' => array(), 'getsize' => TRUE),
Index: includes/theme.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/theme.inc,v
retrieving revision 1.514
diff -u -r1.514 theme.inc
--- includes/theme.inc	24 Aug 2009 00:34:11 -0000	1.514
+++ includes/theme.inc	24 Aug 2009 16:01:34 -0000
@@ -1383,11 +1383,13 @@
  *    - href: the link URL. If omitted, the 'title' is shown as a plain text item in the links list.
  *    - html: (optional) set this to TRUE if 'title' is HTML so it will be escaped.
  *   Array items are passed on to the l() function's $options parameter when creating the link.
+ * @param $attributes
+ *   A keyed array of attributes.
  * @param $heading
  *   An optional keyed array for a heading to precede the links:
  *    - text: the heading text
  *    - level: the heading level (e.g. 'h2', 'h3')
- *    - class: (optional) space-separated classes for the heading
+ *    - class: (optional) an array of the CSS classes for the heading
  *   Headings should be used on navigation menus and any list of links that
  *   consistently appears on multiple pages. To make the heading invisible
  *   use class => 'element-invisible'. Do not use 'display:none', which
@@ -1395,22 +1397,24 @@
  *   screen-reader and keyboard only users to navigate to or skip the links.
  *   See http://juicystudio.com/article/screen-readers-display-none.php
  *   and http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
- * @param $attributes
- *   A keyed array of attributes.
  * @return
  *   A string containing an unordered list of links.
  */
-function theme_links($links, $heading = array(), $attributes = array('class' => array('links'))) {
+function theme_links($links, $attributes = array('class' => array('links')), $heading = array()) {
   global $language;
   $output = '';
 
   if (count($links) > 0) {
     $output = '';
+
+    // Treat the heading first if it is present to prepend it to the
+    // list of links.
     if (!empty($heading['text']) && !empty($heading['level'])) {
-      $output .= '<' . $heading['level'] . (!empty($heading['class']) ?
-        drupal_attributes(array('class' => $heading['class'])) : '') . '>';
-      $output .= check_plain($heading['text']);
-      $output .= '</' . $heading['level'] . '>';
+      $output .= '<' . $heading['level'];
+      if (!empty($heading['class'])) {
+        $output .= ' ' . drupal_attributes(array('class' => $heading['class']));
+      }
+      $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
     }
 
     $output .= '<ul' . drupal_attributes($attributes) . '>';
Index: modules/node/node.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v
retrieving revision 1.63
diff -u -r1.63 node.admin.inc
--- modules/node/node.admin.inc	23 Aug 2009 04:37:52 -0000	1.63
+++ modules/node/node.admin.inc	24 Aug 2009 15:18:33 -0000
@@ -373,7 +373,7 @@
   // Show the 'add new content' link.
   $form['add_content'] = array(
     '#access' => _node_add_access(),
-    '#markup' => theme('links', array(array('title' => t('Add new content'), 'href' => 'node/add')), array('class' => array('action-links'))),
+    '#markup' => theme('links', array(array('title' => t('Add new content'), 'href' => 'node/add')), array(), array('class' => array('action-links'))),
   );
   $form[] = node_filter_form();
   $form['#submit'][] = 'node_filter_form_submit';
Index: modules/system/page.tpl.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/page.tpl.php,v
retrieving revision 1.30
diff -u -r1.30 page.tpl.php
--- modules/system/page.tpl.php	22 Aug 2009 19:58:28 -0000	1.30
+++ modules/system/page.tpl.php	24 Aug 2009 15:50:56 -0000
@@ -156,7 +156,7 @@
 
     <?php if ($main_menu): ?>
       <div id="navigation"><div class="section">
-        <?php print theme('links', $main_menu, array('text' => t('Main menu'), 'level' => 'h2'), array('id' => 'main-menu', 'class' => array('links clearfix'))); ?>
+        <?php print theme('links', $main_menu, array('id' => 'main-menu', 'class' => array('links clearfix')), array('text' => t('Main menu'), 'level' => 'h2')); ?>
       </div></div> <!-- /.section, /#navigation -->
     <?php endif; ?>
 
@@ -195,7 +195,7 @@
     </div></div> <!-- /#main, /#main-wrapper -->
 
     <div id="footer"><div class="section">
-      <?php print theme('links', $secondary_menu, array('text' => t('Secondary menu'), 'level' => 'h2'), array('id' => 'secondary-menu', 'class' => array('links', 'clearfix'))); ?>
+      <?php print theme('links', $secondary_menu, array('id' => 'secondary-menu', 'class' => array('links', 'clearfix')), array('text' => t('Secondary menu'), 'level' => 'h2')); ?>
       <?php if ($footer): ?><div id="footer-region" class="region"><?php print $footer; ?></div><?php endif; ?>
     </div></div> <!-- /.section, /#footer -->
 
Index: themes/garland/template.php
===================================================================
RCS file: /cvs/drupal/drupal/themes/garland/template.php,v
retrieving revision 1.26
diff -u -r1.26 template.php
--- themes/garland/template.php	22 Aug 2009 14:34:23 -0000	1.26
+++ themes/garland/template.php	24 Aug 2009 15:51:49 -0000
@@ -19,12 +19,36 @@
  */
 function garland_preprocess_page(&$vars) {
   $vars['tabs2'] = menu_secondary_local_tasks();
-  $vars['primary_nav'] = isset($vars['main_menu']) ? theme('links', $vars['main_menu'], array(
-    'text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'),
-  ), array('class' => array('links', 'main-menu'))) : FALSE;
-  $vars['secondary_nav'] = isset($vars['secondary_menu']) ? theme('links', $vars['secondary_menu'], array(
-    'text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'),
-  ), array('class' => array('links', 'secondary-menu'))) : FALSE;
+  if (isset($vars['main_menu'])) {
+    $vars['primary_nav'] = theme('links', $vars['main_menu'],
+      array(
+        'class' => array('links', 'main-menu'),
+      ),
+      array(
+        'text' => t('Main menu'),
+        'level' => 'h2',
+        'class' => array('element-invisible'),
+      )
+    );
+  }
+  else {
+    $vars['primary_nav'] = FALSE;
+  }
+  if (isset($vars['secondary_menu'])) {
+    $vars['secondary_nav'] = theme('links', $vars['secondary_menu'],
+      array(
+        'class' => array('links', 'secondary-menu'),
+      ),
+      array(
+        'text' => t('Secondary menu'),
+        'level' => 'h2',
+        'class' => array('element-invisible'),
+      )
+    );
+  }
+  else {
+    $vars['secondary_nav'] = FALSE;
+  }
   $vars['ie_styles'] = garland_get_ie_styles();
 
   // Prepare header
