get_temp_dir

Definition:
function get_temp_dir() {}

Determines a writable directory for temporary files.
Function’s preference is to WP_CONTENT_DIR followed by the return value of

Return values

returns:Writable temporary directory

Source code

function get_temp_dir() {

	static $temp;

	if ( defined('WP_TEMP_DIR') )

		return trailingslashit(WP_TEMP_DIR);



	if ( $temp )

		return trailingslashit($temp);



	$temp = WP_CONTENT_DIR . '/';

	if ( is_dir($temp) && @is_writable($temp) )

		return $temp;



	if  ( function_exists('sys_get_temp_dir') ) {

		$temp = sys_get_temp_dir();

		if ( @is_writable($temp) )

			return trailingslashit($temp);

	}



	$temp = ini_get('upload_tmp_dir');

	if ( is_dir($temp) && @is_writable($temp) )

		return trailingslashit($temp);



	$temp = '/tmp/';

	return $temp;

}

14009

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: