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.
96
questions
0
votes
1
answer
392
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 ...
3
votes
2
answers
3k
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
1
answer
21
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
1
answer
331
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
1
answer
295
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
1
answer
279
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
2
answers
4k
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
1
answer
1k
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
1
answer
251
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
1
answer
634
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
1
answer
217
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
0
answers
100
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 ...
10
votes
3
answers
4k
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
4
answers
2k
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
1
answer
8k
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){
...
3
votes
1
answer
4k
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
1
answer
1k
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
1
answer
543
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
0
answers
314
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
1
answer
401
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 ...
4
votes
1
answer
6k
views
Copy a file from a plugin into my theme directory
I coded a wordpress plugin using php's 'copy()' to copy a file from my plugin directory to my theme directory, but it's not working:
<?
function file_replace() {
$plugin_dir = plugin_dir_path(...
1
vote
1
answer
741
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() ...
2
votes
1
answer
2k
views
Convert PHP readfile to WP_Filesystem
In the script below, I need to convert the readfile to the WP_filesytem equivalent. However, I can't find same in Codex. Any help much appreciated.
This script saves the settings.ini file to the user'...
5
votes
2
answers
6k
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
3
answers
685
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 ...
2
votes
2
answers
2k
views
Using wp_filesystem in Plugins to store customizer settings
I try to fix my plugin with the answers i got here: Using wp_filesystem in Plugins
Background i wrote a theme (https://github.com/bassjobsen/jamedo-bootstrap-start-theme) and a plugin (https://github....
0
votes
1
answer
812
views
Enabling XSendFile causes 404 for images on Wordpress Multisite / Network
I've compiled and installed the XSendFile module and added the following lines to my .htaccess:
XSendFile On
It shows up as being activated in <?php info() ?> under loaded modules.
The ...
1
vote
2
answers
4k
views
Converting fopen/fwrite operations to WP_filesystem
In the function below, I'm trying to convert the fopen/fwrite/fclose methods to the preferred WP_filesystem methods. Everything works as expected using the commented out script block, however, the ...
1
vote
1
answer
4k
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
1
answer
685
views
When to use the Filesystem API? Should I use it at all?
I'm wondering when it is recommended to use the Filesystem API, and whether it's useful at all?
WordPress seems a little inconsistent when it comes to Filesystem API usage, it uses the API only in a ...
0
votes
1
answer
395
views
Unable to access WP admin
I cannot access admin via:
http://example.com/admin
or
http://example.com/wp-admin
Fatal error: Class 'ObjectModel' not found in /home3/xxxxxx/public_html/example.com/wp-includes/class.wp-...
3
votes
2
answers
3k
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/...
1
vote
0
answers
195
views
How does WordPress access theme and plugin files through its editor?
I love that WordPress enables you to edit files in the WP back end, but I want to know how it works. How is WordPress able to access and allow you to edit files that are on a server like that? Please ...
0
votes
1
answer
658
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 ...
0
votes
1
answer
4k
views
Upload PDF and other files from the Front-End
I am trying to create a medical website, where logged-in doctors can actually upload pdfs and other files (such as jpg) from the front-end in posts. Then, after reloading the page, the uploaded files ...
0
votes
1
answer
2k
views
why there is a large file named core in wpmu's directory?
why the file named core is here? can i delete it?
ls -lh
total 37M
-rw-rw-r-- 1 hugemeow pg 16 2012-03-04 04:22 a.php
-rw------- 1 hugemeow pg 30M 2012-10-16 10:41 core // this is the large ...
7
votes
3
answers
9k
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 );
...
3
votes
1
answer
557
views
What is the correct way to check if WP_Filesystem can write to a directory without aking for username / password?
I'm trying to implement caching using the filesystem so i need to check if i can write in a directory. I've read Otto's article, but i've failed to understand how should i implement a check where the ...
7
votes
1
answer
2k
views
Which filters or actions to use after a media upload and delete?
When a media (image) is uploaded and the subsequent images are created (all the different sizes), I would like to perform a few actions. It is simple and I basically need only the new attachment ID, ...
2
votes
2
answers
7k
views
Moving wp-content outside of web root?
Is it possible to move the entire wp-content folder outside of the Web root? I need to prevent anyone to view any asset file (images, pdfs, movies etc) with a direct url to the file...
Any ideas? Or ...
2
votes
1
answer
920
views
What is the best way to move a plugin´s subdirectory+files to wp-content/uploads-directory?
I am developer of the plugin Leaflet Maps Marker (http://www.mapsmarker.com - "Pin, organize & show your favorite places through OpenStreetMap, OGD Vienna or any custom WMTS-map")
and have one ...
1
vote
1
answer
3k
views
How to check if txt file exists inside template folder?
I have a folder inside my theme where I hold some txt files which I am including in a theme. The problem is that before including txt file I need to check if it does exist. I fail checking it the ...
2
votes
3
answers
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 ...
10
votes
3
answers
7k
views
Creating directory in uploads - wp_mkdir_p() or WP_Filesystem?
I don't think I ever had practical need to create folders/files in WP before, but for a plugin I need cache (for resized images) folder in wp-content/uploads.
Which raises the question - do I really ...
0
votes
2
answers
470
views
Upgrading WordPress (File permission group owner)
I have a problem when i want to upgrade Wordpress or install plugin via the Admin.
It's say that I don't have the permission to write. but I can upload images and other things... but i cannot install ...
2
votes
1
answer
3k
views
$wp_filesystem returns NULL. What are the dependencies?
I need to obtain a reference to the $wp_filesystem object. In the test below, the var_dump($wp_filesystem) returns NULL. What additional files are required in order to properly set up $wp_filesystem?
...