wp_xmlrpc_server::pingback_extensions_getPingbacks()publicWP 1.5.0

Retrieves an array of URLs that pingbacked the given URL.

Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html

Method of the class: wp_xmlrpc_server{}

Hooks from the method

Return

Array|IXR_Error.

Usage

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->pingback_extensions_getPingbacks( $url );
$url(string) (required)
-

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 1.5.0 Introduced.

wp_xmlrpc_server::pingback_extensions_getPingbacks() code WP 6.4.3

public function pingback_extensions_getPingbacks( $url ) {
	global $wpdb;

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this );

	$url = $this->escape( $url );

	$post_id = url_to_postid( $url );
	if ( ! $post_id ) {
		// We aren't sure that the resource is available and/or pingback enabled.
		return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
	}

	$actual_post = get_post( $post_id, ARRAY_A );

	if ( ! $actual_post ) {
		// No such post = resource not found.
		return $this->pingback_error( 32, __( 'The specified target URL does not exist.' ) );
	}

	$comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );

	if ( ! $comments ) {
		return array();
	}

	$pingbacks = array();
	foreach ( $comments as $comment ) {
		if ( 'pingback' === $comment->comment_type ) {
			$pingbacks[] = $comment->comment_author_url;
		}
	}

	return $pingbacks;
}