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

Version Description

Release Date - 20th March 2019

  • Simplified Code
Download this release

Release Info

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

Code changes from version 2.0 to 2.1

Files changed (3) hide show
  1. http-https-remover.php +140 -48
  2. index.php +1 -1
  3. readme.txt +7 -2
http-https-remover.php CHANGED
@@ -3,60 +3,152 @@
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');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1
7
  * Author: CONDACORE
8
  * Author URI: https://condacore.com/
9
  * License: GPLv3
10
  */
11
 
12
+ if (!defined('ABSPATH'))
13
+ exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ class HTTP_HTTPS_REMOVER
16
+ {
17
+
18
+ public function __construct()
19
+ {
20
+
21
+ add_action('wp_loaded', array(
22
+ $this,
23
+ 'letsGo'
24
+ ), 99, 1);
25
+
26
+ /* Plugin Activation Hook */
27
+ register_activation_hook( __FILE__, array($this, 'jr_default_activation_hook') );
28
+ /* Add admin notice */
29
+ add_action( 'admin_notices', array($this,'jr_activation_notice_hook') );
30
+ /* Adding links filter */
31
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'jr_add_action_links') );
32
+
33
+ /* Remove Trans */
34
+
35
+ add_action( 'wp_ajax_nopriv_jr_remove_trans', array($this,'jr_remove_set_transient'));
36
+ add_action( 'wp_ajax_jr_remove_trans', array($this,'jr_remove_set_transient'));
37
 
38
+ }
39
+
40
+ public function jr_remove_set_transient(){
41
+ delete_transient( 'jr-wp-admin-notice' );
42
+ echo "Transient Deleted!";
43
+ exit;
44
+ }
45
+
46
+ /**
47
+ * Create transient data
48
+ */
49
+
50
+ public function jr_default_activation_hook() {
51
+ set_transient( 'jr-wp-admin-notice', true, 0 );
52
+ }
53
+
54
+ /**
55
+ * Adding Links
56
+ */
57
+
58
+ function jr_add_action_links ( $links ) {
59
+ $mylinks = array(
60
+ '<a target="_blank" style="color:green;" href="https://sellcodes.com/s/N3bDHV
61
+ ">Get share count recovery</a>',
62
+ );
63
+ return array_merge( $links, $mylinks );
64
+ }
65
+
66
+ /**
67
+ * Admin Notice on Activation.
68
+ */
69
+ public function jr_activation_notice_hook(){
70
 
71
+ /* Check transient */
72
+ if( get_transient( 'jr-wp-admin-notice' ) ){
73
+ ?>
74
+ <div class="updated notice is-dismissible http_custom_class">
75
+ <p>
76
+ Plugin "HTTP / HTTPS Remover: SSL Mixed Content Fix” has been successfully installed and activated – hurray!
77
+ </p>
78
+ <p>
79
+ <strong>Next:</strong> if you don‘t want to lose traffic to your site we strongly recommend to get the <a style="color:green;" target="_blank" href="https://sellcodes.com/s/N3bDHV">Ultimate Social Media plugin</a> which has a share count recovery feature (so that you don‘t lose any share counts after your switch to https) besides many other cool features.
80
+ </p>
81
+ <div class="notice_links" style="padding: 10px 0;">
82
+ <div style="width: 33.333%;float:left;text-align: left;">
83
+ <!--<a style="color:green;" href="#">Get plugin now</a>-->
84
+
85
+ <script type="text/javascript" src="https://sellcodes.com/quick_purchase/XdHlrQnc/embed.js"></script> <div class="sellcodes-quick-purchase"><a style="color: green;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell, 'Helvetica Neue',sans-serif;font-size: 14px !important;text-decoration: underline !important;" class="sc-button" data-product-id="XdHlrQnc" data-option-id="4HiwuC6Y" data-referral="N3bDHV">Get plugin now</a></div>
86
+
87
+ </div>
88
+ <div style="width: 33.333%;float:left;text-align: left;">
89
+ <a style="color:green;" target="_blank" href="https://sellcodes.com/s/N3bDHV">See all plugin features </a>
90
+ </div>
91
+ <div style="width: 33.333%;float:left;text-align: left;">
92
+ <a id="remove_trans_anchor" style="color:#999;" href="#">
93
+ I‘m fine with getting less shares & traffic
94
+ </a>
95
+ </div>
96
+ <div style="clear: both;"></div>
97
+ </div>
98
+ </div>
99
+ <style>
100
+ .http_custom_class .notice-dismiss{
101
+ display: none;
102
+ }
103
+ </style>
104
 
105
+ <script>
106
+ var ajax_request_url = '<?php echo admin_url('admin-ajax.php'); ?>';
107
+ jQuery(document).ready(function($){
108
+ $("#remove_trans_anchor").on("click",function(e){
109
+ e.preventDefault();
110
+ $.ajax({
111
+ url: ajax_request_url,
112
+ type: "POST",
113
+ data: "action=jr_remove_trans",
114
+ success:function(response){
115
+ jQuery('.http_custom_class .notice-dismiss').trigger('click');
116
+ }
117
+ });
118
+ });
119
+ })
120
+ </script>
121
+ <?php
122
+ //delete_transient( 'jr-wp-admin-notice' );
123
+ }
124
+ }
125
+
126
+
127
+ public function letsGo()
128
+ {
129
+ global $pagenow;
130
+ ob_start(array(
131
+ $this,
132
+ 'mainPath'
133
+ ));
134
+ }
135
+
136
+ public function mainPath($buffer)
137
+ {
138
+ $content_type = NULL;
139
+ foreach (headers_list() as $header) {
140
+ if (strpos(strtolower($header), 'content-type:') === 0) {
141
+ $pieces = explode(':', strtolower($header));
142
+ $content_type = trim($pieces[1]);
143
+ break;
144
+ }
145
+ }
146
+ if (is_null($content_type) || substr($content_type, 0, 9) === 'text/html') {
147
+
148
+ $buffer = preg_replace('/https?:/i', '', $buffer);
149
+
150
+ }
151
+ return $buffer;
152
+ }
153
+ }
154
+ new HTTP_HTTPS_REMOVER();
index.php CHANGED
@@ -10,5 +10,5 @@
10
  #
11
  # Plugin: HTTP / HTTPS Remover
12
  # Created by: Marius Bolik
13
- # Copyright: 2017 © CONDACORE
14
  # Web: https://condacore.com
10
  #
11
  # Plugin: HTTP / HTTPS Remover
12
  # Created by: Marius Bolik
13
+ # Copyright: 2019 © CONDACORE
14
  # Web: https://condacore.com
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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
 
@@ -90,6 +90,11 @@ Change all your CDN references to load with // (this will adapt based on how the
90
 
91
  == Changelog ==
92
 
 
 
 
 
 
93
  = 2.0 =
94
  *Release Date - 1 March 2018*
95
 
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: 5.1.1
7
+ Stable tag: 2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
90
 
91
  == Changelog ==
92
 
93
+ = 2.1 =
94
+ *Release Date - 20th March 2019*
95
+
96
+ * Simplified Code
97
+
98
  = 2.0 =
99
  *Release Date - 1 March 2018*
100