Version Description
ADDED: The plugin will try to set itself to load first, before all other plugins.
Download this release
Release Info
Developer | paultgoodchild |
Plugin | CloudFlare Flexible SSL |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.0 to 1.2.0
- plugin.php +73 -2
- readme.txt +5 -1
plugin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: CloudFlare Flexible SSL
|
4 |
* Plugin URI: http://icwp.io/2f
|
5 |
* Description: Fix For CloudFlare Flexible SSL Redirect Loop For WordPress
|
6 |
-
* Version: 1.
|
7 |
* Text Domain: cloudflare-flexible-ssl
|
8 |
* Author: iControlWP
|
9 |
* Author URI: http://icwp.io/2e
|
@@ -18,11 +18,82 @@ class ICWP_Cloudflare_Flexible_SSL {
|
|
18 |
$aIcwpHttpsServerOpts = array( 'HTTP_CF_VISITOR', 'HTTP_X_FORWARDED_PROTO' );
|
19 |
foreach( $aIcwpHttpsServerOpts as $sOption ) {
|
20 |
|
21 |
-
if (
|
22 |
$_SERVER[ 'HTTPS' ] = 'on';
|
23 |
break;
|
24 |
}
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
}
|
28 |
|
3 |
* Plugin Name: CloudFlare Flexible SSL
|
4 |
* Plugin URI: http://icwp.io/2f
|
5 |
* Description: Fix For CloudFlare Flexible SSL Redirect Loop For WordPress
|
6 |
+
* Version: 1.2.0
|
7 |
* Text Domain: cloudflare-flexible-ssl
|
8 |
* Author: iControlWP
|
9 |
* Author URI: http://icwp.io/2e
|
18 |
$aIcwpHttpsServerOpts = array( 'HTTP_CF_VISITOR', 'HTTP_X_FORWARDED_PROTO' );
|
19 |
foreach( $aIcwpHttpsServerOpts as $sOption ) {
|
20 |
|
21 |
+
if ( isset( $_SERVER[ $sOption ] ) && ( strpos( $_SERVER[ $sOption ], 'https' ) !== false ) ) {
|
22 |
$_SERVER[ 'HTTPS' ] = 'on';
|
23 |
break;
|
24 |
}
|
25 |
}
|
26 |
+
|
27 |
+
$this->maintainPluginLoadPosition();
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Sets this plugin to be the first loaded of all the plugins.
|
32 |
+
*/
|
33 |
+
protected function maintainPluginLoadPosition() {
|
34 |
+
$sBaseFile = plugin_basename( __FILE__ );
|
35 |
+
$nLoadPosition = $this->getActivePluginLoadPosition( $sBaseFile );
|
36 |
+
if ( $nLoadPosition > 1 ) {
|
37 |
+
$this->setActivePluginLoadPosition( $sBaseFile, 0 );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param string $sPluginFile
|
43 |
+
* @return int
|
44 |
+
*/
|
45 |
+
public function getActivePluginLoadPosition( $sPluginFile ) {
|
46 |
+
$sOptionKey = is_multisite() ? 'active_sitewide_plugins' : 'active_plugins';
|
47 |
+
$aActive = get_option( $sOptionKey );
|
48 |
+
$nPosition = array_search( $sPluginFile, $aActive );
|
49 |
+
return ( $nPosition === false ) ? -1 : $nPosition;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param string $sPluginFile
|
54 |
+
* @param int $nDesiredPosition
|
55 |
+
*/
|
56 |
+
public function setActivePluginLoadPosition( $sPluginFile, $nDesiredPosition = 0 ) {
|
57 |
+
|
58 |
+
$aActive = $this->setArrayValueToPosition( get_option( 'active_plugins' ), $sPluginFile, $nDesiredPosition );
|
59 |
+
update_option( 'active_plugins', $aActive );
|
60 |
+
|
61 |
+
if ( is_multisite() ) {
|
62 |
+
$aActive = $this->setArrayValueToPosition( get_option( 'active_sitewide_plugins' ), $sPluginFile, $nDesiredPosition );
|
63 |
+
update_option( 'active_sitewide_plugins', $aActive );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @param array $aSubjectArray
|
69 |
+
* @param mixed $mValue
|
70 |
+
* @param int $nDesiredPosition
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function setArrayValueToPosition( $aSubjectArray, $mValue, $nDesiredPosition ) {
|
74 |
+
|
75 |
+
if ( $nDesiredPosition < 0 ) {
|
76 |
+
return $aSubjectArray;
|
77 |
+
}
|
78 |
+
|
79 |
+
$nMaxPossiblePosition = count( $aSubjectArray ) - 1;
|
80 |
+
if ( $nDesiredPosition > $nMaxPossiblePosition ) {
|
81 |
+
$nDesiredPosition = $nMaxPossiblePosition;
|
82 |
+
}
|
83 |
+
|
84 |
+
$nPosition = array_search( $mValue, $aSubjectArray );
|
85 |
+
if ( $nPosition !== false && $nPosition != $nDesiredPosition ) {
|
86 |
+
|
87 |
+
// remove existing and reset index
|
88 |
+
unset( $aSubjectArray[ $nPosition ] );
|
89 |
+
$aSubjectArray = array_values( $aSubjectArray );
|
90 |
+
|
91 |
+
// insert and update
|
92 |
+
// http://stackoverflow.com/questions/3797239/insert-new-item-in-array-on-any-position-in-php
|
93 |
+
array_splice( $aSubjectArray, $nDesiredPosition, 0, $mValue );
|
94 |
+
}
|
95 |
+
|
96 |
+
return $aSubjectArray;
|
97 |
}
|
98 |
}
|
99 |
|
readme.txt
CHANGED
@@ -6,7 +6,7 @@ License URI: http://www.gnu.org/licenses/gpl.html
|
|
6 |
Tags: CloudFlare, SSL, Flexible SSL, Universal SSL, redirect loop, HTTPS, HTTP_X_FORWARDED_PROTO
|
7 |
Requires at least: 3.2.0
|
8 |
Tested up to: 4.3
|
9 |
-
Stable tag: 1.
|
10 |
|
11 |
Fix For CloudFlare Flexible SSL Redirect Loop For WordPress.
|
12 |
|
@@ -46,6 +46,10 @@ For full installation instructions, please review the following article: [Instal
|
|
46 |
|
47 |
== Changelog ==
|
48 |
|
|
|
|
|
|
|
|
|
49 |
= 1.1.0 =
|
50 |
|
51 |
UPDATED: Supported WordPress Version
|
6 |
Tags: CloudFlare, SSL, Flexible SSL, Universal SSL, redirect loop, HTTPS, HTTP_X_FORWARDED_PROTO
|
7 |
Requires at least: 3.2.0
|
8 |
Tested up to: 4.3
|
9 |
+
Stable tag: 1.2.0
|
10 |
|
11 |
Fix For CloudFlare Flexible SSL Redirect Loop For WordPress.
|
12 |
|
46 |
|
47 |
== Changelog ==
|
48 |
|
49 |
+
= 1.2.0 =
|
50 |
+
|
51 |
+
ADDED: The plugin will try to set itself to load first, before all other plugins.
|
52 |
+
|
53 |
= 1.1.0 =
|
54 |
|
55 |
UPDATED: Supported WordPress Version
|