PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.4.0
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.4.0
9.5.11 9.5.10.1 9.5.10 trunk 9.4.0 9.4.1 9.4.2 9.4.3 9.5.0 9.5.0.1 9.5.0.2 9.5.1 9.5.2 9.5.2.2 9.5.2.3 9.5.3 9.5.3.1 9.5.3.2 9.5.4 9.5.5 9.5.6 9.5.7 9.5.8 9.5.9
really-simple-ssl / class-front-end.php
really-simple-ssl Last commit date
assets 11 months ago languages 11 months ago lets-encrypt 1 year ago lib 1 year ago mailer 1 year ago modal 11 months ago onboarding 1 year ago placeholders 1 year ago progress 1 year ago security 11 months ago settings 11 months ago testssl 5 years ago upgrade 1 year ago class-admin.php 1 year ago class-cache.php 2 years ago class-certificate.php 2 years ago class-front-end.php 1 year ago class-installer.php 1 year ago class-mixed-content-fixer.php 3 years ago class-multisite.php 1 year ago class-server.php 1 year ago class-site-health.php 1 year ago class-wp-cli.php 11 months ago compatibility.php 1 year ago force-deactivate.txt 1 year ago functions.php 1 year ago index.php 2 years ago readme.txt 11 months ago rector.php 1 year ago rlrsssl-really-simple-ssl.php 11 months ago rsssl-auto-loader.php 1 year ago security.md 2 years ago ssl-test-page.php 2 years ago system-status.php 1 year ago uninstall.php 1 year ago upgrade.php 11 months ago
class-front-end.php
92 lines
1 <?php
2 defined( 'ABSPATH' ) or die( 'you do not have access to this page!' );
3
4 if ( ! class_exists( 'rsssl_front_end' ) ) {
5
6 class rsssl_front_end {
7
8 private static $_this;
9 public $wp_redirect;
10 public $ssl_enabled;
11
12 public function __construct() {
13 if ( isset( self::$_this ) ) {
14 wp_die( 'you cannot create a second instance.' );
15 }
16
17 self::$_this = $this;
18 $this->ssl_enabled = rsssl_get_option( 'ssl_enabled' );
19 $this->wp_redirect = rsssl_get_option( 'redirect', 'redirect' ) === 'wp_redirect';
20 add_action( 'rest_api_init', array( $this, 'wp_rest_api_force_ssl' ), ~PHP_INT_MAX );
21 }
22
23 public static function this() {
24 return self::$_this;
25 }
26
27 /**
28 * PHP redirect, when ssl is true.
29 *
30 * @since 2.2
31 *
32 * @access public
33 *
34 */
35
36 public function force_ssl() {
37 if ( $this->ssl_enabled && $this->wp_redirect ) {
38 add_action( 'wp', array( $this, 'wp_redirect_to_ssl' ), 40, 3 );
39 }
40 }
41
42
43 /**
44 * Force SSL on wp rest api
45 *
46 * @since 2.5.14
47 *
48 * @access public
49 *
50 */
51
52 public function wp_rest_api_force_ssl(): void {
53 //check for Command Line
54 if ( php_sapi_name() === 'cli' ) {
55 return;
56 }
57
58 if ( ! array_key_exists( 'HTTP_HOST', $_SERVER ) ) {
59 return;
60 }
61
62 if ( $this->ssl_enabled && ! is_ssl() && ! ( defined( 'rsssl_no_rest_api_redirect' ) && rsssl_no_rest_api_redirect ) ) {
63 $redirect_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
64 wp_redirect( $redirect_url, 301 );
65 exit;
66 }
67 }
68
69
70 /**
71 * Redirect using wp redirect
72 *
73 * @since 2.5.0
74 *
75 * @access public
76 *
77 */
78
79 public function wp_redirect_to_ssl(): void {
80 if ( ! array_key_exists( 'HTTP_HOST', $_SERVER ) ) {
81 return;
82 }
83
84 if ( ! is_ssl() && ! ( defined( 'rsssl_no_wp_redirect' ) && rsssl_no_wp_redirect ) ) {
85 $redirect_url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
86 $redirect_url = apply_filters( 'rsssl_wp_redirect_url', $redirect_url );
87 wp_redirect( $redirect_url, 301, 'WordPress - Really Simple Security' );
88 exit;
89 }
90 }
91 }
92 }