Questions tagged [wp-filesystem]

The Filesystem API abstracts out the functionality needed for reading and writing local files to the filesystem to be done securely, on a variety of host types.

0
votes
0answers
5 views

Is there a way to request_filesystem_credentials's output without echo-ing the form on the check?

I'm inside a data-centered system where I don't have much output and I need to know if I can write a file to a directory using the WP_Filesystem. Problem is, the request_filesystem_credentials outputs ...
0
votes
1answer
12 views

Restrict file access based on user roles [closed]

Problem Statement: There are three custom roles, HR,Employee and Marketing. User with role as HR and Marketing can upload and view all files. User with role as Employee should only be able to access ...
0
votes
0answers
10 views

How to upload a file to a different directory, but not its preview images?

I use a filter (in my custom plugin for my website) to force upload of files loaded with an Ultimate Member plugin form in a directory different from the default 'uploads' one. The filter works ...
0
votes
1answer
34 views

Unzip_file causing Media file upload error

When I attempt to use the unzip_file function below in my functions.php: require_once(ABSPATH . 'wp-admin/includes/file.php'); WP_Filesystem(); $destination = wp_upload_dir(); $destination_path = $...
0
votes
1answer
68 views

How to upload .tex files in wordpress?

I am trying to upload tex files in my wordpress site. The methods I have tried and failed or the following. First of all the error I got is, Sorry, this file type is not permitted for security ...
0
votes
0answers
19 views

Moving large files between WordPress installs

