Make WordPress Core

Opened 5 years ago

Last modified 2 years ago

#38296 new enhancement

Remove $sep variable duplication from Ternary Operator

Reported by: joelcj91 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.1
Component: Administration Keywords: has-patch
Focuses: administration Cc:


In WP_List_Table class, we are using ternary operators a lot. We know that the main advantage of the ternary operator is, it makes code shorter.

Instead of uisng ternary operator like this,

( $i == $action_count ) ? $sep = '' : $sep = ' | ';

Can we use,

$sep = ( $i == $action_count ) ? '' : ' | ';

So the variable $sep is written once. Shortening the code a bit.

Attachments (2)

38296.patch (609 bytes) - added by joelcj91 5 years ago.
Patch to remove variable duplication
38296.2.patch (634 bytes) - added by joelcj91 2 years ago.
Patch refresh

Download all attachments as: .zip

Change History (5)

5 years ago

Patch to remove variable duplication

#1 @joelcj91
5 years ago

  • Keywords has-patch added

#2 @desrosj
2 years ago

  • Keywords needs-refresh added
  • Milestone changed from Awaiting Review to Future Release
  • Version changed from 4.6.1 to 3.1

Thanks for this, @joelcj91! Sorry that it took so long to receive a response.

This is a good suggestion, IMO. Are you able to refresh the patch to apply cleanly to trunk?

2 years ago

Patch refresh

#3 @joelcj91
2 years ago

  • Keywords needs-refresh removed

Thanks, @desrosj. I have updated the patch after updating the trunk.

Note: See TracTickets for help on using tickets.