WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18017 closed enhancement (fixed)

set_url_scheme() function

Reported by: jkudish Owned by: jkudish
Milestone: 3.4 Priority: normal
Severity: minor Version:
Component: General Keywords: has-patch needs-testing
Focuses: Cc:

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 3 years ago.
18017b.diff (1.1 KB) - added by jkudish 3 years ago.
18017-3.diff (1.1 KB) - added by jkudish 3 years 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 2 years ago.
Refresh, add relative support
18017-ut.diff (2.6 KB) - added by ryan 2 years ago.
unit tests

Download all attachments as: .zip

Change History (18)

jkudish3 years ago

comment:1 ryan3 years ago

  • 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().

comment:2 jkudish3 years ago

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

Thanks!

Last edited 3 years ago by jkudish (previous) (diff)

jkudish3 years ago

comment:3 jkudish3 years ago

Here's the updated function with an apply_filters too

comment:4 jkudish3 years ago

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

jkudish3 years 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)

comment:5 jkudish3 years ago

  • Keywords needs-testing added

comment:7 marfarma2 years ago

  • Cc pauli.price@… added

comment:9 marfarma2 years ago

Related: #19037

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

comment:10 holizz2 years ago

  • Cc tom@… added

ryan2 years ago

Refresh, add relative support

ryan2 years ago

unit tests

comment:11 ryan2 years ago

  • Milestone changed from Future Release to 3.4

comment:12 ryan2 years ago

  • 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.