| 1 |
<?php |
| 2 |
namespace Elementor\Core\Debug\Classes; |
| 3 |
|
| 4 |
use Elementor\Modules\SafeMode\Module as Safe_Mode; |
| 5 |
use Elementor\Utils; |
| 6 |
|
| 7 |
class Htaccess extends Inspection_Base { |
| 8 |
|
| 9 |
private $message = ''; |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
$this->message = esc_html__( 'Your site\'s .htaccess file appears to be missing.', 'elementor' ); |
| 13 |
} |
| 14 |
|
| 15 |
public function run() { |
| 16 |
$safe_mode_enabled = get_option( Safe_Mode::OPTION_ENABLED, '' ); |
| 17 |
if ( empty( $safe_mode_enabled ) || is_multisite() ) { |
| 18 |
return true; |
| 19 |
} |
| 20 |
|
| 21 |
$permalink_structure = get_option( 'permalink_structure' ); |
| 22 |
if ( empty( $permalink_structure ) || empty( $_SERVER['SERVER_SOFTWARE'] ) ) { |
| 23 |
return true; |
| 24 |
} |
| 25 |
|
| 26 |
$server = strtoupper( Utils::get_super_global_value( $_SERVER, 'SERVER_SOFTWARE' ) ); |
| 27 |
|
| 28 |
if ( strstr( $server, 'APACHE' ) ) { |
| 29 |
$htaccess_file = get_home_path() . '.htaccess'; |
| 30 |
/* translators: %s: Path to .htaccess file. */ |
| 31 |
$this->message .= ' ' . sprintf( esc_html__( 'File Path: %s', 'elementor' ), $htaccess_file ) . ' '; |
| 32 |
return file_exists( $htaccess_file ); |
| 33 |
} |
| 34 |
return true; |
| 35 |
} |
| 36 |
|
| 37 |
public function get_name() { |
| 38 |
return 'apache-htaccess'; |
| 39 |
} |
| 40 |
|
| 41 |
public function get_message() { |
| 42 |
return $this->message; |
| 43 |
} |
| 44 |
|
| 45 |
public function get_help_doc_url() { |
| 46 |
return 'https://go.elementor.com/preview-not-loaded/#htaccess'; |
| 47 |
} |
| 48 |
} |
| 49 |
|