| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\System_Info\Reporters; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Api; |
| 5 | -use Elementor\Utils; | |
| 6 | 5 | |
| 7 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | 7 | exit; // Exit if accessed directly. |
| 9 | 8 | } |
| @@ -17,8 +16,9 @@ | ||
| 17 | 16 | * @since 1.0.0 |
| 18 | 17 | */ |
| 19 | 18 | class Server extends Base { |
| 20 | 19 | |
| 20 | + const KEY_PATH_WP_ROOT_DIR = 'wp_root'; | |
| 21 | 21 | const KEY_PATH_WP_CONTENT_DIR = 'wp_content'; |
| 22 | 22 | const KEY_PATH_UPLOADS_DIR = 'uploads'; |
| 23 | 23 | const KEY_PATH_ELEMENTOR_UPLOADS_DIR = 'elementor_uploads'; |
| 24 | 24 | const KEY_PATH_HTACCESS_FILE = '.htaccess'; |
| @@ -98,9 +98,9 @@ | ||
| 98 | 98 | * } |
| 99 | 99 | */ |
| 100 | 100 | public function get_software() { |
| 101 | 101 | return [ |
| 102 | - 'value' => Utils::get_super_global_value( $_SERVER, 'SERVER_SOFTWARE' ), | |
| 102 | + 'value' => $_SERVER['SERVER_SOFTWARE'], | |
| 103 | 103 | ]; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| @@ -122,16 +122,11 @@ | ||
| 122 | 122 | public function get_php_version() { |
| 123 | 123 | $result = [ |
| 124 | 124 | 'value' => PHP_VERSION, |
| 125 | 125 | ]; |
| 126 | - $recommended_php_version = '7.4'; | |
| 127 | 126 | |
| 128 | - if ( version_compare( $result['value'], $recommended_php_version, '<' ) ) { | |
| 129 | - $result['recommendation'] = sprintf( | |
| 130 | - /* translators: %s: Recommended PHP version. */ | |
| 131 | - esc_html__( 'We recommend using PHP version %s or higher.', 'elementor' ), | |
| 132 | - $recommended_php_version | |
| 133 | - ); | |
| 127 | + if ( version_compare( $result['value'], '5.4', '<' ) ) { | |
| 128 | + $result['recommendation'] = _x( 'We recommend to use php 5.4 or higher', 'System Info', 'elementor' ); | |
| 134 | 129 | |
| 135 | 130 | $result['warning'] = true; |
| 136 | 131 | } |
| 137 | 132 | |
| @@ -153,9 +148,9 @@ | ||
| 153 | 148 | * } |
| 154 | 149 | */ |
| 155 | 150 | public function get_php_memory_limit() { |
| 156 | 151 | $result = [ |
| 157 | - 'value' => (string) ini_get( 'memory_limit' ), | |
| 152 | + 'value' => (string) get_cfg_var( 'memory_limit' ), | |
| 158 | 153 | ]; |
| 159 | 154 | |
| 160 | 155 | $min_recommended_memory = '128M'; |
| 161 | 156 | $preferred_memory = '256M'; |
| @@ -165,10 +160,10 @@ | ||
| 165 | 160 | $min_recommended_bytes = wp_convert_hr_to_bytes( $min_recommended_memory ); |
| 166 | 161 | |
| 167 | 162 | if ( $memory_limit_bytes < $min_recommended_bytes ) { |
| 168 | 163 | $result['recommendation'] = sprintf( |
| 169 | - /* translators: 1: Minimum recommended_memory, 2: Preferred memory, 3: WordPress wp-config memory documentation. */ | |
| 170 | - __( 'We recommend setting memory to at least %1$s. (%2$s or higher is preferred) For more information, read about <a href="%3$s">how to increase memory allocated to PHP</a>.', 'elementor' ), | |
| 164 | + /* translators: 1: Minimum recommended_memory, 2: Preferred memory, 3: WordPress wp-config memory documentation. */ | |
| 165 | + _x( 'We recommend setting memory to at least %1$s. (%2$sMB or higher is preferred) For more information, read about <a href="%3$s">how to Increase memory allocated to PHP</a>.', 'System Info', 'elementor' ), | |
| 171 | 166 | $min_recommended_memory, |
| 172 | 167 | $preferred_memory, |
| 173 | 168 | 'https://go.elementor.com/wordpress-wp-config-memory/' |
| 174 | 169 | ); |
| @@ -314,10 +309,11 @@ | ||
| 314 | 309 | * @type bool $warning Whether to display a warning. True if some required |
| 315 | 310 | * folders don't have writing permissions, False otherwise. |
| 316 | 311 | * } |
| 317 | 312 | */ |
| 318 | - public function get_write_permissions(): array { | |
| 313 | + public function get_write_permissions() : array { | |
| 319 | 314 | $paths_to_check = [ |
| 315 | + static::KEY_PATH_WP_ROOT_DIR => $this->get_system_path( static::KEY_PATH_WP_ROOT_DIR ), | |
| 320 | 316 | static::KEY_PATH_HTACCESS_FILE => $this->get_system_path( static::KEY_PATH_HTACCESS_FILE ), |
| 321 | 317 | static::KEY_PATH_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_UPLOADS_DIR ), |
| 322 | 318 | static::KEY_PATH_ELEMENTOR_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_ELEMENTOR_UPLOADS_DIR ), |
| 323 | 319 | ]; |
| @@ -325,8 +321,12 @@ | ||
| 325 | 321 | $paths_permissions = $this->get_paths_permissions( $paths_to_check ); |
| 326 | 322 | |
| 327 | 323 | $write_problems = []; |
| 328 | 324 | |
| 325 | + if ( ! $paths_permissions[ static::KEY_PATH_WP_ROOT_DIR ]['write'] ) { | |
| 326 | + $write_problems[] = 'WordPress root directory'; | |
| 327 | + } | |
| 328 | + | |
| 329 | 329 | if ( ! $paths_permissions[ static::KEY_PATH_UPLOADS_DIR ]['write'] ) { |
| 330 | 330 | $write_problems[] = 'WordPress uploads directory'; |
| 331 | 331 | } |
| 332 | 332 | |
| @@ -347,9 +347,9 @@ | ||
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return [ |
| 350 | 350 | 'value' => $value, |
| 351 | - 'warning' => (bool) $write_problems, | |
| 351 | + 'warning' => ! ! $write_problems, | |
| 352 | 352 | ]; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | 355 | /** |
| @@ -416,9 +416,9 @@ | ||
| 416 | 416 | /** |
| 417 | 417 | * @param $paths [] Paths to check permissions. |
| 418 | 418 | * @return array []{exists: bool, read: bool, write: bool, execute: bool} |
| 419 | 419 | */ |
| 420 | - public function get_paths_permissions( $paths ): array { | |
| 420 | + public function get_paths_permissions( $paths ) : array { | |
| 421 | 421 | $permissions = []; |
| 422 | 422 | |
| 423 | 423 | foreach ( $paths as $key_path => $path ) { |
| 424 | 424 | $permissions[ $key_path ] = $this->get_path_permissions( $path ); |
| @@ -432,10 +432,13 @@ | ||
| 432 | 432 | * |
| 433 | 433 | * @param $path_key |
| 434 | 434 | * @return string |
| 435 | 435 | */ |
| 436 | - public function get_system_path( $path_key ): string { | |
| 436 | + public function get_system_path( $path_key ) : string { | |
| 437 | 437 | switch ( $path_key ) { |
| 438 | + case static::KEY_PATH_WP_ROOT_DIR: | |
| 439 | + return ABSPATH; | |
| 440 | + | |
| 438 | 441 | case static::KEY_PATH_WP_CONTENT_DIR: |
| 439 | 442 | return WP_CONTENT_DIR; |
| 440 | 443 | |
| 441 | 444 | case static::KEY_PATH_HTACCESS_FILE: |
| @@ -463,9 +466,9 @@ | ||
| 463 | 466 | * |
| 464 | 467 | * @param $path |
| 465 | 468 | * @return array{exists: bool, read: bool, write: bool, execute: bool} |
| 466 | 469 | */ |
| 467 | - public function get_path_permissions( $path ): array { | |
| 470 | + public function get_path_permissions( $path ) : array { | |
| 468 | 471 | if ( empty( $path ) ) { |
| 469 | 472 | return [ |
| 470 | 473 | 'exists' => false, |
| 471 | 474 | 'read' => false, |