wpseek.com
WordPress开发者和主题制作者的搜索引擎
get_temp_dir › WordPress Function
Since2.5.0
已弃用n/a
› get_temp_dir ( 没有参数 )
| 返回: |
|
| 定义在: |
|
| 文档: |
Determines a writable directory for temporary files.
Function's preference is the return value ofsys_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.Related Functions: get_sitemap_url, get_the_id, get_theme_mod, get_template_directory, get_term_to_edit
源码
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/';
}