HTTP / HTTPS Remover: SSL Mixed Content Fix - Version 2.0

Version Description

Release Date - 1 March 2018

  • Completely rewritten code.
  • Bug fixes
Download this release

Release Info

Developer condacore
Plugin Icon 128x128 HTTP / HTTPS Remover: SSL Mixed Content Fix
Version 2.0
Comparing to
See all releases

Code changes from version 1.5.3 to 2.0

Files changed (2) hide show
  1. http-https-remover.php +49 -87
  2. readme.txt +33 -21
http-https-remover.php CHANGED
@@ -2,99 +2,61 @@
2
  /**
3
  * Plugin Name: HTTP / HTTPS Remover
4
  * Plugin URI: https://de.wordpress.org/plugins/http-https-remover/
5
- * Description: This Plugin cleans all the URLs in the source code while it removes the http:// and https:// and replaces it with //
6
- * Version: 1.5.3
7
  * Author: CONDACORE
8
  * Author URI: https://condacore.com/
9
  * License: GPLv3
10
  */
11
-
12
-
13
- # _____ ____ _ _ _____ _____ ____ _____ ______
14
- # / ____/ __ \| \ | | __ \ /\ / ____/ __ \| __ \| ____|
15
- # | | | | | | \| | | | | / \ | | | | | | |__) | |__
16
- # | | | | | | . ` | | | |/ /\ \| | | | | | _ /| __|
17
- # | |___| |__| | |\ | |__| / ____ \ |___| |__| | | \ \| |____
18
- # \_____\____/|_| \_|_____/_/ \_\_____\____/|_| \_\______|
19
- #
20
-
21
-
22
- if (!defined('ABSPATH')) exit;
23
- class HTTP_HTTPS_REMOVER
24
 
 
 
25
  {
26
-
27
-
28
- //Add some links on the plugin page
29
-
30
- // ###########################################
31
- // ##### Apply Plugin on the whole Site ######
32
- // ###########################################
33
- public function __construct()
34
-
35
- {
36
-
37
- add_action('wp_loaded', array(
38
- $this,
39
- 'letsGo'
40
- ) , 99, 1);
41
- }
42
- // #########################
43
- // ##### More Code... ######
44
- // #########################
45
- public function letsGo()
46
 
47
- {
48
- global $pagenow;
49
- ob_start(array(
50
- $this,
51
- 'mainPath'
52
- ));
53
- }
54
- public function mainPath($buffer)
55
-
56
- {
57
- $content_type = NULL;
58
- foreach(headers_list() as $header) {
59
- if (strpos(strtolower($header) , 'content-type:') === 0) {
60
- $pieces = explode(':', strtolower($header));
61
- $content_type = trim($pieces[1]);
62
- break;
63
- }
64
- }
65
- if (is_null($content_type) || substr($content_type, 0, 9) === 'text/html') {
66
- // ###############################
67
- // ##### The important Path ######
68
- // ###############################
69
-
70
-
71
-
72
- $buffer = str_replace(array('http://'.$_SERVER['HTTP_HOST'],'https://'.$_SERVER['HTTP_HOST']), '//'.$_SERVER['HTTP_HOST'], $buffer);
73
- $buffer = str_replace('content="//'.$_SERVER['HTTP_HOST'], 'content="https://'.$_SERVER['HTTP_HOST'], $buffer);
74
- $buffer = str_replace('> //'.$_SERVER['HTTP_HOST'], '> https://'.$_SERVER['HTTP_HOST'], $buffer);
75
- $buffer = str_replace('"url" : "//', '"url" : "https://', $buffer);
76
- $buffer = str_replace('"url": "//', '"url": "https://', $buffer);
77
- $buffer = preg_replace(array('|http://(.*?).googleapis.com|','|https://(.*?).googleapis.com|'), '//$1.googleapis.com', $buffer);
78
- $buffer = preg_replace(array('|http://(.*?).google.com|','|https://(.*?).google.com|'), '//$1.google.com', $buffer);
79
- $buffer = preg_replace(array('|http://(.*?).gravatar.com|','|https://(.*?).gravatar.com|'), '//$1.gravatar.com', $buffer);
80
- $buffer = preg_replace(array('|http://(.*?).w.org|','|https://(.*?).w.org|'), '//$1.w.org', $buffer);
81
-
82
-
83
-
84
- }
85
- return $buffer;
86
- }
87
  }
88
- new HTTP_HTTPS_REMOVER();
89
 
