Benvenuto nel nostro sito, ora troverai la soluzione di quello che stavi cercando.
Trova un server di pingback URI basato sull'URL dato.
Descrizione
Controlla l'HTML per il link rel="pingback" e le intestazioni x-pingback. Esegue prima il controllo delle intestazioni x-pingback e le restituisce, se disponibili. Il controllo del rel="pingback" ha più spese rispetto alla sola intestazione.
Parametri
- $url
-
(stringa)(Richiesto)URL da pingare.
- $deprecato
-
(stringa)(Opzionale)Non utilizzato.
Valore predefinito: ''
Ritorno
(stringa|falso) Stringa contenente l'URI in caso di successo, falso in caso di fallimento.
Fonte
File: wp-includes/comment.php
functiondiscover_pingback_server_uri($url,$deprecated=''){if(!empty($deprecated)){_deprecated_argument(__FUNCTION__,'2.7.0');}$pingback_str_dquote='rel="pingback"';$pingback_str_squote='rel='pingback'';/** @todo Should use Filter Extension or custom preg_match instead. */$parsed_url=parse_url($url);if(!isset($parsed_url['host'])){// Not a URL. This should never happen.returnfalse;}// Do not search for a pingback server on our own uploads.$uploads_dir=wp_get_upload_dir();if(0===strpos($url,$uploads_dir['baseurl'])){returnfalse;}$response=wp_safe_remote_head($url,array('timeout'=>2,'httpversion'=>'1.0',));if(is_wp_error($response)){returnfalse;}if(wp_remote_retrieve_header($response,'x-pingback')){returnwp_remote_retrieve_header($response,'x-pingback');}// Not an (x)html, sgml, or xml page, no use going further.if(preg_match('#(image|audio|video|model)/#is',wp_remote_retrieve_header($response,'content-type'))){returnfalse;}// Now do a GET since we're going to look in the HTML headers (and we're sure it's not a binary file).$response=wp_safe_remote_get($url,array('timeout'=>2,'httpversion'=>'1.0',));if(is_wp_error($response)){returnfalse;}$contents=wp_remote_retrieve_body($response);$pingback_link_offset_dquote=strpos($contents,$pingback_str_dquote);$pingback_link_offset_squote=strpos($contents,$pingback_str_squote);if($pingback_link_offset_dquote||$pingback_link_offset_squote){$quote=($pingback_link_offset_dquote)?'"':''';$pingback_link_offset=('"'===$quote)?$pingback_link_offset_dquote:$pingback_link_offset_squote;$pingback_href_pos=strpos($contents,'href=',$pingback_link_offset);$pingback_href_start=$pingback_href_pos+6;$pingback_href_end=strpos($contents,$quote,$pingback_href_start);$pingback_server_url_len=$pingback_href_end-$pingback_href_start;$pingback_server_url=substr($contents,$pingback_href_start,$pingback_server_url_len);// We may find rel="pingback" but an incomplete pingback URL.if($pingback_server_url_len>0){// We got it!return$pingback_server_url;}}returnfalse;}
Correlato
Utilizzi
Usi | Descrizione |
---|---|
wp-includes/functions.php: wp_get_upload_dir() |
Recupera le informazioni sulla directory di upload. |
wp-includes/functions.php: _deprecated_argument() |
Segna un argomento di una funzione come deprecato e informa quando è stato usato. |
wp-includes/http.php: wp_safe_remote_head() |
Recupera la risposta grezza di una richiesta HTTP sicura usando il metodo HEAD. |
wp-includes/http.php: wp_remote_retrieve_header() |
Recupera una singola intestazione per nome dalla risposta grezza. |
wp-includes/http.php: wp_safe_remote_get() |
Recupera la risposta grezza di una richiesta HTTP sicura con il metodo GET. |
wp-includes/http.php: wp_remote_retrieve_body() |
Recupera solo il corpo dalla risposta grezza. |
wp-includes/load.php: is_wp_error() |
Controlla se la variabile data è un errore di WordPress. |
Utilizzato da
Usato da | Descrizione |
---|---|
wp-includes/comment.php: pingback() |
Effettua il pingback dei link trovati in un post. |
Changelog
Versione | Descrizione |
---|---|
1.5.0 | Introdotto. |
Sezione recensioni e valutazioni
Hai la possibilità di aggiungere valore alle nostre informazioni pagando la tua anzianità nelle interpretazioni.