PluginProbe
FeedWordPress / 2012.1212
FeedWordPress v2012.1212
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | feedwordpressrpc.class.php +21 -28 trunk2012.1212 View file →
@@ -3,12 +3,12 @@
3 3 ## XML-RPC HOOKS: accept XML-RPC update pings from Contributors ################
4 4 ################################################################################
5 5
6 6 class FeedWordPressRPC {
7 - public function __construct () {
7 + function FeedWordPressRPC () {
8 8 add_filter('xmlrpc_methods', array($this, 'xmlrpc_methods'));
9 9 }
10 -
10 +
11 11 function xmlrpc_methods ($args = array()) {
12 12 $args['weblogUpdates.ping'] = array($this, 'ping');
13 13 $args['feedwordpress.subscribe'] = array($this, 'subscribe');
14 14 $args['feedwordpress.deactivate'] = array($this, 'deactivate');
@@ -15,21 +15,24 @@
15 15 $args['feedwordpress.delete'] = array($this, 'delete');
16 16 $args['feedwordpress.nuke'] = array($this, 'nuke');
17 17 return $args;
18 18 }
19 -
19 +
20 20 function ping ($args) {
21 21 global $feedwordpress;
22 -
22 +
23 23 $delta = @$feedwordpress->update($args[1]);
24 24 if (is_null($delta)):
25 25 return array('flerror' => true, 'message' => "Sorry. I don't syndicate <$args[1]>.");
26 26 else:
27 - $mesg = array(); // unused? (gwyneth 20230920)
28 - return array('flerror' => false, 'message' => "Thanks for the ping.".fwp_update_set_results_message($delta));
27 + $mesg = array();
28 + if (isset($delta['new'])) { $mesg[] = ' '.$delta['new'].' new posts were syndicated'; }
29 + if (isset($delta['updated'])) { $mesg[] = ' '.$delta['updated'].' existing posts were updated'; }
30 +
31 + return array('flerror' => false, 'message' => "Thanks for the ping.".implode(' and', $mesg));
29 32 endif;
30 33 }
31 -
34 +
32 35 function validate (&$args) {
33 36 global $wp_xmlrpc_server;
34 37
35 38 // First two params are username/password
@@ -36,12 +39,11 @@
36 39 $username = $wp_xmlrpc_server->escape(array_shift($args));
37 40 $password = $wp_xmlrpc_server->escape(array_shift($args));
38 41
39 42 $ret = array();
40 - // $user is unused. Is it just a return value, or should it be stored somewhere? (gwyneth 20230920)
41 - if ( ! $user = $wp_xmlrpc_server->login($username, $password) ) :
43 + if ( !$user = $wp_xmlrpc_server->login($username, $password) ) :
42 44 $ret = $wp_xmlrpc_server->error;
43 - elseif ( !current_user_can('manage_links')) :
45 + elseif (!current_user_can('manage_links')) :
44 46 $ret = new IXR_Error(401, 'Sorry, you cannot change the subscription list.');
45 47 endif;
46 48 return $ret;
47 49 }
@@ -52,24 +54,15 @@
52 54 // The remaining params are feed URLs
53 55 foreach ($args as $arg) :
54 56 $finder = new FeedFinder($arg, /*verify=*/ false, /*fallbacks=*/ 1);
55 57 $feeds = array_values(array_unique($finder->find()));
56 -
58 +
57 59 if (count($feeds) > 0) :
58 - // $link_id is never used, possibly because it's just a discardable return value. However,
59 - // it _can_ return a WP_Error, so it might make sense to check for it? (gwyneth 20230920)
60 60 $link_id = FeedWordPress::syndicate_link(
61 61 /*title=*/ feedwordpress_display_url($feeds[0]),
62 62 /*homepage=*/ $feeds[0],
63 63 /*feed=*/ $feeds[0]
64 64 );
65 - // just to make sure! (gwyneth 20230920)
66 - if ( is_wp_error( $link_id ) ) :
67 - FeedWordPress::diagnostic(
68 - 'fwp-rpc/subscribe',
69 - implode( '|', $link_id->get_error_messages() )
70 - );
71 - endif;
72 65 $ret[] = array(
73 66 'added',
74 67 $feeds[0],
75 68 $arg,
@@ -83,9 +76,9 @@
83 76 endforeach;
84 77 endif;
85 78 return $ret;
86 79 } /* FeedWordPressRPC::subscribe () */
87 -
80 +
88 81 function unsubscribe ($method, $args) {
89 82 $ret = $this->validate($args);
90 83 if (is_array($ret)) : // Success
91 84 // The remaining params are feed URLs
@@ -90,16 +83,16 @@
90 83 if (is_array($ret)) : // Success
91 84 // The remaining params are feed URLs
92 85 foreach ($args as $arg) :
93 86 $link_id = FeedWordPress::find_link($arg);
94 -
95 - if ( ! $link_id) :
87 +
88 + if (!$link_id) :
96 89 $link_id = FeedWordPress::find_link($arg, 'link_url');
97 90 endif;
98 -
91 +
99 92 if ($link_id) :
100 93 $link = new SyndicatedLink($link_id);
101 -
94 +
102 95 $link->{$method}();
103 96 $ret[] = array(
104 97 'deactivated',
105 98 $arg,
@@ -113,17 +106,17 @@
113 106 endforeach;
114 107 endif;
115 108 return $ret;
116 109 } /* FeedWordPress::unsubscribe () */
117 -
110 +
118 111 function deactivate ($args) {
119 112 return $this->unsubscribe('deactivate', $args);
120 113 } /* FeedWordPressRPC::deactivate () */
121 -
114 +
122 115 function delete ($args) {
123 116 return $this->unsubscribe('delete', $args);
124 117 } /* FeedWordPressRPC::delete () */
125 -
118 +
126 119 function nuke ($args) {
127 120 return $this->unsubscribe('nuke', $args);
128 121 } /* FeedWordPressRPC::nuke () */
129 122 } /* class FeedWordPressRPC */