What method would be most compatible for most WordPress installs, to transfer a large file [up to 100GB] between one WordPress install [client] to another [host]. Assume total control over [host] but [...
0
votes
1answer
40 views

Where to write custom logs in WordPress

I am creating a plugin in WordPress, the plugin creates logs for some events, my question is where should I write custom logs, so that no explicit file read/write permission required. I am looking to ...
2
votes
4answers
342 views

how to change max file upload size WordPress 4.9.8 [closed]

As the title states i have tried it with the htaccess file to change the maximum upload size and nothing i have even created a php.ini file in the root of the wordpress folder and still nothing can ...
0
votes
1answer
62 views

Need folder for CPT templates for eg: single-{post_type}.php

Hello I feel like my WP theme folder is getting a bit messy is there a way to put all the custom page-{post_type}.php, and single-{post_type}.php inside a folder instead of having them in the root of ...
0
votes
0answers
91 views

WP_Filesystem and global $wp_filesystem;

I am using this code to unzip the file and it woks ok: WP_Filesystem(); $unzipfile = unzip_file( $upload_path.$fileName, $upload_path); But when I want to delete the folder with files, I only ...
0
votes
1answer
28 views

What functions of WP_Filesystem allow me to create a file with code-generated contents in a directory?

I'm generating a very useful .dat file, but I read that file_put_contents if frowned upon and that WP_Filesystem should be used instead. I see no methods to take dynamic input and create a file and ...
1
vote
1answer
49 views

How do I edit the php/html for a particular post?

I am new to Wordpress but I am comfortable coding in html/php and want to create custom forms on some of my posts. My site is currently running on localhost. I feel very silly because I have been ...
1
vote
1answer
153 views

wp_filesystem put_contents issue with owner/group

I am using put_contents() function to put images on the server, works fine on localhost, though on server, the user group when the file are downloaded to server is "nginx nobody" and that is causing ...
0
votes
0answers
46 views

Change default wordpress FS owner

is it possible to change the default fs owner for wordpress? In our shared dev environment, we don't have access to the www-data user. Files created by wordpress under wp-content have the owner www-...
1
vote
1answer
120 views

Why my wordpress blog files are getting changed?

I have a blog on wordpress and is hosted on godaddy. I continously getting few of the core wordpress files changed automatically. My blog project is on git so I can figure it out easily and reset the ...
1
vote
3answers
2k views

Relative file paths in CSS when linking directly (not enqueuing)

I am creating a single-page child theme, in which (apologies to the Wordpress community) I am basically trying to stay out of using PHP or the Wordpress API as much as possible, because I really just ...
5
votes
1answer
172 views

Do I need to use WP_Filesystem when creating a downloadable file on the fly?

I have a method that creates a downloadable CSV on the fly when a button is clicked: header( 'Content-type: text/csv' ); header( 'Cache-Control: no-store, no-cache' ); header( 'Content-Disposition: ...
0
votes
1answer
208 views

Allowing all/different file type uploads

I've looked through a number of previously accepted answers, but none seem to work/apply to the latest versions of WordPress. I'm trying to allow .rfa file types to be uploaded to the media library. ...
0
votes
1answer
19 views

Is there a name for trivial WP PHP files like functions.php, archive php entry.php, page.php and so forth?

Is there a name for trivial WP PHP files like functions.php, archive php entry.php, page.php and so forth? Is there a "category" (in the general sense of the term) they all fall into? I want to know ...
1
vote
1answer
124 views

What to use , set_transient, set_option or file system? [closed]

I have a shortcode that can parse page contents. For example you give it a link to a GitHub md file , it reads it and saves the page content for you. $parse_atts = array( 'id' => $id, ...
0
votes
0answers
15 views

Downloadable content file structure

I have a bunch of files that will be used as downloadable content. Do I have to upload it as media or can I just upload to a folder through FTP? If yes, which folder?
0
votes
1answer
118 views

Media Upload to custom database and Custom Directory

I started developing a Plugin.I wanted to keep a form where the user can send an input text and a video/image to the website.The image should enter into the folder and the URL of the image/video ...
0
votes
2answers
17 views

trying to locate the correct file to edit my internal linking anchor tags

I am trying to locate the correct file to edit my internal linking anchor tags i.e.<a href= Can anyone point me to to the correct file? When I view the source code I see about 50 of them but I am ...
2
votes
1answer
549 views

How to append_contents using WP_Filesystem?

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 ...
0
votes
1answer
471 views

Download a zip folder of selected files

I'm trying to download multiple files from the server in a zipped folder. Here is the code I have thus far: HTML <form method="post"> <input type="checkbox" name="checked[]" value="<?...
2
votes
2answers
662 views

How to fix the error “file_get_contents was found in the file functions.php”?

I am building a wordpress theme, I reach the step of finalization. Right now, I am struggling to fix an error raised by Theme Check, : file_get_contents was found in the file functions.php File ...
1
vote
0answers
93 views

Copy Folder to another Folder using WP Filesystem

I want to copy a plugin folder to another folder, outside the WordPress installation, but in the same host, accessible via the same FTP account. Is there a way? I read something about copying ...
0
votes
1answer
389 views

Right way to download file from source to destination

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. /** *...
3
votes
1answer
231 views

What exactly does $wp_filesystem->abspath() return?

The real problem I have when using the $wp_filesystem is defining the correct paths. In the documentation of the filesystem the path (for example for the plugins directory) is usually set like this: $...
0
votes
1answer
195 views

Why does unzip_file always return true but nothing happens?

I am trying to use the $wp_filesystem of WordPress to unzip a file located inside the wp-content/plugins and place it at the same location. However whatever I try the WordPress method unzip_file() ...
0
votes
1answer
163 views

Why WordPress not using WP_Filesystem

On wp-admin/plugin-editor.php and wp-admin/theme-editor.php, why WordPress not using $wp_filesystem to read and modify the file? if writing and modifying file do not require wp_filesystem then when to ...
2
votes
2answers
945 views

What's a simple but secure method to get file contents into WordPress?

The scenario I'm developing a plugin, and part of it requires lots of text content (help descriptions) that I would prefer to keep as separate text files (in a subdirectory within the plugin) for ...
0
votes
1answer
15 views

Wordpress upload path decalration

I am trying to use wp-filesystem to write css data.I have things working perfect here. $filepath = get_template_directory() . '/dynamic/'; $wp_filesystem->mkdir($filepath); But this ...
0
votes
1answer
147 views

Error Copying Directory On Plugin Activation

I am trying to copy directory using WP_Filesystem API with the method copy_dir() on plugin activation, but it is give me the following error message: Plugin could not be activated because it ...
0
votes
1answer
145 views

Should I use Filesystem API for reading files or listing directories?

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 ...
0
votes
1answer
159 views

Is there a way to use WP filesystem without credentials when FS_METHOD is NOT set to direct?

The title is handful but so is the issue. I am building a theme than can generate/compress CSS files . So I need to move some files around etc. All this was working flawlessly until I figured out ...
1
vote
2answers
2k views

Downloading File from Outside Web Root

I've set up some code to download zip files that exist in a folder above the web root. The download will be triggered from a user account page within WordPress. They don't need to be bank-level secure,...
1
vote
1answer
449 views

Creating directory and file using native wordpress file system

I am creating directory and a css file using conventional php method. Here it is $upload_dir = wp_upload_dir(); $dirpath = $upload_dir['basedir'] . '/dynamic/'; $filepath = $dirpath. 'dynamic.css'; ...
0
votes
1answer
226 views

Running rmdir function on post save

How can I make wordpress call this function when a post is saved? $folder = "/temp/files/"; //path of the folder to be removed function delFolder($folder) { foreach(glob($folder . '/*') as $...
2
votes
1answer
356 views

Can't access wp_filesystem in cron function

I'm writing a plugin for integrating WP with Visma. It will basically spit out an XML file every third hour using wp cron (going to setup server cron for wp-cron.php on the live site) and save it to ...
0
votes
1answer
84 views

WP_Filesystem usage within a block of code

What i am trying to do is to have this function working within my plugin block of code without having it as plugin on it own. My current and working solution outside wordpress is Save contents $...
0
votes
0answers
80 views

version control for wordpress? (wordpress folder and database at same time)

I am familiar with version control to some extent. I have been using git and github for school purposes. Now when I use wordpress it makes sense that I can use git when developing on my local ...
8
votes
3answers
2k views

Standard location for plugin to save/cache files?

Are there official guidelines on where a plugin should cache files? If not, is there a best-practice out there that I can follow? For example, a plugin grabs content from a back-end system ...
2
votes
4answers
1k views

Why cant the WP Filesystem API read googlefonts.json?

I've inherited a site built with a theme by Highgrade (southcentral) which is built using the Redux framework. I'm seeing the following error in the frontend and admin panel: Warning: Invalid ...
0
votes
1answer
5k views

Use WP_Filesystem to list files in directory

Is there a way to list files in a directory using WP_filesystem instead of something like: function listFolderFiles($dir){ $ffs = scandir($dir); echo '<ol>'; foreach($ffs as $ff){ ...
2
votes
1answer
3k views

Copy and delete a directory with WordPress functions

I have successfully used copy_dir() to copy a directory to a new location. How can I delete a directory using WordPress functions?
3
votes
1answer
825 views

Convenient way to use wp_filesystem

I'd like to use $wp_filesystem which seems to be the recommended way to manipulate file system objects in WordPress but compare this: plain PHP code: mkdir('abc'); WP Filesystem API code: $url = ...
0
votes
1answer
472 views

WP_Filesystem in custom customize control

I'm currently trying to edit the following file so it uses the WP_Filesystem methods instead of direct PHP filesystem calls: google-font-dropdown-custom-control.php My current code looks as follows: ...
0
votes
0answers
281 views

how to create or rewrite files in wordpress plugin folder

i'm developing my own plugin. in that i used a simple php file to generate contact vcards in the plugin folder. for this i used fopen & fwrite. but the file is not creating in the plugin folder. ...
0
votes
1answer
238 views

How to display dialog box to save file from wp_filesystem->put_contents function?

I have this fragment: if(!$wp_filesystem->put_contents( $file_path, $file_content, FS_CHMOD_FILE )) { echo 'error during creating the file'; } This code works properly, but instead of saving ...