I get the following error when using $wp_filesystem->copy(); to copy a file from one destination to another. Undefined variable: temphangle in <b>../htdocs/wp-admin/includes/class-wp-filesystem-ftpext.php</b> on line <b>159</b> Any idea what temphangle is?
There is a reply from 2014, that is a great answer to a question I have, but WordPress changes, and I'm wondering if this is still true, "WP Filesystem API will ask for FTP credentials, but it will do so for each operation. They aren't stored persistently." Where does wordpress store the FTP credentials? If this is still true, I'm guessing that the interaction between WordPress and the host would be that the host would send the default (main) FTP …
I have scenario that appends the contents into the files, I was using normal file system function of PHP Now I have decided to use WordPress WP_Filesystem but I cannot see any methods of it which do append the contents into the files. It has only the put_contents(), Is there any way to append the file content using WordPress's FS?
I'm trying to download a file from one location to another. The code is working perfect. Here is the code snippet: Helper Function - Create directory in /uploads/{$dir_name}/ and return paths. /** * Create folder in /uploads/{$dir_name}/ * @return array() */ function get_dirpath( $dir_name = 'test' ) { $wp_info = wp_upload_dir(); // SSL workaround. if ( is_ssl() ) { $wp_info['baseurl'] = str_ireplace( 'http://', 'https://', $wp_info['baseurl'] ); } // Build the paths. $dir_info = array( 'path' => $wp_info['basedir'] . '/' . …
I know that i should use Filesystem API to write files and I understand why but is there any difference if I read file with wp_filesystem or plain PHP? And what about listing directories? Consider this example: In wp-content I have my-plugin-templates-folder which has to be listed by my-plugin. Does anybody met with configuration which disallow webserver process list this directory so I should use wp_filesystem?
I was in the process checking some of my existing plugins for any unsafe filesystem accesses, when I ran across WP_Image_Editor's save function, which calls _save, which finally calls make_image (below). WP_Image_Editor was released in WP 3.5, while the Filesystem API has been around since WP 2.6, so I would presume that the reasoning is related to the specifics of the use-case rather than just not being changed to meet new standards. protected function make_image( $filename, $function, $arguments ) { …
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.
wp_upload_bits() allows you to put arbitrary binary data into a file, but it selects the path where the file is placed and doesn't allow configuration of this destination besides the basename. There's always the option of playing with the Filesystem API directly, but I was wondering if there is a similar function to wp_upload_bits() that would wrap the logic for me. Last thing I want is to reinvent the wheel. It's probably not relevant, but the bits being uploaded are …