| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | * @since 1.0.0 |
| 18 | 18 | */ |
| 19 | 19 | class Server extends Base { |
| 20 | 20 | |
| 21 | + const KEY_PATH_WP_ROOT_DIR = 'wp_root'; | |
| 21 | 22 | const KEY_PATH_WP_CONTENT_DIR = 'wp_content'; |
| 22 | 23 | const KEY_PATH_UPLOADS_DIR = 'uploads'; |
| 23 | 24 | const KEY_PATH_ELEMENTOR_UPLOADS_DIR = 'elementor_uploads'; |
| 24 | 25 | const KEY_PATH_HTACCESS_FILE = '.htaccess'; |
| @@ -122,15 +123,14 @@ | ||
| 122 | 123 | public function get_php_version() { |
| 123 | 124 | $result = [ |
| 124 | 125 | 'value' => PHP_VERSION, |
| 125 | 126 | ]; |
| 126 | - $recommended_php_version = '7.4'; | |
| 127 | 127 | |
| 128 | - if ( version_compare( $result['value'], $recommended_php_version, '<' ) ) { | |
| 128 | + if ( version_compare( $result['value'], '7.4', '<' ) ) { | |
| 129 | 129 | $result['recommendation'] = sprintf( |
| 130 | 130 | /* translators: %s: Recommended PHP version. */ |
| 131 | - esc_html__( 'We recommend using PHP version %s or higher.', 'elementor' ), | |
| 132 | - $recommended_php_version | |
| 131 | + esc_html_x( 'We recommend using PHP version %s or higher.', 'System Info', 'elementor' ), | |
| 132 | + '7.4' | |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | $result['warning'] = true; |
| 136 | 136 | } |
| @@ -153,9 +153,9 @@ | ||
| 153 | 153 | * } |
| 154 | 154 | */ |
| 155 | 155 | public function get_php_memory_limit() { |
| 156 | 156 | $result = [ |
| 157 | - 'value' => (string) ini_get( 'memory_limit' ), | |
| 157 | + 'value' => (string) get_cfg_var( 'memory_limit' ), | |
| 158 | 158 | ]; |
| 159 | 159 | |
| 160 | 160 | $min_recommended_memory = '128M'; |
| 161 | 161 | $preferred_memory = '256M'; |
| @@ -166,9 +166,9 @@ | ||
| 166 | 166 | |
| 167 | 167 | if ( $memory_limit_bytes < $min_recommended_bytes ) { |
| 168 | 168 | $result['recommendation'] = sprintf( |
| 169 | 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' ), | |
| 170 | + _x( '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>.', 'System Info', 'elementor' ), | |
| 171 | 171 | $min_recommended_memory, |
| 172 | 172 | $preferred_memory, |
| 173 | 173 | 'https://go.elementor.com/wordpress-wp-config-memory/' |
| 174 | 174 | ); |
| @@ -314,10 +314,11 @@ | ||
| 314 | 314 | * @type bool $warning Whether to display a warning. True if some required |
| 315 | 315 | * folders don't have writing permissions, False otherwise. |
| 316 | 316 | * } |
| 317 | 317 | */ |
| 318 | - public function get_write_permissions(): array { | |
| 318 | + public function get_write_permissions() : array { | |
| 319 | 319 | $paths_to_check = [ |
| 320 | + static::KEY_PATH_WP_ROOT_DIR => $this->get_system_path( static::KEY_PATH_WP_ROOT_DIR ), | |
| 320 | 321 | static::KEY_PATH_HTACCESS_FILE => $this->get_system_path( static::KEY_PATH_HTACCESS_FILE ), |
| 321 | 322 | static::KEY_PATH_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_UPLOADS_DIR ), |
| 322 | 323 | static::KEY_PATH_ELEMENTOR_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_ELEMENTOR_UPLOADS_DIR ), |
| 323 | 324 | ]; |
| @@ -325,8 +326,12 @@ | ||
| 325 | 326 | $paths_permissions = $this->get_paths_permissions( $paths_to_check ); |
| 326 | 327 | |
| 327 | 328 | $write_problems = []; |
| 328 | 329 | |
| 330 | + if ( ! $paths_permissions[ static::KEY_PATH_WP_ROOT_DIR ]['write'] ) { | |
| 331 | + $write_problems[] = 'WordPress root directory'; | |
| 332 | + } | |
| 333 | + | |
| 329 | 334 | if ( ! $paths_permissions[ static::KEY_PATH_UPLOADS_DIR ]['write'] ) { |
| 330 | 335 | $write_problems[] = 'WordPress uploads directory'; |
| 331 | 336 | } |
| 332 | 337 | |
| @@ -347,9 +352,9 @@ | ||
| 347 | 352 | } |
| 348 | 353 | |
| 349 | 354 | return [ |
| 350 | 355 | 'value' => $value, |
| 351 | - 'warning' => (bool) $write_problems, | |
| 356 | + 'warning' => ! ! $write_problems, | |
| 352 | 357 | ]; |
| 353 | 358 | } |
| 354 | 359 | |
| 355 | 360 | /** |
| @@ -416,9 +421,9 @@ | ||
| 416 | 421 | /** |
| 417 | 422 | * @param $paths [] Paths to check permissions. |
| 418 | 423 | * @return array []{exists: bool, read: bool, write: bool, execute: bool} |
| 419 | 424 | */ |
| 420 | - public function get_paths_permissions( $paths ): array { | |
| 425 | + public function get_paths_permissions( $paths ) : array { | |
| 421 | 426 | $permissions = []; |
| 422 | 427 | |
| 423 | 428 | foreach ( $paths as $key_path => $path ) { |
| 424 | 429 | $permissions[ $key_path ] = $this->get_path_permissions( $path ); |
| @@ -432,10 +437,13 @@ | ||
| 432 | 437 | * |
| 433 | 438 | * @param $path_key |
| 434 | 439 | * @return string |
| 435 | 440 | */ |
| 436 | - public function get_system_path( $path_key ): string { | |
| 441 | + public function get_system_path( $path_key ) : string { | |
| 437 | 442 | switch ( $path_key ) { |
| 443 | + case static::KEY_PATH_WP_ROOT_DIR: | |
| 444 | + return ABSPATH; | |
| 445 | + | |
| 438 | 446 | case static::KEY_PATH_WP_CONTENT_DIR: |
| 439 | 447 | return WP_CONTENT_DIR; |
| 440 | 448 | |
| 441 | 449 | case static::KEY_PATH_HTACCESS_FILE: |
| @@ -463,9 +471,9 @@ | ||
| 463 | 471 | * |
| 464 | 472 | * @param $path |
| 465 | 473 | * @return array{exists: bool, read: bool, write: bool, execute: bool} |
| 466 | 474 | */ |
| 467 | - public function get_path_permissions( $path ): array { | |
| 475 | + public function get_path_permissions( $path ) : array { | |
| 468 | 476 | if ( empty( $path ) ) { |
| 469 | 477 | return [ |
| 470 | 478 | 'exists' => false, |
| 471 | 479 | 'read' => false, |