From f2b5b56ea53f22566bd4d61a5aa93c3251d0bbd2 Mon Sep 17 00:00:00 2001
From: S H Mohanjith <moha@mohanjith.net>
Date: Wed, 4 Dec 2013 23:02:22 +0200
Subject: [PATCH] Change WP_CONTENT_URL if using SSL

---
 wp-includes/default-constants.php | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/wp-includes/default-constants.php b/wp-includes/default-constants.php
index 4f135c8..51dc5ce 100644
--- a/wp-includes/default-constants.php
+++ b/wp-includes/default-constants.php
@@ -97,8 +97,13 @@ function wp_initial_constants() {
  * @since 3.0.0
  */
 function wp_plugin_directory_constants() {
-	if ( !defined('WP_CONTENT_URL') )
-		define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
+	if ( !defined('WP_CONTENT_URL') ) {
+		if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) {
+			define( 'WP_CONTENT_URL', preg_replace( '/^http:/', 'https:' , get_option('siteurl') ) . '/wp-content' ); // full url - WP_CONTENT_DIR is defined further up with http: replaced by https:
+		} else {
+			define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
+		}
+	}
 
 	/**
 	 * Allows for the plugins directory to be moved from the default location.
-- 
1.7.11.1

