Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




url_is_accessable_via_ssl [ WordPress Function ]

url_is_accessable_via_ssl ( $url )
Parameters:
  • (string) $url
Returns:
  • (bool) Whether SSL access is available
Defined at:



Determines if the blog can be accessed over SSL.

Determines if blog can be accessed over SSL by using cURL to access the site using the https in the siteurl. Requires cURL extension to work correctly.

Source


<?php
function url_is_accessable_via_ssl($url)
{
    if (
in_array('curl'get_loaded_extensions())) {
        
$ssl preg_replace'/^http:\/\//''https://',  $url );

        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL$ssl);
        
curl_setopt($chCURLOPT_FAILONERRORtrue);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
        
curl_setopt($chCURLOPT_CONNECTTIMEOUT5);

        
curl_exec($ch);

        
$status curl_getinfo($chCURLINFO_HTTP_CODE);
        
curl_close ($ch);

        if (
$status == 200 || $status == 401) {
            return 
true;
        }
    }
    return 
false;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics