Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I properly indent this code in PHP (I'm using WordPress)? I'm mostly concerned about how the <button> comes into this equation @ items_wrap.

<?php
if (has_nav_menu('primary_navigation')) :
  wp_nav_menu( array(
      'theme_location'    =>  'primary_navigation',
      'container'         =>  'nav',
      'container_class'   =>  'nav-primary',
      'menu_class'        =>  'nav toggleable hide',
      'items_wrap'        =>  '<button class="dropdown-toggle script-dependant">'.__('Menu', 'yolk').'</button><ul id="%1$s" class="%2$s">%3$s</ul>',
      'walker'            =>  new detailed_navigational_menu_walker
  ) );
endif;
?>
share|improve this question

closed as off-topic by syb0rg, Jamal Jun 13 at 21:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

I would consider going ahead and defining some variables to make this configuration more easy to read. I also prefer to keep lines of code to the often recommended ~80 characters per line limit. Use concatenation to break up long strings across lines.

Perhaps something like this:

<?php
if (has_nav_menu('primary_navigation')) :
    $nav_menu_config = array(
        'theme_location'    =>  'primary_navigation',
        'container'         =>  'nav',
        'container_class'   =>  'nav-primary',
        'menu_class'        =>  'nav toggleable hide',
        'items_wrap'        =>
            '<button class="dropdown-toggle script-dependant">' .
            __('Menu', 'yolk') . '</button>' .
            '<ul id="%1$s" class="%2$s">%3$s</ul>',
        'walker'            =>  new detailed_navigational_menu_walker  
    );            
    wp_nav_menu($nav_menu_config);
endif;
?>
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.