You shouldn’t use file_get_contents() for remote requests. WordPress does the heavy lifting for you when determining what is compatible on your host.
Instead of file_get_contents() use the following to check for 404s:
$request = wp_remote_get($url);
$status = $request['response']['code'];
if($status === 404){
//do something
}
You can also use wp_remote_retrieve_body($request) to get the contents of the request.
Related Posts:
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- How can I reduce the amount of files loaded/included per plugin?
- How to create custom LOGIN and REGISTRATION forms?
- wamp server wordprocess whole from begining up on filezilla
- How to add product images using script?
- Retrieve categories of a WooCommerce product in hierachical order
- How do I make a wordpress plugin with menu item etc
- How to use get_categories() with Event Organiser plugin
- Setting up widgets in wordpress with a unique ID for the after_title argument
- Dashboard Disappears after Upgrade
- The website has resulted in too many redirects (redirect plugin)?
- Hide Theme options and Customize Admin menu
- Make specific products accessible only to a user role in WooCommerce
- Is it possible to require approval before a page edit is made live?
- Namespaces declared by a theme/plugin should start with the theme/plugin prefix. Found: “eustatos\test_plugin”
- How to provide a plugin which requires CMB2 (plugin dependencies)?
- WooCommerce – How can I list the same product as a variation and also as a simple product [closed]
- Memberpress functions/documentation
- Editing admin pages in WordPress [closed]
- scrolltop always 0, can’t trigger script
- Add column to plugins table screen
- Auto activate plugin with unique user settings
- Pagination Broken on Static Pages but Works on Blog Articles
- How to change constants in WordPress wp-config.php programmatically?
- Parse error: syntax error, unexpected ‘new’ (T_NEW) in /misc/41/000/204/381/9/user/web/ragami.net/wp-settings.php on line 219
- add_shortcode is not working in plugin where others are working
- Plugin options page with live preview?
- WordPress plugin admin html being shown in Customizer iframe
- WordPress backend delay by server side HTTP Request
- Anspress Customization: How to show logged in user votes on a single answer?
- accessing parent variables in child construct without executing action in parent
- Ajax : Call undefined function plugin_function() … can’t call any plugin function
- Setup wp_schedule_event within a custom plugin
- How to over-ride a file in a plugin? [closed]
- execute function after one completed
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- WHy custom plugin slows down the loading of the pages?
- How Can I Safely Remove WP-Super Cache without messing my site up? [closed]
- Display Plugin Panels Outside of Admin Areas
- What are the correct permissions so WP doesn’t ask for FTP credentials if installing plugin?
- Super slow plugin page (lots of error 500)
- Looking for Gallery Plugin [closed]
- Notice: Undefined index: mtral_field_subscriber
- Delete free version plugin will also delete premium plugin
- URL rewrite with external JSON query
- How to delete a theme using AJAX
- Adding a responsive grid onto a page (without using a Bootstrap theme) [closed]
- Class or function wrapper for plugin code
- Licensing a Plugin [closed]
- Add a function call after content automatically?
- Var_dump ACF “API”
- Equivalent of admin.php for public pages
- Detect plugin/theme installation (via upload)
- WP Editor, save content and category on frontend
- Adding a pagenavi to function for displaying bookmarks
- google +1 like polling system
- A good heatmapping plugin for WordPress? (No 3rd-party services please) [closed]
- TN3 Plugin Not Working Under IIS / WebMatrix
- Limiting title characters in the AZIndex plugin
- What is the most efficient way of adding additional functionaliy for admin only
- Disable WordPress Theme Browser and Plugin Browser
- Add hook after content without formatting
- Sold out Label for variable products which are partially sold out
- admin_post hook not firing function inside class
- how to auto random increment for post view
- Merging new theme and plugins from development site to production
- .com creates automated link in post
- post id or permalink auto-incrementing number and reset everyday
- WordPress sitemap “Extra content at the end of the document”
- Looking for Image Slider that is based on default WP Media Library
- catch urls with specific pattern and show specific content for them by plugin
- Not displaying Woocommerce product page in lightbox
- Title and date of last post stays on page even after replacing the_content
- Above the fold plugin error “The Proxy Cache directory contains n cache entries.”
- User / membership Plugin [closed]
- Can we validate data from jquery
- Fetching WP.me shortlinks for posts using WP Rest API
- How to display widget in front end?
- show-hide based on select option jquery wordpress
- Where to store media uploaded by the plugin?
- error_log() not working in add_filter auto update callback
- Follow author on muti-user WordPress site
- Creating a register settings class that supports extended classes
- Add a checkbox in plugin options page and make it actually work
- WordPress crashes when I click add new plugin
- wp_insert_post hook not being called with wp_publish_post or wp_insert_post?
- Calling a function from a link in WordPress
- Live coding in WordPress
- Making a particular kind of search engine with WordPress?
- SMS messaging twordpress plugin [closed]
- Looking for a home page carousel [closed]
- Sell “create a post”, paid account for post creation
- How to remove site name (https://exp.com/) from WORDPRESS site source links or file load url
- How to customized post slider layout in elementor wordpress [closed]
- I’m getting the following error: Fatal error: Uncaught Error: Call to undefined function oil_paint_regeneration() [closed]
- Can’t change login logo & css – older plugin data blocking?
- Learnpress FATAL ERROR
- is_singular() in mu-plugins not working
- How to access a function declared in child theme’s functions file in a plugin file?
- WordPress child theme widget customization – Eduma