WordPress HTTPS (SSL) - Version 1.7

Version Description

  • Bug fix - External URL's were not being forced to HTTPS after the last update.
  • Added the functionality to correct relative URL's when using Shared SSL.
  • General code cleanup and such.
Download this release

Release Info

Developer Mvied
Plugin Icon wp plugin WordPress HTTPS (SSL)
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.5 to 1.7

Files changed (4) hide show
  1. readme.txt +9 -3
  2. screenshot-1.png +0 -0
  3. screenshot-2.png +0 -0
  4. wordpress-https.php +53 -21
readme.txt CHANGED
@@ -4,13 +4,13 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: encrypted, ssl, http, https
5
  Requires at least: 2.7.0
6
  Tested up to: 3.0.1
7
- Stable tag: 1.6.5
8
 
9
- Features: Force HTTPS on only certain pages. Fix partially encrypted errors. Disable WordPress from changing links to HTTPS. And more!
10
 
11
  == Description ==
12
 
13
- WordPress HTTPS is a WordPress plugin that is intended to be an all-in-one solution to using SSL on WordPress sites. Here are the currently available features:
14
 
15
  <ul>
16
  <li>Change all internal scripts, stylesheets and images to HTTPS if the page is being viewed via HTTPS to prevent partially encrypted errors.</li>
@@ -65,6 +65,10 @@ In most cases, yes. There are limitations to what this plugin can fix. Here are
65
 
66
  == Changelog ==
67
 
 
 
 
 
68
  = 1.6.5 =
69
  * Added support for Shared SSL.
70
  = 1.6.3 =
@@ -105,6 +109,8 @@ In most cases, yes. There are limitations to what this plugin can fix. Here are
105
  * Initial Release.
106
 
107
  == Upgrade Notice ==
 
 
108
  = 1.6.1 =
109
  Version 1.6.1 fixes a bug with using a static page for the posts page.
110
  = 1.0.1 =
4
  Tags: encrypted, ssl, http, https
5
  Requires at least: 2.7.0
6
  Tested up to: 3.0.1
7
+ Stable tag: 1.7
8
 
9
+ WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites. Free support provided!
10
 
11
  == Description ==
12
 
13
+ Here are the currently available features:
14
 
15
  <ul>
16
  <li>Change all internal scripts, stylesheets and images to HTTPS if the page is being viewed via HTTPS to prevent partially encrypted errors.</li>
65
 
66
  == Changelog ==
67
 
68
+ = 1.7 =
69
+ * Bug fix - External URL's were not being forced to HTTPS after the last update.
70
+ * Added the functionality to correct relative URL's when using Shared SSL.
71
+ * General code cleanup and such.
72
  = 1.6.5 =
73
  * Added support for Shared SSL.
74
  = 1.6.3 =
109
  * Initial Release.
110
 
111
  == Upgrade Notice ==
112
+ = 1.7 =
113
+ 1.6.5 created a bug in which external elements were no longer forced to HTTPS. Please update to fix this.
114
  = 1.6.1 =
115
  Version 1.6.1 fixes a bug with using a static page for the posts page.
116
  = 1.0.1 =
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
wordpress-https.php CHANGED
@@ -2,9 +2,9 @@
2
  /*
3
  Plugin Name: WordPress HTTPS
4
  Plugin URI: http://mvied.com/projects/wordpress-https/
5
- Description: Force HTTPS on only certain pages. Fix partially encrypted errors. Disable WordPress from changing links to HTTPS. And more!
6
  Author: Mike Ems
7
- Version: 1.6.5
8
  Author URI: http://mvied.com/
9
  */
10
 
