WordPress HTTPS (SSL) - Version 0.1

Version Description

  • Initial Release
Download this release

Release Info

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

Version 0.1

Files changed (2) hide show
  1. readme.txt +24 -0
  2. wordpress-https.php +54 -0
readme.txt ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: Mvied
3
+ Tags: encrypted, ssl, http, https
4
+ Requires at least: 2.1.0
5
+ Tested up to: 3.0.1
6
+ Stable tag: trunk
7
+
8
+ This plugin ensures that all elements on a page are accessed through HTTPS if the page is being accessed via HTTPS.
9
+
10
+ == Description ==
11
+
12
+ This plugin ensures that all elements on a page are accessed through HTTPS if the page is being accessed via HTTPS.
13
+
14
+ Unlike the [HTTPS for Wordpress](http://wordpress.org/extend/plugins/https-for-wordpress/ "HTTPS for Wordpress") plugin, elements will be loaded with HTTPS regardless of how the plugin author added the elements to the page.
15
+
16
+ == Installation ==
17
+
18
+ 1. Upload `wordpress-https.php` to the `/wp-content/plugins/` directory
19
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
20
+
21
+ == Changelog ==
22
+
23
+ = 0.1 =
24
+ * Initial Release
wordpress-https.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WordPress HTTPS
4
+ Plugin URI: http://mvied.com/projects/wordpress-https/
5
+ Description: This plugin ensures that all elements on a page are accessed through HTTPS if the page is being accessed via HTTPS. Inspired by <a href="http://wordpress.org/extend/plugins/https-for-wordpress/">HTTPS for Wordpress</a>.
6
+ Author: Mike Ems
7
+ Version: 0.1
8
+ Author URI: http://mvied.com/
9
+ */
10
+
11
+ /* Copyright 2010 Mike Ems (email : mike@mvied.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+ */
27
+
28
+ function wphttps_process($buffer) {
29
+ // Only rewrite URLs if the page is currently HTTPS.
30
+ if($_SERVER["HTTPS"] == "on") {
31
+ // If HTTPS is active on a page, siteurl will return a https URL.
32
+ // We need the url without https so that we can find it and replace
33
+ // it within the source of the page.
34
+ $httpsUrl = get_bloginfo('siteurl');
35
+ $httpUrl = str_replace('https://','http://',get_bloginfo('siteurl'));
36
+
37
+ // Match all script, link, and img tags that need to be set to https
38
+ preg_match_all('/\<(script|link|img)+(.*)http:\/\/[-\w\.]+[^\"\']*\b/im',$buffer,$matches);
39
+ foreach ($matches[0] as $match) {
40
+ if (strpos($match,$httpUrl) > -1 && ((strpos($match,'link') > -1 && strpos($match,'stylesheet') > -1) || strpos($match,'script') > -1 || strpos($match,'img') > -1) ) {
41
+ $buffer = str_replace($match,str_replace('http','https',$match),$buffer);
42
+ }
43
+ }
44
+ }
45
+ return $buffer;
46
+ }
47
+
48
+ function wphttps_buffer_start() { ob_start("wphttps_process"); }
49
+ function wphttps_buffer_end() { ob_end_flush(); }
50
+
51
+ add_action('send_headers', 'wphttps_buffer_start');
52
+ add_action('wp_footer', 'wphttps_buffer_end');
53
+
54
+ ?>