[resolved] PHP Notice on line 46 of optimizely.php (2 posts)

  1. Josh Eaton
    Posted 1 year ago #

    Using Optimizely with WP_DEBUG turned on generates a PHP Notice:

    PHP Notice: Undefined index: HTTPS in /wp-content/plugins/optimizely/optimizely.php on line 46

    The line in question:

    if (!$_SERVER['HTTPS']) {

    I'd recommend replacing this entire block with the code below, as the HTTPS value could be set and be 'off':

    if( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) {
        $script = "https:" . $projectScript;
    } else {
        $script = "http:" . $projectScript;

    I tried to find a GitHub repo for this plugin but couldn't, otherwise I would have submitted a pull request. Please add this to the next version of the plugin.


  2. lkraav
    Posted 1 year ago #

    Actually the solution here is to drop this block entirely and just use protocol-relative URLs, which $projectScript already has!

    Following echo statement then needs to use $projectScript instead of $script and all is fine.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.