get_temp_dir()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_temp_dir(): string
Описание
Функция предпочитает возвращаемое значение sys_get_temp_dir(), затем значение upload_tmp_dir из php.ini, затем WP_CONTENT_DIR и, наконец, по умолчанию /tmp/.
Обратите внимание, что sys_get_temp_dir() учитывает переменную окружения TMPDIR.
Если функция не находит место с правом записи, его можно переопределить константой WP_TEMP_DIR в файле wp-config.php.
Оригинал (английский)
Function’s preference is the return value of sys_get_temp_dir(), followed by the upload_tmp_dir value from php.ini, followed by WP_CONTENT_DIR, before finally defaulting to /tmp/.
Note that sys_get_temp_dir() honors the TMPDIR environment variable.
In the event that this function does not find a writable location, it may be overridden by the WP_TEMP_DIR constant in your wp-config.php file.
Возвращаемое значение
string
Исходный код
wp-includes/functions.php:2235
function get_temp_dir() {
static $temp = '';
if ( defined( 'WP_TEMP_DIR' ) ) {
return trailingslashit( WP_TEMP_DIR );
}
if ( $temp ) {
return trailingslashit( $temp );
}
if ( function_exists( 'sys_get_temp_dir' ) ) {
$temp = sys_get_temp_dir();
if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
return trailingslashit( $temp );
}
}
$temp = ini_get( 'upload_tmp_dir' );
if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) {
return trailingslashit( $temp );
}
$temp = WP_CONTENT_DIR . '/';
if ( is_dir( $temp ) && wp_is_writable( $temp ) ) {
return $temp;
}
return '/tmp/';
}
История изменений
| Версия | Описание |
|---|---|
| 2.5.0 | Introduced. |

