Skip to content
Permalink
Browse files

Add support for prepending stylesheets (or any other link)

  • Loading branch information
flack committed Nov 30, 2019
1 parent f489a46 commit a677af41acd856cb387272bd16f86f24961be1e5
Showing with 8 additions and 10 deletions.
  1. +8 −10 lib/midcom/helper/head.php
@@ -272,23 +272,21 @@ private function _get_attribute_string($attributes) : string
* @param array $attributes Array of attribute => value pairs to be placed in the tag.
* @see print_head_elements()
*/
public function add_link_head(array $attributes)
public function add_link_head(array $attributes, bool $prepend = false)
{
if (!array_key_exists('href', $attributes)) {
return false;
return;
}
// Register each URL only once
if (($key = array_search($attributes['href'], $this->_linkhrefs)) !== false) {
if (end($this->_linkhrefs) != $attributes['href']) {
unset($this->_linkhrefs[$key]);
$this->_linkhrefs[] = $attributes['href'];
reset($this->_linkhrefs);
}
return false;
unset($this->_linkhrefs[$key]);
}
if ($prepend) {
array_unshift($this->_linkhrefs, $attributes['href']);
} else {
$this->_linkhrefs[] = $attributes['href'];
}
$this->_linkhrefs[] = $attributes['href'];
$this->_link_head[$attributes['href']] = $attributes;
}

0 comments on commit a677af4

Please sign in to comment.
You can’t perform that action at this time.