weblog_ping

Send a pingback.

Description

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

Parameters (2)

0. $server — Optional. (string) => ''
Host of blog to connect to.
1. $path — Optional. (string) => ''
Path to send the ping.

Usage

  1. if ( !function_exists( 'weblog_ping' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Host of blog to connect to. 
  5. $server = ''; 
  6.  
  7. // Path to send the ping. 
  8. $path = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = weblog_ping($server, $path); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function weblog_ping($server = '', $path = '') { 
  2. include_once( ABSPATH . WPINC . '/class-IXR.php' ); 
  3. include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); 
  4.  
  5. // using a timeout of 3 seconds should be enough to cover slow servers 
  6. $client = new WP_HTTP_IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path)); 
  7. $client->timeout = 3; 
  8. $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); 
  9.  
  10. // when set to true, this outputs debug messages by itself 
  11. $client->debug = false; 
  12. $home = trailingslashit( home_url() ); 
  13. if ( !$client->query('weblogUpdates.extendedPing', get_option('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping 
  14. $client->query('weblogUpdates.ping', get_option('blogname'), $home);