The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

WordPress HTTPS (SSL)
admin_url() doesn't return proper scheme even when $scheme is passed (1 post)

  1. Jonathan Cowher
    Posted 2 years ago #

    I have a plugin that I manage and we use

    admin_url('admin-ajax.php', ( is_ssl() ) ? 'https' : 'http'));

    to make sure our ajax requests use the proper url.

    When the "force SSL on admin" setting is not enabled admin_url() will ALWAYS use http instead of https scheme. Here's the workaround I used:

    //make sure admin_url() returns proper scheme - set to super low priority to make sure this is run last
    add_filter('admin_url', array(&$this, 'filter_admin_url'), 999);
     * Ensures that admin_url() uses the correct URL scheme when WordPress HTTPS
     * plugin is enabled
     * @since
     * @param string $url
     * @return string
    function filter_admin_url( $url ) {
       if ( class_exists('WordPressHTTPS') )
          return is_ssl() ? str_replace('http://', 'https://', $url) : str_replace('https://', 'http://', $url);
       return $url;


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress HTTPS (SSL)
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Jonathan Cowher
  • This topic is not resolved
  • WordPress version: 3.8.1


No tags yet.