In my theme i will use the WP_Filesystem to write a file to for example:
$file = get_template_directory().'/library/assets/css/wpless2css.css';
Which outputs something like /home/user/domain/http_docs/wp-contents/theme/mytheme/library/assets/css/wpless2css.css
This will work unless the ftp user will be chroot to /home/user/domain/
(on some servers?).
In the case of a chroot the WP_Filesystem can’t find $file
.
A solution seems to define FTP_PATH
in wp-config.php into /home/user/domain/
and use:
if(FTP_BASE) $file = str_replace(FTP_BASE,'',get_template_directory()).'/library/assets/css/wpless2css.css';
I’m looking for a solution more robust and support for the different possible permissions systems.
After changing
FTP_BASE
in mywp-config
i found the update function of WP broken. Then i realize the update function work the same way and don’t need any additional settings.In
wp-admin/includes/update-core.php
i found the usage of$wp_filesystem->wp_content_dir()
. This solves my problem too.On http://xref.wordpress.org/branches/3.8/WordPress/Filesystem/WP_Filesystem_Base.html you will find a list of possible useful functions:
In fact @otto give my the answer earlier (Using wp_filesystem in Plugins), here he wrote: