Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
PUM_AssetCache::is_file_accessible( string $filename )
Tests whether the file is accessible and returns 200 status code
Description Description
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Warning: foreach() argument must be of type array|object, string given in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 813
Warning: Array to string conversion in /mnt/data/home/502433.cloudwaysapps.com/rhbymdevka/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 808
Parameters Parameters
- $filename
-
(Required) Filename of cache file to test.
Return Return
(bool) True if file exists and is accessible
Source Source
File: classes/AssetCache.php
private static function is_file_accessible( $filename ) { if ( ! $filename || empty( $filename ) || ! is_string( $filename ) ) { PUM_Utils_Logging::instance()->log( 'Cannot check if file is accessible. Filename passed: ' . print_r( $filename, true ) ); return false; } $cache_url = PUM_Helpers::get_cache_dir_url(); if ( false === $cache_url ) { PUM_Utils_Logging::instance()->log( 'Cannot access cache file when tested. Cache URL returned false.' ); } $protocol = is_ssl() ? 'https:' : 'http:'; $file = $protocol . $cache_url . '/' . $filename; $results = wp_remote_request( $file, array( 'method' => 'HEAD', 'sslverify' => false, )); // If it returned a WP_Error, let's log its error message. if ( is_wp_error( $results ) ) { $error = $results->get_error_message(); PUM_Utils_Logging::instance()->log( sprintf( 'Cannot access cache file when tested. Tested file: %s Error given: %s', esc_html( $file ), esc_html( $error ) ) ); } // If it returned valid array... if ( is_array( $results ) && isset( $results['response'] ) ) { $status_code = $results['response']['code']; // ... then, check if it's a valid status code. Only if it is a valid 2XX code, will this method return true. if ( false !== $status_code && ( 200 <= $status_code && 300 > $status_code ) ) { return true; } else { PUM_Utils_Logging::instance()->log( sprintf( 'Cannot access cache file when tested. Status code received was: %s', esc_html( $status_code ) ) ); } } return false; }
Expand full source code Collapse full source code View on Trac