I've already answered this question but ran into another situation that I feel merits a separate answer instead of making my first answer more complicated.
In some cases, we use Cloudflare Flexible SSL. Due to the way Cloudflare does SSL, this adds support for SSL but not via a certificate on the server or via the standard SSL port so the common
$_SERVER['HTTPS'] variable isn't available to check nor are you able to just check to see if the secure port is in use.
The solution I came across is to check for the
$_SERVER['HTTP_X_FORWARDED_PROTO'] variable. This may not work in all situations, but it worked for me and can be substituted in for the URI_SCHEME check in the answer above:
// Support Cloudflare SSL
// Standard SSL support
define('URI_SCHEME', ( isset($_SERVER['HTTPS'] ) ) ? "https://" : "http://" );
If anyone would like to edit and add any other Cloudflare specific fixes, feel free. I surely don't have the domain knowledge in this area to claim this is a final answer, just one that helped me out in getting assets serving over SSL on a Cloudflare-enabled site.