weblog_ping() WordPress Function

The weblog_ping() function is used to notify a specified URL when a new post is published to a WordPress site. This is useful for site owners who want to be notified when new content is published so they can index it or syndicate it.

weblog_ping( string $server = '', string $path = '' ) #

Sends a pingback.


Parameters

$server

(string)(Optional)Host of blog to connect to.

Default value: ''

$path

(string)(Optional)Path to send the ping.

Default value: ''


Top ↑

Source

File: wp-includes/comment.php

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 );
	}
}


Top ↑

Changelog

Changelog
VersionDescription
1.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More