$wp_filesystem
is a global variable containing the instance of the (auto-)configured filesystem object after the filesystem “factory” has been run.
To run the factory “over” the global variable (so to set it), just call the WP_Filesystem()
function which is, guess what, undocumented in codex. At least the docblock contains some information and you can read the sourcecode (if that’s an option for you).
Anyway, I would give it a try to add a function call to your code after requiring the file.php from the /wp-admin/includes
directory. Probably this already solves your issue.
If you are looking for a (better) file-system abstraction than/next to the built-in one, consider the file-system objects in SPL which is part of PHP already.
Related Posts:
- Where to store PHP files created by plugin / themes
- Get page content using slug
- Standard location for plugin to save/cache files?
- What is the correct way to build a widget using OOP
- Do I need to use WP_Filesystem when creating a downloadable file on the fly?
- Has anyone managed to integrate the wp_editor inside a widget?
- Two-step login process – Is it possible?
- How do I edit the php/html for a particular post?
- How to store accumulate multiple option values in a single array using Options_API
- Admin-ajax.php appending a status code to ajax response
- Why cant the WP Filesystem API read googlefonts.json?
- Using wp_filesystem in Plugins to store customizer settings
- Show dialog box in TinyMCE plugin and use WordPress php functions in it
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Files automatically added
- Applying OO patterns and principles to plugin development
- Plugin writing: access file that was just uploaded
- How to implement filesystem cache in WordPress
- Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin
- “dashboard”-named PHP file doesn’t get included
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- Where to write custom logs in WordPress
- wp_filesystem put_contents issue with owner/group
- Widget HTML Display Problem
- wordpress JSONAPI introspector always limits number at 10?
- How to replace file_get_contents() with a WordPress Filesystem call
- WordPress Specified file failed upload test
- Running rmdir function on post save
- Make Database query only when option is updated
- Getting a WordPress Debug Strategy
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Look for a file in a theme before loading from plugin
- Working of foreach loop with array
- Cleaning a filename after image sideloading a url that contains `%20`
- Adding Permalink to Slides with ‘Simple Nivo Slider’ plugin?
- Setting a post’s category
- Why doesn’t update_post_meta work for certain strings?
- post content and shortcode content displaying out of order
- “Rendering of admin template [path to template] failed”
- How to determine which capability to use?
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- WordPress Filesystem create CSS-File – get Shortcode ID for Name
- foreach argument to get specific file types getting too many returns
- Why does unzip_file always return true but nothing happens?
- Displaying $_FILES data (simlar to $_POST)
- WordPress upload path decalration
- Do Not Back Up? Is there any accepted way to tell backup and clone plugins to skip a certain file? [closed]
- How to prevent Composer dependency conflicts amongst WP plugins?
- Widget development – Drop down options won’t save
- Does using set_transient() function can lead to MySQL problems?
- permalinks with get variables
- dbDelta ALTER TABLE syntax?
- Dynamic URL to reference custom PHP files
- I should hide the API Key in a plugin?
- Some nav-menu filters do nothing
- How can I view all WP generated thumbnails in Media Manager?
- Only allow plugin to be activated on root site of multisite
- what is the best practice for including ‘wp-includes’ classes
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Custom Plugin Database relations
- How to put placeholder text in the main post input area?
- How can i get the title i specified in add_options_page for my header
- Is there a way to list tags order by post_meta field
- how to redirect to another post without getting headers already sent error?
- Redirect user to a particular link in 10 seconds after using wp_die
- How to check if txt file exists inside template folder?
- Change template dynamically
- add a class when login
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- Programmatically detect if wp-cron is disabled?
- Widget is to be compatible with all themes
- How to create a table with filters for my plugin
- Automated Cart Update With Alert Box Each Time
- wp_insert_user() function password never match
- How to setAttributes in Gutenberg block?
- Prevent third party plugin’s admin page access based on user type
- Adding widgets to my plugin page instead of WordPress dashboard
- How to insert data into database using wp cron job
- I have 2 plugins using the same wp_login action hook and one is not working
- Using a multiple element in widget form
- Update Data parameter of a wp_localize_script() call
- Download button in a plugin’s settings page
- Data not insert and update through ajax and jQuery in admin page?
- Full documentation about $args for register_rest_route?
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- WP Plugin with Upgrade option
- How can I control if post updated
- Proper Prepare Statement for ALTER TABLE and using AFTER
- Bootstrap Error in WordPress plugin
- wp_enqueue_scripts in a plugin’s class
- Proper way to create an administration page without adding it to the menu
- Settings API form – submit with AJAX
- Custom premium registration form and profile page for a WordPress Web Application
- Proper structure for first WP plugin?
- How to Disable Content Warning Dialog for Logged in users
- How to load another page file of my custom plugin file
- dbDelta not doing what it says
- Custom options page for themes
- How can I make my website with wordpress having on-spot editing feature as compared to concrete5 CMS?
- Custom field fetch error on woocommerce pdf invoice