use implode() on classes rather than muck about with spaces

Created on 12 April 2011, about 13 years ago
Updated 2 May 2024, about 2 months ago

This gets pretty tiresome:

      $first_class = $index == 1 ? ' first ' : '';
      $oddeven_class = $index % 2 == 0 ? ' even ' : ' odd ';
      $last_class = $index == $count ? ' last ' : '';

Better to leave off the spaces either side and just implode with a space.

For that matter, there's not really a need to name all these -- they are only used again when making the LI.

So this would do:

$classes[] = $index % 2 == 0 ? 'even' : 'odd';
// etc

Not making a patch yet, as would clash with #508690: level-based classes for drop-down menus β†’ .

πŸ“Œ Task
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024