Opened 23 months ago

Closed 12 months ago

Last modified 12 months ago

#18017 closed enhancement (fixed)

set_url_scheme() function

Reported by: jkudish Owned by: jkudish
Priority: normal Milestone: 3.4
Component: General Version:
Severity: minor Keywords: has-patch needs-testing
Cc: pauli.price@…, tom@…

Description

After seeing the idea suggested on ticket #14835 and discussing it in #18005, I thought I'd add in this function which filters a url to return the url with correct protocol (http/https).

Next step would be to implement the function throughout wherever there already is such filtering (or where there should be).

What do you think? Good minor addition to 3.2.x or 3.3?

Attachments (5)

18017.diff (639 bytes) - added by jkudish 23 months ago.
18017b.diff (1.1 KB) - added by jkudish 23 months ago.
18017-3.diff (1.1 KB) - added by jkudish 23 months ago.
as Nacin pointed out, I had a little tabbing issue in the diff, here's the update - also following a better naming convention (-# instead of -b)
18017.2.diff (1.4 KB) - added by ryan 12 months ago.
Refresh, add relative support
18017-ut.diff (2.6 KB) - added by ryan 12 months ago.
unit tests

Download all attachments as: .zip

Change History (18)

  • Milestone changed from Awaiting Review to Future Release

That's a good start. I think it should have an optional $scheme argument that is handled in the same manner as is done get_site_url(). That way you could pass http, https, admin, login, or login_post if you need to force a particular scheme or context. The default would check is_ssl().

I'll take a look a bit later at get_site_url() and I can send in a new patch shortly.

Thanks!

Last edited 23 months ago by jkudish (previous) (diff)

Here's the updated function with an apply_filters too

How do we go about now adding this function when needed in other places within core?

as Nacin pointed out, I had a little tabbing issue in the diff, here's the update - also following a better naming convention (-# instead of -b)

  • Keywords needs-testing added
  • Cc pauli.price@… added

Related: #19037

See wp-hacker's thread titled: "Fixing some SSL cases for 3.4" to follow the evolving discussion.

  • Cc tom@… added

ryan12 months ago

Refresh, add relative support

ryan12 months ago

unit tests

  • Milestone changed from Future Release to 3.4
  • Resolution set to fixed
  • Status changed from new to closed

In [20828]:

Introduce set_url_scheme(). Includes get_site_url() logic for determining when to use http vs. https. Use this to rerite urls to obey is_ssl(). Props jkudish. fixes #18017

Note: See TracTickets for help on using tickets.