@@ -24,7 +24,7 @@ if ( !class_exists('WordPressHTTPS') ) {
24
  *
25
  * @var int
26
  */
27
- var $plugin_version = '1.6.5';
28
 
29
  /**
30
  * Plugin URL
@@ -47,6 +47,13 @@ if ( !class_exists('WordPressHTTPS') ) {
47
  */
48
  var $https_url;
49
 
 
 
 
 
 
 
 
50
  /**
51
  * Default options
52
  *
@@ -70,15 +77,17 @@ if ( !class_exists('WordPressHTTPS') ) {
70
 
71
  // Assign HTTP URL
72
  $this->http_url = get_option('home');
 
 
73
 
74
- // Assign HTTPS URL and prevent WordPress from causing a redirect loop if using Shared SSL
75
  if (get_option('wordpress-https_sharedssl') == 1 && get_option('wordpress-https_sharedssl_host') != '') {
 
 
 
76
  $this->https_url = get_option('wordpress-https_sharedssl_host');
77
-
78
  // Prevent WordPress from causing a redirect loop if using Shared SSL
79
  remove_filter('template_redirect', 'redirect_canonical');
80
- } else {
81
- $this->https_url = $this->replace_http($this->http_url);
82
  }
83
 
84
  // Define default options
@@ -115,8 +124,12 @@ if ( !class_exists('WordPressHTTPS') ) {
115
  }
116
  }
117
  }
 
 
 
 
118
  } else {
119
- // If not admin page, check to see if the page needs to be redirected
120
  add_action('template_redirect', array(&$this, 'check_https'));
121
  }
122
 
@@ -133,10 +146,6 @@ if ( !class_exists('WordPressHTTPS') ) {
133
  add_filter('bloginfo_url', array(&$this, 'bloginfo'), 10, 2);
134
  }
135
 
136
- // Add 'Force SSL' checkbox to add/edit post pages
137
- add_action('post_submitbox_misc_actions', array(&$this, 'post_checkbox'));
138
- add_action('save_post', array(&$this, 'post_save'));
139
-
140
  // Start output buffering
141
  add_action('plugins_loaded', array(&$this, 'buffer_start'));
142
 
@@ -152,7 +161,7 @@ if ( !class_exists('WordPressHTTPS') ) {
152
  */
153
  function process($buffer) {
154
  if ( $this->is_ssl() ) {
155
- preg_match_all('/\<(script|link|img|input)[^>]+((http|https):\/\/[\/-\w\.]+)[^>]+>/im',$buffer,$matches);
156
 
157
  for ($i = 0; $i<=sizeof($matches[0]); $i++) {
158
  $html = $matches[0][$i];
@@ -160,24 +169,43 @@ if ( !class_exists('WordPressHTTPS') ) {
160
  $url = $matches[2][$i];
161
  $scheme = $matches[3][$i];
162
 
163
- if ( ( $type == 'link' && strpos($html, 'stylesheet') !== false ) || ( $type == 'input' && strpos($html, 'image') !== false ) || $type == 'script' || $type == 'img' ) {
164
  if ( strpos($html,$this->http_url) !== false && get_option('wordpress-https_internalurls') == 1 ) {
165
  $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
166
  } else if ( get_option('wordpress-https_externalurls') == 1 ) {
167
  if ( get_option('wordpress-https_bypass') == 1 ) {
168
- $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
169
  } else if (@file_get_contents($this->replace_http($url))) {
170
- $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
171
  }
172
  }
173
  }
174
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
  return $buffer;
177
  }
178
 
 
 
 
 
 
 
179
  function is_ssl() {
180
- if ( get_option('wordpress-https_sharedssl') == 1 ) {
181
  if ( strpos($this->https_url, $_SERVER['HTTP_X_FORWARDED_SERVER']) !== false ) {
182
  return true;
183
  } else {
@@ -189,7 +217,7 @@ if ( !class_exists('WordPressHTTPS') ) {
189
  }
190
 
191
  /**
192
- * Checks to see if the current page needs to be redirected
193
  *
194
  * @param none
195
  * @return void
@@ -225,10 +253,14 @@ if ( !class_exists('WordPressHTTPS') ) {
225
  */
226
  function redirect($ssl = true) {
227
  if ( !$this->is_ssl() && $ssl == true ) {
228
- wp_redirect($this->https_url . $_SERVER['REQUEST_URI']);
229
- exit();
230
  } else if ($this->is_ssl() && $ssl == false) {
231
- wp_redirect($this->http_url . $_SERVER['REQUEST_URI']);
 
 
 
 
 
232
  exit();
233
  }
234
  }
2
  /*
3
  Plugin Name: WordPress HTTPS
4
  Plugin URI: http://mvied.com/projects/wordpress-https/
5
+ Description: WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites. Free support provided!
6
  Author: Mike Ems
7
+ Version: 1.7
8
  Author URI: http://mvied.com/
9
  */
10
 
24
  *
25
  * @var int
26
  */
27
+ var $plugin_version = '1.7';
28
 
29
  /**
30
  * Plugin URL
47
  */
48
  var $https_url;
49
 
50
+ /**
51
+ * Shared SSL
52
+ *
53
+ * @var boolean
54
+ */
55
+ var $shared_ssl = 0;
56
+
57
  /**
58
  * Default options
59
  *
77
 
78
  // Assign HTTP URL
79
  $this->http_url = get_option('home');
80
+ // Assign HTTPS URL
81
+ $this->https_url = $this->replace_http($this->http_url);
82
 
83
+ // Shared SSL
84
  if (get_option('wordpress-https_sharedssl') == 1 && get_option('wordpress-https_sharedssl_host') != '') {
85
+ // Turn on Shared SSL
86
+ $this->shared_ssl = 1;
87
+ // Assign HTTPS URL to Shared SSL Host
88
  $this->https_url = get_option('wordpress-https_sharedssl_host');
 
89
  // Prevent WordPress from causing a redirect loop if using Shared SSL
90
  remove_filter('template_redirect', 'redirect_canonical');
 
 
91
  }
92
 
93
  // Define default options
124
  }
125
  }
126
  }
127
+
128
+ // Add 'Force SSL' checkbox to add/edit post pages
129
+ add_action('post_submitbox_misc_actions', array(&$this, 'post_checkbox'));
130
+ add_action('save_post', array(&$this, 'post_save'));
131
  } else {
132
+ // If not admin page, check if the page needs to be redirected
133
  add_action('template_redirect', array(&$this, 'check_https'));
134
  }
135
 
146
  add_filter('bloginfo_url', array(&$this, 'bloginfo'), 10, 2);
147
  }
148
 
 
 
 
 
149
  // Start output buffering
150
  add_action('plugins_loaded', array(&$this, 'buffer_start'));
151
 
161
  */
162
  function process($buffer) {
163
  if ( $this->is_ssl() ) {
164
+ preg_match_all('/\<(script|link|img|input|form)[^>]+((http|https):\/\/[\/-\w\.#]+)[^>]+>/im',$buffer,$matches);
165
 
166
  for ($i = 0; $i<=sizeof($matches[0]); $i++) {
167
  $html = $matches[0][$i];
169
  $url = $matches[2][$i];
170
  $scheme = $matches[3][$i];
171
 
172
+ if ( ( $type == 'link' && strpos($html, 'stylesheet') !== false ) || ( $type == 'input' && strpos($html, 'image') !== false ) || $type == 'img' || $type == 'script' ) {
173
  if ( strpos($html,$this->http_url) !== false && get_option('wordpress-https_internalurls') == 1 ) {
174
  $buffer = str_replace($html, str_replace($this->http_url, $this->https_url, $html), $buffer);
175
  } else if ( get_option('wordpress-https_externalurls') == 1 ) {
176
  if ( get_option('wordpress-https_bypass') == 1 ) {
177
+ $buffer = str_replace($html, $this->replace_http($html), $buffer);
178
  } else if (@file_get_contents($this->replace_http($url))) {
179
+ $buffer = str_replace($html, $this->replace_http($html), $buffer);
180
  }
181
  }
182
  }
183
  }
184
+
185
+ // Look for any relative paths that should be udpated to the Shared SSL path
186
+ if ( $this->shared_ssl == 1 ) {
187
+ preg_match_all('/\<(script|link|img|input|form|a)[^>]+[\'"](\/[\/-\w\.#]*)[^>]+>/im',$buffer,$matches);
188
+
189
+ for ($i = 0; $i<=sizeof($matches[0]); $i++) {
190
+ $html = $matches[0][$i];
191
+ $type = $matches[1][$i];
192
+ $url = $matches[2][$i];
193
+
194
+ $buffer = str_replace($html, str_replace($url, $this->https_url . $url, $html), $buffer);
195
+ }
196
+ }
197
  }
198
  return $buffer;
199
  }
200
 
201
+ /**
202
+ * Checks if the current page is SSL
203
+ *
204
+ * @param none
205
+ * @return void
206
+ */
207
  function is_ssl() {
208
+ if ( $this->shared_ssl == 1 ) {
209
  if ( strpos($this->https_url, $_SERVER['HTTP_X_FORWARDED_SERVER']) !== false ) {
210
  return true;
211
  } else {
217
  }
218
 
219
  /**
220
+ * Checks if the current page needs to be redirected
221
  *
222
  * @param none
223
  * @return void
253
  */
254
  function redirect($ssl = true) {
255
  if ( !$this->is_ssl() && $ssl == true ) {
256
+ $url = parse_url($this->https_url);
 
257
  } else if ($this->is_ssl() && $ssl == false) {
258
+ $url = parse_url($this->http_url);
259
+ } else {
260
+ $url = false;
261
+ }
262
+ if ($url) {
263
+ wp_redirect($url['scheme'] . '://' . $url['host'] . (($this->shared_ssl) ? $url['path'] : '') . $_SERVER['REQUEST_URI']);
264
  exit();
265
  }
266
  }