On this page
weblog_ping( string $server = '', string $path = '' )
Sends a pingback.
Parameters
$serverstring Optional-
Host of blog to connect to.
Default:
'' $pathstring Optional-
Path to send the ping.
Default:
''
Source
File: wp-includes/comment.php. View all references
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 );
}
}
Related
Uses
| Uses | Description |
|---|---|
| WP_HTTP_IXR_Client::__construct() wp-includes/class-wp-http-ixr-client.php | |
| trailingslashit() wp-includes/formatting.php | Appends a trailing slash. |
| get_bloginfo() wp-includes/general-template.php | Retrieves information about the current site. |
| home_url() wp-includes/link-template.php | Retrieves the URL for the current site where the front end is accessible. |
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
Used By
| Used By | Description |
|---|---|
| generic_ping() wp-includes/comment.php | Sends pings to all of the ping site services. |
Changelog
| Version | Description |
|---|---|
| 1.2.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/weblog_ping