WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 3 weeks ago

#52886 new enhancement

Update esc_url to allow for specifying an https:// as default protocol

Reported by: mkaz Owned by:
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch needs-unit-tests
Focuses: Cc:

Description

If no protocol is specified for esc_url the function will automatically prepend the http:// protocol. This is likely now the wrong assumption, but potentially can break backwards compatibility if changed, since developers may rely on this.

So this change proposes an additional parameter to the function to specify a default protocol, keeping the old default but now allowing for one to ask for https://

This came up in this ticket: https://github.com/WordPress/gutenberg/pull/30100

The usage could then be:

`
esc_url( $url, null, 'display', 'https://' );
`

Attachments (1)

52886.diff (2.2 KB) - added by mkaz 5 weeks ago.

Download all attachments as: .zip

Change History (3)

@mkaz
5 weeks ago

#1 @rachelbaker
3 weeks ago

  • Keywords has-patch needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.8

#2 @SergeyBiryukov
3 weeks ago

Thanks for the patch!

Just noting that the @since tag should be in the function DocBlock, after @since 2.8.0, and should follow this format for consistency:

@since 5.8.0 Added the `$default_protocol` parameter.
Note: See TracTickets for help on using tickets.