Placing assets for external use

I have used symbolic links for convenience for awhile on a dev server but they are not 100% reliable as some PHP functions will return the filesystem path of the target instead of the path to the symlink itself. The most notable example (though not really a function) is the magic constant __FILE__. (Also https://bugs.php.net/bug.php?id=46260) … Read more

Converting fopen/fwrite operations to WP_filesystem

The get_contents function returns the contents of the file, not a file handle. Using put_contents with $f after that is incorrect. Try $wp_filesystem->put_contents( $htaccess_file, $htaccessnew, FS_CHMOD_FILE ) instead. Also, it’s not necessarily safe to use things like “get_home_path” and such with the WP_Filesystem. The remote path may not match the local path. You’ll need to … Read more

Adding Adobe files to a wordpress site [closed]

Allowing file types outside of WP’s defaults exposes your site to some security risks, and some hosts don’t allow certain filetypes. If your host allows these filetypes, you can use the following function in a plugin or a child theme: function wpse_file_uploads($mime_types){ // photoshop $mime_types[‘psd’] = ‘image/vnd.adobe.photoshop’; // illustrator $mime_types[‘ai’] = ‘application/postscript’; // indesign $mime_types[‘indd’] … Read more

Is fopen() forbidden in WP?

File system access is tricky thing between different possible server configurations. If you need to implement it reliably in WP you should look into its API for such. See Using the WP_Filesystem.