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
0 answers
27 views

Wordpress - tracking options

I wanted to ask, how much is it possible to track users when using WP as a CMS. For example, can I see, when users go to certain directories like wp/files or open specific documents like wp/files/docs/...
Mel's user avatar
  • 1
0 votes
0 answers
19 views

Does unzip_file() over-write by default?

The question is in the title Does unzip_file() over-write any existing files by default? The docs at https://developer.wordpress.org/reference/functions/unzip_file/ don't address this one way or the ...
Steve's user avatar
  • 263
0 votes
0 answers
42 views

How do I upload my Wordpress code files from previous website onto local host Wordpress website?

I have Wordpress code files from an old website which I downloaded from WP File Manager that I want to look at on my local host. I have downloaded Xampp and set up a local host Wordpress website. How ...
H D's user avatar
  • 1
0 votes
2 answers
82 views

unzip_file not working with the remote file

I'm trying to use unzip_file to extract the remote archive with no success. It works only with the local path using get_template_directory() but with a remote zip archive URL I'm getting Incompatible ...
Alexander's user avatar
  • 133
0 votes
1 answer
299 views

PHP File_exist() not working - Checking if File Exist in WordPress Theme Directory

I am trying to check if a certain archive file template exists in the WP theme directory. This is my code, I am not sure what I am missing here. <?php $file_name = '/archive.php'; $...
Tamara's user avatar
  • 302
0 votes
0 answers
350 views

Setting wp_temp_dir and permissions not working for "Missing A Temporary Folder" error

I have a problem uploading files to my main webpress site (e.g. www.main.com) and all the other pages that live in it (e.g. www.main.com/anotherpage). I know there is a method to set a temp folder ...
mors's user avatar
  • 3
0 votes
0 answers
26 views

Submitting form from input[type=file] dialog box

I am attempting to trigger a form submit from an input [type=file] dialog box window. I realize this might be a bit substandard, but here's what I'm trying to do. User clicks the browse button, and ...
Nick's user avatar
  • 11
0 votes
0 answers
199 views

How can I create a WordPress dynamic download counter

I am creating a WordPress website that enable customers to download music and I want to track downloads and display the results next to the WordPress download button. I am using the WordPress convert ...
Sam's user avatar
  • 1
0 votes
0 answers
37 views

Admin Custom Plugin List Files in admin Table

I'm building a plugin that works only in admin. I've a page where I need a list of files, users can only download or delete the file. I've this questions: I don't know what is better to list the ...
Alex's user avatar
  • 1
0 votes
1 answer
109 views

How can I add a method to create files when in theme-editor.php

This is a concept of my goal I want to be able to create files in the current opened directory by entering the complete file name and and extension in a text field, click create and use the AJAX ...
Nadal's user avatar
  • 59
1 vote
1 answer
46 views

Register visits of my pages in wordpresss

I have a shortcode that obtains the name of the person logged into wordpress, I would like that shortcode when the person enters a page where I have my shortcode create a .text file and save their ...
Gerardo Marroquin's user avatar
0 votes
1 answer
312 views

How do you find a file in the media library using the file URL?

We have about 2000 files in our media library and we are working on an audit to organize the files and create a name hierarchy. But until that is done, I am trying to locate a handful of specific ...
Garrett Massey's user avatar
1 vote
1 answer
418 views

Unable to check if image uploaded by wp_image_editor exists using file_exists function

I am developing a podcast theme where i have a form that allows the user to upload their podcast cover arts. The Podcast cover art’s dimension should fall under 1400×1400 and 3000×3000 since we are ...
Rahul K's user avatar
  • 13
0 votes
1 answer
66 views

temphangle variable missing when using wp_filesystem copy

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-...
RafaSashi's user avatar
  • 427
1 vote
1 answer
886 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() . ...
ralphjsmit's user avatar
1 vote
1 answer
772 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 ...
kanlukasz's user avatar
  • 454
0 votes
2 answers
4k 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' ); ?...
ralphjsmit's user avatar
1 vote
0 answers
72 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: ...
maja's user avatar
  • 19
0 votes
1 answer
938 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); ...
Sabbir's user avatar
  • 107
3 votes
3 answers
3k 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 ...
Jesse's user avatar
  • 133
0 votes
0 answers
411 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 ...
Kimsea Sok's user avatar
1 vote
1 answer
230 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/...
Jimmery's user avatar
  • 135
0 votes
0 answers
736 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 ...
Savio menezes's user avatar
0 votes
0 answers
390 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 ...
pjk_ok's user avatar
  • 888
0 votes
0 answers
67 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 ...
Artisolution's user avatar
0 votes
2 answers
181 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 = $...
Troy Templeman's user avatar
0 votes
1 answer
363 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 ...
gloom's user avatar
  • 175
2 votes
1 answer
3k 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 ...
Surjan Raghuwanshi's user avatar
2 votes
4 answers
1k 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 ...
djwayne1985's user avatar
0 votes
1 answer
160 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 ...
Kristian Bendtsen's user avatar
0 votes
1 answer
444 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 ...
coolpasta's user avatar
  • 879
1 vote
1 answer
479 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 ...
ellen's user avatar
  • 335
1 vote
1 answer
721 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 ...
Kash's user avatar
  • 151
0 votes
0 answers
98 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-...
Tom M's user avatar
  • 101
1 vote
1 answer
182 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 ...
Umar's user avatar
  • 79
2 votes
3 answers
9k 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 ...
Igid's user avatar
  • 133
5 votes
1 answer
687 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: ...
user3574603's user avatar
0 votes
1 answer
1k 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. ...
SamXronn's user avatar
  • 185
0 votes
1 answer
23 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 ...
Arcticooling's user avatar
2 votes
1 answer
448 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, ...
Benn's user avatar
  • 993
0 votes
0 answers
19 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?
Henrique Vilela's user avatar
0 votes
1 answer
603 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 ...
Pavan Kalyan's user avatar
0 votes
2 answers
21 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 ...
Eddiece's user avatar
  • 11
2 votes
1 answer
939 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 ...
Thamaraiselvam's user avatar
0 votes
1 answer
974 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="<?...
Michelle M.'s user avatar
3 votes
2 answers
1k 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 ...
user3415011's user avatar
1 vote
0 answers
279 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 ...
hackuniverse's user avatar
0 votes
1 answer
1k 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. /** * ...
maheshwaghmare's user avatar
3 votes
1 answer
309 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: $...
phpheini's user avatar
  • 133
0 votes
1 answer
377 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() ...
phpheini's user avatar
  • 133