| @@ -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'; |
| @@ -314,10 +315,11 @@ | ||
| 314 | 315 | * @type bool $warning Whether to display a warning. True if some required |
| 315 | 316 | * folders don't have writing permissions, False otherwise. |
| 316 | 317 | * } |
| 317 | 318 | */ |
| 318 | - public function get_write_permissions(): array { | |
| 319 | + public function get_write_permissions() : array { | |
| 319 | 320 | $paths_to_check = [ |
| 321 | + static::KEY_PATH_WP_ROOT_DIR => $this->get_system_path( static::KEY_PATH_WP_ROOT_DIR ), | |
| 320 | 322 | static::KEY_PATH_HTACCESS_FILE => $this->get_system_path( static::KEY_PATH_HTACCESS_FILE ), |
| 321 | 323 | static::KEY_PATH_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_UPLOADS_DIR ), |
| 322 | 324 | static::KEY_PATH_ELEMENTOR_UPLOADS_DIR => $this->get_system_path( static::KEY_PATH_ELEMENTOR_UPLOADS_DIR ), |
| 323 | 325 | ]; |
| @@ -325,8 +327,12 @@ | ||
| 325 | 327 | $paths_permissions = $this->get_paths_permissions( $paths_to_check ); |
| 326 | 328 | |
| 327 | 329 | $write_problems = []; |
| 328 | 330 | |
| 331 | + if ( ! $paths_permissions[ static::KEY_PATH_WP_ROOT_DIR ]['write'] ) { | |
| 332 | + $write_problems[] = 'WordPress root directory'; | |
| 333 | + } | |
| 334 | + | |
| 329 | 335 | if ( ! $paths_permissions[ static::KEY_PATH_UPLOADS_DIR ]['write'] ) { |
| 330 | 336 | $write_problems[] = 'WordPress uploads directory'; |
| 331 | 337 | } |
| 332 | 338 | |
| @@ -347,9 +353,9 @@ | ||
| 347 | 353 | } |
| 348 | 354 | |
| 349 | 355 | return [ |
| 350 | 356 | 'value' => $value, |
| 351 | - 'warning' => (bool) $write_problems, | |
| 357 | + 'warning' => ! ! $write_problems, | |
| 352 | 358 | ]; |
| 353 | 359 | } |
| 354 | 360 | |
| 355 | 361 | /** |
| @@ -416,9 +422,9 @@ | ||
| 416 | 422 | /** |
| 417 | 423 | * @param $paths [] Paths to check permissions. |
| 418 | 424 | * @return array []{exists: bool, read: bool, write: bool, execute: bool} |
| 419 | 425 | */ |
| 420 | - public function get_paths_permissions( $paths ): array { | |
| 426 | + public function get_paths_permissions( $paths ) : array { | |
| 421 | 427 | $permissions = []; |
| 422 | 428 | |
| 423 | 429 | foreach ( $paths as $key_path => $path ) { |
| 424 | 430 | $permissions[ $key_path ] = $this->get_path_permissions( $path ); |
| @@ -432,10 +438,13 @@ | ||
| 432 | 438 | * |
| 433 | 439 | * @param $path_key |
| 434 | 440 | * @return string |
| 435 | 441 | */ |
| 436 | - public function get_system_path( $path_key ): string { | |
| 442 | + public function get_system_path( $path_key ) : string { | |
| 437 | 443 | switch ( $path_key ) { |
| 444 | + case static::KEY_PATH_WP_ROOT_DIR: | |
| 445 | + return ABSPATH; | |
| 446 | + | |
| 438 | 447 | case static::KEY_PATH_WP_CONTENT_DIR: |
| 439 | 448 | return WP_CONTENT_DIR; |
| 440 | 449 | |
| 441 | 450 | case static::KEY_PATH_HTACCESS_FILE: |
| @@ -463,9 +472,9 @@ | ||
| 463 | 472 | * |
| 464 | 473 | * @param $path |
| 465 | 474 | * @return array{exists: bool, read: bool, write: bool, execute: bool} |
| 466 | 475 | */ |
| 467 | - public function get_path_permissions( $path ): array { | |
| 476 | + public function get_path_permissions( $path ) : array { | |
| 468 | 477 | if ( empty( $path ) ) { |
| 469 | 478 | return [ |
| 470 | 479 | 'exists' => false, |
| 471 | 480 | 'read' => false, |