PluginProbe ʕ •ᴥ•ʔ
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) / 9.5.0.2
Really Simple Security – Simple and Performant Security (formerly Really Simple SSL) v9.5.0.2
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 9 months ago languages 8 months ago lets-encrypt 9 months ago lib 1 year ago mailer 10 months ago modal 9 months ago onboarding 10 months ago placeholders 9 months ago progress 1 year ago security 8 months ago settings 9 months ago testssl 5 years ago upgrade 9 months ago .wp-env.json 10 months ago SECURITY.md 9 months ago class-admin.php 9 months ago class-cache.php 2 years ago class-certificate.php 2 years ago class-front-end.php 1 year ago class-installer.php 10 months 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 10 months ago index.php 2 years ago readme.txt 8 months ago rector.php 1 year ago rlrsssl-really-simple-ssl.php 8 months ago rsssl-auto-loader.php 1 year ago sbom.json.gz 8 months ago ssl-test-page.php 2 years ago system-status.php 9 months ago uninstall.php 9 months ago upgrade.php 9 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 }