combine conditional checks

Signed-off-by: Andy Fragen <andy@thefragens.com>
This commit is contained in:
Andy Fragen 2025-08-16 09:04:05 -07:00
parent 945d0c0077
commit e8f58a6c48

View file

@ -176,20 +176,18 @@ function fetch_metadata_doc( string $url ) {
* @return bool|array
*/
function fetch_metadata_from_local( $response, $url ) {
if ( ! $response ) {
if ( str_contains( $url, home_url() ) ) {
$did = explode( '/', parse_url( $url, PHP_URL_PATH ) );
$did = array_pop( $did );
$body = wp_cache_get( 'fair-metadata-endpoint-' . $did, 'metadata-endpoints' );
$response = [];
$response = [
'headers' => [],
'body' => json_encode( $body ),
];
$response = ! $body ? false : $response;
if ( $response ) {
wp_cache_set( CACHE_KEY . md5( $url ), $response, 'metadata-docs', CACHE_LIFETIME );
}
if ( ! $response && str_contains( $url, home_url() ) ) {
$did = explode( '/', parse_url( $url, PHP_URL_PATH ) );
$did = array_pop( $did );
$body = wp_cache_get( 'fair-metadata-endpoint-' . $did, 'metadata-endpoints' );
$response = [];
$response = [
'headers' => [],
'body' => json_encode( $body ),
];
$response = ! $body ? false : $response;
if ( $response ) {
wp_cache_set( CACHE_KEY . md5( $url ), $response, 'metadata-docs', CACHE_LIFETIME );
}
}