-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-force-ssl.php
109 lines (97 loc) · 3.34 KB
/
wp-force-ssl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
Plugin Name: WP Force SSL
Plugin URI: https://www.kosvrouvas.com
Description: Redirect all traffic from HTTP to HTTPS to all pages of your WordPress website.
Stable Tag: 1.4
Author: Kostas Vrouvas
Version: 1.4
*/
//
register_activation_hook( __FILE__, 'wpfssl_welcome_screen_activate' );
function wpfssl_welcome_screen_activate() {
set_transient( '_welcome_screen_activation_redirect', true, 30 );
}
add_action( 'admin_init', 'wpfssl_welcome_screen_do_activation_redirect' );
function wpfssl_welcome_screen_do_activation_redirect() {
// Bail if no activation redirect
if ( ! get_transient( '_welcome_screen_activation_redirect' ) ) {
return;
}
// Delete the redirect transient
delete_transient( '_welcome_screen_activation_redirect' );
// Bail if activating from network, or bulk
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
return;
}
// Redirect to bbPress about page
wp_safe_redirect( add_query_arg( array( 'page' => 'wpfssl-welcome-screen' ), admin_url( 'index.php' ) ) );
}
add_action('admin_menu', 'wpfssl_welcome_screen_pages');
function wpfssl_welcome_screen_pages() {
add_dashboard_page(
'Welcome to WP Force SSL',
'Welcome to WP Force SSL',
'read',
'wpfssl-welcome-screen',
'wpfssl_welcome_screen_content'
);
}
function wpfssl_welcome_screen_content() {
?>
<div id="wpbody">
<div id="wpbody-content">
<div class="wrap about-wrap">
<h1>Thank you for installing WP Force SSL!</h1>
<div class="about-text">
This plugin helps you redirect HTTP traffic to HTTPS without the need of touching any code.</div>
<h3>Some things are required for this to happen:</h3>
<ul class="ul-disc">
<li>You need an SSL Certificate in order for this plugin to work.</li>
<li>You need to change http to https in both the WordPress Address (URL) and Site Address (URL) parameters under Settings > General. (Required by WordPress itself).</li>
</ul>
<br>
<br>
<hr>
<h1>Changelog:</h1>
<br>
<h4>1.4</h4>
<p><small>Release date: December 9th, 2018</small></p>
<ul class="ul-disc">
<li>Changed function naming to avoid conflicts reported by users.</li>
</ul>
<h4>1.3</h4>
<p><small>Release date: February 11th, 2016</small></p>
<ul class="ul-disc">
<li>Dropping support for PHP 5.3: Only 15.9% of the people that use WordPress use PHP 5.3, it reached end of life and you should ask your host to upgrade.</li>
</ul>
<h4>1.2.1</h4>
<p><small>Release date: April 22th, 2015</small></p>
<ul class="ul-disc">
<li>Fixed an issue where some users were getting a error message for no valid header when activating the plugin.</li>
</ul>
<h4>1.2</h4>
<ul class="ul-disc">
<li>Dropping support for PHP 5.2: Only 5.7% of the people that use WordPress use PHP 5.2, it's old, buggy, and insecure.</li>
</ul>
</div>
</div>
</div><!-- wpbody-content -->
<?php
}
add_action( 'admin_head', 'wpfssl_welcome_screen_remove_menus' );
function wpfssl_welcome_screen_remove_menus() {
remove_submenu_page( 'index.php', 'wpfssl-welcome-screen' );
}
// Prevent direct access to this file.
if( !defined( 'ABSPATH' ) ) {
exit( 'You are not allowed to access this file directly.' );
}
// Check if PHP is at the minimum required version
if( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
define( 'WP_FORCE_SSL_FILE', __FILE__ );
require_once dirname( __FILE__ ) . '/plugin.php';
} else {
require_once dirname( __FILE__ ) . '/php-backwards-compatibility.php';
}
?>