#318636: make l() themable.

From: damz <damz@devland.local>


---
 common.inc |   16 +++++++++++++++-
 theme.inc  |   12 ++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git includes/common.inc includes/common.inc
index e82e8b2..73e0dc5 100644
--- includes/common.inc
+++ includes/common.inc
@@ -2605,7 +2605,18 @@ function l($text, $path, array $options = array()) {
     $options['attributes']['title'] = strip_tags($options['attributes']['title']);
   }
 
-  return '<a href="' . check_plain(url($path, $options)) . '"' . drupal_attributes($options['attributes']) . '>' . ($options['html'] ? $text : check_plain($text)) . '</a>';
+  $variables = array(
+    'path' => check_plain(url($path, $options)),
+    'attributes' => $options['attributes'],
+    'text' => $options['html'] ? $text : check_plain($text),
+  );
+  if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
+    // Only call theme() if Drupal has been fully bootstrapped.
+    return theme('link', $variables);
+  }
+  else {
+    return theme_link($variables);
+  }
 }
 
 /**
@@ -4915,6 +4926,9 @@ function drupal_common_theme() {
     'indentation' => array(
       'arguments' => array('size' => 1),
     ),
+    'link' => array(
+      'arguments' => array('path' => NULL, 'attributes' => array(), 'text' => NULL),
+    ),
     // from pager.inc
     'pager' => array(
       'arguments' => array('tags' => array(), 'element' => 0, 'parameters' => array(), 'quantity' => 9),
diff --git includes/theme.inc includes/theme.inc
index e570302..137a34d 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -2029,6 +2029,18 @@ function theme_indentation($variables) {
 }
 
 /**
+ * Theme an internal Drupal link.
+ *
+ * @param $path
+ */
+function theme_link($variables) {
+  if (!is_array($variables['attributes'])) {
+    print_r($variables);
+  }
+  return '<a href="' . $variables['path'] . '"' . drupal_attributes($variables['attributes']) . '>' . $variables['text'] . '</a>';
+}
+
+/**
  * @} End of "defgroup themeable".
  */
 
