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:
- A better way to override plugin’s JS files?
- How can I reduce the amount of files loaded/included per plugin?
- Disable author pages for specific users
- How do you import members from another system to WordPress and update passwords so they’ll work?
- Get info (url) from already enqueued styles
- WordPress import does not fetch images, but just links them
- How to create custom LOGIN and REGISTRATION forms?
- wamp server wordprocess whole from begining up on filezilla
- Show the “ratingValue” and “ratingCount” values of KK Star Ratings Plugin
- bulk post_content update
- Retrieve categories of a WooCommerce product in hierachical order
- Dequeue / Deregister script and replace it with a new plugin
- How to use get_categories() with Event Organiser plugin
- Setting up widgets in wordpress with a unique ID for the after_title argument
- What are WordPress installation percentages by version?
- Dashboard Disappears after Upgrade
- Show a confirmation message on plugin deactivation
- How extend shortcode default values for a plugin?
- The website has resulted in too many redirects (redirect plugin)?
- Hide Theme options and Customize Admin menu
- How to debug register_setting callback function
- Is it possible to require approval before a page edit is made live?
- How to edit Image layout in single product page in woocommerce on wordpress?
- How to provide a plugin which requires CMB2 (plugin dependencies)?
- Can a manually uploaded plugin be made to track updates from the WordPress.org plugin directory?
- 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]
- Dropdown menu on custom page with product to choose number of products per page
- Custom form action to handle data inside a plugin
- WP Post Template – Templates in own folder
- 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?
- Plugin options page with live preview?
- How to hide CSS by default and show on button press
- How to upload WordPress Images to remote web server and display those images in WordPress gallery [closed]
- How to update post’s content on post publish?
- WordPress backend delay by server side HTTP Request
- Anspress Customization: How to show logged in user votes on a single answer?
- Create a table with wordpress plugin boilerplate
- Ordering taxonomies by rank
- Embed plugin into Custom Page Template
- My homemade plugin is trying to update to someone else’s plugin
- Can I create a table on my DB without creating a plugin?
- Retrieving links and names of images from a NextGEN gallery [closed]
- How to get the first post and second post in a wordpress blog?
- Plugin development: what to prefix?
- Submit Form data to another page via Ajax (WordPress Way)
- Getting taxonomy images to display on single-post with their terms
- Where to populate custom terms in custom taxonomy in plugin?
- Is changing post from category in a large blog a good practice?
- Contact Form 7 – Show image on successful send? [closed]
- Send email to multiple addresses on Contact Form 7, but exclude personal details on all but one
- Display site language setting in source code
- add_submenu_page returns null
- simple-job-board Plugin throws an error on live server [closed]
- How to return the values from a row where a value occurs for the first time among the rows available?
- Smarter navigation plugin and custom taxonomies
- Remember the Meta Value With Radio Buttons
- How to embed a new string in url?
- Make 2 different WooCommerce checkout pages?
- Plugin code will not work properly inside a class [closed]
- WordPress – “tag page” additional, custom content
- Making a Contact Form 7 calendar entry “required” [closed]
- W3 Total Cache plugin chronic message
- How to prevent plugin, theme installation failures on WordPress?
- How to add a PW Gift Card to a Woocommerce Order request API?
- Get all image in media Gallery with alt/title?
- WP Function does not trigger on Webhook API Call
- In a plugin, How to update a json file using ajax
- how to add custom culomn to add user wordpress in plugin
- How to add specific script to WordPress webpage that will working with user input and databases
- Displaying different content depending on variable
- Found wp_deregister_script WARNING in redux framework plugin
- After reading 3 story by user ask for subscription popup
- Pay Employee via WordPress
- Fatal error: Uncaught Error: Call to undefined function
- How to echo a PHP Code After the Content
- Display information from metabox
- Share on social media created listing after submission
- Ajax call fails and returns [object Object]
- Create Biographies
- How to link file or image from wordpress plugin dir to theme by using themes function.php, is it possible?
- Direct URL to a template via plugin
- Which One Is Better For Managing Add Ons For Extensible Plugin?
- WP REST API Access-Control-Allow-Origin response is cached
- How to `remove_action` from plugin
- How to tell which Plugin is displaying?
- Wp Pagenavi how to display all results
- Posts are deleted everyday at night
- Get Core Functionality from Within a (Secondary) Plugin File
- Single dash converted to double dash
- How to provide access to specific plugin to all the user roles except subscriber in wordpress
- Output pure JSON wordpress
- WordPress plugin add_filter returning a link does not work. What is the correct way?
- How to create separate shop pages in woocommerce for each product category [closed]
- FacetWP custom display based on post type [closed]
- Creating a Table Row by Row
- Getting 504 Gateway Timeout Error on AWS Server! [closed]