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
1answer
21 views

What dependencies should I load and to use the WP_Filesystem?

I'm building a Wordpress theme which has a WP_Filesystem call in it: <?php $wp_filesystem = new WP_Filesystem_Direct(null); echo $wp_filesystem->get_contents(get_stylesheet_directory() . ...
1
vote
1answer
15 views

Can I delete `wp-config-sample.php` after installing and configuring Wordpress?

Can I remove wp-config-sample.php after installing and configuring Wordpress? Could this have any consequences in the future? Is this file restored after updating? At first glance, it just seems ...
0
votes
2answers
46 views

How to replace file_get_contents() with a Wordpress Filesystem call

I'm using the PHP file_get_contents() function to retrieve and echo the contents of an SVG-file. <?php echo file_get_contents( get_stylesheet_directory_uri() . '/assets/images/Search_Glyph.svg' ); ?...
0
votes
0answers
18 views

Display the full content of a post in the search result page

For my website, I want the users to search for their pdf reports (using their report ID, which will be the same as the name of the file), i.e., the user has to enter the exact report ID to get their ...
1
vote
0answers
23 views

Why Wordpress plugin url ajax doesn't work?

I need to send information to the plugin folder via ajax. Wordpress has a function for the link "plugin_dir_url (__ FILE__)" which works properly but if I put it in ajax it doesn't work. Function: ...
0
votes
1answer
44 views

how to get json file in wordpress template

I am trying to get data from JSON file in Wordpress template using file_get_contents But can not get the file $data = file_get_contents("../assets/data2.json"); $arr = json_decode($data, true); ...
0
votes
0answers
31 views

How to move files to media library/upload directory?

I made a mistake uploading my files and I don't want to re-upload it again. I wanted to make my files available to download by any users, and in this tutorial, it shows how to do that. Unfortunately, ...
0
votes
1answer
250 views

Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?

Background I'm developing a plugin for WordPress. I initially used file_get_contents() for two purposes: A remote file (which I changed to wp_remote_post()) A local file in the plugin dir (what this ...
0
votes
0answers
75 views

How to Copy Upload Image using WP_Filesystem_Direct

I'm trying to export post_type and its attached image. However, I'm stacking at copying file to export directory. WP_Filesystem_Direct::copy failed to open stream ( No file or directory ). Here ...
1
vote
1answer
34 views

Finding the path of a specific WordPress install

I have recently taken over a WordPress website. Once I got access to the server I found that there were more than 70 installations of WordPress spread across it (files and DBs). What is the quickest/...
0
votes
0answers
140 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 ...
0
votes
0answers
65 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
0answers
150 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
30 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 ...
0
votes
1answer
77 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
194 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
613 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
744 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
112 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
101 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
146 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
371 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
78 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
127 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
5k 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
372 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
541 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
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
298 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?
0
votes
1answer
229 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
18 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
664 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
666 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
971 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
128 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
571 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
273 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
279 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
258 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
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 ...
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
188 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
217 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
185 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 ...
2
votes
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,...
2
votes
1answer
656 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
239 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 $...
3
votes
1answer
442 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
119 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 $...