Make WordPress Core

Changeset 1672 for trunk/xmlrpc.php


Ignore:
Timestamp:
09/16/2004 03:20:39 PM (22 years ago)
Author:
michelvaldrighi
Message:

added pingback.extensions.getPingbacks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r1671 r1672  
    114114                  // PingBack
    115115                  'pingback.ping' => 'this:pingback_ping',
     116                  'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
    116117
    117118                  'demo.sayHello' => 'this:sayHello',
     
    10171018          global $wpdb;
    10181019
    1019           $post_ID = intval($args[0]);
     1020          $post_ID = intval($args);
    10201021
    10211022          $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     
    11111112
    11121113                // let's find which post is linked to
     1114                // FIXME: does url_to_postid() cover all these cases already?
     1115                //        if so, then let's use it and drop the old code.
    11131116                $urltest = parse_url($pagelinkedto);
    11141117                if ($post_ID = url_to_postid($pagelinkedto)) {
     
    12621265                return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
    12631266        }
     1267
     1268
     1269        /* pingback.extensions.getPingbacks returns an array of URLs
     1270           that pingbacked the given URL
     1271           specs on http://www.aquarionics.com/misc/archives/blogite/0198.html */
     1272        function pingback_extensions_getPingbacks($args) {
     1273
     1274                global $wpdb;
     1275
     1276                $url = $args;
     1277
     1278                $post_ID = url_to_postid($url);
     1279                if (!$post_ID) {
     1280                        // We aren't sure that the resource is available and/or pingback enabled
     1281                        return '0x0021';
     1282                }
     1283
     1284                $actual_post = wp_get_single_post($post_ID, ARRAY_A);
     1285
     1286                if (!$actual_post) {
     1287                        // No such post = resource not found
     1288                        return '0x0020';
     1289                }
     1290
     1291                $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
     1292
     1293                if (!$comments) {
     1294                        return array();
     1295                }
     1296
     1297                $pingbacks = array();
     1298                foreach($comments as $comment) {
     1299                        if ((strpos($comment->comment_content, '<pingback />') === 0)
     1300                            || ('pingback' == $comment->comment_type)) {
     1301                                $pingbacks[] = $comment->comment_author_url;
     1302                        }
     1303                }
     1304
     1305                return $pingbacks;
     1306        }
    12641307}
    12651308
Note: See TracChangeset for help on using the changeset viewer.