wp_xmlrpc_server::mt_getTrackbackPings()
Retrieves trackbacks sent to a given post.
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->mt_getTrackbackPings( $post_id );
- $post_id(int) (required)
- -
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
Since 1.5.0 | Introduced. |
wp_xmlrpc_server::mt_getTrackbackPings() wp xmlrpc server::mt getTrackbackPings code WP 6.7.2
public function mt_getTrackbackPings( $post_id ) { global $wpdb; /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this ); $actual_post = get_post( $post_id, ARRAY_A ); if ( ! $actual_post ) { return new IXR_Error( 404, __( 'Sorry, no such post.' ) ); } $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(); } $trackback_pings = array(); foreach ( $comments as $comment ) { if ( 'trackback' === $comment->comment_type ) { $content = $comment->comment_content; $title = substr( $content, 8, ( strpos( $content, '</strong>' ) - 8 ) ); $trackback_pings[] = array( 'pingTitle' => $title, 'pingURL' => $comment->comment_author_url, 'pingIP' => $comment->comment_author_IP, ); } } return $trackback_pings; }