Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#60640 new enhancement

Use of "selected" function for "Week Starts On" on General Setting page

Reported by: bhargavbhandari90 Owned by:
Priority: normal Milestone: Future Release
Component: Administration Version: 6.5
Severity: minor Keywords: has-patch
Cc: Focuses:

Description

For the dropdown of weekdays for the "Week Starts On" field is using the following turnery operation for "selected=selectd"

$selected = ( get_option( 'start_of_week' ) == $day_index ) ? 'selected="selected"' : '';

We should use WP's selected function instead of turnery operation

Attachments (2)

60640.diff​ (620 bytes ) - added by bhargavbhandari90 3 years ago.
Use "selected" function for weekdays dropdown selected
60640-v2.diff​ (619 bytes ) - added by bhargavbhandari90 3 years ago.
Use "selected" function for weekdays dropdown selected

Download all attachments as: .zip

Change History (8)

@bhargavbhandari90
3 years ago

Use "selected" function for weekdays dropdown selected

#1 @swissspidy
3 years ago

  • Keywords has-patch added
  • Milestone Awaiting Review → Future Release

Note that selected() does a strict comparison (===) whereas the existing code does a loose comparison (==). This would need to use (int) get_option( 'start_of_week' ) to be safe.

#2 @bhargavbhandari90
3 years ago

Thanks @swissspidy. Updating patch

@bhargavbhandari90
3 years ago

Use "selected" function for weekdays dropdown selected

​@mukesh27 commented on ​PR #6181:


3 years ago
#4

It print additional selected='selected' in HTML. Check screenshot.
https://github.com/WordPress/wordpress-develop/assets/10103365/59a191e6-d5cb-4c2c-beb7-ccec0db001a8

​@bhargavbhandari90 commented on ​PR #6181:


3 years ago
#5

Thank you @mukeshpanchal27 for pointing this out. I've improved the code. Should be fine now.

​@audrasjb commented on ​PR #6181:


2 years ago
#6

I updated your PR to resolve some conflicts against trunk.

Note: See TracTickets for help on using tickets.