90
- //Add some links on the plugin page
91
- add_filter('plugin_row_meta', 'http_https_remover_extra_links', 10, 2);
92
-
93
- function http_https_remover_extra_links($links, $file) {
94
- if ( $file == plugin_basename(dirname(__FILE__).'/http-https-remover.php') ) {
95
- //$links[] = '<a href="https://condacore.com/portfolio/http-https-remover/#beta" target="_blank">' . esc_html__('Become a Beta Tester', 'http-https-remover') . '</a>';
96
- $links[] = '<a href="https://twitter.com/condacore" target="_blank">' . esc_html__('Twitter', 'http-https-remover') . '</a>';
97
- $links[] = '<a href="https://paypal.me/MariusBolik" target="_blank">' . esc_html__('Donate', 'http-https-remover') . '</a>';
98
- }
99
- return $links;
100
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /**
3
  * Plugin Name: HTTP / HTTPS Remover
4
  * Plugin URI: https://de.wordpress.org/plugins/http-https-remover/
5
+ * Description: This Plugin creates protocol relative urls by removing http + https from links.
6
+ * Version: 2.0
7
  * Author: CONDACORE
8
  * Author URI: https://condacore.com/
9
  * License: GPLv3
10
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ // Function for srcset URLs
13
+ function protcol_relative_url_srcset($sources)
14
  {
15
+ foreach ($sources as &$source) {
16
+ $link = str_replace("http://", "//", $source['url']);
17
+ $link = str_replace("https://", "//", $link);
18
+ $source['url'] = $link;
19
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ return $sources;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  }
 
23
 
24
+ // Function for all other URLs
25
+ function callback_protcol_relative_url($buffer)
26
+ {
27
+ $re = "/(<(script|link|base|img|form|a)([^>]*)(href|src|srcset|action)=[\"'])https?:\\/\\//i";
28
+ $subst = "$1//";
29
+ $return = preg_replace($re, $subst, $buffer);
30
+
31
+ // on regex error, skip overwriting buffer
32
+ if ($return) {
33
+ $buffer = $return;
34
+ }
35
+ return $buffer;
36
+ }
37
+
38
+ function http_https_remover_extra_links($links, $file)
39
+ {
40
+ if ($file == plugin_basename(dirname(__FILE__).'/http-https-remover.php')) {
41
+ //$links[] = '<a href="https://condacore.com/portfolio/http-https-remover/#beta" target="_blank">' . esc_html__('Become a Beta Tester', 'http-https-remover') . '</a>';
42
+ $links[] = '<a href="https://twitter.com/condacore" target="_blank">' . esc_html__('Twitter', 'http-https-remover') . '</a>';
43
+ $links[] = '<a href="https://paypal.me/MariusBolik" target="_blank">' . esc_html__('Donate', 'http-https-remover') . '</a>';
44
+ }
45
+ return $links;
46
+ }
47
+
48
+ function buffer_start_protcol_relative_url()
49
+ {
50
+ ob_start('callback_protcol_relative_url');
51
+ }
52
+ function buffer_end_protcol_relative_url()
53
+ {
54
+ ob_end_flush();
55
+ }
56
+
57
+ // http://codex.wordpress.org/Plugin_API/Action_Reference
58
+ add_filter('plugin_row_meta', 'http_https_remover_extra_links', 10, 2);
59
+ add_filter('wp_calculate_image_srcset', 'protcol_relative_url_srcset');
60
+ add_action('wp_loaded', 'buffer_start_protcol_relative_url' , 99, 1);
61
+ //add_action('registered_taxonomy', 'buffer_start_protcol_relative_url');
62
+ add_action('shutdown', 'buffer_end_protcol_relative_url');
readme.txt CHANGED
@@ -1,14 +1,14 @@
1
- === HTTP / HTTPS Remover ===
2
  Contributors: condacore
3
  Donate link: https://www.paypal.me/MariusBolik
4
- Tags: http, https, mixed content
5
  Requires at least: 3.0.1
6
- Tested up to: 4.7.4
7
- Stable tag: 1.5.3
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
- A fix for mixed content! This Plugin removes HTTP and HTTPS protocols from all links. Works in Front- and Backend!
12
 
13
  == Description ==
14
 
@@ -17,17 +17,32 @@ Main features:
17
  * Works in Front- and Backend
18
  * Makes every Plugin compatible with https
19
  * No Setup needed
20
- * Compatible with Visual Composer
21
  * Fixes Google Fonts issues
22
  * Makes your website faster
23
 
24
  = What does this Plugin do? =
25
 
26
- Links with "http://" extensions need to change to contain the “s” part of HTTP protocol (https://) pointing out to an SSL-reserved port. A more elegant way of handling different protocols is to have only slashes where port is expected "//". so that page can use the protocol used to open the page itself:
27
- 1. If page was loaded via http links with "//", it will be transformed to http://
28
- 1. If page was loaded via https links with "//", it will be ultimately transformed to https://
29
-
30
- Of course, this only applies to links that are loading content from your own domain, Google Fonts and other Google APIs. Your users are counting on you to protect them when they visit your website. It is important to fix your mixed content issues to protect all your visitors, including those on older browsers. And that's what this plugin does!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
  = What is Mixed Content? =
33
 
@@ -47,18 +62,10 @@ With Plugin:
47
  src="//domain.com/script02.js"
48
  src="//domain.com/script03.js"`
49
 
50
- = If using CloudFlare or other Caching Plugin =
51
 
52
- **If using CloudFlare Plugin:**
53
- 1. Go to Settings -> CloudFlare -> More Settings
54
- 2. Disable "Automatic HTTPS Rewrites" (Our Plugin is better) :)
55
- 3. Go back to "Home" in CloudFlare Plugin and click "Purge Cache" for the changes to take effect!
56
-
57
- **Other Cache Plugin:**
58
  If the plugin isn't working like expected please purge/clear cache for the changes to take effect!
59
 
60
- For more info visit us at [condacore.com](https://condacore.com/ "CONDACORE Website")
61
-
62
  == Installation ==
63
 
64
  1. Upload `http-https-remover` folder to your `/wp-content/plugins/` directory.
@@ -75,7 +82,6 @@ In Firefox the padlock icon will reflect a warning with mixed content.
75
 
76
  = What if I am using a CDN? =
77
 
78
- Change all your CDN references to load with https://
79
  Change all your CDN references to load with // (this will adapt based on how the page is loaded)
80
 
81
  == Screenshots ==
@@ -84,6 +90,12 @@ Change all your CDN references to load with // (this will adapt based on how the
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
87
  = 1.5.3 =
88
  *Release Date - 28 April 2017*
89
 
1
+ === HTTP / HTTPS Remover: SSL Mixed Content Fix ===
2
  Contributors: condacore
3
  Donate link: https://www.paypal.me/MariusBolik
4
+ Tags: SSL, https, force SSL, mixed content, insecure content, secure website, website security, TLS, security, secure socket layers, HSTS
5
  Requires at least: 3.0.1
6
+ Tested up to: 4.9.4
7
+ Stable tag: 2.0
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
11
+ A fix for mixed content! This Plugin creates protocol relative urls by removing http + https from links. Works in Front- and Backend!
12
 
13
  == Description ==
14
 
17
  * Works in Front- and Backend
18
  * Makes every Plugin compatible with https
19
  * No Setup needed
20
+ * Compatible with Visual Composer & Disqus
21
  * Fixes Google Fonts issues
22
  * Makes your website faster
23
 
24
  = What does this Plugin do? =
25
 
26
+ With protocol relative url's you simply leave off the http: or https: part of the resource path. The browser will automatically load the resource using the same protocol that the page was loaded with.
27
+
28
+ For example, an absolute url may look like
29
+ `
30
+ src="http://domain.com/script.js"
31
+ `
32
+ If you were to load this from a https page the script will not be loaded – as non-https resources are not loaded from https pages (for security reasons).
33
+
34
+ The protocol relative url would look like
35
+ `
36
+ src="//domain.com/script.js"
37
+ `
38
+ and would load if the web page was http or https.
39
+
40
+ **Tipp:** Check your Settings -> General page and make sure your WordPress Address and Site Address are starting with "https".
41
+ Add the following two lines in your wp-config.php above the line that​ says "Stop Editing Here":
42
+ `
43
+ define('FORCE_SSL', true);
44
+ define('FORCE_SSL_ADMIN',true);
45
+ `
46
 
47
  = What is Mixed Content? =
48
 
62
  src="//domain.com/script02.js"
63
  src="//domain.com/script03.js"`
64
 
65
+ = If using Cache Plugins =
66
 
 
 
 
 
 
 
67
  If the plugin isn't working like expected please purge/clear cache for the changes to take effect!
68
 
 
 
69
  == Installation ==
70
 
71
  1. Upload `http-https-remover` folder to your `/wp-content/plugins/` directory.
82
 
83
  = What if I am using a CDN? =
84
 
 
85
  Change all your CDN references to load with // (this will adapt based on how the page is loaded)
86
 
87
  == Screenshots ==
90
 
91
  == Changelog ==
92
 
93
+ = 2.0 =
94
+ *Release Date - 1 March 2018*
95
+
96
+ * Completely rewritten code.
97
+ * Bug fixes
98
+
99
  = 1.5.3 =
100
  *Release Date - 28 April 2017*
101