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.

Filter by
Sorted by
Tagged with
0
votes
0answers
29 views

Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?

I am experimenting with bulk import from csv file for my plugin. As I am new to plugin develpoment, please guide me if I am doing something wrong. What I have: I have 4 columns of multiple rows in a ...
2
votes
2answers
1k 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 ...
2
votes
2answers
2k views

How do you use unzip_file()?

I have been trying to use the unzip_file() function. It says undefined so I looked into it and the WP_Filesystem() must be called and set up. So easy, right? require_once(ABSPATH .'/wp-admin/includes/...
0
votes
0answers
19 views

Converting fopen/fwrite to WP_Filesystem

I'm using code from the Easy Theme Child plugin in my theme, but it fails the Theme Check plugin with the following error: WARNING: fopen/fwrite was found in the file grtsth-easy-child-theme-...
0
votes
1answer
549 views

How to include form for WP_Filesystem()?

I've used a bit of code to try and write a dynamic.css file to a theme folder and it works fine. BUT, it doesn't work on certain shared hosting situations so the request_filesystem_credentials() ...
0
votes
0answers
67 views

Add `manifest.json` file to a Custom Wordpress Theme

I'm building a custom Wordpress theme and would like to add a manifest.json file so I can utilise the ​​"orientation": "portrait-primary" that you can use with PWAs to lock the orientation on mobile ...
0
votes
0answers
18 views

Wordpress Filesystem create CSS-File - get Shortcode ID for Name

My Script creates an CSS File when i save the post with the shortcode ID at the end of the filename. e.g. (test-293.css) The Problem is, that i need to register this individual File in my frontend and ...
4
votes
2answers
4k views

Call to a member function put_contents() on a non-object

I have a plugin and I am creating a css file in wp_content. I used this: $this->content_dir = WP_CONTENT_DIR . "/some_folder"; $path = $this->content_dir . 'options.css'; $css='some string'; ...
0
votes
0answers
6 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
0answers
16 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
57 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 = $...
5
votes
3answers
5k views

How to use WordPress HTTP API to download file from remote location

So this PHP code works for me: $ch = curl_init( TCS_CPDF_REMOTE_ZIP ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $data = curl_exec( $ch ); curl_close( $ch ); ...
0
votes
1answer
157 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
1answer
187 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 ...
0
votes
1answer
345 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. ...
2
votes
4answers
502 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
92 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
1answer
60 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
95 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
276 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
67 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
126 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
2answers
3k 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
3answers
4k 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
273 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
500 views

Wordpress Creates Unused (Unregistered) Image Sizes

I have a news blog created on WordPress. I've set up WordPress to create 3 resized versions of images when uploading them. 315x215(featured image with cropping option enabled) 620x (to create images ...
1
vote
1answer
2k views

Using wp_handle_upload() to Direct Specific Path by Using $overrides

How do you use wp_handle_upload function and apply_filters together to upload files on a specific path? What is going to be the override? For example: $overrides = array('file' => 'C:\\uploads\\...
2
votes
3answers
2k views

Where is Featured Image code stored in WP?

Well, I'm looking for source code of these two small containers (PHP backend, HTML frontend & JS used to attach the image): I want to build a theme option based on Featured Image code, but I'm ...
0
votes
1answer
21 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
237 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
16 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?
3
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?
0
votes
1answer
170 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
610 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
572 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="<?...
3
votes
2answers
850 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
110 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
468 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
399 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 ...
3
votes
1answer
256 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
232 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
197 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 ...
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
166 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
201 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
3answers
572 views

How to move core js files into the footer

while testing for page speed, i found 2 js files that causes the speed delay, according to PageSpeed Insight. files names are /wp-includes/js/swfobject.js /wp-includes/js/comment-reply.min.js how ...
0
votes
1answer
173 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
1answer
581 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
236 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 $...