From 512c20e9b91cf28f89322bfeaa6de7dbee8c6514 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Sun, 21 Mar 2004 07:36:07 +0000 Subject: [PATCH] Generic update pinging. Needs review. git-svn-id: https://develop.svn.wordpress.org/trunk@982 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/post.php | 4 +--- wp-includes/functions.php | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/wp-admin/post.php b/wp-admin/post.php index f001b32fc9..1d5eecab45 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -161,14 +161,12 @@ switch($action) { if((get_settings('use_geo_positions')) && ($post_latf != null) && ($post_lonf != null)) { pingGeoUrl($post_ID); } - pingWeblogs($blog_ID); - pingBlogs($blog_ID); if ($post_pingback) { pingback($content, $post_ID); } - apply_filters('action_publish_post', $post_ID); + do_action('publish_post', $post_ID); // Time for trackbacks $to_ping = $wpdb->get_var("SELECT to_ping FROM $tableposts WHERE ID = $post_ID"); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d56deda654..a5561915cd 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -561,6 +561,49 @@ function timer_stop($display=0,$precision=3) { //if called like timer_stop(1), w return $timetotal; } +function weblog_ping($server = '', $path = '') { + $f = new xmlrpcmsg('weblogUpdates.ping', + array(new xmlrpcval(get_settings('blog_name'), 'string'), + new xmlrpcval(get_settings('blog_url') ,'string'))); + $c = new xmlrpc_client($path, $server, 80); + $r = $c->send($f); + if (!$r) { die("send failed"); } + + if ($debug) { + print "

Response Object Dump:

\n"; + print "
\n";
+    print_r($r);
+    print "
\n"; + } + + $v=@xmlrpc_decode($r->value()); + if (!$r->faultCode()) { + $result['message'] = "

"; + $result['message'] = $result['message'] . $v["message"] . "
\n"; + $result['message'] = $result['message'] . "

"; + } else { + $result['err'] = $r->faultCode(); + $result['message'] = "\n"; + } + + print '
' . $result['message'] . '
'; +} + +function generic_ping($post_id = 0) { + $services = get_settings('ping_sites'); + $services = preg_replace("|(\s)+|", '$1', $serivces); // Kill dupe lines + $services = explode("\n", trim($services)); + foreach ($services as $service) { + $uri = parse_url($service); + weblog_ping($uri['host'], $uri['path']); + } +} + +add_action('publish_post', 'generic_ping'); // pings Weblogs.com function pingWeblogs($blog_ID = 1) {