mirror of
https://ghproxy.net/https://github.com/fairpm/fair-plugin.git
synced 2025-09-04 12:45:45 +08:00
combine conditional checks
Signed-off-by: Andy Fragen <andy@thefragens.com>
This commit is contained in:
parent
945d0c0077
commit
e8f58a6c48
1 changed files with 12 additions and 14 deletions
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue