wp_safe_remote_head example


function wp_get_http_headers( $url$deprecated = false ) {
    if ( ! empty( $deprecated ) ) {
        _deprecated_argument( __FUNCTION__, '2.7.0' );
    }

    $response = wp_safe_remote_head( $url );

    if ( is_wp_error( $response ) ) {
        return false;
    }

    return wp_remote_retrieve_headers( $response );
}

/** * Determines whether the publish date of the current post in the loop is different * from the publish date of the previous post in the loop. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ * Conditional Tags} article in the Theme Developer Handbook. * * @since 0.71 * * @global string $currentday The day of the current post in the loop. * @global string $previousday The day of the previous post in the loop. * * @return int 1 when new day, 0 if not a new day. */
if ( ! isset( $parsed_url['host'] ) ) { // Not a URL. This should never happen.         return false;
    }

    // Do not search for a pingback server on our own uploads.     $uploads_dir = wp_get_upload_dir();
    if ( str_starts_with( $url$uploads_dir['baseurl'] ) ) {
        return false;
    }

    $response = wp_safe_remote_head(
        $url,
        array(
            'timeout'     => 2,
            'httpversion' => '1.0',
        )
    );

    if ( is_wp_error( $response ) ) {
        return false;
    }

    
Home | Imprint | This part of the site doesn't use cookies.