$wp_filesystem->get_contents()
$wp_filesystem->get_contents()
replaced file_get_contents()
perfectly as a drop-in replacement. Of course, it must be initiated with WP_Filesystem();
first.
Here is a before and after example…
Before:
if ( (strpos ( file_get_contents ( $check_this_file ),
$check_this_string ) === false) ) {...}
After:
WP_Filesystem();
if ( (strpos ( $wp_filesystem->get_contents ( $check_this_file ),
$check_this_string ) === false) ) {...}
Related Posts:
- Standard location for plugin to save/cache files?
- Do I need to use WP_Filesystem when creating a downloadable file on the fly?
- $wp_filesystem returns NULL. What are the dependencies?
- Why cant the WP Filesystem API read googlefonts.json?
- Using wp_filesystem in Plugins to store customizer settings
- Where to write custom logs in WordPress
- wp_filesystem put_contents issue with owner/group
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- 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
- Why does unzip_file always return true but nothing happens?
- WordPress upload path decalration
- Is it ever okay to include inline CSS in plugins?
- Is it mandatory to use $wpdb->prefix in custom tables
- add_action hook for completely new post?
- Is get_option function cached?
- How do I log plugin (cron) actions?
- Is there a hook for when you switch themes?
- Problems after wp_set_password() containing an apostrophe
- Error getting correct blog_id on MU from functions.php
- product-attribute-slug-is-too-long-28-characters-max
- Front-End Form Submission in Shortcode
- Confusion on WP Nonce usage in my Plugin
- Plugin Localization
- Error : “Updating failed: The response is not a valid JSON response” with custom shortcode
- array_map() for sanitizing $_POST
- Add media and attach images to pages
- calling jquery function on plugin page
- Is there a faster way than wp_insert_post to add content to a blog
- Show comments fields in two columns
- Ajax in WordPress – path issue
- How to determine if the current file is loaded in a plugin or in a theme?
- Decrease RSS cache time in plugin?
- Which action is triggered when a theme was modified?
- Check if someone is editing a post (this content is currently locked)
- How to add a custom tag in contact form 7 and change the output in email?
- WordPress setting with select – where is my mistake?
- How can I create a plugin that changes the title color of a website?
- How to check if Woocommerce Order number equals to post ID?
- Two functions utilizing registration_errors filter
- Issue plugin commands in admin settings page
- Creating a shortcode, but getting tied up with OOP and Classes?
- Call PHP file within a plugin to activate function
- add_action not calling back to function
- Adding custom fields to WordPress nav menus
- Example Dashboard Widget, Cancel not working
- add_shortcode() not working inside of function
- How to add and remove a page
- correct way to call javascript into hook function
- “dashboard”-named PHP file doesn’t get included
- How to get plugin activate URL to use URL vars?
- rewrite URL based on selected taxonomy for post page
- is it recommended to use WP_List_Table?
- Multiple Plugin best practice in Multisite
- wp-cron and execution of code in is_admin() included script
- use of do_action() without any functions attached
- json_decode does not work on WordPress
- Delist entries in the_loop
- esc_html__() and __() not working within arrays
- Uploaded attachment not set as featured image
- WordPress – manually relate a post to page(s)?
- Styles don’t load correctly. Insecure content
- How to use apiFetch to get author information in Gutenberg properly?
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- Can we use a library under MIT license in a WooCommerce plugin?
- How to display the specific post content by using POST ID
- Soap web service request from wordpress plugin
- How to list all images used on a specific page?
- Create fixed static pages
- Use options to control jQuery plugin
- Including template in shortcodes
- Is there anything special required to make a plugin work in a multisite environment?
- How to exclude categories from get_categories() select list inside a widget admin panel
- How to exclude “uncategorized” from custom categories widget?
- How to create wordpress media library UI on plugin page
- Why my theme’s css not working on another site
- Override category archive page title (not the head title)
- Using custom IDP with WP
- Trying to run a Ajax request from a checkout form in woocommerce via a custom plugin
- get_queried_object_id combined with wp_redirect gets wrong id
- Using WordPress Boilerplate (WPBP) for WP Multisite Plugin
- WordPress5.2.3: Better File Download Plugin validation issue
- How do I make secure API calls from my WordPress plugin?
- esc_attr() on hard coded string
- Creating a return url for getting data from external api
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- How to handle ajax Request in a complex-structured plugin?
- How to use functions from Woocommerce documentation?
- Is it possible to restore an expired transient?
- WP API users per page
- action callback, for action dispatched as reported by hook sniffer, not called
- How to use get_pages( ) correctly with ‘child_of’ to replace page with child page
- variable created in page.php is null inside of header.php
- Access WordPress Tag Function From Modal
- Problem with Poedit [closed]
- Insert plugin html content to a specific spot in the frontpage
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Need someone to help you want to manage points for members to code interface functions? thank you
- WordPress plugin boilerplate AJAX functionality
- Run different permission_callback depending on HTTP method of custom REST API endpoint