This patch is a starting point for cleaning up existing theme functions so they use the recently improved version of drupal_attributes() (#493746: Enhance drupal_attributes() for multiple valued values).

There is lots to cover, so I started in menu.inc. First serious patch here, so be gentle :o)

CommentFileSizeAuthor
menu.inc-attributes.patch5.89 KBjacine

Comments

ChrisBryant’s picture

Nice start Jacine! Subscribing.

pasqualle’s picture

1.

+  //print_r($link); die;

2.

+function theme_menu_tree($tree, $attributes = array()) {
+function theme_menu_local_tasks($attributes = array()) {

do we need the new $attributes parameter?

3.

-function theme_menu_local_action($link) {
-  return '<li>' . $link . "</li>\n";
+function theme_menu_local_action($link = array()) {
+  $link['attributes'] = array();
+  return '<li' . drupal_attributes($link['attributes']) . '>' . $link['value'] . "</li>\n";

there is no improvement here. I guess the $link['attributes'] = array(); line should be changed to

if (!isset($link['attributes'])) {
  $link['attributes'] = array();
}

or

  $link['attributes'][] = 'something';

4. in theme_menu_local_tasks() as I see the secondary local tasks will have a "tabs primary secondary" class after the patch..

scor’s picture

subscribing. good initiative. We're already doing something similar in the RDF patches.

What are the plans to deal with the tpl files? Let themer alter the array of CSS classes before drupal_attributes?

Status: Needs review » Needs work

The last submitted patch failed testing.

jacine’s picture

Hmm... Was going to reroll this and keep going, but this seems like such a better approach: #572618: All theme functions should take a single argument to make preprocess sane and meaningful

Don't know what to do :(

TraumTaenzer’s picture

Status: Needs work » Needs review

menu.inc-attributes.patch queued for re-testing.

jacine’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Too late for this.

Anonymous’s picture

Status: Needs work » Closed (won't fix)

I think that this is obsolete with the Twig work. Feel free to tell me I'm wrong.