Version Description
- Memory optimization.
- Added secure URL filtering.
- Users receiving 404 errors on every page when using Shared SSL should now be able to use those Shared SSL's that previously did not work.
- Added support for qTranslate.
- Added support for securing custom post types.
- Added $url to the force_ssl filter as the third arguement. See FAQ for example usage.
Download this release
Release Info
Developer | Mvied |
Plugin | WordPress HTTPS (SSL) |
Version | 3.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.4 to 3.1
- .htaccess +0 -1
- admin/css/settings.css +44 -31
- admin/templates/metabox/filters.php +43 -0
- admin/templates/metabox/settings.php +13 -11
- lib/Mvied/Module/Interface.php +0 -20
- lib/Mvied/{Module.php → Plugin/Module.php} +5 -5
- lib/Mvied/Plugin/Module/Interface.php +36 -0
- lib/Mvied/README.md +1 -0
- lib/Mvied/Theme.php +372 -0
- lib/Mvied/Theme/Module.php +46 -0
- lib/Mvied/Theme/Module/Interface.php +36 -0
- lib/WordPressHTTPS.php +98 -26
- lib/WordPressHTTPS/Module/Admin.php +1 -4
- lib/WordPressHTTPS/Module/Admin/Post.php +15 -21
- lib/WordPressHTTPS/Module/Admin/Settings.php +19 -6
- lib/WordPressHTTPS/Module/Filters.php +189 -58
- lib/WordPressHTTPS/Module/Hooks.php +71 -26
- lib/WordPressHTTPS/Module/Parser.php +32 -157
- lib/WordPressHTTPS/Url.php +11 -9
- readme.txt +13 -6
- uninstall.php +1 -0
- wordpress-https.php +2 -2
.htaccess
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
Options -Indexes
|
|
admin/css/settings.css
CHANGED
@@ -1,49 +1,52 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
background: url(images/admin-icon32.png) no-repeat;
|
3 |
}
|
4 |
|
5 |
-
.meta-box-sortables {
|
6 |
margin: 0 8px;
|
7 |
}
|
8 |
|
9 |
-
#poststuff .column-primary {
|
10 |
width: 60%;
|
11 |
padding: 0;
|
12 |
}
|
13 |
-
#poststuff .column-secondary {
|
14 |
width: 40%;
|
15 |
float: right;
|
16 |
padding: 0;
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
position: fixed;
|
21 |
-
bottom: 50%;
|
22 |
-
left: 50%;
|
23 |
-
margin-left: -25%;
|
24 |
-
width: 50%;
|
25 |
-
z-index: 10;
|
26 |
-
text-align: center;
|
27 |
-
}
|
28 |
-
|
29 |
-
#message {
|
30 |
margin: 15px 0 0 0;
|
31 |
}
|
32 |
-
#message p {
|
33 |
line-height: 100%;
|
34 |
}
|
35 |
|
36 |
-
img.loading {
|
37 |
display: block;
|
38 |
position: absolute;
|
39 |
top: 7px;
|
40 |
right: 7px;
|
41 |
}
|
42 |
|
43 |
-
img.waiting {
|
44 |
display: none;
|
45 |
}
|
46 |
-
img
|
47 |
vertical-align: middle;
|
48 |
margin-left: 5px;
|
49 |
}
|
@@ -53,44 +56,54 @@ img#submit-waiting {
|
|
53 |
margin: 5px auto 13px auto;
|
54 |
}
|
55 |
|
56 |
-
#
|
57 |
margin: -5px 0 0 0;
|
58 |
}
|
59 |
-
#
|
60 |
margin: 7px 0 0 0;
|
61 |
vertical-align: bottom;
|
62 |
}
|
63 |
-
#
|
64 |
-
#
|
65 |
line-height: 1em;
|
66 |
padding: 10px;
|
67 |
}
|
68 |
-
#
|
69 |
padding: 2px 0 0 0;
|
70 |
}
|
71 |
-
#
|
72 |
padding-top: 0;
|
73 |
}
|
74 |
-
#
|
75 |
width: 140px;
|
76 |
line-height: 32px;
|
77 |
padding: 0;
|
78 |
}
|
79 |
-
#
|
80 |
display: block;
|
81 |
margin-top: 5px;
|
82 |
}
|
83 |
-
#
|
|
|
84 |
float: left;
|
85 |
margin-right: 10px;
|
86 |
}
|
87 |
-
#
|
88 |
display: inline-block;
|
89 |
padding-top: 10px;
|
90 |
}
|
91 |
-
#
|
92 |
width: 70%;
|
93 |
}
|
94 |
-
#exclusive_https_row label {
|
95 |
padding-top: 5px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
}
|
1 |
+
.wphttps-message-wrap {
|
2 |
+
position: fixed;
|
3 |
+
bottom: 50%;
|
4 |
+
left: 50%;
|
5 |
+
margin-left: -25%;
|
6 |
+
width: 50%;
|
7 |
+
z-index: 10;
|
8 |
+
text-align: center;
|
9 |
+
}
|
10 |
+
.wphttps-message-wrap ul {
|
11 |
+
margin: 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
#wphttps-main #icon-options-https {
|
15 |
background: url(images/admin-icon32.png) no-repeat;
|
16 |
}
|
17 |
|
18 |
+
#wphttps-main .meta-box-sortables {
|
19 |
margin: 0 8px;
|
20 |
}
|
21 |
|
22 |
+
#wphttps-main #poststuff .column-primary {
|
23 |
width: 60%;
|
24 |
padding: 0;
|
25 |
}
|
26 |
+
#wphttps-main #poststuff .column-secondary {
|
27 |
width: 40%;
|
28 |
float: right;
|
29 |
padding: 0;
|
30 |
}
|
31 |
|
32 |
+
#wphttps-main #message {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
margin: 15px 0 0 0;
|
34 |
}
|
35 |
+
#wphttps-main #message p {
|
36 |
line-height: 100%;
|
37 |
}
|
38 |
|
39 |
+
#wphttps-main img.loading {
|
40 |
display: block;
|
41 |
position: absolute;
|
42 |
top: 7px;
|
43 |
right: 7px;
|
44 |
}
|
45 |
|
46 |
+
#wphttps-main img.waiting {
|
47 |
display: none;
|
48 |
}
|
49 |
+
#wphttps-main img.submit-waiting {
|
50 |
vertical-align: middle;
|
51 |
margin-left: 5px;
|
52 |
}
|
56 |
margin: 5px auto 13px auto;
|
57 |
}
|
58 |
|
59 |
+
#wphttps-main input[type="text"] {
|
60 |
margin: -5px 0 0 0;
|
61 |
}
|
62 |
+
#wphttps-main input[type="checkbox"] {
|
63 |
margin: 7px 0 0 0;
|
64 |
vertical-align: bottom;
|
65 |
}
|
66 |
+
#wphttps-main table tr td,
|
67 |
+
#wphttps-main table tr th {
|
68 |
line-height: 1em;
|
69 |
padding: 10px;
|
70 |
}
|
71 |
+
#wphttps-main table tr td {
|
72 |
padding: 2px 0 0 0;
|
73 |
}
|
74 |
+
#wphttps-main table tr td:first-child {
|
75 |
padding-top: 0;
|
76 |
}
|
77 |
+
#wphttps-main table th {
|
78 |
width: 140px;
|
79 |
line-height: 32px;
|
80 |
padding: 0;
|
81 |
}
|
82 |
+
#wphttps-main label.label-radio {
|
83 |
display: block;
|
84 |
margin-top: 5px;
|
85 |
}
|
86 |
+
#wphttps-main #settings-reset,
|
87 |
+
#wphttps-main #filters-reset {
|
88 |
float: left;
|
89 |
margin-right: 10px;
|
90 |
}
|
91 |
+
#wphttps-main #ssl_port_label {
|
92 |
display: inline-block;
|
93 |
padding-top: 10px;
|
94 |
}
|
95 |
+
#wphttps-main #ssl_host {
|
96 |
width: 70%;
|
97 |
}
|
98 |
+
#wphttps-main #exclusive_https_row label {
|
99 |
padding-top: 5px;
|
100 |
+
}
|
101 |
+
|
102 |
+
#wphttps-main #admin_menu_row label {
|
103 |
+
display: inline;
|
104 |
+
}
|
105 |
+
|
106 |
+
#wphttps-main #secure_filter_row textarea {
|
107 |
+
width: 95%;
|
108 |
+
height: 120px;
|
109 |
}
|
admin/templates/metabox/filters.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<form name="<?php echo $this->getPlugin()->getSlug(); ?>_filters_form" id="<?php echo $this->getPlugin()->getSlug(); ?>_filters_form" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
|
2 |
+
<?php settings_fields($this->getPlugin()->getSlug()); ?>
|
3 |
+
|
4 |
+
<table class="form-table">
|
5 |
+
<tr valign="top" id="secure_filter_row">
|
6 |
+
<th scope="row">
|
7 |
+
Secure Filters
|
8 |
+
<p class="description">Example: If you have an E-commerce shop and all of the URL's begin with /store/, you could secure all store links by entering '/store/' on one line.</p>
|
9 |
+
</th>
|
10 |
+
<td>
|
11 |
+
<textarea name="secure_filter" id="secure_filter"><?php echo implode("\n", $this->getPlugin()->getSetting('secure_filter')); ?></textarea>
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
</table>
|
15 |
+
|
16 |
+
<input type="hidden" name="action" value="save" />
|
17 |
+
|
18 |
+
<p class="button-controls">
|
19 |
+
<input type="submit" name="filters-save" value="Save Changes" class="button-primary" id="filters-save" />
|
20 |
+
<input type="submit" name="filters-reset" value="Reset" class="button-secondary" id="filters-reset" />
|
21 |
+
<img alt="Waiting..." src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting submit-waiting" />
|
22 |
+
</p>
|
23 |
+
</form>
|
24 |
+
<script type="text/javascript">
|
25 |
+
jQuery(document).ready(function($) {
|
26 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form').submit(function() {
|
27 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form .submit-waiting').show();
|
28 |
+
}).ajaxForm({
|
29 |
+
data: { ajax: '1'},
|
30 |
+
success: function(responseText, textStatus, XMLHttpRequest) {
|
31 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_filters_form .submit-waiting').hide();
|
32 |
+
$('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
|
33 |
+
}
|
34 |
+
});
|
35 |
+
|
36 |
+
$('#filters-reset').click(function(e, el) {
|
37 |
+
if ( ! confirm('Are you sure you want to reset all WordPress HTTPS filters?') ) {
|
38 |
+
e.preventDefault();
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
});
|
42 |
+
});
|
43 |
+
</script>
|
admin/templates/metabox/settings.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
}
|
8 |
$ssl_host = rtrim($ssl_host, '/');
|
9 |
?>
|
10 |
-
<form name="
|
11 |
<?php settings_fields($this->getPlugin()->getSlug()); ?>
|
12 |
|
13 |
<table class="form-table">
|
@@ -86,9 +86,11 @@
|
|
86 |
<th scope="row">Admin Menu Location</th>
|
87 |
<td>
|
88 |
<fieldset>
|
89 |
-
<label for="
|
90 |
-
<input type="radio" name="admin_menu" value="side"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'side') ? ' checked="checked"' : ''); ?>> <span>Admin Sidebar</span>
|
91 |
-
|
|
|
|
|
92 |
</label>
|
93 |
</fieldset>
|
94 |
</td>
|
@@ -100,23 +102,23 @@
|
|
100 |
<input type="hidden" name="ssl_host_diff" value="<?php echo (($this->getPlugin()->getSetting('ssl_host_diff') != 1) ? 0 : 1); ?>" />
|
101 |
|
102 |
<p class="button-controls">
|
103 |
-
<input type="submit" name="
|
104 |
-
<input type="submit" name="
|
105 |
-
<img alt="Waiting..." src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting
|
106 |
</p>
|
107 |
</form>
|
108 |
<script type="text/javascript">
|
109 |
jQuery(document).ready(function($) {
|
110 |
-
$('#<?php echo $this->getPlugin()->getSlug(); ?>').submit(function() {
|
111 |
-
$('
|
112 |
}).ajaxForm({
|
113 |
data: { ajax: '1'},
|
114 |
success: function(responseText, textStatus, XMLHttpRequest) {
|
115 |
-
$('
|
116 |
$('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
|
117 |
}
|
118 |
});
|
119 |
-
|
120 |
$('#settings-reset').click(function(e, el) {
|
121 |
if ( ! confirm('Are you sure you want to reset all WordPress HTTPS settings?') ) {
|
122 |
e.preventDefault();
|
7 |
}
|
8 |
$ssl_host = rtrim($ssl_host, '/');
|
9 |
?>
|
10 |
+
<form name="<?php echo $this->getPlugin()->getSlug(); ?>_settings_form" id="<?php echo $this->getPlugin()->getSlug(); ?>_settings_form" action="<?php echo $_SERVER['REQUEST_URI']; ?>" method="post">
|
11 |
<?php settings_fields($this->getPlugin()->getSlug()); ?>
|
12 |
|
13 |
<table class="form-table">
|
86 |
<th scope="row">Admin Menu Location</th>
|
87 |
<td>
|
88 |
<fieldset>
|
89 |
+
<label for="admin_menu_side" class="label-radio">
|
90 |
+
<input type="radio" name="admin_menu" id="admin_menu_side" value="side"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'side') ? ' checked="checked"' : ''); ?>> <span>Admin Sidebar</span>
|
91 |
+
</label>
|
92 |
+
<label for="admin_menu_settings" class="label-radio">
|
93 |
+
<input type="radio" name="admin_menu" id="admin_menu_settings" value="settings"<?php echo (($this->getPlugin()->getSetting('admin_menu') === 'settings') ? ' checked="checked"' : ''); ?>> <span>General Settings</span>
|
94 |
</label>
|
95 |
</fieldset>
|
96 |
</td>
|
102 |
<input type="hidden" name="ssl_host_diff" value="<?php echo (($this->getPlugin()->getSetting('ssl_host_diff') != 1) ? 0 : 1); ?>" />
|
103 |
|
104 |
<p class="button-controls">
|
105 |
+
<input type="submit" name="settings-save" value="Save Changes" class="button-primary" id="settings-save" />
|
106 |
+
<input type="submit" name="settings-reset" value="Reset" class="button-secondary" id="settings-reset" />
|
107 |
+
<img alt="Waiting..." src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" class="waiting submit-waiting" />
|
108 |
</p>
|
109 |
</form>
|
110 |
<script type="text/javascript">
|
111 |
jQuery(document).ready(function($) {
|
112 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form').submit(function() {
|
113 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').show();
|
114 |
}).ajaxForm({
|
115 |
data: { ajax: '1'},
|
116 |
success: function(responseText, textStatus, XMLHttpRequest) {
|
117 |
+
$('#<?php echo $this->getPlugin()->getSlug(); ?>_settings_form .submit-waiting').hide();
|
118 |
$('#message-body').html(responseText).fadeOut(0).fadeIn().delay(5000).fadeOut();
|
119 |
}
|
120 |
});
|
121 |
+
|
122 |
$('#settings-reset').click(function(e, el) {
|
123 |
if ( ! confirm('Are you sure you want to reset all WordPress HTTPS settings?') ) {
|
124 |
e.preventDefault();
|
lib/Mvied/Module/Interface.php
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Module Interface
|
4 |
-
*
|
5 |
-
* @author Mike Ems
|
6 |
-
* @package Mvied
|
7 |
-
*
|
8 |
-
*/
|
9 |
-
|
10 |
-
interface Mvied_Module_Interface {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Initializes the module
|
14 |
-
*
|
15 |
-
* @param none
|
16 |
-
* @return void
|
17 |
-
*/
|
18 |
-
public function init();
|
19 |
-
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/Mvied/{Module.php → Plugin/Module.php}
RENAMED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Module
|
4 |
*
|
5 |
* Each Module in the project will extend this base Module class.
|
6 |
* Modules can be treated as independent plugins. Think of them as sub-plugins.
|
@@ -8,12 +8,12 @@
|
|
8 |
* @author Mike Ems
|
9 |
* @package Mvied
|
10 |
*/
|
11 |
-
class
|
12 |
|
13 |
/**
|
14 |
* Plugin object that this module extends
|
15 |
*
|
16 |
-
* @var
|
17 |
*/
|
18 |
protected $_plugin;
|
19 |
|
@@ -28,7 +28,7 @@ class Mvied_Module {
|
|
28 |
$this->_plugin = $plugin;
|
29 |
return $this;
|
30 |
}
|
31 |
-
|
32 |
/**
|
33 |
* Get Plugin
|
34 |
*
|
@@ -42,5 +42,5 @@ class Mvied_Module {
|
|
42 |
|
43 |
return $this->_plugin;
|
44 |
}
|
45 |
-
|
46 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Module
|
4 |
*
|
5 |
* Each Module in the project will extend this base Module class.
|
6 |
* Modules can be treated as independent plugins. Think of them as sub-plugins.
|
8 |
* @author Mike Ems
|
9 |
* @package Mvied
|
10 |
*/
|
11 |
+
class Mvied_Plugin_Module {
|
12 |
|
13 |
/**
|
14 |
* Plugin object that this module extends
|
15 |
*
|
16 |
+
* @var Mvied_Plugin
|
17 |
*/
|
18 |
protected $_plugin;
|
19 |
|
28 |
$this->_plugin = $plugin;
|
29 |
return $this;
|
30 |
}
|
31 |
+
|
32 |
/**
|
33 |
* Get Plugin
|
34 |
*
|
42 |
|
43 |
return $this->_plugin;
|
44 |
}
|
45 |
+
|
46 |
}
|
lib/Mvied/Plugin/Module/Interface.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Plugin Module Interface
|
4 |
+
*
|
5 |
+
* @author Mike Ems
|
6 |
+
* @package Mvied
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
interface Mvied_Plugin_Module_Interface {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Initializes the module
|
14 |
+
*
|
15 |
+
* @param none
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function init();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Set Plugin
|
22 |
+
*
|
23 |
+
* @param Mvied_Plugin $plugin
|
24 |
+
* @return Mvied_Plugin_Module
|
25 |
+
* @uses Mvied_Plugin
|
26 |
+
*/
|
27 |
+
public function setPlugin( Mvied_Plugin $plugin );
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get Plugin
|
31 |
+
*
|
32 |
+
* @param none
|
33 |
+
* @return Mvied_Plugin
|
34 |
+
*/
|
35 |
+
public function getPlugin();
|
36 |
+
}
|
lib/Mvied/README.md
CHANGED
@@ -6,3 +6,4 @@ This library was created by Mvied for quickly creating Plugins and Themes with W
|
|
6 |
Tutorial
|
7 |
-------
|
8 |
|
|
6 |
Tutorial
|
7 |
-------
|
8 |
|
9 |
+
You can find an example plugin using this library at https://github.com/Mvied/mvied-example-plugin
|
lib/Mvied/Theme.php
ADDED
@@ -0,0 +1,372 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author Mike Ems
|
4 |
+
* @package Mvied
|
5 |
+
*/
|
6 |
+
class Mvied_Theme {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Module directory
|
10 |
+
*
|
11 |
+
* @var string
|
12 |
+
*/
|
13 |
+
protected $_module_directory;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Loaded Modules
|
17 |
+
*
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
protected $_modules = array();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Logger
|
24 |
+
*
|
25 |
+
* @var Mvied_Logger_Interface
|
26 |
+
*/
|
27 |
+
protected $_logger;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Theme Settings
|
31 |
+
*
|
32 |
+
* @var array
|
33 |
+
*/
|
34 |
+
protected $_settings = array();
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Theme Slug
|
38 |
+
*
|
39 |
+
* Used as a unqiue identifier for the theme.
|
40 |
+
*
|
41 |
+
* @var string
|
42 |
+
*/
|
43 |
+
protected $_slug;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Theme Version
|
47 |
+
*
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_version;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Set Module Directory
|
54 |
+
*
|
55 |
+
* @param string $module_directory
|
56 |
+
* @return object $this
|
57 |
+
*/
|
58 |
+
public function setModuleDirectory( $module_directory ) {
|
59 |
+
$this->_module_directory = $module_directory;
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Get Module Directory
|
65 |
+
*
|
66 |
+
* @param none
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function getModuleDirectory() {
|
70 |
+
return $this->_module_directory;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get Available Modules
|
75 |
+
*
|
76 |
+
* @param none
|
77 |
+
* @return array $modules
|
78 |
+
*/
|
79 |
+
public function getAvailableModules() {
|
80 |
+
$modules = array();
|
81 |
+
if ( is_dir($this->getModuleDirectory()) && $module_directory = opendir($this->getModuleDirectory()) ) {
|
82 |
+
while ( false !== ($entry = readdir($module_directory)) ) {
|
83 |
+
if ( $entry != '.' && $entry != '..' ) {
|
84 |
+
$module = str_replace('.php', '', $entry);
|
85 |
+
if ( $module != 'Interface' ) {
|
86 |
+
$modules[] = $module;
|
87 |
+
if ( is_dir($this->getModuleDirectory() . $module) && $sub_module_directory = opendir($this->getModuleDirectory() . $module) ) {
|
88 |
+
while ( false !== ($entry = readdir($sub_module_directory)) ) {
|
89 |
+
if ( $entry != '.' && $entry != '..' ) {
|
90 |
+
$sub_module = str_replace('.php', '', $entry);
|
91 |
+
$modules[] = $module . '\\' . $sub_module;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
return $modules;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get Module
|
104 |
+
*
|
105 |
+
* @param string $module
|
106 |
+
* @return object
|
107 |
+
*/
|
108 |
+
public function getModule( $module ) {
|
109 |
+
$module = 'Module\\' . $module;
|
110 |
+
if ( isset($module) ) {
|
111 |
+
if ( isset($this->_modules[$module]) ) {
|
112 |
+
return $this->_modules[$module];
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
die('Module not found: \'' . $module . '\'.');
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Get Modules
|
121 |
+
*
|
122 |
+
* Returns an array of all loaded modules
|
123 |
+
*
|
124 |
+
* @param none
|
125 |
+
* @return array $modules
|
126 |
+
*/
|
127 |
+
public function getModules() {
|
128 |
+
$modules = array();
|
129 |
+
if ( isset($this->_modules) ) {
|
130 |
+
$modules = $this->_modules;
|
131 |
+
}
|
132 |
+
return $modules;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Set Module
|
137 |
+
*
|
138 |
+
* @param string $module
|
139 |
+
* @param object $object
|
140 |
+
* @return $this
|
141 |
+
*/
|
142 |
+
public function setModule( $module, $object ) {
|
143 |
+
$this->_modules[$module] = $object;
|
144 |
+
return $this;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Set Logger
|
149 |
+
*
|
150 |
+
* @param object $logger
|
151 |
+
* @return object $this
|
152 |
+
*/
|
153 |
+
public function setLogger( Mvied_Logger_Interface $logger ) {
|
154 |
+
$this->_logger = $logger;
|
155 |
+
return $this;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Get Logger
|
160 |
+
*
|
161 |
+
* @param none
|
162 |
+
* @return object
|
163 |
+
*/
|
164 |
+
public function getLogger() {
|
165 |
+
if ( ! isset($this->_logger) ) {
|
166 |
+
die(__CLASS__ . ' missing Logger dependency.');
|
167 |
+
}
|
168 |
+
|
169 |
+
return $this->_logger->getInstance();
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Get Theme Setting
|
174 |
+
*
|
175 |
+
* @param string $setting
|
176 |
+
* @param int $setting_blog_id
|
177 |
+
* @return mixed
|
178 |
+
*/
|
179 |
+
public function getSetting( $setting, $blog_id = 0 ) {
|
180 |
+
$setting_full = $this->getSlug() . '_' . $setting;
|
181 |
+
if ( $blog_id > 0 ) {
|
182 |
+
$value = get_blog_option($blog_id, $setting_full);
|
183 |
+
} else {
|
184 |
+
$value = get_option($setting_full);
|
185 |
+
}
|
186 |
+
|
187 |
+
// Load default option
|
188 |
+
if ( $value === false ) {
|
189 |
+
$value = $this->_settings[$setting];
|
190 |
+
}
|
191 |
+
// Convert 1's and 0's to boolean
|
192 |
+
switch( $value ) {
|
193 |
+
case "1":
|
194 |
+
$value = true;
|
195 |
+
break;
|
196 |
+
case "0":
|
197 |
+
$value = false;
|
198 |
+
break;
|
199 |
+
}
|
200 |
+
return $value;
|
201 |
+
}
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Get Theme Settings
|
205 |
+
*
|
206 |
+
* @param none
|
207 |
+
* @return array
|
208 |
+
*/
|
209 |
+
public function getSettings() {
|
210 |
+
return $this->_settings;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Set Theme Setting
|
215 |
+
*
|
216 |
+
* @param string $setting
|
217 |
+
* @param mixed $value
|
218 |
+
* @return $this
|
219 |
+
*/
|
220 |
+
public function setSetting( $setting, $value ) {
|
221 |
+
$setting = $this->getSlug() . '_' . $setting;
|
222 |
+
update_option($setting, $value);
|
223 |
+
return $this;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Set Slug
|
228 |
+
*
|
229 |
+
* @param string $slug
|
230 |
+
* @return object $this
|
231 |
+
*/
|
232 |
+
public function setSlug( $slug ) {
|
233 |
+
$this->_slug = $slug;
|
234 |
+
return $this;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Get Slug
|
239 |
+
*
|
240 |
+
* @param none
|
241 |
+
* @return string
|
242 |
+
*/
|
243 |
+
public function getSlug() {
|
244 |
+
return $this->_slug;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Set Version
|
249 |
+
*
|
250 |
+
* @param string $version
|
251 |
+
* @return object $this
|
252 |
+
*/
|
253 |
+
public function setVersion( $version ) {
|
254 |
+
$this->_version = $version;
|
255 |
+
return $this;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Get Version
|
260 |
+
*
|
261 |
+
* @param none
|
262 |
+
* @return string
|
263 |
+
*/
|
264 |
+
public function getVersion() {
|
265 |
+
return $this->_version;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Init
|
270 |
+
*
|
271 |
+
* Initializes all of the modules.
|
272 |
+
*
|
273 |
+
* @param none
|
274 |
+
* @return $this
|
275 |
+
*/
|
276 |
+
public function init() {
|
277 |
+
$modules = $this->getModules();
|
278 |
+
foreach( $modules as $module ) {
|
279 |
+
$module->init();
|
280 |
+
}
|
281 |
+
return $this;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Is Module Loaded?
|
286 |
+
*
|
287 |
+
* @param string $module
|
288 |
+
* @return boolean
|
289 |
+
*/
|
290 |
+
public function isModuleLoaded( $module ) {
|
291 |
+
if ( is_object($this->getModule($module)) ) {
|
292 |
+
return true;
|
293 |
+
} else {
|
294 |
+
return false;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* Load Module
|
300 |
+
*
|
301 |
+
* @param string $module
|
302 |
+
* @return $this
|
303 |
+
*/
|
304 |
+
public function loadModule( $module ) {
|
305 |
+
if ( strpos(get_class($this), '_') !== false ) {
|
306 |
+
$base_class = substr(get_class($this), 0, strpos(get_class($this), '_'));
|
307 |
+
} else {
|
308 |
+
$base_class = get_class($this);
|
309 |
+
}
|
310 |
+
$module_full = 'Module\\' . $module;
|
311 |
+
$filename = str_replace('\\', '/', $module);
|
312 |
+
$filename = $filename . '.php';
|
313 |
+
|
314 |
+
require_once($this->getModuleDirectory() . $filename);
|
315 |
+
|
316 |
+
$class = $base_class . '_' . str_replace('\\', '_', $module_full);
|
317 |
+
if ( ! isset($this->_modules[$class]) || ! is_object($this->_modules[$class]) || get_class($this->_modules[$class]) != $class ) {
|
318 |
+
try {
|
319 |
+
$object = new $class;
|
320 |
+
$this->setModule($module_full, $object);
|
321 |
+
$this->getModule($module)->setTheme($this);
|
322 |
+
} catch ( Exception $e ) {
|
323 |
+
die('Unable to load module: \'' . $module . '\'. ' . $e->getMessage());
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
return $this;
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* Load Modules
|
332 |
+
*
|
333 |
+
* Load specified modules. If no modules are specified, all modules are loaded.
|
334 |
+
*
|
335 |
+
* @param array $modules
|
336 |
+
* @return $this
|
337 |
+
*/
|
338 |
+
public function loadModules( $modules = array() ) {
|
339 |
+
if ( sizeof($modules) == 0 ) {
|
340 |
+
$modules = $this->getAvailableModules();
|
341 |
+
}
|
342 |
+
|
343 |
+
foreach( $modules as $module ) {
|
344 |
+
$this->loadModule( $module );
|
345 |
+
}
|
346 |
+
return $this;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Unload Module
|
351 |
+
*
|
352 |
+
* @param string $module
|
353 |
+
* @return $this
|
354 |
+
*/
|
355 |
+
public function unloadModule( $module ) {
|
356 |
+
if ( strpos(get_class($this), '_') !== false ) {
|
357 |
+
$base_class = substr(get_class($this), 0, strpos(get_class($this), '_'));
|
358 |
+
} else {
|
359 |
+
$base_class = get_class($this);
|
360 |
+
}
|
361 |
+
$module = 'Module\\' . $module;
|
362 |
+
|
363 |
+
$modules = $this->getModules();
|
364 |
+
|
365 |
+
unset($modules[$module]);
|
366 |
+
|
367 |
+
$this->_modules = $modules;
|
368 |
+
|
369 |
+
return $this;
|
370 |
+
}
|
371 |
+
|
372 |
+
}
|
lib/Mvied/Theme/Module.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Theme Module
|
4 |
+
*
|
5 |
+
* Each Module in the project will extend this base Module class.
|
6 |
+
* Modules can be treated as independent plugins. Think of them as sub-plugins.
|
7 |
+
*
|
8 |
+
* @author Mike Ems
|
9 |
+
* @package Mvied
|
10 |
+
*/
|
11 |
+
class Mvied_Theme_Module {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Theme object that this module extends
|
15 |
+
*
|
16 |
+
* @var Mvied_Theme
|
17 |
+
*/
|
18 |
+
protected $_theme;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Set Theme
|
22 |
+
*
|
23 |
+
* @param Mvied_Theme $theme
|
24 |
+
* @return object $this
|
25 |
+
* @uses Mvied_Theme
|
26 |
+
*/
|
27 |
+
public function setTheme( Mvied_Theme $theme ) {
|
28 |
+
$this->_theme = $theme;
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get Theme
|
34 |
+
*
|
35 |
+
* @param none
|
36 |
+
* @return Mvied_Theme
|
37 |
+
*/
|
38 |
+
public function getTheme() {
|
39 |
+
if ( ! isset($this->_theme) ) {
|
40 |
+
die('Module ' . __CLASS__ . ' missing Theme dependency.');
|
41 |
+
}
|
42 |
+
|
43 |
+
return $this->_theme;
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
lib/Mvied/Theme/Module/Interface.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Theme Module Interface
|
4 |
+
*
|
5 |
+
* @author Mike Ems
|
6 |
+
* @package Mvied
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
|
10 |
+
interface Mvied_Theme_Module_Interface {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Initializes the module
|
14 |
+
*
|
15 |
+
* @param none
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
public function init();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Set Theme
|
22 |
+
*
|
23 |
+
* @param Mvied_Theme $theme
|
24 |
+
* @return Mvied_Theme_Module
|
25 |
+
* @uses Mvied_Theme
|
26 |
+
*/
|
27 |
+
public function setTheme( Mvied_Theme $theme );
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Get Theme
|
31 |
+
*
|
32 |
+
* @param none
|
33 |
+
* @return Mvied_Theme
|
34 |
+
*/
|
35 |
+
public function getTheme();
|
36 |
+
}
|
lib/WordPressHTTPS.php
CHANGED
@@ -43,6 +43,7 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
43 |
'ssl_proxy' => 0, // Proxy detection
|
44 |
'debug' => 0, // Debug Mode
|
45 |
'admin_menu' => 'side', // HTTPS Admin Menu location
|
|
|
46 |
);
|
47 |
|
48 |
/**
|
@@ -170,10 +171,9 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
170 |
* @return boolean
|
171 |
*/
|
172 |
public function isUrlLocal($url) {
|
173 |
-
$
|
174 |
-
$url = WordPressHTTPS_Url::fromString($string);
|
175 |
|
176 |
-
if ( $this->getHttpUrl()->getHost() != $
|
177 |
return false;
|
178 |
} else {
|
179 |
return true;
|
@@ -188,22 +188,41 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
188 |
*/
|
189 |
public function makeUrlHttps( $string ) {
|
190 |
$url = WordPressHTTPS_Url::fromString( $string ); // URL to replace HTTP URL
|
191 |
-
if ( $url
|
192 |
-
$
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
if ( $this->
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
}
|
202 |
}
|
203 |
-
|
204 |
-
} else {
|
205 |
-
return $string;
|
206 |
}
|
|
|
207 |
}
|
208 |
|
209 |
/**
|
@@ -214,18 +233,61 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
214 |
*/
|
215 |
public function makeUrlHttp( $string ) {
|
216 |
$url = WordPressHTTPS_Url::fromString( $string ); // URL to replace HTTP URL
|
217 |
-
if ( $url
|
218 |
-
$
|
219 |
-
|
220 |
-
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
224 |
}
|
225 |
-
|
226 |
-
} else {
|
227 |
-
return $string;
|
228 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
}
|
230 |
|
231 |
/**
|
@@ -276,7 +338,7 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
276 |
}
|
277 |
|
278 |
if ( $url ) {
|
279 |
-
$path = $_SERVER['REQUEST_URI'];
|
280 |
if ( $this->getHttpsUrl()->getPath() != '/' ) {
|
281 |
$path = str_replace($this->getHttpsUrl()->getPath(), '', $path);
|
282 |
}
|
@@ -296,6 +358,16 @@ class WordPressHTTPS extends Mvied_Plugin {
|
|
296 |
}
|
297 |
}
|
298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
// Redirect
|
300 |
if ( function_exists('wp_redirect') ) {
|
301 |
wp_redirect($url, 301);
|
43 |
'ssl_proxy' => 0, // Proxy detection
|
44 |
'debug' => 0, // Debug Mode
|
45 |
'admin_menu' => 'side', // HTTPS Admin Menu location
|
46 |
+
'secure_filter' => array(), // Array of expressions to secure URL's against
|
47 |
);
|
48 |
|
49 |
/**
|
171 |
* @return boolean
|
172 |
*/
|
173 |
public function isUrlLocal($url) {
|
174 |
+
$url_parts = parse_url($url);
|
|
|
175 |
|
176 |
+
if ( $url_parts && $this->getHttpUrl()->getHost() != $url_parts['host'] && $this->getHttpsUrl()->getHost() != $url_parts['host'] ) {
|
177 |
return false;
|
178 |
} else {
|
179 |
return true;
|
188 |
*/
|
189 |
public function makeUrlHttps( $string ) {
|
190 |
$url = WordPressHTTPS_Url::fromString( $string ); // URL to replace HTTP URL
|
191 |
+
if ( $url ) {
|
192 |
+
if ( $this->isUrlLocal($url) ) {
|
193 |
+
$url->setScheme('https');
|
194 |
+
$url->setHost($this->getHttpsUrl()->getHost());
|
195 |
+
$url->setPort($this->getHttpsUrl()->getPort());
|
196 |
+
|
197 |
+
if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpsUrl()->getPath()) === false ) {
|
198 |
+
if ( $this->getHttpUrl()->getPath() == '/' ) {
|
199 |
+
$url->setPath(rtrim($this->getHttpsUrl()->getPath(), '/') . $url->getPath());
|
200 |
+
} else {
|
201 |
+
$url->setPath(str_replace($this->getHttpUrl()->getPath(), $this->getHttpsUrl()->getPath(), $url->getPath()));
|
202 |
+
}
|
203 |
+
}
|
204 |
+
|
205 |
+
$string = $url->toString();
|
206 |
+
} else {
|
207 |
+
if ( $url->getScheme() == 'http' && @in_array($url, $this->getSetting('secure_external_urls')) == false && @in_array($url, $this->getSetting('unsecure_external_urls')) == false ) {
|
208 |
+
$test_url = clone $url;
|
209 |
+
$test_url->setScheme('https');
|
210 |
+
if ( $test_url->isValid() ) {
|
211 |
+
// Cache this URL as available over HTTPS for future reference
|
212 |
+
$this->addSecureExternalUrl($url->toString());
|
213 |
+
} else {
|
214 |
+
// If not available over HTTPS, mark as an unsecure external URL
|
215 |
+
$this->addUnsecureExternalUrl($url->toString());
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
if ( in_array($url->toString(), $this->getSetting('secure_external_urls')) ) {
|
220 |
+
$string = str_replace($url, str_replace('http://', 'https://', $url), $string);
|
221 |
}
|
222 |
}
|
223 |
+
unset($url);
|
|
|
|
|
224 |
}
|
225 |
+
return $string;
|
226 |
}
|
227 |
|
228 |
/**
|
233 |
*/
|
234 |
public function makeUrlHttp( $string ) {
|
235 |
$url = WordPressHTTPS_Url::fromString( $string ); // URL to replace HTTP URL
|
236 |
+
if ( $url ) {
|
237 |
+
if ( $this->isUrlLocal($url) ) {
|
238 |
+
$url->setScheme('http');
|
239 |
+
$url->setHost($this->getHttpUrl()->getHost());
|
240 |
+
$url->setPort($this->getHttpUrl()->getPort());
|
241 |
+
|
242 |
+
if ( $this->getSetting('ssl_host_diff') && strpos($url->getPath(), $this->getHttpsUrl()->getPath()) !== false ) {
|
243 |
+
$url->setPath(str_replace($this->getHttpsUrl()->getPath(), $this->getHttpUrl()->getPath(), $url->getPath()));
|
244 |
+
}
|
245 |
|
246 |
+
$string = $url->toString();
|
247 |
+
} else {
|
248 |
+
if ( $url ) {
|
249 |
+
$string = str_replace($url, str_replace('https://', 'http://', $url), $string);
|
250 |
+
}
|
251 |
}
|
252 |
+
unset($url);
|
|
|
|
|
253 |
}
|
254 |
+
return $string;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Add Secure External URL
|
259 |
+
*
|
260 |
+
* @param string $value
|
261 |
+
* @return $this
|
262 |
+
*/
|
263 |
+
public function addSecureExternalUrl( $value ) {
|
264 |
+
if ( trim($value) == '' ) {
|
265 |
+
return $this;
|
266 |
+
}
|
267 |
+
|
268 |
+
$secure_external_urls = (array) $this->getSetting('secure_external_urls');
|
269 |
+
array_push($secure_external_urls, (string) $value);
|
270 |
+
$this->setSetting('secure_external_urls', $secure_external_urls);
|
271 |
+
|
272 |
+
return $this;
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Add Unsecure External URL
|
277 |
+
*
|
278 |
+
* @param string $value
|
279 |
+
* @return $this
|
280 |
+
*/
|
281 |
+
public function addUnsecureExternalUrl( $value ) {
|
282 |
+
if ( trim($value) == '' ) {
|
283 |
+
return $this;
|
284 |
+
}
|
285 |
+
|
286 |
+
$unsecure_external_urls = (array) $this->getSetting('unsecure_external_urls');
|
287 |
+
array_push($unsecure_external_urls, (string) $value);
|
288 |
+
$this->setSetting('unsecure_external_urls', $unsecure_external_urls);
|
289 |
+
|
290 |
+
return $this;
|
291 |
}
|
292 |
|
293 |
/**
|
338 |
}
|
339 |
|
340 |
if ( $url ) {
|
341 |
+
$path = ( isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI'] );
|
342 |
if ( $this->getHttpsUrl()->getPath() != '/' ) {
|
343 |
$path = str_replace($this->getHttpsUrl()->getPath(), '', $path);
|
344 |
}
|
358 |
}
|
359 |
}
|
360 |
|
361 |
+
// Use a cookie to detect redirect loops
|
362 |
+
$redirect_count = ( isset($_COOKIE['redirect_count']) && is_numeric($_COOKIE['redirect_count']) ? (int)$_COOKIE['redirect_count']+1 : 1 );
|
363 |
+
setcookie('redirect_count', $redirect_count, 0, '/');
|
364 |
+
// If redirect count is greater than 2, prevent redirect and log the redirect loop
|
365 |
+
if ( $redirect_count > 2 ) {
|
366 |
+
setcookie('redirect_count', null, -time(), '/');
|
367 |
+
$this->getLogger()->log('[ERROR] Redirect Loop!');
|
368 |
+
return;
|
369 |
+
}
|
370 |
+
|
371 |
// Redirect
|
372 |
if ( function_exists('wp_redirect') ) {
|
373 |
wp_redirect($url, 301);
|
lib/WordPressHTTPS/Module/Admin.php
CHANGED
@@ -9,10 +9,7 @@
|
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
require_once('Mvied/Module/Interface.php');
|
14 |
-
|
15 |
-
class WordPressHTTPS_Module_Admin extends Mvied_Module implements Mvied_Module_Interface {
|
16 |
|
17 |
/**
|
18 |
* Initialize Module
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
+
class WordPressHTTPS_Module_Admin extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Initialize Module
|
lib/WordPressHTTPS/Module/Admin/Post.php
CHANGED
@@ -9,10 +9,7 @@
|
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
require_once('Mvied/Module/Interface.php');
|
14 |
-
|
15 |
-
class WordPressHTTPS_Module_Admin_Post extends Mvied_Module implements Mvied_Module_Interface {
|
16 |
|
17 |
/**
|
18 |
* Initialize Module
|
@@ -35,24 +32,21 @@ class WordPressHTTPS_Module_Admin_Post extends Mvied_Module implements Mvied_Mod
|
|
35 |
* @return void
|
36 |
*/
|
37 |
public function add_meta_box_post() {
|
38 |
-
|
39 |
-
|
40 |
-
__( 'HTTPS', $this->getPlugin()->getSlug() ),
|
41 |
-
array($this->getPlugin()->getModule('Admin'), 'meta_box_render'),
|
42 |
-
'post',
|
43 |
-
'side',
|
44 |
-
'high',
|
45 |
-
array( 'metabox' => 'post' )
|
46 |
-
);
|
47 |
-
add_meta_box(
|
48 |
-
$this->getPlugin()->getSlug(),
|
49 |
-
__( 'HTTPS', $this->getPlugin()->getSlug() ),
|
50 |
-
array($this->getPlugin()->getModule('Admin'), 'meta_box_render'),
|
51 |
-
'page',
|
52 |
-
'side',
|
53 |
-
'high',
|
54 |
-
array( 'metabox' => 'post' )
|
55 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
|
58 |
/**
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
+
class WordPressHTTPS_Module_Admin_Post extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Initialize Module
|
32 |
* @return void
|
33 |
*/
|
34 |
public function add_meta_box_post() {
|
35 |
+
$args = array(
|
36 |
+
'public' => true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
);
|
38 |
+
$post_types = get_post_types( $args );
|
39 |
+
foreach($post_types as $post_type ) {
|
40 |
+
add_meta_box(
|
41 |
+
$this->getPlugin()->getSlug(),
|
42 |
+
__( 'HTTPS', $this->getPlugin()->getSlug() ),
|
43 |
+
array($this->getPlugin()->getModule('Admin'), 'meta_box_render'),
|
44 |
+
$post_type,
|
45 |
+
'side',
|
46 |
+
'core',
|
47 |
+
array( 'metabox' => 'post' )
|
48 |
+
);
|
49 |
+
};
|
50 |
}
|
51 |
|
52 |
/**
|
lib/WordPressHTTPS/Module/Admin/Settings.php
CHANGED
@@ -9,10 +9,7 @@
|
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
-
|
13 |
-
require_once('Mvied/Module/Interface.php');
|
14 |
-
|
15 |
-
class WordPressHTTPS_Module_Admin_Settings extends Mvied_Module implements Mvied_Module_Interface {
|
16 |
|
17 |
/**
|
18 |
* Initialize Module
|
@@ -50,6 +47,15 @@ class WordPressHTTPS_Module_Admin_Settings extends Mvied_Module implements Mvied
|
|
50 |
'core',
|
51 |
array( 'metabox' => 'settings' )
|
52 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
add_meta_box(
|
54 |
$this->getPlugin()->getSlug() . '_updates',
|
55 |
__( 'Developer Updates', $this->getPlugin()->getSlug() ),
|
@@ -148,13 +154,13 @@ class WordPressHTTPS_Module_Admin_Settings extends Mvied_Module implements Mvied
|
|
148 |
$errors = array();
|
149 |
$reload = false;
|
150 |
$logout = false;
|
151 |
-
if (
|
152 |
foreach ($this->getPlugin()->getSettings() as $key => $default) {
|
153 |
$this->getPlugin()->setSetting($key, $default);
|
154 |
}
|
155 |
$this->getPlugin()->install();
|
156 |
$reload = true;
|
157 |
-
} else {
|
158 |
foreach ($this->getPlugin()->getSettings() as $key => $default) {
|
159 |
if ( !array_key_exists($key, $_POST) && $default == 0 ) {
|
160 |
$_POST[$key] = 0;
|
@@ -227,6 +233,13 @@ class WordPressHTTPS_Module_Admin_Settings extends Mvied_Module implements Mvied
|
|
227 |
$this->getPlugin()->setSetting($key, $_POST[$key]);
|
228 |
}
|
229 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
}
|
231 |
|
232 |
if ( $logout ) {
|
9 |
*
|
10 |
*/
|
11 |
|
12 |
+
class WordPressHTTPS_Module_Admin_Settings extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Initialize Module
|
47 |
'core',
|
48 |
array( 'metabox' => 'settings' )
|
49 |
);
|
50 |
+
add_meta_box(
|
51 |
+
$this->getPlugin()->getSlug() . '_filters',
|
52 |
+
__( 'URL Filters', $this->getPlugin()->getSlug() ),
|
53 |
+
array($this->getPlugin()->getModule('Admin'), 'meta_box_render'),
|
54 |
+
'toplevel_page_' . $this->getPlugin()->getSlug(),
|
55 |
+
'main',
|
56 |
+
'core',
|
57 |
+
array( 'metabox' => 'filters' )
|
58 |
+
);
|
59 |
add_meta_box(
|
60 |
$this->getPlugin()->getSlug() . '_updates',
|
61 |
__( 'Developer Updates', $this->getPlugin()->getSlug() ),
|
154 |
$errors = array();
|
155 |
$reload = false;
|
156 |
$logout = false;
|
157 |
+
if ( isset($_POST['settings-reset']) ) {
|
158 |
foreach ($this->getPlugin()->getSettings() as $key => $default) {
|
159 |
$this->getPlugin()->setSetting($key, $default);
|
160 |
}
|
161 |
$this->getPlugin()->install();
|
162 |
$reload = true;
|
163 |
+
} else if ( isset($_POST['settings-save']) ) {
|
164 |
foreach ($this->getPlugin()->getSettings() as $key => $default) {
|
165 |
if ( !array_key_exists($key, $_POST) && $default == 0 ) {
|
166 |
$_POST[$key] = 0;
|
233 |
$this->getPlugin()->setSetting($key, $_POST[$key]);
|
234 |
}
|
235 |
}
|
236 |
+
} else if ( isset($_POST['filters-save']) ) {
|
237 |
+
$filters = array_map('trim', explode("\n", $_POST['secure_filter']));
|
238 |
+
$filters = array_filter($filters); // Removes blank array items
|
239 |
+
$this->getPlugin()->setSetting('secure_filter', $filters);
|
240 |
+
} else if ( isset($_POST['filters-reset']) ) {
|
241 |
+
$this->getPlugin()->setSetting('secure_filter', array());
|
242 |
+
$reload = true;
|
243 |
}
|
244 |
|
245 |
if ( $logout ) {
|
lib/WordPressHTTPS/Module/Filters.php
CHANGED
@@ -7,10 +7,7 @@
|
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
require_once('Mvied/Module/Interface.php');
|
12 |
-
|
13 |
-
class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module_Interface {
|
14 |
|
15 |
/**
|
16 |
* Initialize
|
@@ -22,50 +19,47 @@ class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module
|
|
22 |
// Prevent WordPress' canonical redirect when using a different SSL Host
|
23 |
if ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->isSsl() ) {
|
24 |
remove_filter('template_redirect', 'redirect_canonical');
|
|
|
|
|
25 |
}
|
26 |
-
|
27 |
// Add SSL Host to allowed redirect hosts
|
28 |
add_filter('allowed_redirect_hosts' , array(&$this, 'allowed_redirect_hosts'), 10, 1);
|
29 |
-
|
30 |
// Filter get_avatar
|
31 |
add_filter('get_avatar', array(&$this, 'get_avatar'), 10, 5);
|
32 |
-
|
33 |
// Filter admin_url
|
34 |
add_filter('admin_url', array(&$this, 'admin_url'), 10, 3);
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
// Filter force_ssl
|
37 |
-
add_filter('force_ssl', array(&$this, '
|
38 |
-
add_filter('force_ssl', array(&$this, '
|
|
|
|
|
39 |
|
40 |
-
// Filter
|
41 |
if ( $this->getPlugin()->isSsl() ) {
|
42 |
-
add_filter('site_url', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
43 |
add_filter('template_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
44 |
add_filter('stylesheet_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
45 |
}
|
46 |
|
47 |
-
// Filter
|
48 |
-
if (
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
add_filter('bloginfo', array(&$this, 'bloginfo'), 10, 2);
|
55 |
-
add_filter('bloginfo_url', array(&$this, 'bloginfo'), 10, 2);
|
56 |
-
|
57 |
-
// If the whole site is not HTTPS, set links to the front-end to HTTP from within the admin panel
|
58 |
-
} else if ( is_admin() && $this->getPlugin()->getSetting('ssl_admin') == 0 && $this->getPlugin()->isSsl() && WordPressHTTPS_Url::fromString(get_option('home'))->getScheme() != 'https' ) {
|
59 |
-
$filters = array('page_link', 'post_link', 'category_link', 'get_archives_link', 'tag_link', 'search_link');
|
60 |
-
foreach( $filters as $filter ) {
|
61 |
-
add_filter($filter, array($this->getPlugin(), 'makeUrlHttp'), 10);
|
62 |
-
}
|
63 |
}
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
add_filter(
|
68 |
-
add_filter('post_link', array($this->getPlugin(), 'makeUrlHttps'), 9);
|
69 |
}
|
70 |
}
|
71 |
|
@@ -75,14 +69,30 @@ class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module
|
|
75 |
*
|
76 |
* @param string $url
|
77 |
* @param string $path
|
78 |
-
* @param
|
79 |
* @return string $url
|
80 |
*/
|
81 |
-
public function admin_url( $url, $path, $
|
82 |
-
if ( ( $
|
83 |
$url = $this->getPlugin()->makeUrlHttps($url);
|
84 |
}
|
|
|
|
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
return $url;
|
87 |
}
|
88 |
|
@@ -98,23 +108,6 @@ class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module
|
|
98 |
return $content;
|
99 |
}
|
100 |
|
101 |
-
/**
|
102 |
-
* Blog Info
|
103 |
-
* WordPress Filter - get_bloginfo, bloginfo
|
104 |
-
*
|
105 |
-
* @param string $result
|
106 |
-
* @param string $show
|
107 |
-
* @return string $result
|
108 |
-
*/
|
109 |
-
public function bloginfo( $result = '', $show = '' ) {
|
110 |
-
if ( $show == 'stylesheet_url' || $show == 'template_url' || $show == 'wpurl' || $show == 'home' || $show == 'siteurl' || $show == 'Url' ) {
|
111 |
-
if ( WordPressHTTPS_Url::fromString(get_option('home'))->getScheme() != 'https' ) {
|
112 |
-
$result = $this->getPlugin()->makeUrlHttp($result);
|
113 |
-
}
|
114 |
-
}
|
115 |
-
return $result;
|
116 |
-
}
|
117 |
-
|
118 |
/**
|
119 |
* Get Avatar
|
120 |
* WordPress Filter - get_avatar
|
@@ -135,18 +128,155 @@ class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module
|
|
135 |
|
136 |
return $avatar;
|
137 |
}
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
/**
|
140 |
* Secure Post
|
141 |
* WordPress HTTPS Filter - force_ssl
|
142 |
*
|
143 |
* @param boolean $force_ssl
|
144 |
* @param int $post_id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
* @return boolean $force_ssl
|
146 |
*/
|
147 |
-
public function
|
148 |
-
if (
|
149 |
-
$force_ssl =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
}
|
151 |
return $force_ssl;
|
152 |
}
|
@@ -157,10 +287,11 @@ class WordPressHTTPS_Module_Filters extends Mvied_Module implements Mvied_Module
|
|
157 |
*
|
158 |
* @param boolean $force_ssl
|
159 |
* @param int $post_id
|
|
|
160 |
* @return boolean $force_ssl
|
161 |
*/
|
162 |
-
public function secure_child_post( $force_ssl, $post_id ) {
|
163 |
-
if (
|
164 |
$postParent = get_post($post_id);
|
165 |
while ( $postParent->post_parent ) {
|
166 |
$postParent = get_post( $postParent->post_parent );
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
+
class WordPressHTTPS_Module_Filters extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
11 |
|
12 |
/**
|
13 |
* Initialize
|
19 |
// Prevent WordPress' canonical redirect when using a different SSL Host
|
20 |
if ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->isSsl() ) {
|
21 |
remove_filter('template_redirect', 'redirect_canonical');
|
22 |
+
// Filter SSL Host path out of request
|
23 |
+
add_filter('request', array(&$this, 'request'), 10, 1);
|
24 |
}
|
25 |
+
|
26 |
// Add SSL Host to allowed redirect hosts
|
27 |
add_filter('allowed_redirect_hosts' , array(&$this, 'allowed_redirect_hosts'), 10, 1);
|
28 |
+
|
29 |
// Filter get_avatar
|
30 |
add_filter('get_avatar', array(&$this, 'get_avatar'), 10, 5);
|
31 |
+
|
32 |
// Filter admin_url
|
33 |
add_filter('admin_url', array(&$this, 'admin_url'), 10, 3);
|
34 |
+
|
35 |
+
// Filter site_url
|
36 |
+
add_filter('site_url', array(&$this, 'site_url'), 10, 4);
|
37 |
+
|
38 |
+
// Filter bloginfo
|
39 |
+
add_filter('bloginfo_url', array(&$this, 'bloginfo_url'), 10, 2);
|
40 |
+
|
41 |
// Filter force_ssl
|
42 |
+
add_filter('force_ssl', array(&$this, 'secure_different_host_admin'), 20, 3);
|
43 |
+
add_filter('force_ssl', array(&$this, 'secure_child_post'), 30, 3);
|
44 |
+
add_filter('force_ssl', array(&$this, 'secure_post'), 40, 3);
|
45 |
+
add_filter('force_ssl', array(&$this, 'secure_exclusive'), 50, 3);
|
46 |
|
47 |
+
// Filter stylesheet directories
|
48 |
if ( $this->getPlugin()->isSsl() ) {
|
|
|
49 |
add_filter('template_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
50 |
add_filter('stylesheet_directory_uri', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
51 |
}
|
52 |
|
53 |
+
// Filter login/logout URL's
|
54 |
+
if ( $this->getPlugin()->isSsl() || $this->getPlugin()->getSetting('ssl_admin') ) {
|
55 |
+
add_filter('logout_url', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
56 |
+
add_filter('login_url', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
57 |
+
add_filter('loginout', array($this->getPlugin(), 'makeUrlHttps'), 10);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
+
$filters = array('page_link', 'post_link', 'category_link', 'archives_link', 'tag_link', 'search_link');
|
61 |
+
foreach( $filters as $filter ) {
|
62 |
+
add_filter($filter, array(&$this, 'secure_post_link'), 10);
|
|
|
63 |
}
|
64 |
}
|
65 |
|
69 |
*
|
70 |
* @param string $url
|
71 |
* @param string $path
|
72 |
+
* @param int $blog_id
|
73 |
* @return string $url
|
74 |
*/
|
75 |
+
public function admin_url( $url, $path, $blog_id ) {
|
76 |
+
if ( ( $this->getPlugin()->getSetting('ssl_admin') || ( ( is_admin() || $GLOBALS['pagenow'] == 'wp-login.php' ) && $this->getPlugin()->isSsl() ) ) && ( ! is_multisite() || ( is_multisite() && parse_url($url, PHP_URL_HOST) == $this->getPlugin()->getHttpsUrl()->getHost() ) ) ) {
|
77 |
$url = $this->getPlugin()->makeUrlHttps($url);
|
78 |
}
|
79 |
+
return $url;
|
80 |
+
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Site URL
|
84 |
+
* WordPress Filter - site_url
|
85 |
+
*
|
86 |
+
* @param string $url
|
87 |
+
* @param string $path
|
88 |
+
* @param string $scheme
|
89 |
+
* @param int $blog_id
|
90 |
+
* @return string $url
|
91 |
+
*/
|
92 |
+
public function site_url( $url, $path, $scheme, $blog_id ) {
|
93 |
+
if ( $scheme == 'https' ) {
|
94 |
+
$url = $this->getPlugin()->makeUrlHttps($url);
|
95 |
+
}
|
96 |
return $url;
|
97 |
}
|
98 |
|
108 |
return $content;
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
/**
|
112 |
* Get Avatar
|
113 |
* WordPress Filter - get_avatar
|
128 |
|
129 |
return $avatar;
|
130 |
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Blog Info
|
134 |
+
* WordPress Filter - bloginfo_url
|
135 |
+
*
|
136 |
+
* @param string $result
|
137 |
+
* @param string $show
|
138 |
+
* @return string $result
|
139 |
+
*/
|
140 |
+
public function bloginfo_url( $result = '', $show = '' ) {
|
141 |
+
if ( $this->getPlugin()->isSsl() ) {
|
142 |
+
$result = rtrim($this->getPlugin()->makeUrlHttps(rtrim($result, '/') . '/'), '/');
|
143 |
+
} else if ( strpos(get_option('home'), 'https') !== 0 ) {
|
144 |
+
$result = rtrim($this->getPlugin()->makeUrlHttp(rtrim($result, '/') . '/'), '/');
|
145 |
+
}
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Filter Request
|
151 |
+
* WordPress Filter - request
|
152 |
+
*
|
153 |
+
* @param array $request
|
154 |
+
* @return array $request
|
155 |
+
*/
|
156 |
+
public function request( $request ) {
|
157 |
+
$request['pagename'] = str_replace(trim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . '/', '', @$request['pagename']);
|
158 |
+
return $request;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Secure Post Link
|
163 |
+
*
|
164 |
+
* @param string $url
|
165 |
+
* @return string $url
|
166 |
+
*/
|
167 |
+
public function secure_post_link( $url ) {
|
168 |
+
$force_ssl = apply_filters('force_ssl', null, 0, $url);
|
169 |
+
if ( $force_ssl ) {
|
170 |
+
$url = $this->getPlugin()->makeUrlHttps($url);
|
171 |
+
} else if ( $this->getPlugin()->getSetting('exclusive_https') ) {
|
172 |
+
$url = $this->getPlugin()->makeUrlHttp($url);
|
173 |
+
}
|
174 |
+
return $url;
|
175 |
+
}
|
176 |
+
|
177 |
/**
|
178 |
* Secure Post
|
179 |
* WordPress HTTPS Filter - force_ssl
|
180 |
*
|
181 |
* @param boolean $force_ssl
|
182 |
* @param int $post_id
|
183 |
+
* @param string $url
|
184 |
+
* @return boolean $force_ssl
|
185 |
+
*/
|
186 |
+
public function secure_post( $force_ssl, $post_id = 0, $url = '' ) {
|
187 |
+
if ( $url != '' ) {
|
188 |
+
$url_parts = parse_url($url);
|
189 |
+
if ( $this->getPlugin()->isUrlLocal($url) ) {
|
190 |
+
if ( $this->getPlugin()->getHttpsUrl()->getPath() != '/' ) {
|
191 |
+
if ( $this->getPlugin()->getSetting('ssl_host_diff') ) {
|
192 |
+
$url_parts['path'] = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), '', $url_parts['path']);
|
193 |
+
}
|
194 |
+
if ( $this->getPlugin()->getHttpUrl()->getPath() != '/' ) {
|
195 |
+
$url_parts['path'] = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $url_parts['path']);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// qTranslate integration - strips language from beginning of url path
|
200 |
+
if ( defined('QTRANS_INIT') && constant('QTRANS_INIT') == true ) {
|
201 |
+
global $q_config;
|
202 |
+
if ( isset($q_config['enabled_languages']) ) {
|
203 |
+
foreach($q_config['enabled_languages'] as $language) {
|
204 |
+
$url_parts['path'] = preg_replace('/^\/' . $language . '\//', '/', $url_parts['path']);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
// Check secure filters
|
210 |
+
if ( sizeof($this->getPlugin()->getSetting('secure_filter')) > 0 ) {
|
211 |
+
foreach( $this->getPlugin()->getSetting('secure_filter') as $filter ) {
|
212 |
+
if ( strpos($url, $filter) !== false ) {
|
213 |
+
$force_ssl = true;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( preg_match("/page_id=([\d]+)/", parse_url($url, PHP_URL_QUERY), $postID) ) {
|
219 |
+
$post = $postID[1];
|
220 |
+
} else if ( $url_parts['path'] == '' || $url_parts['path'] == '/' ) {
|
221 |
+
if ( get_option('show_on_front') == 'page' ) {
|
222 |
+
$post = get_option('page_on_front');
|
223 |
+
}
|
224 |
+
if ( $this->getPlugin()->getSetting('frontpage') ) {
|
225 |
+
$force_ssl = true;
|
226 |
+
}
|
227 |
+
} else if ( $post = get_page_by_path($url_parts['path']) ) {
|
228 |
+
$post = $post->ID;
|
229 |
+
//TODO When logged in to HTTP and visiting an HTTPS page, admin links will always be forced to HTTPS, even if the user is not logged in via HTTPS. I need to find a way to detect this.
|
230 |
+
} else if ( ( strpos($url_parts['path'], 'wp-admin') !== false || strpos($url_parts['path'], 'wp-login') !== false ) && ( $this->getPlugin()->isSsl() || $this->getPlugin()->getSetting('ssl_admin') ) ) {
|
231 |
+
if ( ! is_multisite() || ( is_multisite() && strpos($url_parts['host'], $this->getPlugin()->getHttpsUrl()->getHost()) !== false ) ) {
|
232 |
+
$force_ssl = true;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
} else if ( is_multisite() ) {
|
236 |
+
// get_blog_details returns an object with a property of blog_id
|
237 |
+
if ( $blog_details = get_blog_details( array( 'domain' => $url_parts['host'] )) ) {
|
238 |
+
// set $blog_id using $blog_details->blog_id
|
239 |
+
$blog_id = $blog_details->blog_id;
|
240 |
+
if ( $this->getPlugin()->getSetting('ssl_admin', $blog_id) && $url_parts['scheme'] != 'https' && ( ! $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) || ( $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) && is_user_logged_in() ) ) ) {
|
241 |
+
$force_ssl = true;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
}
|
246 |
+
if ( (int) $post > 0 ) {
|
247 |
+
$force_ssl = (( get_post_meta($post, 'force_ssl', true) == 1 ) ? true : $force_ssl);
|
248 |
+
}
|
249 |
+
return $force_ssl;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Always secure pages when using a different SSL Host.
|
254 |
+
* WordPress HTTPS Filter - force_ssl
|
255 |
+
*
|
256 |
+
* @param boolean $force_ssl
|
257 |
+
* @param int $post_id
|
258 |
+
* @param string $url
|
259 |
* @return boolean $force_ssl
|
260 |
*/
|
261 |
+
public function secure_exclusive( $force_ssl, $post_id = 0, $url = '' ) {
|
262 |
+
if ( is_null($force_ssl) && strpos(get_option('home'), 'https') !== 0 && $this->getPlugin()->getSetting('exclusive_https') ) {
|
263 |
+
$force_ssl = false;
|
264 |
+
}
|
265 |
+
return $force_ssl;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* Always secure pages when using a different SSL Host.
|
270 |
+
* WordPress HTTPS Filter - force_ssl
|
271 |
+
*
|
272 |
+
* @param boolean $force_ssl
|
273 |
+
* @param int $post_id
|
274 |
+
* @param string $url
|
275 |
+
* @return boolean $force_ssl
|
276 |
+
*/
|
277 |
+
public function secure_different_host_admin( $force_ssl, $post_id = 0, $url = '' ) {
|
278 |
+
if ( ! $this->getPlugin()->getSetting('ssl_host_subdomain') && $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->getSetting('ssl_admin') && is_user_logged_in() ) {
|
279 |
+
$force_ssl = true;
|
280 |
}
|
281 |
return $force_ssl;
|
282 |
}
|
287 |
*
|
288 |
* @param boolean $force_ssl
|
289 |
* @param int $post_id
|
290 |
+
* @param string $url
|
291 |
* @return boolean $force_ssl
|
292 |
*/
|
293 |
+
public function secure_child_post( $force_ssl, $post_id = 0, $url = '' ) {
|
294 |
+
if ( $post_id > 0 ) {
|
295 |
$postParent = get_post($post_id);
|
296 |
while ( $postParent->post_parent ) {
|
297 |
$postParent = get_post( $postParent->post_parent );
|
lib/WordPressHTTPS/Module/Hooks.php
CHANGED
@@ -7,10 +7,7 @@
|
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
require_once('Mvied/Module/Interface.php');
|
12 |
-
|
13 |
-
class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_Interface {
|
14 |
|
15 |
/**
|
16 |
* Initialize
|
@@ -28,11 +25,17 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
28 |
add_action('set_auth_cookie', array(&$this, 'set_cookie'), 10, 5);
|
29 |
add_action('set_logged_in_cookie', array(&$this, 'set_cookie'), 10, 5);
|
30 |
}
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
|
38 |
// Run proxy check
|
@@ -51,7 +54,52 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
51 |
}
|
52 |
|
53 |
// Check if the page needs to be redirected
|
54 |
-
add_action('template_redirect', array(&$this, 'redirect_check'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
}
|
56 |
|
57 |
/**
|
@@ -95,21 +143,7 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
95 |
}
|
96 |
|
97 |
if ( $post->ID > 0 ) {
|
98 |
-
$force_ssl = apply_filters('force_ssl', null, $post->ID );
|
99 |
-
}
|
100 |
-
|
101 |
-
// Secure Front Page
|
102 |
-
if ( is_front_page() ) {
|
103 |
-
if ( $this->getPlugin()->getSetting('frontpage') ) {
|
104 |
-
$force_ssl = true;
|
105 |
-
} else if ( ! $this->getPlugin()->getSetting('frontpage') && $this->getPlugin()->getSetting('exclusive_https') && ( ! $this->getPlugin()->getSetting('ssl_host_diff') || ( $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->getSetting('ssl_admin') && ! is_user_logged_in() ) ) ) {
|
106 |
-
$force_ssl = false;
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
// Exclusive HTTPS
|
111 |
-
if ( $this->getPlugin()->getSetting('exclusive_https') && $this->getPlugin()->isSsl() && ! isset($force_ssl) ) {
|
112 |
-
$force_ssl = false;
|
113 |
}
|
114 |
|
115 |
if ( ! $this->getPlugin()->isSsl() && isset($force_ssl) && $force_ssl ) {
|
@@ -139,7 +173,7 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
139 |
if ( ( $scheme == 'secure_auth' && $this->getPlugin()->isSsl() ) || ( $this->getPlugin()->getSetting('ssl_admin') && ! $this->getPlugin()->getSetting('ssl_host_subdomain') ) ) {
|
140 |
$secure = true;
|
141 |
}
|
142 |
-
$secure = apply_filters('secure_auth_cookie',
|
143 |
|
144 |
if( $scheme == 'logged_in' ) {
|
145 |
$cookie_name = LOGGED_IN_COOKIE;
|
@@ -149,6 +183,7 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
149 |
} else {
|
150 |
$cookie_name = AUTH_COOKIE;
|
151 |
$scheme = 'auth';
|
|
|
152 |
}
|
153 |
|
154 |
//$cookie_domain = COOKIE_DOMAIN;
|
@@ -181,7 +216,7 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
181 |
$cookie_path = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path;
|
182 |
$cookie_path_site = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_site;
|
183 |
$cookie_path_plugins = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_plugins;
|
184 |
-
$cookie_path_admin = $cookie_path_site . 'wp-admin';
|
185 |
}
|
186 |
|
187 |
if ( $scheme == 'logged_in' ) {
|
@@ -195,6 +230,16 @@ class WordPressHTTPS_Module_Hooks extends Mvied_Module implements Mvied_Module_I
|
|
195 |
}
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
/**
|
199 |
* Clear Cookies
|
200 |
* WordPress Hook - clear_auth_cookie
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
+
class WordPressHTTPS_Module_Hooks extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
11 |
|
12 |
/**
|
13 |
* Initialize
|
25 |
add_action('set_auth_cookie', array(&$this, 'set_cookie'), 10, 5);
|
26 |
add_action('set_logged_in_cookie', array(&$this, 'set_cookie'), 10, 5);
|
27 |
}
|
28 |
+
}
|
29 |
|
30 |
+
// Filter scripts
|
31 |
+
add_action('wp_print_scripts', array(&$this, 'fix_scripts'), 100, 0);
|
32 |
+
|
33 |
+
// Filter styles
|
34 |
+
add_action('wp_print_styles', array(&$this, 'fix_styles'), 100, 0);
|
35 |
+
|
36 |
+
// Filter redirects in admin panel
|
37 |
+
if ( is_admin() && ( $this->getPlugin()->getSetting('ssl_admin') || $this->getPlugin()->isSsl() ) ) {
|
38 |
+
add_action('wp_redirect', array($this->getPlugin(), 'redirectAdmin'), 10, 1);
|
39 |
}
|
40 |
|
41 |
// Run proxy check
|
54 |
}
|
55 |
|
56 |
// Check if the page needs to be redirected
|
57 |
+
add_action('template_redirect', array(&$this, 'redirect_check'), 10, 1);
|
58 |
+
add_action('template_redirect', array(&$this, 'clear_redirect_count_cookie'), 9, 1);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Fix Enqueued Scripts
|
63 |
+
*
|
64 |
+
* @param none
|
65 |
+
* @return void
|
66 |
+
*/
|
67 |
+
public function fix_scripts() {
|
68 |
+
global $wp_scripts;
|
69 |
+
if ( isset($wp_scripts) && sizeof($wp_scripts->registered) > 0 ) {
|
70 |
+
foreach ( $wp_scripts->registered as $script ) {
|
71 |
+
if ( strpos($script->src, 'http') !== 0 ) {
|
72 |
+
$script->src = site_url($script->src);
|
73 |
+
}
|
74 |
+
if ( $this->getPlugin()->isSsl() ) {
|
75 |
+
$script->src = $this->getPlugin()->makeUrlHttps($script->src);
|
76 |
+
} else {
|
77 |
+
$script->src = $this->getPlugin()->makeUrlHttp($script->src);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Fix Enqueued Styles
|
85 |
+
*
|
86 |
+
* @param none
|
87 |
+
* @return void
|
88 |
+
*/
|
89 |
+
public function fix_styles() {
|
90 |
+
global $wp_styles;
|
91 |
+
if ( isset($wp_styles) && sizeof($wp_styles->registered) > 0 ) {
|
92 |
+
foreach ( (array)$wp_styles->registered as $style ) {
|
93 |
+
if ( strpos($style->src, 'http') !== 0 ) {
|
94 |
+
$style->src = site_url($style->src);
|
95 |
+
}
|
96 |
+
if ( $this->getPlugin()->isSsl() ) {
|
97 |
+
$style->src = $this->getPlugin()->makeUrlHttps($style->src);
|
98 |
+
} else {
|
99 |
+
$style->src = $this->getPlugin()->makeUrlHttp($style->src);
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
}
|
104 |
|
105 |
/**
|
143 |
}
|
144 |
|
145 |
if ( $post->ID > 0 ) {
|
146 |
+
$force_ssl = apply_filters('force_ssl', null, $post->ID, ( $this->getPlugin()->isSsl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
}
|
148 |
|
149 |
if ( ! $this->getPlugin()->isSsl() && isset($force_ssl) && $force_ssl ) {
|
173 |
if ( ( $scheme == 'secure_auth' && $this->getPlugin()->isSsl() ) || ( $this->getPlugin()->getSetting('ssl_admin') && ! $this->getPlugin()->getSetting('ssl_host_subdomain') ) ) {
|
174 |
$secure = true;
|
175 |
}
|
176 |
+
$secure = apply_filters('secure_auth_cookie', @$secure, $user_id);
|
177 |
|
178 |
if( $scheme == 'logged_in' ) {
|
179 |
$cookie_name = LOGGED_IN_COOKIE;
|
183 |
} else {
|
184 |
$cookie_name = AUTH_COOKIE;
|
185 |
$scheme = 'auth';
|
186 |
+
$secure = false;
|
187 |
}
|
188 |
|
189 |
//$cookie_domain = COOKIE_DOMAIN;
|
216 |
$cookie_path = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path;
|
217 |
$cookie_path_site = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_site;
|
218 |
$cookie_path_plugins = rtrim($this->getPlugin()->getHttpsUrl()->getPath(), '/') . $cookie_path_plugins;
|
219 |
+
$cookie_path_admin = rtrim($cookie_path_site, '/') . '/wp-admin';
|
220 |
}
|
221 |
|
222 |
if ( $scheme == 'logged_in' ) {
|
230 |
}
|
231 |
}
|
232 |
|
233 |
+
/**
|
234 |
+
* Removes redirect_count cookie.
|
235 |
+
*
|
236 |
+
* @param none
|
237 |
+
* @return void
|
238 |
+
*/
|
239 |
+
public function clear_redirect_count_cookie() {
|
240 |
+
setcookie('redirect_count', null, -time(), '/');
|
241 |
+
}
|
242 |
+
|
243 |
/**
|
244 |
* Clear Cookies
|
245 |
* WordPress Hook - clear_auth_cookie
|
lib/WordPressHTTPS/Module/Parser.php
CHANGED
@@ -7,10 +7,7 @@
|
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
require_once('Mvied/Module/Interface.php');
|
12 |
-
|
13 |
-
class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_Interface {
|
14 |
|
15 |
/**
|
16 |
* HTML
|
@@ -18,7 +15,7 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
18 |
* @var string
|
19 |
*/
|
20 |
protected $_html;
|
21 |
-
|
22 |
/**
|
23 |
* Extensions
|
24 |
*
|
@@ -27,42 +24,6 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
27 |
* @var array
|
28 |
*/
|
29 |
protected $_extensions = array('jpg', 'jpeg', 'png', 'gif', 'css', 'js');
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Add Secure External URL
|
33 |
-
*
|
34 |
-
* @param string $value
|
35 |
-
* @return $this
|
36 |
-
*/
|
37 |
-
public function addSecureExternalUrl( $value ) {
|
38 |
-
if ( trim($value) == '' ) {
|
39 |
-
return $this;
|
40 |
-
}
|
41 |
-
|
42 |
-
$secure_external_urls = (array) $this->getPlugin()->getSetting('secure_external_urls');
|
43 |
-
array_push($secure_external_urls, (string) $value);
|
44 |
-
$this->getPlugin()->setSetting('secure_external_urls', $secure_external_urls);
|
45 |
-
|
46 |
-
return $this;
|
47 |
-
}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Add Unsecure External URL
|
51 |
-
*
|
52 |
-
* @param string $value
|
53 |
-
* @return $this
|
54 |
-
*/
|
55 |
-
public function addUnsecureExternalUrl( $value ) {
|
56 |
-
if ( trim($value) == '' ) {
|
57 |
-
return $this;
|
58 |
-
}
|
59 |
-
|
60 |
-
$unsecure_external_urls = (array) $this->getPlugin()->getSetting('unsecure_external_urls');
|
61 |
-
array_push($unsecure_external_urls, (string) $value);
|
62 |
-
$this->getPlugin()->setSetting('unsecure_external_urls', $unsecure_external_urls);
|
63 |
-
|
64 |
-
return $this;
|
65 |
-
}
|
66 |
|
67 |
/**
|
68 |
* Initialize
|
@@ -100,7 +61,7 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
100 |
|
101 |
return $this->_html;
|
102 |
}
|
103 |
-
|
104 |
/**
|
105 |
* Start output buffering
|
106 |
*
|
@@ -110,7 +71,7 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
110 |
public function startOutputBuffering() {
|
111 |
ob_start(array(&$this, 'parseHtml'));
|
112 |
}
|
113 |
-
|
114 |
/**
|
115 |
* Secure element
|
116 |
*
|
@@ -120,37 +81,12 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
120 |
*/
|
121 |
public function secureElement( $url, $type = '' ) {
|
122 |
$updated = false;
|
123 |
-
$url = WordPressHTTPS_Url::fromString($url);
|
124 |
$upload_dir = wp_upload_dir();
|
125 |
$upload_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), $this->getPlugin()->getHttpUrl()->getPath(), parse_url($upload_dir['baseurl'], PHP_URL_PATH));
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
$updated = $this->getPlugin()->makeUrlHttps($url);
|
131 |
-
$this->_html = str_replace($url, $updated, $this->_html);
|
132 |
-
}
|
133 |
-
// If external and not HTTPS
|
134 |
-
} else if ( $url->getPath() != 'https' ) {
|
135 |
-
if ( @in_array($url->toString(), $this->getPlugin()->getSetting('secure_external_urls')) == false && @in_array($url->toString(), $this->getPlugin()->getSetting('unsecure_external_urls')) == false ) {
|
136 |
-
if ( $url->getScheme() != 'https' ) {
|
137 |
-
$test_url = clone $url;
|
138 |
-
$test_url->setScheme('https');
|
139 |
-
if ( $test_url->isValid() ) {
|
140 |
-
// Cache this URL as available over HTTPS for future reference
|
141 |
-
$this->addSecureExternalUrl($url->toString());
|
142 |
-
} else {
|
143 |
-
// If not available over HTTPS, mark as an unsecure external URL
|
144 |
-
$this->addUnsecureExternalUrl($url->toString());
|
145 |
-
}
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( in_array($url, $this->getPlugin()->getSetting('secure_external_urls')) ) {
|
150 |
-
$updated = clone $url;
|
151 |
-
$updated->setScheme('https');
|
152 |
-
$this->_html = str_replace($url, $updated, $this->_html);
|
153 |
-
}
|
154 |
}
|
155 |
|
156 |
// Add log entry if this change hasn't been logged
|
@@ -163,7 +99,7 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
163 |
$this->getPlugin()->getLogger()->log($log);
|
164 |
}
|
165 |
}
|
166 |
-
|
167 |
/**
|
168 |
* Unsecure element
|
169 |
*
|
@@ -173,16 +109,12 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
173 |
*/
|
174 |
public function unsecureElement( $url, $type = '' ) {
|
175 |
$updated = false;
|
176 |
-
$url = WordPressHTTPS_Url::fromString($url);
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
$updated = $this->getPlugin()->makeUrlHttp($url);
|
182 |
-
$this->_html = str_replace($url, $updated, $this->_html);
|
183 |
-
}
|
184 |
}
|
185 |
-
|
186 |
// Add log entry if this change hasn't been logged
|
187 |
if ( $updated && $url != $updated ) {
|
188 |
$log = '[FIXED] Element: ' . ( $type != '' ? '<' . $type . '> ' : '' ) . $url . ' => ' . $updated;
|
@@ -201,24 +133,22 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
201 |
public function normalizeElements() {
|
202 |
$httpMatches = array();
|
203 |
$httpsMatches = array();
|
204 |
-
if ( !
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpsMatches);
|
209 |
-
}
|
210 |
|
211 |
-
if (
|
212 |
$url = clone $this->getPlugin()->getHttpUrl();
|
213 |
$url->setScheme('https');
|
214 |
preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpMatches);
|
215 |
}
|
|
|
216 |
$matches = array_merge($httpMatches, $httpsMatches);
|
217 |
for ($i = 0; $i < sizeof($matches[0]); $i++) {
|
218 |
if ( isset($matches[1][$i]) ) {
|
219 |
-
$
|
220 |
-
if ( $
|
221 |
-
$url = $url->toString();
|
222 |
$this->_html = str_replace($url, $this->getPlugin()->makeUrlHttp($url), $this->_html);
|
223 |
}
|
224 |
}
|
@@ -227,8 +157,6 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
227 |
}
|
228 |
|
229 |
/**
|
230 |
-
* Fix Elements
|
231 |
-
*
|
232 |
* Fixes schemes on DOM elements.
|
233 |
*
|
234 |
* @param none
|
@@ -255,15 +183,15 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
255 |
( $type == 'input' && strpos($html, 'image') !== false ) ||
|
256 |
( $type == 'param' && strpos($html, 'movie') !== false )
|
257 |
) {
|
258 |
-
if ( $scheme == 'http' &&
|
259 |
$this->secureElement($url, $type);
|
260 |
-
} else if ( $scheme == 'https' &&
|
261 |
$this->unsecureElement($url, $type);
|
262 |
}
|
263 |
}
|
264 |
}
|
265 |
}
|
266 |
-
|
267 |
/**
|
268 |
* Fix CSS background images or imports.
|
269 |
*
|
@@ -282,7 +210,7 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
282 |
}
|
283 |
}
|
284 |
}
|
285 |
-
|
286 |
/**
|
287 |
* Fix elements that are being referenced relatively.
|
288 |
*
|
@@ -311,10 +239,8 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
311 |
}
|
312 |
}
|
313 |
}
|
314 |
-
|
315 |
/**
|
316 |
-
* Fix Extensions
|
317 |
-
*
|
318 |
* Fixes schemes on DOM elements with extensions specified in $this->_extensions
|
319 |
*
|
320 |
* @param none
|
@@ -366,65 +292,14 @@ class WordPressHTTPS_Module_Parser extends Mvied_Module implements Mvied_Module_
|
|
366 |
$scheme = $matches[3][$i];
|
367 |
$updated = false;
|
368 |
|
369 |
-
|
370 |
|
371 |
-
$
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
$url_parts['path'] = str_replace($this->getPlugin()->getHttpUrl()->getPath(), '', $url_parts['path']);
|
378 |
-
}
|
379 |
-
}
|
380 |
-
|
381 |
-
if ( $this->getPlugin()->isUrlLocal($url) && preg_match("/page_id=([\d]+)/", parse_url($url, PHP_URL_QUERY), $postID) ) {
|
382 |
-
$post = $postID[1];
|
383 |
-
} else if ( $this->getPlugin()->isUrlLocal($url) && ( $url_parts['path'] == '' || $url_parts['path'] == '/' ) ) {
|
384 |
-
if ( get_option('show_on_front') == 'posts' ) {
|
385 |
-
$post = true;
|
386 |
-
} else {
|
387 |
-
$post = get_option('page_on_front');
|
388 |
-
}
|
389 |
-
if ( $this->getPlugin()->getSetting('frontpage') ) {
|
390 |
-
$force_ssl = true;
|
391 |
-
} else if ( $this->getPlugin()->getSetting('exclusive_https') ) {
|
392 |
-
$force_ssl = false;
|
393 |
-
}
|
394 |
-
} else if ( $this->getPlugin()->isUrlLocal($url) && ($post = get_page_by_path($url_parts['path'])) ) {
|
395 |
-
$post = $post->ID;
|
396 |
-
//TODO When logged in to HTTP and visiting an HTTPS page, admin links will always be forced to HTTPS, even if the user is not logged in via HTTPS. I need to find a way to detect this.
|
397 |
-
} else if ( ( strpos($url_parts['path'], 'wp-admin') !== false || strpos($url_parts['path'], 'wp-login') !== false ) && ( $this->getPlugin()->isSsl() || $this->getPlugin()->getSetting('ssl_admin') ) ) {
|
398 |
-
if ( ! is_multisite() || ( is_multisite() && strpos($url_parts['host'], $this->getPlugin()->getHttpsUrl()->getHost()) !== false ) ) {
|
399 |
-
$post = true;
|
400 |
-
$force_ssl = true;
|
401 |
-
} else if ( is_multisite() ) {
|
402 |
-
// get_blog_details returns an object with a property of blog_id
|
403 |
-
if ( $blog_details = get_blog_details( array( 'domain' => $url_parts['host'] )) ) {
|
404 |
-
// set $blog_id using $blog_details->blog_id
|
405 |
-
$blog_id = $blog_details->blog_id;
|
406 |
-
if ( $this->getPlugin()->getSetting('ssl_admin', $blog_id) && $scheme != 'https' && ( ! $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) || ( $this->getPlugin()->getSetting('ssl_host_diff', $blog_id) && is_user_logged_in() ) ) ) {
|
407 |
-
$this->_html = str_replace($url, str_replace('http', 'https', $url), $this->_html);
|
408 |
-
}
|
409 |
-
}
|
410 |
-
}
|
411 |
-
}
|
412 |
-
|
413 |
-
if ( isset($post) ) {
|
414 |
-
// Always change links to HTTPS when logged in via different SSL Host
|
415 |
-
if ( $type == 'a' && ! $this->getPlugin()->getSetting('ssl_host_subdomain') && $this->getPlugin()->getSetting('ssl_host_diff') && $this->getPlugin()->getSetting('ssl_admin') && is_user_logged_in() ) {
|
416 |
-
$force_ssl = true;
|
417 |
-
} else if ( (int) $post > 0 ) {
|
418 |
-
$force_ssl = apply_filters('force_ssl', $force_ssl, $post );
|
419 |
-
}
|
420 |
-
|
421 |
-
if ( $force_ssl == true || WordPressHTTPS_Url::fromString(get_option('home'))->getScheme() == 'https' ) {
|
422 |
-
$updated = $this->getPlugin()->makeUrlHttps($url);
|
423 |
-
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
|
424 |
-
} else if ( $this->getPlugin()->getSetting('exclusive_https') ) {
|
425 |
-
$updated = $this->getPlugin()->makeUrlHttp($url);
|
426 |
-
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
|
427 |
-
}
|
428 |
}
|
429 |
|
430 |
// Add log entry if this change hasn't been logged
|
7 |
*
|
8 |
*/
|
9 |
|
10 |
+
class WordPressHTTPS_Module_Parser extends Mvied_Plugin_Module implements Mvied_Plugin_Module_Interface {
|
|
|
|
|
|
|
11 |
|
12 |
/**
|
13 |
* HTML
|
15 |
* @var string
|
16 |
*/
|
17 |
protected $_html;
|
18 |
+
|
19 |
/**
|
20 |
* Extensions
|
21 |
*
|
24 |
* @var array
|
25 |
*/
|
26 |
protected $_extensions = array('jpg', 'jpeg', 'png', 'gif', 'css', 'js');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
/**
|
29 |
* Initialize
|
61 |
|
62 |
return $this->_html;
|
63 |
}
|
64 |
+
|
65 |
/**
|
66 |
* Start output buffering
|
67 |
*
|
71 |
public function startOutputBuffering() {
|
72 |
ob_start(array(&$this, 'parseHtml'));
|
73 |
}
|
74 |
+
|
75 |
/**
|
76 |
* Secure element
|
77 |
*
|
81 |
*/
|
82 |
public function secureElement( $url, $type = '' ) {
|
83 |
$updated = false;
|
|
|
84 |
$upload_dir = wp_upload_dir();
|
85 |
$upload_path = str_replace($this->getPlugin()->getHttpsUrl()->getPath(), $this->getPlugin()->getHttpUrl()->getPath(), parse_url($upload_dir['baseurl'], PHP_URL_PATH));
|
86 |
|
87 |
+
if ( ! is_admin() || ( is_admin() && strpos($url, $upload_path) === false ) ) {
|
88 |
+
$updated = $this->getPlugin()->makeUrlHttps($url);
|
89 |
+
$this->_html = str_replace($url, $updated, $this->_html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
|
92 |
// Add log entry if this change hasn't been logged
|
99 |
$this->getPlugin()->getLogger()->log($log);
|
100 |
}
|
101 |
}
|
102 |
+
|
103 |
/**
|
104 |
* Unsecure element
|
105 |
*
|
109 |
*/
|
110 |
public function unsecureElement( $url, $type = '' ) {
|
111 |
$updated = false;
|
|
|
112 |
|
113 |
+
if ( ! is_admin() || ( is_admin() && strpos($url, $upload_path) === false ) ) {
|
114 |
+
$updated = $this->getPlugin()->makeUrlHttp($url);
|
115 |
+
$this->_html = str_replace($url, $updated, $this->_html);
|
|
|
|
|
|
|
116 |
}
|
117 |
+
|
118 |
// Add log entry if this change hasn't been logged
|
119 |
if ( $updated && $url != $updated ) {
|
120 |
$log = '[FIXED] Element: ' . ( $type != '' ? '<' . $type . '> ' : '' ) . $url . ' => ' . $updated;
|
133 |
public function normalizeElements() {
|
134 |
$httpMatches = array();
|
135 |
$httpsMatches = array();
|
136 |
+
if ( $this->getPlugin()->getSetting('ssl_host_diff') && !is_admin() && $GLOBALS['pagenow'] != 'wp-login.php' ) {
|
137 |
+
$url = clone $this->getPlugin()->getHttpsUrl();
|
138 |
+
$url->setScheme('http');
|
139 |
+
preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpsMatches);
|
|
|
|
|
140 |
|
141 |
+
if ( $this->getPlugin()->isSsl() ) {
|
142 |
$url = clone $this->getPlugin()->getHttpUrl();
|
143 |
$url->setScheme('https');
|
144 |
preg_match_all('/(' . str_replace('/', '\/', preg_quote($url->toString())) . '[^\'"]*)[\'"]?/im', $this->_html, $httpMatches);
|
145 |
}
|
146 |
+
|
147 |
$matches = array_merge($httpMatches, $httpsMatches);
|
148 |
for ($i = 0; $i < sizeof($matches[0]); $i++) {
|
149 |
if ( isset($matches[1][$i]) ) {
|
150 |
+
$url_parts = parse_url($matches[1][$i]);
|
151 |
+
if ( $url_parts && strpos($url_parts['path'], 'wp-admin') === false && strpos($url_parts['path'], 'wp-login') === false ) {
|
|
|
152 |
$this->_html = str_replace($url, $this->getPlugin()->makeUrlHttp($url), $this->_html);
|
153 |
}
|
154 |
}
|
157 |
}
|
158 |
|
159 |
/**
|
|
|
|
|
160 |
* Fixes schemes on DOM elements.
|
161 |
*
|
162 |
* @param none
|
183 |
( $type == 'input' && strpos($html, 'image') !== false ) ||
|
184 |
( $type == 'param' && strpos($html, 'movie') !== false )
|
185 |
) {
|
186 |
+
if ( $scheme == 'http' && $this->getPlugin()->isSsl() ) {
|
187 |
$this->secureElement($url, $type);
|
188 |
+
} else if ( $scheme == 'https' && !$this->getPlugin()->isSsl() && strpos($url, 'wp-admin') === false ) {
|
189 |
$this->unsecureElement($url, $type);
|
190 |
}
|
191 |
}
|
192 |
}
|
193 |
}
|
194 |
+
|
195 |
/**
|
196 |
* Fix CSS background images or imports.
|
197 |
*
|
210 |
}
|
211 |
}
|
212 |
}
|
213 |
+
|
214 |
/**
|
215 |
* Fix elements that are being referenced relatively.
|
216 |
*
|
239 |
}
|
240 |
}
|
241 |
}
|
242 |
+
|
243 |
/**
|
|
|
|
|
244 |
* Fixes schemes on DOM elements with extensions specified in $this->_extensions
|
245 |
*
|
246 |
* @param none
|
292 |
$scheme = $matches[3][$i];
|
293 |
$updated = false;
|
294 |
|
295 |
+
$force_ssl = apply_filters('force_ssl', null, 0, $url );
|
296 |
|
297 |
+
if ( $force_ssl == true ) {
|
298 |
+
$updated = $this->getPlugin()->makeUrlHttps($url);
|
299 |
+
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
|
300 |
+
} else if ( $this->getPlugin()->isUrlLocal($url) && $this->getPlugin()->getSetting('exclusive_https') ) {
|
301 |
+
$updated = $this->getPlugin()->makeUrlHttp($url);
|
302 |
+
$this->_html = str_replace($html, str_replace($url, $updated, $html), $this->_html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
}
|
304 |
|
305 |
// Add log entry if this change hasn't been logged
|
lib/WordPressHTTPS/Url.php
CHANGED
@@ -371,6 +371,8 @@ class WordPressHTTPS_Url {
|
|
371 |
return $this->_content;
|
372 |
}
|
373 |
|
|
|
|
|
374 |
if ( function_exists('curl_init') ) {
|
375 |
$ch = curl_init();
|
376 |
|
@@ -387,18 +389,18 @@ class WordPressHTTPS_Url {
|
|
387 |
$content = curl_exec($ch);
|
388 |
$info = curl_getinfo($ch);
|
389 |
curl_close($ch);
|
390 |
-
|
391 |
-
if (
|
392 |
-
|
393 |
-
} else {
|
394 |
-
return $content;
|
395 |
}
|
396 |
-
}
|
397 |
-
|
398 |
-
|
|
|
|
|
399 |
}
|
400 |
}
|
401 |
-
return
|
402 |
}
|
403 |
|
404 |
/**
|
371 |
return $this->_content;
|
372 |
}
|
373 |
|
374 |
+
$this->_content = false;
|
375 |
+
|
376 |
if ( function_exists('curl_init') ) {
|
377 |
$ch = curl_init();
|
378 |
|
389 |
$content = curl_exec($ch);
|
390 |
$info = curl_getinfo($ch);
|
391 |
curl_close($ch);
|
392 |
+
|
393 |
+
if ( isset($info['http_code']) && !( $info['http_code'] == 0 || $info['http_code'] == 404 ) ) {
|
394 |
+
$this->_content = $content;
|
|
|
|
|
395 |
}
|
396 |
+
}
|
397 |
+
|
398 |
+
if ( !$this->_content && @ini_get('allow_url_fopen') ) {
|
399 |
+
if ( ($content = @file_get_contents($this->toString())) !== false ) {
|
400 |
+
$this->_content = $content;
|
401 |
}
|
402 |
}
|
403 |
+
return $this->_content;
|
404 |
}
|
405 |
|
406 |
/**
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: security, encryption, ssl, shared ssl, private ssl, public ssl, private ssl, http, https
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4
|
7 |
-
Stable tag: 3.
|
8 |
|
9 |
WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
|
10 |
|
@@ -49,24 +49,24 @@ Most insecure content warnings can generally be resolved by changing absolute re
|
|
49 |
|
50 |
= Is there a hook or filter to force pages to be secure? =
|
51 |
Yes! Here is an example of how to use the 'force_ssl' filter to force a page to be secure.
|
52 |
-
`function custom_force_ssl( $force_ssl, $post_id ) {
|
53 |
if ( $post_id == 5 ) {
|
54 |
return true
|
55 |
}
|
56 |
return $force_ssl;
|
57 |
}
|
58 |
|
59 |
-
add_filter('force_ssl' , 'custom_force_ssl', 10,
|
60 |
|
61 |
You can also use this filter to filter pages based on their URL. Let's say you have an E-commerce site and all of your E-commerce URL's contain 'store'.
|
62 |
-
`function store_force_ssl( $force_ssl, $post_id ) {
|
63 |
-
if ( strpos($
|
64 |
$force_ssl = true;
|
65 |
}
|
66 |
return $force_ssl;
|
67 |
}
|
68 |
|
69 |
-
add_filter('force_ssl', 'store_force_ssl', 10,
|
70 |
|
71 |
== Screenshots ==
|
72 |
1. WordPress HTTPS Settings screen
|
@@ -77,6 +77,13 @@ add_filter('force_ssl', 'store_force_ssl', 10, 2);`
|
|
77 |
* SSL Domain Mapping
|
78 |
|
79 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 3.0.4 =
|
81 |
* Fixed multiple bugs for sites using SSL for the entire site.
|
82 |
* Bug Fix - plugin should no longer try to load hidden files as modules.
|
4 |
Tags: security, encryption, ssl, shared ssl, private ssl, public ssl, private ssl, http, https
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4
|
7 |
+
Stable tag: 3.1
|
8 |
|
9 |
WordPress HTTPS is intended to be an all-in-one solution to using SSL on WordPress sites.
|
10 |
|
49 |
|
50 |
= Is there a hook or filter to force pages to be secure? =
|
51 |
Yes! Here is an example of how to use the 'force_ssl' filter to force a page to be secure.
|
52 |
+
`function custom_force_ssl( $force_ssl, $post_id = 0, $url = '' ) {
|
53 |
if ( $post_id == 5 ) {
|
54 |
return true
|
55 |
}
|
56 |
return $force_ssl;
|
57 |
}
|
58 |
|
59 |
+
add_filter('force_ssl' , 'custom_force_ssl', 10, 3);`
|
60 |
|
61 |
You can also use this filter to filter pages based on their URL. Let's say you have an E-commerce site and all of your E-commerce URL's contain 'store'.
|
62 |
+
`function store_force_ssl( $force_ssl, $post_id = 0, $url = '' ) {
|
63 |
+
if ( strpos($url, 'store') !== false ) {
|
64 |
$force_ssl = true;
|
65 |
}
|
66 |
return $force_ssl;
|
67 |
}
|
68 |
|
69 |
+
add_filter('force_ssl', 'store_force_ssl', 10, 3);`
|
70 |
|
71 |
== Screenshots ==
|
72 |
1. WordPress HTTPS Settings screen
|
77 |
* SSL Domain Mapping
|
78 |
|
79 |
== Changelog ==
|
80 |
+
= 3.1 =
|
81 |
+
* Memory optimization.
|
82 |
+
* Added secure URL filtering.
|
83 |
+
* Users receiving 404 errors on every page when using Shared SSL should now be able to use those Shared SSL's that previously did not work.
|
84 |
+
* Added support for qTranslate.
|
85 |
+
* Added support for securing custom post types.
|
86 |
+
* Added $url to the force_ssl filter as the third arguement. See FAQ for example usage.
|
87 |
= 3.0.4 =
|
88 |
* Fixed multiple bugs for sites using SSL for the entire site.
|
89 |
* Bug Fix - plugin should no longer try to load hidden files as modules.
|
uninstall.php
CHANGED
@@ -21,6 +21,7 @@ delete_option('wordpress-https_ssl_host_subdomain');
|
|
21 |
delete_option('wordpress-https_version');
|
22 |
delete_option('wordpress-https_debug');
|
23 |
delete_option('wordpress-https_admin_menu');
|
|
|
24 |
|
25 |
// Delete force_ssl custom_field from posts and pages
|
26 |
delete_metadata('post', null, 'force_ssl', null, true);
|
21 |
delete_option('wordpress-https_version');
|
22 |
delete_option('wordpress-https_debug');
|
23 |
delete_option('wordpress-https_admin_menu');
|
24 |
+
delete_option('wordpress-https_secure_filter');
|
25 |
|
26 |
// Delete force_ssl custom_field from posts and pages
|
27 |
delete_metadata('post', null, 'force_ssl', null, true);
|
wordpress-https.php
CHANGED
@@ -4,7 +4,7 @@
|
|
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.
|
6 |
Author: Mike Ems
|
7 |
-
Version: 3.
|
8 |
Author URI: http://mvied.com/
|
9 |
*/
|
10 |
|
@@ -48,7 +48,7 @@ spl_autoload_register('wphttps_autoloader');
|
|
48 |
if ( function_exists('get_bloginfo') && ! defined('WP_UNINSTALL_PLUGIN') ) {
|
49 |
$wordpress_https = new WordPressHTTPS;
|
50 |
$wordpress_https->setSlug('wordpress-https');
|
51 |
-
$wordpress_https->setVersion('3.
|
52 |
$wordpress_https->setLogger(WordPressHTTPS_Logger::getInstance());
|
53 |
$wordpress_https->setPluginUrl(plugins_url('', __FILE__));
|
54 |
$wordpress_https->setDirectory(dirname(__FILE__));
|
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.
|
6 |
Author: Mike Ems
|
7 |
+
Version: 3.1
|
8 |
Author URI: http://mvied.com/
|
9 |
*/
|
10 |
|
48 |
if ( function_exists('get_bloginfo') && ! defined('WP_UNINSTALL_PLUGIN') ) {
|
49 |
$wordpress_https = new WordPressHTTPS;
|
50 |
$wordpress_https->setSlug('wordpress-https');
|
51 |
+
$wordpress_https->setVersion('3.1');
|
52 |
$wordpress_https->setLogger(WordPressHTTPS_Logger::getInstance());
|
53 |
$wordpress_https->setPluginUrl(plugins_url('', __FILE__));
|
54 |
$wordpress_https->setDirectory(dirname(__FILE__));
|