WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. webgeekconsulting
    Member
    Posted 5 months 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 2.9.2.4
     *
     * @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;
    }

    https://wordpress.org/plugins/wordpress-https/

Reply

You must log in to post.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 5 months ago by webgeekconsulting
  • This topic is not resolved
  • WordPress version: 3.8.1

Tags

No tags yet.