• Hi there,

    I just implemented a custom fix for this plugin on a WordPress site running on Pantheon. I was looking for a github respository (or something similar) to submit my fix but could not find one.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,

    You can paste your fix here, on this forum. Maybe, i will integrate your fix in next release if it don’t break main plugin features.

    Best regards.

    Thread Starter yarnboy

    (@yarnboy)

    The changes are all to the wp_cassify_get_current_url function in wp_cassify_utils.php. See the comments in the code:

    	public static function wp_cassify_get_current_url( $wp_cassify_default_wordpress_blog_http_port = 80, $wp_cassify_default_wordpress_blog_https_port = 443 ) {
    
    		$current_url = ( @$_SERVER[ 'HTTPS' ] == 'on' ) ? 'https://' : 'https://';
    
    		// If cassified application is hosted behind reverse proxy.
    		if ( isset( $_SERVER[ 'HTTP_X_FORWARDED_HOST' ] ) ) {
    			$current_url .= $_SERVER[ 'HTTP_X_FORWARDED_HOST' ];
    		} elseif (isset( $_ENV['PANTHEON_SITE'] )) { // Are we on Pantheon? Use HTTP_HOST
    			$current_url .= $_SERVER['HTTP_HOST'];
    		}
    		else {
    			$current_url .= $_SERVER[ 'SERVER_NAME' ];
    		}
    
    		if( ( $_SERVER[ 'SERVER_PORT' ] != $wp_cassify_default_wordpress_blog_http_port ) &&
    			( $_SERVER[ 'SERVER_PORT' ] != $wp_cassify_default_wordpress_blog_https_port ) &&
    			!isset( $_ENV['PANTHEON_SITE'] ) ) // Don't use the port if we're on Pantheon
    		  {
    			$current_url .= ':' . $_SERVER[ 'SERVER_PORT' ];
    		}
    
    		// Specific use case configuration for WordPress hosted on nginx behind AWS loadbalancer.
    		if (
    			isset( $_SERVER[ 'HTTP_HOST' ] ) &&
    			isset( $_SERVER[ 'HTTP_X_FORWARDED_PORT' ] ) &&
    			isset( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] ) ) {
    
    			$current_url = ( @$_SERVER[ 'HTTPS' ] == 'on' ? 'https://' : 'https://' ) . $_SERVER[ 'HTTP_HOST' ];
    
    			if( ( $_SERVER[ 'HTTP_X_FORWARDED_PORT' ] != $wp_cassify_default_wordpress_blog_http_port ) &&
    				( $_SERVER[ 'HTTP_X_FORWARDED_PORT' ] != $wp_cassify_default_wordpress_blog_https_port ) ) {
    				$current_url .= ':' . $_SERVER[ 'SERVER_PORT' ];
    			}
    
    			if ( $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] == 'https' ) {
    				$current_url = str_replace( "http:", "https:", $current_url );
    			}
    		}
    
    		$current_url .= $_SERVER[ 'REQUEST_URI' ];
    
    		return $current_url;
    	}
    

    So, I just updated my site running wp-cassify to WordPress 4.9.6 (I know I should have done that weeks ago), and wp-cassify broke. I am hosted on Pantheon. Is that what this fix is for?

    Thread Starter yarnboy

    (@yarnboy)

    Possibly. Depends on how wp-cassify broke. Can you be more specific? Any error messages?

    • This reply was modified 6 years, 4 months ago by yarnboy.

    I finally figured out that the recent update stream from Pantheon (or possibly WP 4.9.6) revised my wp-config.php and took out the custom code that you have to have in there for Pantheon (probably what you have listed above). I added that back in and it is working now.

    Thread Starter yarnboy

    (@yarnboy)

    Great! I’m not sure wp-config.php is the best place for the custom code, though, as it might get wiped out again by the next update. In my installation, I’ve edited the plugin itself (see my post above). Maybe the plugin author will include my fix in the next update.

    I’ll vote for that! I can’t seem to remember to check the wp-config after every update and re-add the code.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Fix for Pantheon enviroments’ is closed to new replies.