WordPress: Issues with Plugins when only admin area is using SSL

On another Blog I have (http://www.ff-pitten.at) I recently activated SSL for the admin area (see https://codex.wordpress.org/Administration_Over_SSL).

After this change, I was able to securly login, but suddenly some plugins failed to fetch some JavaScript and CSS files.

While debugging this issue I found that those plugins use the configured URL for the site (set at Settings -> General -> WordPress Address (URL) and Site Address (URL)).

To solve this issue, you need to specify the WP Address and Site Address depending on how the current page is called (http or https).

Just add to the wp-config.php file the folling before the file ‘wp-settings.php’ is included:

define(MY_BASE_URL, "www.ff-pitten.at");
if ($_SERVER['REQUEST_SCHEME'] == "https") {
define('WP_HOME','https://'.MY_BASE_URL);
define('WP_SITEURL','https://'.MY_BASE_URL);
} else {
define('WP_HOME','http://'.MY_BASE_URL);
define('WP_SITEURL','http://'.MY_BASE_URL);
}

HINT: you should change the MY_BASE_URL to your URL….

Leave a Reply

Your email address will not be published. Required fields are marked *