weblog_ping

函式
weblog_ping ( $server = '', $path = '' )
引數
  • (string) $server Host of blog to connect to.
    Required:
    Default: (empty)
  • (string) $path Path to send the ping.
    Required:
    Default: (empty)
定義位置
相關方法
get_blog_optionbloginfowp_loginadd_blog_optiondelete_blog_option
引入
1.2.0
棄用
-

weblog_ping: 這個函式用於通知一個外部服務列表,即網站已經被更新。它不需要任何引數,依靠WordPress選項中指定的服務列表。

發出一個pingback。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function weblog_ping( $server = '', $path = '' ) {
include_once ABSPATH . WPINC . '/class-IXR.php';
include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';
// Using a timeout of 3 seconds should be enough to cover slow servers.
$client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
$client->timeout = 3;
$client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );
// When set to true, this outputs debug messages by itself.
$client->debug = false;
$home = trailingslashit( home_url() );
if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping.
$client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home );
}
}
function weblog_ping( $server = '', $path = '' ) { include_once ABSPATH . WPINC . '/class-IXR.php'; include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php'; // Using a timeout of 3 seconds should be enough to cover slow servers. $client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) ); $client->timeout = 3; $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); // When set to true, this outputs debug messages by itself. $client->debug = false; $home = trailingslashit( home_url() ); if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping. $client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home ); } }
function weblog_ping( $server = '', $path = '' ) {
	include_once ABSPATH . WPINC . '/class-IXR.php';
	include_once ABSPATH . WPINC . '/class-wp-http-ixr-client.php';

	// Using a timeout of 3 seconds should be enough to cover slow servers.
	$client             = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' === $path ) ) ? false : $path ) );
	$client->timeout    = 3;
	$client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' );

	// When set to true, this outputs debug messages by itself.
	$client->debug = false;
	$home          = trailingslashit( home_url() );
	if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping.
		$client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home );
	}
}

常見問題

FAQs
檢視更多 >