WP_Automatic_Updater::is_allowed_dir
Checks whether access to a given directory is allowed.
This is used when detecting version control checkouts. Takes into account the PHP open_basedir restrictions, so that WordPress does not try to access directories it is not allowed to.
Метод класса: WP_Automatic_Updater{}
Хуков нет.
Возвращает
true|false. True if access to the directory is allowed, false otherwise.
Использование
$WP_Automatic_Updater = new WP_Automatic_Updater(); $WP_Automatic_Updater->is_allowed_dir( $dir );
- $dir(строка) (обязательный)
- The directory to check.
Список изменений
| С версии 6.2.0 | Введена. |
Код WP_Automatic_Updater::is_allowed_dir() WP Automatic Updater::is allowed dir WP 7.0
public function is_allowed_dir( $dir ) {
if ( is_string( $dir ) ) {
$dir = trim( $dir );
}
if ( ! is_string( $dir ) || '' === $dir ) {
_doing_it_wrong(
__METHOD__,
sprintf(
/* translators: %s: The "$dir" argument. */
__( 'The "%s" argument must be a non-empty string.' ),
'$dir'
),
'6.2.0'
);
return false;
}
$open_basedir = ini_get( 'open_basedir' );
if ( empty( $open_basedir ) ) {
return true;
}
$open_basedir_list = explode( PATH_SEPARATOR, $open_basedir );
foreach ( $open_basedir_list as $basedir ) {
if ( '' !== trim( $basedir ) && str_starts_with( $dir, $basedir ) ) {
return true;
}
}
return false;
}