always use require_once for wp-load.php (fixes "ABSPATH defined multiple times")
|Reported by:||convissor||Owned by:|
|Severity:||normal||Keywords:||require_once require wp-load.php|
The wp-load.php file should always be included via require_once. This allows developers to include files when necessary with having to run into the "ABSPATH defined multiple times" notice (let alone waste time processing the file).
In trunk, require_once is already used in the majority of cases for wp-load.php:
- 24 require_once
- 8 require
- 1 include
This has come up because of a situation in a plugin where it is necessary to manually include the wp-login.php. But then wp-login.php calls require wp-load.php and the constant re-declaration notice arises.
In two cases, the patch changes relative paths (eg ./ to dirname(__FILE__)) to avoid safe mode problems and improve the ability to run files from anywhere(1), which is helpful for testing from the command line.
(1) Paths in PHP are relative to the present working directory, not the directory the file is in.