wp_filesystem [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Initialises and connects the WordPress Filesystem Abstraction classes.
This function will include the chosen transport and attempt connecting.
Plugins may add extra transports, And force WordPress to use them by returning the filename via the 'filesystem_method_file' filter.
Source
<?php
function WP_Filesystem( $args = false, $context = false ) {
global $wp_filesystem;
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php');
$method = get_filesystem_method($args, $context);
if ( ! $method )
return false;
if ( ! class_exists("WP_Filesystem_$method") ) {
$abstraction_file = apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes/class-wp-filesystem-' . $method . '.php', $method);
if ( ! file_exists($abstraction_file) )
return;
require_once($abstraction_file);
}
$method = "WP_Filesystem_$method";
$wp_filesystem = new $method($args);
//Define the timeouts for the connections. Only available after the construct is called to allow for per-transport overriding of the default.
if ( ! defined('FS_CONNECT_TIMEOUT') )
define('FS_CONNECT_TIMEOUT', 30);
if ( ! defined('FS_TIMEOUT') )
define('FS_TIMEOUT', 30);
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() )
return false;
if ( !$wp_filesystem->connect() )
return false; //There was an error connecting to the server.
// Set the permission constants if not already set.
if ( ! defined('FS_CHMOD_DIR') )
define('FS_CHMOD_DIR', 0755 );
if ( ! defined('FS_CHMOD_FILE') )
define('FS_CHMOD_FILE', 0644 );
return true;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- WordPress › Support » How to initialize WP_Filesystem object?
I don't want to use FS_METHOD define to force wp_filesystem to the correct driver (for my particular server) as a long term solution. (TL;DR)So what should I be ...
wordpress.org - WordPress › Support » How to initialize WP_Filesystem object?
I'm trying to use the the wordpress file system abstraction class in a plugin. I can't figure out what I'm supposed to pass in to WP_Filesystem to correctly initialize ...
wordpress.org - Tutorial: Using the WP_Filesystem » Otto on WordPress
Apr 5, 2011 ... The WP_Filesystem basically support five different ways of writing files to the system and they all ensure that ownership of those files remains ...
ottopress.com - WP_Filesystem Tutorial on ottopress.com | ThemeShaper
Apr 19, 2011 ... A great writeup by Otto on how, why, and when to use WP_Filesystem to write files from a WordPress theme or plugin, including code samples ...
themeshaper.com
Gebruikersdiscussies [ wordpress.org ]
- itscoolreally on "File uploads and WP_Filesystem"
- rcain on "File uploads and WP_Filesystem"
- zerpex on "use WP_Filesystem (alike) to upload images?"
- griffinjt on "File uploads and WP_Filesystem"
- fhsm on "How to initialize WP_Filesystem object?"
- fhsm on "How to initialize WP_Filesystem object?"
- Dion Hulse (@dd32) on "How to initialize WP_Filesystem object?"
- fhsm on "How to initialize WP_Filesystem object?"
- fhsm on "How to initialize WP_Filesystem object?"
- fhsm on "How to initialize WP_Filesystem object?"