|
7 | 7 | * Author: BitCryptic |
8 | 8 | */ |
9 | 9 |
|
10 | | -if (defined('WP_CLI') && WP_CLI) return; |
11 | | - |
12 | | -add_action('plugins_loaded', function() { |
13 | | - $host = $_SERVER['HTTP_HOST'] ?? ''; |
14 | | - $proto = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? ''; |
15 | | - |
16 | | - if ( |
17 | | - (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') && |
18 | | - ($proto === 'https' || strpos($host, '.') !== false) |
19 | | - ) { |
20 | | - $_SERVER['HTTPS'] = 'on'; |
21 | | - } |
22 | | -}); |
23 | | - |
24 | | -add_filter('home_url', function($url) { |
25 | | - return str_starts_with($url, 'http:') ? 'https:' . substr($url, 5) : $url; |
26 | | -}); |
27 | | - |
28 | | -add_filter('site_url', function($url) { |
29 | | - return str_starts_with($url, 'http:') ? 'https:' . substr($url, 5) : $url; |
30 | | -}); |
31 | | - |
32 | | -add_filter('rank_math/rest_api_url', function() { |
33 | | - return get_site_url(null, '/wp-json/'); |
34 | | -}); |
35 | | - |
36 | | -function badFunctionName( ) |
37 | | -{ |
38 | | -echo "This line is missing indentation and spacing."; |
| 10 | +if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 11 | + return; |
39 | 12 | } |
40 | 13 |
|
| 14 | +add_action( |
| 15 | + 'plugins_loaded', |
| 16 | + function () { |
| 17 | + $host = $_SERVER['HTTP_HOST'] ?? ''; |
| 18 | + $proto = $_SERVER['HTTP_X_FORWARDED_PROTO'] ?? ''; |
| 19 | + |
| 20 | + if ( |
| 21 | + ( ! isset( $_SERVER['HTTPS'] ) || $_SERVER['HTTPS'] !== 'on' ) && |
| 22 | + ( $proto === 'https' || strpos( $host, '.' ) !== false ) |
| 23 | + ) { |
| 24 | + $_SERVER['HTTPS'] = 'on'; |
| 25 | + } |
| 26 | + } |
| 27 | +); |
| 28 | + |
| 29 | +add_filter( |
| 30 | + 'home_url', |
| 31 | + function ( $url ) { |
| 32 | + return str_starts_with( $url, 'http:' ) ? 'https:' . substr( $url, 5 ) : $url; |
| 33 | + } |
| 34 | +); |
| 35 | + |
| 36 | +add_filter( |
| 37 | + 'site_url', |
| 38 | + function ( $url ) { |
| 39 | + return str_starts_with( $url, 'http:' ) ? 'https:' . substr( $url, 5 ) : $url; |
| 40 | + } |
| 41 | +); |
| 42 | + |
| 43 | +add_filter( |
| 44 | + 'rank_math/rest_api_url', |
| 45 | + function () { |
| 46 | + return get_site_url( null, '/wp-json/' ); |
| 47 | + } |
| 48 | +); |
0 commit comments