Easy HTTPS Redirection - Version 1.8

Version Description

Download this release

Release Info

Developer mra13
Plugin Icon 128x128 Easy HTTPS Redirection
Version 1.8
Comparing to
See all releases

Code changes from version 1.6 to 1.8

https-redirection-settings.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /* Function for display htaccess settings page in the admin area */
4
 
5
  function httpsrdrctn_settings_page() {
@@ -32,21 +31,23 @@ function httpsrdrctn_settings_page() {
32
  //httpsrdrctn_generate_htaccess();
33
  }
34
  }
 
35
  /* Display form on the setting page */
36
  ?>
37
- <div class="wrap">
38
- <div class="icon32 icon32-bws" id="icon-options-general"></div>
39
- <h2><?php _e('HTTPS Redirection Settings', 'https_redirection'); ?></h2>
40
-
41
- <div style="background: #fff6d5; border: 1px solid #d1b655; color: #3f2502; margin: 10px 0; padding: 5px 5px 5px 10px; text-shadow: 1px 1px #ffffff;">
42
- <p>When you enable the HTTPS redirection, the plugin will force redirect the URL to the HTTPS version of the URL.
43
- So before enabling this plugin's feature, enter your site's HTTPS URL (example: https://yoursite.com/some-page) in the browser's address bar to make sure the page loads correctly.
44
  Otherwise you may get locked out if your SSL certificate is not installed correctly on your site or the HTTPS URL is not working and this plugin is auto redirecting to the HTTPS URL.
45
- </p>
46
- </div>
 
47
 
48
- <?php
49
- if ( get_option('permalink_structure') ) {
50
  //Pretty permalink is enabled. So allow HTTPS redirection feature.
51
  ?>
52
  <div id="httpsrdrctn_settings_notice" class="updated fade" style="display:none"><p><strong><?php _e("Notice:", 'https_redirection'); ?></strong> <?php _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'https_redirection'); ?></p></div>
@@ -57,38 +58,66 @@ function httpsrdrctn_settings_page() {
57
  <tr valign="top">
58
  <th scope="row"><?php _e('Enable automatic redirection to the "HTTPS"', 'https_redirection'); ?></th>
59
  <td>
60
- <label><input type="checkbox" name="httpsrdrctn_https" value="1" <?php if ('1' == $httpsrdrctn_options['https']) echo "checked=\"checked\" "; ?>/></label><br />
61
  <p class="description">Use this option to make your webpage(s) load in HTTPS version only. If someone enters a non-https URL in the browser's address bar then the plugin will automatically redirect to the HTTPS version of that URL.</p>
62
-
63
- <br />
64
- <p>You can apply a force HTTPS redirection on your entire domain or just a few pages.</p>
65
- <label <?php if ('0' == $httpsrdrctn_options['https']) echo 'class="hidden"'; ?>><input type="radio" name="httpsrdrctn_https_domain" value="1" <?php if ('1' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> The whole domain</label><br />
66
- <label <?php if ('0' == $httpsrdrctn_options['https']) echo 'class="hidden"'; ?>><input type="radio" name="httpsrdrctn_https_domain" value="0" <?php if ('0' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> A few pages</label><br />
67
- <?php foreach ($httpsrdrctn_options['https_pages_array'] as $https_page) { ?>
68
- <span class="<?php if ('1' == $httpsrdrctn_options['https_domain'] || '0' == $httpsrdrctn_options['https']) echo 'hidden'; ?>" >
69
- <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="<?php echo $https_page; ?>" /> <span class="rewrite_delete_item">&nbsp;</span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br />
70
- </span>
71
- <?php } ?>
72
- <span class="rewrite_new_item <?php if ('1' == $httpsrdrctn_options['https_domain'] || '0' == $httpsrdrctn_options['https']) echo 'hidden'; ?>" >
73
- <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="" /> <span class="rewrite_add_item">&nbsp;</span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br />
74
- </span>
75
- </td>
76
- </tr>
77
- <tr valign="top">
78
- <th scope="row"><?php _e('Force resources to use HTTPS URL', 'https_redirection'); ?></th>
79
- <td>
80
- <label><input type="checkbox" name="httpsrdrctn_force_resources" value="1" <?php if (isset($httpsrdrctn_options['force_resources']) && $httpsrdrctn_options['force_resources'] == '1') echo "checked=\"checked\" "; ?>/></label><br />
81
- <p class="description">When checked, the plugin will force load HTTPS URL for any static resources in your content. Example: if you have have an image embedded in a post with a NON-HTTPS URL, this option will change that to a HTTPS URL.</p>
82
  </td>
83
  </tr>
84
  </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  <input type="hidden" name="httpsrdrctn_form_submit" value="submit" />
86
  <p class="submit">
87
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
88
  </p>
89
  <?php wp_nonce_field(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name'); ?>
90
  </form>
91
-
 
 
 
 
 
 
 
 
 
 
92
  <div style="background: #FFEBE8; border: 1px solid #CC0000; color: #333333; margin: 10px 0; padding: 5px 5px 5px 10px;">
93
  <p><strong><?php _e("Notice:", 'https_redirection'); ?></strong> <?php _e("It is very important to be extremely attentive when making changes to .htaccess file.", 'https_redirection'); ?></p>
94
  <p>If after making changes your site stops functioning, do the following:</p>
@@ -102,19 +131,19 @@ function httpsrdrctn_settings_page() {
102
 
103
  <p>The changes will be applied immediately after saving the changes, if you are not sure - do not click the "Save changes" button.</p>
104
  </div>
105
-
106
- <?php
107
  } else {
108
- //pretty permalink is NOT enabled. This plugin can't work.
109
- ?>
110
  <div class="error">
111
- <p><?php _e('HTTPS redirection only works if you have pretty permalinks enabled.', 'https_redirection'); ?></p>
112
- <p><?php _e('To enable pretty permalinks go to <em>Settings > Permalinks</em> and select any option other than "default".', 'https_redirection'); ?></p>
113
- <p><a href="options-permalink.php">Enable Permalinks</a></p>
114
  </div>
115
- <?php
116
- }
117
  ?>
118
- </div>
119
  <?php
120
  }
1
  <?php
 
2
  /* Function for display htaccess settings page in the admin area */
3
 
4
  function httpsrdrctn_settings_page() {
31
  //httpsrdrctn_generate_htaccess();
32
  }
33
  }
34
+ $siteSSLurl = get_home_url(null, '', 'https');
35
  /* Display form on the setting page */
36
  ?>
37
+ <div class="wrap">
38
+ <div class="icon32 icon32-bws" id="icon-options-general"></div>
39
+ <h2><?php _e('HTTPS Redirection Settings', 'https_redirection'); ?></h2>
40
+
41
+ <div style="background: #fff6d5; border: 1px solid #d1b655; color: #3f2502; margin: 10px 0; padding: 5px 5px 5px 10px; text-shadow: 1px 1px #ffffff;">
42
+ <p>When you enable the HTTPS redirection, the plugin will force redirect the URL to the HTTPS version of the URL.
43
+ So before enabling this plugin's feature, visit your site's HTTPS URL <a href="<?php echo $siteSSLurl; ?>" target="_blank"><?php echo $siteSSLurl; ?></a> to make sure the page loads correctly.
44
  Otherwise you may get locked out if your SSL certificate is not installed correctly on your site or the HTTPS URL is not working and this plugin is auto redirecting to the HTTPS URL.
45
+ </p>
46
+ <p><span style='font-weight:bold;color:red;'>Important!</span> If you're using caching plugins similar to W3 Total Cache or WP Super Cache, you need to clear their cache after you enable or disable automatic redirection option. Failing to do so may result in mixed content warning from browser.</p>
47
+ </div>
48
 
49
+ <?php
50
+ if (get_option('permalink_structure')) {
51
  //Pretty permalink is enabled. So allow HTTPS redirection feature.
52
  ?>
53
  <div id="httpsrdrctn_settings_notice" class="updated fade" style="display:none"><p><strong><?php _e("Notice:", 'https_redirection'); ?></strong> <?php _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'https_redirection'); ?></p></div>
58
  <tr valign="top">
59
  <th scope="row"><?php _e('Enable automatic redirection to the "HTTPS"', 'https_redirection'); ?></th>
60
  <td>
61
+ <label><input type="checkbox" id="httpsrdrctn-checkbox" name="httpsrdrctn_https" value="1" <?php if ('1' == $httpsrdrctn_options['https']) echo "checked=\"checked\" "; ?>/></label><br />
62
  <p class="description">Use this option to make your webpage(s) load in HTTPS version only. If someone enters a non-https URL in the browser's address bar then the plugin will automatically redirect to the HTTPS version of that URL.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  </td>
64
  </tr>
65
  </table>
66
+ <div style="position: relative">
67
+ <table class="form-table">
68
+ <tr>
69
+ <th scope="row">Apply HTTPS redirection on:</th>
70
+ <td>
71
+ <label><input type="radio" name="httpsrdrctn_https_domain" value="1" <?php if ('1' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> The whole domain</label><br />
72
+ <label><input type="radio" name="httpsrdrctn_https_domain" value="0" <?php if ('0' == $httpsrdrctn_options['https_domain']) echo "checked=\"checked\" "; ?>/> A few pages</label><br />
73
+ <?php foreach ($httpsrdrctn_options['https_pages_array'] as $https_page) { ?>
74
+ <span>
75
+ <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="<?php echo $https_page; ?>" /> <span class="rewrite_delete_item">&nbsp;</span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br />
76
+ </span>
77
+ <?php } ?>
78
+ <span class="rewrite_new_item" >
79
+ <?php echo str_replace("http://", "https://", home_url()); ?>/<input type="text" name="httpsrdrctn_https_pages_array[]" value="" /> <span class="rewrite_add_item">&nbsp;</span> <span class="rewrite_item_blank_error"><?php _e('Please, fill field', 'list'); ?></span><br />
80
+ </span>
81
+ </td>
82
+ </tr>
83
+ <tr valign="top">
84
+ <th scope="row"><?php _e('Force resources to use HTTPS URL', 'https_redirection'); ?></th>
85
+ <td>
86
+ <label><input type="checkbox" name="httpsrdrctn_force_resources" value="1" <?php if (isset($httpsrdrctn_options['force_resources']) && $httpsrdrctn_options['force_resources'] == '1') echo "checked=\"checked\" "; ?>/></label><br />
87
+ <p class="description">When checked, the plugin will force load HTTPS URL for any static resources in your content. Example: if you have have an image embedded in a post with a NON-HTTPS URL, this option will change that to a HTTPS URL.</p>
88
+ </td>
89
+ </tr>
90
+ </table>
91
+ <style>
92
+ #httpsrdrctn-overlay {
93
+ position: absolute;
94
+ top: 10px;
95
+ background-color: white;
96
+ width: 100%;
97
+ height: 100%;
98
+ opacity: 0.5;
99
+ text-align: center;
100
+ }
101
+ </style>
102
+ <div id="httpsrdrctn-overlay"<?php echo ($httpsrdrctn_options['https'] == 1 ? ' class="hidden"' : ''); ?>></div>
103
+ </div>
104
  <input type="hidden" name="httpsrdrctn_form_submit" value="submit" />
105
  <p class="submit">
106
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
107
  </p>
108
  <?php wp_nonce_field(plugin_basename(__FILE__), 'httpsrdrctn_nonce_name'); ?>
109
  </form>
110
+
111
+ <script>
112
+ jQuery('input#httpsrdrctn-checkbox').change(function () {
113
+ if (jQuery(this).is(':checked')) {
114
+ jQuery('div#httpsrdrctn-overlay').fadeOut('fast');
115
+ } else {
116
+ jQuery('div#httpsrdrctn-overlay').fadeIn('fast');
117
+ }
118
+ });
119
+ </script>
120
+
121
  <div style="background: #FFEBE8; border: 1px solid #CC0000; color: #333333; margin: 10px 0; padding: 5px 5px 5px 10px;">
122
  <p><strong><?php _e("Notice:", 'https_redirection'); ?></strong> <?php _e("It is very important to be extremely attentive when making changes to .htaccess file.", 'https_redirection'); ?></p>
123
  <p>If after making changes your site stops functioning, do the following:</p>
131
 
132
  <p>The changes will be applied immediately after saving the changes, if you are not sure - do not click the "Save changes" button.</p>
133
  </div>
134
+
135
+ <?php
136
  } else {
137
+ //pretty permalink is NOT enabled. This plugin can't work.
138
+ ?>
139
  <div class="error">
140
+ <p><?php _e('HTTPS redirection only works if you have pretty permalinks enabled.', 'https_redirection'); ?></p>
141
+ <p><?php _e('To enable pretty permalinks go to <em>Settings > Permalinks</em> and select any option other than "default".', 'https_redirection'); ?></p>
142
+ <p><a href="options-permalink.php">Enable Permalinks</a></p>
143
  </div>
144
+ <?php
145
+ }
146
  ?>
147
+ </div>
148
  <?php
149
  }
https-redirection.php CHANGED
@@ -2,12 +2,14 @@
2
 
3
  /*
4
  Plugin Name: Easy HTTPS (SSL) Redirection
5
- Plugin URI: https://www.tipsandtricks-hq.com/development-center
6
  Description: The plugin HTTPS Redirection allows an automatic redirection to the "HTTPS" version/URL of the site.
7
  Author: Tips and Tricks HQ
8
- Version: 1.6
9
  Author URI: https://www.tipsandtricks-hq.com/
10
  License: GPLv2 or later
 
 
11
  */
12
 
13
  if (!defined('ABSPATH')) {
@@ -72,7 +74,7 @@ function register_httpsrdrctn_settings() {
72
 
73
  $httpsrdrctn_option_defaults = array(
74
  'https' => 0,
75
- 'https_domain' => 0,
76
  'https_pages_array' => array(),
77
  'force_resources' => 0,
78
  'plugin_option_version' => $httpsrdrctn_plugin_info["Version"]
@@ -124,7 +126,6 @@ function httpsrdrctn_register_plugin_links($links, $file) {
124
 
125
  /*
126
  * Function that changes "http" embeds to "https"
127
- * TODO - Need to make it better so it only does it for static resources like JS, CSS and Images
128
  */
129
 
130
  function httpsrdrctn_filter_content($content) {
@@ -172,7 +173,7 @@ function httpsrdrctn_the_content($content) {
172
  $pages_str = '';
173
  $on_https_page = false;
174
  foreach ($httpsrdrctn_options['https_pages_array'] as $https_page) {
175
- $pages_str.=preg_quote($https_page, '/') . '[\/|][\'"]|'; //let's add page to the preg expression string in case we'd need it later
176
  if ($https_page == $slug) { //if we are on the page that is in the array, let's set the var to true
177
  $on_https_page = true;
178
  } else { //if not - let's replace all links to that page only to https
2
 
3
  /*
4
  Plugin Name: Easy HTTPS (SSL) Redirection
5
+ Plugin URI: https://www.tipsandtricks-hq.com/wordpress-easy-https-redirection-plugin
6
  Description: The plugin HTTPS Redirection allows an automatic redirection to the "HTTPS" version/URL of the site.
7
  Author: Tips and Tricks HQ
8
+ Version: 1.8
9
  Author URI: https://www.tipsandtricks-hq.com/
10
  License: GPLv2 or later
11
+ Text Domain: https-redirection
12
+ Domain Path: /languages/
13
  */
14
 
15
  if (!defined('ABSPATH')) {
74
 
75
  $httpsrdrctn_option_defaults = array(
76
  'https' => 0,
77
+ 'https_domain' => 1,
78
  'https_pages_array' => array(),
79
  'force_resources' => 0,
80
  'plugin_option_version' => $httpsrdrctn_plugin_info["Version"]
126
 
127
  /*
128
  * Function that changes "http" embeds to "https"
 
129
  */
130
 
131
  function httpsrdrctn_filter_content($content) {
173
  $pages_str = '';
174
  $on_https_page = false;
175
  foreach ($httpsrdrctn_options['https_pages_array'] as $https_page) {
176
+ $pages_str .= preg_quote($https_page, '/') . '[\/|][\'"]|'; //let's add page to the preg expression string in case we'd need it later
177
  if ($https_page == $slug) { //if we are on the page that is in the array, let's set the var to true
178
  $on_https_page = true;
179
  } else { //if not - let's replace all links to that page only to https
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ
3
  Donate link: http://www.tipsandtricks-hq.com/development-center
4
  Tags: redirection, https, automatic redirection, htaccess, ssl, https redirection, ssl certificate, secure page, secure, force ssl, force https
5
  Requires at least: 3.5
6
- Tested up to: 4.8
7
- Stable tag: 1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -93,6 +93,14 @@ Here is an example for German language files.
93
 
94
  == Changelog ==
95
 
 
 
 
 
 
 
 
 
96
  = v1.6 =
97
  - Improved the "Force Load Static Files Using HTTPS" feature.
98
  - The htaccess redirection is now detected based on SERVER_PORT (this is should work better on most servers).
3
  Donate link: http://www.tipsandtricks-hq.com/development-center
4
  Tags: redirection, https, automatic redirection, htaccess, ssl, https redirection, ssl certificate, secure page, secure, force ssl, force https
5
  Requires at least: 3.5
6
+ Tested up to: 4.9
7
+ Stable tag: 1.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
93
 
94
  == Changelog ==
95
 
96
+ = v1.8 =
97
+ - Apply HTTPS redirection on the whole domain will be the default selected option after plugin install. You an change this option when you actually go to enable the feature.
98
+
99
+ = v1.7 =
100
+ - Additional options are only accessible when "Enable automatic redirection to the "HTTPS" is enabled.
101
+ - https://www.yoursite.com/some-page is replaced with site's actual https address in Settings information box.
102
+ - Added reminder for user to clear cache of optimization plugins similar to W3 Total Cache or WP Super Cache.
103
+
104
  = v1.6 =
105
  - Improved the "Force Load Static Files Using HTTPS" feature.
106
  - The htaccess redirection is now detected based on SERVER_PORT (this is should work better on most servers).