get_filesystem_method [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Determines which Filesystem Method to use.
The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())
Note that the return value of this function can be overridden in 2 ways - By defining FS_METHOD in your
wp-config.php
file - By using the filesystem_method filter Valid values for these are: 'direct', 'ssh', 'ftpext' or 'ftpsockets' Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.
Source
<?php
function get_filesystem_method($args = array(), $context = false) {
$method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure that this is either 'direct', 'ssh', 'ftpext' or 'ftpsockets'
if ( ! $method && function_exists('getmyuid') && function_exists('fileowner') ){
if ( !$context )
$context = WP_CONTENT_DIR;
$context = trailingslashit($context);
$temp_file_name = $context . 'temp-write-test-' . time();
$temp_handle = @fopen($temp_file_name, 'w');
if ( $temp_handle ) {
if ( getmyuid() == @fileowner($temp_file_name) )
$method = 'direct';
@fclose($temp_handle);
@unlink($temp_file_name);
}
}
if ( ! $method && isset($args['connection_type']) && 'ssh' == $args['connection_type'] && extension_loaded('ssh2') && function_exists('stream_get_contents') ) $method = 'ssh2';
if ( ! $method && extension_loaded('ftp') ) $method = 'ftpext';
if ( ! $method && ( extension_loaded('sockets') || function_exists('fsockopen') ) ) $method = 'ftpsockets'; //Sockets: Socket extension; PHP Mode: FSockopen / fwrite / fread
return apply_filters('filesystem_method', $method, $args);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- WordPress › Support » new auto update for plugins not working
function get_filesystem_method() { /* $tempFile = tempnam(get_temp_dir(), 'WPU '); if ( getmyuid() == fileowner($tempFile) ) { unlink($tempFile); return 'direct'; } ...
wordpress.org - #10205 (getmyuid() called instead of posix_getuid() in ...
In wp-admin/includes/file.php, the function get_filesystem_method() attempts to figure out whether it is able to write files correctly, and therefore whether it can ...
core.trac.wordpress.org - get_filesystem_method | A HitchHackers guide through WordPress
Feb 12, 2011 ... function get_filesystem_method($args = array(), $context = false) { $method = defined('FS_METHOD') ? FS_METHOD : false; //Please ensure ...
hitchhackerguide.com - get_filesystem_method() WordPress function reference, arguments ...
Determines which Filesystem Method to use. The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, ...
queryposts.com