Make WordPress Core

Opened 10 years ago

Last modified 5 years ago

#30285 reopened defect (bug)

url_to_postid on FORCE_SSL_ADMIN takes https path instead of http

Reported by: ste_95's profile Ste_95 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0
Component: General Keywords: reporter-feedback
Focuses: Cc:


A server has FORCE_SSL_ADMIN set to TRUE, which makes its wp-admin load under SSL, though the public pages are still on http.

Now, I have a plugin which runs in the admin area. When I call url_to_postid with a post permalink under http ( the function always returns 0. What happens is that url_to_postid uses site_url to parse the permalink, but site_url with FORCE_SSL_ADMIN returns the path with https, thus not finding it in the http permalink.

I think url_to_postid should always take the public settings even when called from an admin context, as it will take in input public paths.

Change History (3)

#1 @johnbillion
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Thanks for the report.

I'm unable to reproduce this issue. url_to_postid() uses home_url(), not site_url(). Calling url_to_postid() with a permalink to a post or page works as expected both with FORCE_SSL_ADMIN set to true, and with the 'WordPress Address' option set to an https URL.

Please deactivate all your plugins and see if the issue persists. It could be that one of your plugins is interfering and causing the issue. If you can reproduce the issue with all plugins deactivated and the default theme enabled, please re-open with exact details to reproduce the issue.


#2 @sboisvert
8 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

We're seeing this problem. It seems very similar to #33109
@johnbillion Are you still not able to reproduce? If not I can try to reproduce on a vanilla install but I don't see any filters that would be impacting this on our side. Just to be sure, you were calling url_to_postid() from inside the WP_ADMIN context (in this case it's an AJAX call for us).
Let me know what you need to reproduce this. We can send in a patch.

Props to Kaitlyn from 10up for finding this ticket.

#3 @johnbillion
8 years ago

  • Keywords reporter-feedback added
  • Milestone set to Awaiting Review

@sboisvert Are you seeing this problem pre- or post- r36750?

Regardless, steps to reproduce would be a big help.

Note: See TracTickets for help on using tickets.