PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.10
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.10
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 1 month ago core 1 month ago languages 1 month ago lets-encrypt 1 month ago lib 1 month ago mailer 1 month ago modal 1 month ago placeholders 1 month ago progress 1 month ago security 1 month ago settings 1 month ago testssl 1 month ago upgrade 1 month ago .wp-env.json 1 month ago SECURITY.md 1 month ago class-admin.php 1 month ago class-cache.php 1 month ago class-certificate.php 1 month ago class-front-end.php 1 month ago class-installer.php 1 month ago class-mixed-content-fixer.php 1 month ago class-multisite.php 1 month ago class-server.php 1 month ago class-site-health.php 1 month ago class-wp-cli.php 1 month ago compatibility.php 1 month ago force-deactivate.txt 1 month ago functions.php 1 month ago index.php 1 month ago readme.txt 1 month ago rector.php 1 month ago rlrsssl-really-simple-ssl.php 1 month ago rsssl-auto-loader.php 1 month ago sbom.json.gz 1 month ago ssl-test-page.php 1 month ago system-status.php 1 month ago uninstall.php 1 month ago upgrade.php 1 month 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 === '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 }