Skip to content
Newer
Older
100644 3408 lines (2779 sloc) 90.4 KB
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
1 <?php
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
2 /**
3 * XML-RPC protocol support for WordPress
4 *
5 * @license GPL v2 <./license.txt>
6 * @package WordPress
7 */
8
9 /**
10 * Whether this is a XMLRPC Request
11 *
12 * @var bool
13 */
cb09336 Make the xmlrpc user the current user. fixes #2273
ryan authored Jan 13, 2006
14 define('XMLRPC_REQUEST', true);
15
16 // Some browser-embedded clients send cookies. We don't want them.
17 $_COOKIE = array();
18
321c310 Remove trailing whitespace
ryan authored Sep 3, 2007
19 // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
f432ed6 Fix for PHP version 5.2.2 where $HTTP_RAW_POST_DATA isn't set. fixes …
rob1n authored May 11, 2007
20 // but we can do it ourself.
21 if ( !isset( $HTTP_RAW_POST_DATA ) ) {
22 $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
23 }
24
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
25 // fix for mozBlog and other cases where '<?xml' isn't on the very first line
60ccea9 Check if HTTP_RAW_POST_DATA is set to avoid undefined var warning. Pr…
ryan authored Jan 30, 2006
26 if ( isset($HTTP_RAW_POST_DATA) )
27 $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
28
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
29 /** Include the bootstrap for setting up WordPress environment */
5b81135 Allow wp-config.php to exist one level up from WordPress root directo…
ryan authored May 21, 2008
30 include('./wp-load.php');
af8c37f Add RSD support. See http://archipelago.phrasewise.com/rsd
matt authored Nov 7, 2005
31
321c310 Remove trailing whitespace
ryan authored Sep 3, 2007
32 if ( isset( $_GET['rsd'] ) ) { // http://archipelago.phrasewise.com/rsd
9ce729e Content-Type, not Content-type, as headers are case sensitive. Props …
rob1n authored Jun 2, 2007
33 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
af8c37f Add RSD support. See http://archipelago.phrasewise.com/rsd
matt authored Nov 7, 2005
34 ?>
849a0d2 Use get_option instead of get_settings. Just 'cause.
ryan authored Aug 30, 2006
35 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
af8c37f Add RSD support. See http://archipelago.phrasewise.com/rsd
matt authored Nov 7, 2005
36 <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd">
37 <service>
38 <engineName>WordPress</engineName>
39 <engineLink>http://wordpress.org/</engineLink>
40 <homePageLink><?php bloginfo_rss('url') ?></homePageLink>
41 <apis>
509df64 Add 'rpc' context to siteurl which obeys ADMIN and LOGIN forced SSL. …
ryan authored Jul 4, 2009
42 <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
43 <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
44 <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
45 <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" />
46 <api name="Atom" blogID="" preferred="false" apiLink="<?php echo apply_filters('atom_service_url', site_url('wp-app.php/service', 'rpc') ) ?>" />
af8c37f Add RSD support. See http://archipelago.phrasewise.com/rsd
matt authored Nov 7, 2005
47 </apis>
48 </service>
49 </rsd>
50 <?php
51 exit;
52 }
53
770613e Admin includes reorg. see #4334
ryan authored May 25, 2007
54 include_once(ABSPATH . 'wp-admin/includes/admin.php');
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
55 include_once(ABSPATH . WPINC . '/class-IXR.php');
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
56
57 // Turn off all warnings and errors.
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
58 // error_reporting(0);
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
59
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
60 /**
61 * Posts submitted via the xmlrpc interface get that title
62 * @name post_default_title
63 * @var string
64 */
65 $post_default_title = "";
66
67 /**
68 * Whether to enable XMLRPC Logging.
69 *
70 * @name xmlrpc_logging
71 * @var int|bool
72 */
80b3445 fixed comment_status screwup, removed debug stuff, screwed up big tim…
michelvaldrighi authored Sep 14, 2004
73 $xmlrpc_logging = 0;
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
74
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
75 /**
76 * logIO() - Writes logging info to a file.
77 *
78 * @uses $xmlrpc_logging
79 * @package WordPress
80 * @subpackage Logging
81 *
82 * @param string $io Whether input or output
83 * @param string $msg Information describing logging reason.
84 * @return bool Always return true
85 */
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
86 function logIO($io,$msg) {
87 global $xmlrpc_logging;
88 if ($xmlrpc_logging) {
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
89 $fp = fopen("../xmlrpc.log","a+");
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
90 $date = gmdate("Y-m-d H:i:s ");
91 $iot = ($io == "I") ? " Input: " : " Output: ";
92 fwrite($fp, "\n\n".$date.$iot.$msg);
93 fclose($fp);
94 }
95 return true;
96 }
97
75ec542 avoid $HTTP_RAW_POST_DATA notices. props mgeisler and Nazgul. fixes #…
markjaquith authored Oct 4, 2006
98 if ( isset($HTTP_RAW_POST_DATA) )
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
99 logIO("I", $HTTP_RAW_POST_DATA);
100
101 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
102 * WordPress XMLRPC server implementation.
103 *
104 * Implements compatability for Blogger API, MetaWeblog API, MovableType, and
105 * pingback. Additional WordPress API for managing comments, pages, posts,
106 * options, etc.
107 *
108 * Since WordPress 2.6.0, WordPress XMLRPC server can be disabled in the
109 * administration panels.
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
110 *
111 * @package WordPress
112 * @subpackage Publishing
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
113 * @since 1.5.0
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored May 25, 2008
114 */
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
115 class wp_xmlrpc_server extends IXR_Server {
116
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
117 /**
118 * Register all of the XMLRPC methods that XMLRPC server understands.
119 *
120 * PHP4 constructor and sets up server and method property. Passes XMLRPC
121 * methods through the 'xmlrpc_methods' filter to allow plugins to extend
122 * or replace XMLRPC methods.
123 *
124 * @since 1.5.0
125 *
126 * @return wp_xmlrpc_server
127 */
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
128 function wp_xmlrpc_server() {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
129 $this->methods = array(
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
130 // WordPress API
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
131 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs',
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
132 'wp.getPage' => 'this:wp_getPage',
133 'wp.getPages' => 'this:wp_getPages',
134 'wp.newPage' => 'this:wp_newPage',
135 'wp.deletePage' => 'this:wp_deletePage',
136 'wp.editPage' => 'this:wp_editPage',
137 'wp.getPageList' => 'this:wp_getPageList',
138 'wp.getAuthors' => 'this:wp_getAuthors',
139 'wp.getCategories' => 'this:mw_getCategories', // Alias
e89192b Strip trailing whitespace
ryan authored Dec 9, 2008
140 'wp.getTags' => 'this:wp_getTags',
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
141 'wp.newCategory' => 'this:wp_newCategory',
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
142 'wp.deleteCategory' => 'this:wp_deleteCategory',
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
143 'wp.suggestCategories' => 'this:wp_suggestCategories',
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
144 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
145 'wp.getCommentCount' => 'this:wp_getCommentCount',
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
146 'wp.getPostStatusList' => 'this:wp_getPostStatusList',
147 'wp.getPageStatusList' => 'this:wp_getPageStatusList',
5d69e51 Expose page template functionality via XML-RPC. Props josephscott. fi…
ryan authored May 6, 2008
148 'wp.getPageTemplates' => 'this:wp_getPageTemplates',
c678502 Add XMLRPC options api. See #7123 props josephscott.
westi authored Jun 17, 2008
149 'wp.getOptions' => 'this:wp_getOptions',
150 'wp.setOptions' => 'this:wp_setOptions',
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
151 'wp.getComment' => 'this:wp_getComment',
152 'wp.getComments' => 'this:wp_getComments',
153 'wp.deleteComment' => 'this:wp_deleteComment',
154 'wp.editComment' => 'this:wp_editComment',
155 'wp.newComment' => 'this:wp_newComment',
156 'wp.getCommentStatusList' => 'this:wp_getCommentStatusList',
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
157
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
ryan authored Nov 19, 2006
158 // Blogger API
159 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs',
160 'blogger.getUserInfo' => 'this:blogger_getUserInfo',
161 'blogger.getPost' => 'this:blogger_getPost',
162 'blogger.getRecentPosts' => 'this:blogger_getRecentPosts',
163 'blogger.getTemplate' => 'this:blogger_getTemplate',
164 'blogger.setTemplate' => 'this:blogger_setTemplate',
165 'blogger.newPost' => 'this:blogger_newPost',
166 'blogger.editPost' => 'this:blogger_editPost',
167 'blogger.deletePost' => 'this:blogger_deletePost',
168
169 // MetaWeblog API (with MT extensions to structs)
170 'metaWeblog.newPost' => 'this:mw_newPost',
171 'metaWeblog.editPost' => 'this:mw_editPost',
172 'metaWeblog.getPost' => 'this:mw_getPost',
173 'metaWeblog.getRecentPosts' => 'this:mw_getRecentPosts',
174 'metaWeblog.getCategories' => 'this:mw_getCategories',
175 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject',
176
177 // MetaWeblog API aliases for Blogger API
178 // see http://www.xmlrpc.com/stories/storyReader$2460
179 'metaWeblog.deletePost' => 'this:blogger_deletePost',
180 'metaWeblog.getTemplate' => 'this:blogger_getTemplate',
181 'metaWeblog.setTemplate' => 'this:blogger_setTemplate',
182 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs',
183
184 // MovableType API
185 'mt.getCategoryList' => 'this:mt_getCategoryList',
186 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles',
187 'mt.getPostCategories' => 'this:mt_getPostCategories',
188 'mt.setPostCategories' => 'this:mt_setPostCategories',
189 'mt.supportedMethods' => 'this:mt_supportedMethods',
190 'mt.supportedTextFilters' => 'this:mt_supportedTextFilters',
191 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings',
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
192 'mt.publishPost' => 'this:mt_publishPost',
193
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
ryan authored Nov 19, 2006
194 // PingBack
195 'pingback.ping' => 'this:pingback_ping',
196 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
197
198 'demo.sayHello' => 'this:sayHello',
199 'demo.addTwoNumbers' => 'this:addTwoNumbers'
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
200 );
c678502 Add XMLRPC options api. See #7123 props josephscott.
westi authored Jun 17, 2008
201
202 $this->initialise_blog_option_info( );
087df40 Allow plugins to hook into XML-RPC server.
saxmatt authored Jan 6, 2005
203 $this->methods = apply_filters('xmlrpc_methods', $this->methods);
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
204 $this->IXR_Server($this->methods);
205 }
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
206
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
207 /**
208 * Test XMLRPC API by saying, "Hello!" to client.
209 *
210 * @since 1.5.0
211 *
212 * @param array $args Method Parameters.
213 * @return string
214 */
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
215 function sayHello($args) {
216 return 'Hello!';
217 }
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
218
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
219 /**
220 * Test XMLRPC API by adding two numbers for client.
221 *
222 * @since 1.5.0
223 *
224 * @param array $args Method Parameters.
225 * @return int
226 */
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
227 function addTwoNumbers($args) {
228 $number1 = $args[0];
229 $number2 = $args[1];
230 return $number1 + $number2;
231 }
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
232
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
233 /**
234 * Check user's credentials.
235 *
236 * @since 1.5.0
237 *
238 * @param string $user_login User's username.
239 * @param string $user_pass User's password.
240 * @return bool Whether authentication passed.
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
241 * @deprecated use wp_xmlrpc_server::login
242 * @see wp_xmlrpc_server::login
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
243 */
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
244 function login_pass_ok($user_login, $user_pass) {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
245 if ( !get_option( 'enable_xmlrpc' ) ) {
246 $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
247 return false;
248 }
249
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
ryan authored Nov 19, 2006
250 if (!user_pass_ok($user_login, $user_pass)) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
251 $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixe…
ryan authored Nov 19, 2006
252 return false;
253 }
254 return true;
a7322e8 big oopsie related to moving the xmlrpc.php file: somehow it got repl…
michelvaldrighi authored Sep 17, 2004
255 }
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
256
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
257 /**
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
258 * Log user in.
259 *
260 * @since 2.8
261 *
262 * @param string $username User's username.
263 * @param string $password User's password.
264 * @return mixed WP_User object if authentication passed, false otherwise
265 */
266 function login($username, $password) {
267 if ( !get_option( 'enable_xmlrpc' ) ) {
268 $this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this blog. An admin user can enable them at %s'), admin_url('options-writing.php') ) );
269 return false;
270 }
271
272 $user = wp_authenticate($username, $password);
273
274 if (is_wp_error($user)) {
275 $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
276 return false;
277 }
278
279 set_current_user( $user->ID );
280 return $user;
281 }
282
283 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
284 * Sanitize string or array of strings for database.
285 *
286 * @since 1.5.2
287 *
288 * @param string|array $array Sanitize single string or array of strings.
289 * @return string|array Type matches $array and sanitized for the database.
290 */
9c9ba0a Escape XMLRPC args.
ryan authored Jun 28, 2005
291 function escape(&$array) {
292 global $wpdb;
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
293
7f1945b xmlrpc updates from Joseph Scott.
ryan authored Mar 3, 2007
294 if(!is_array($array)) {
715ea73 editPage and newPage escaping fixes from Joseph.
ryan authored Feb 12, 2007
295 return($wpdb->escape($array));
296 }
297 else {
298 foreach ( (array) $array as $k => $v ) {
299 if (is_array($v)) {
300 $this->escape($array[$k]);
301 } else if (is_object($v)) {
302 //skip
303 } else {
304 $array[$k] = $wpdb->escape($v);
305 }
9c9ba0a Escape XMLRPC args.
ryan authored Jun 28, 2005
306 }
307 }
308 }
e61a7ce work in progress: replacement for xmlrpc.php, using IXR
michelvaldrighi authored May 23, 2004
309
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
310 /**
311 * Retrieve custom fields for post.
312 *
313 * @since 2.5.0
314 *
315 * @param int $post_id Post ID.
316 * @return array Custom fields, if exist.
317 */
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
318 function get_custom_fields($post_id) {
319 $post_id = (int) $post_id;
320
321 $custom_fields = array();
322
323 foreach ( (array) has_meta($post_id) as $meta ) {
324 // Don't expose protected fields.
325 if ( strpos($meta['meta_key'], '_wp_') === 0 ) {
326 continue;
327 }
328
329 $custom_fields[] = array(
330 "id" => $meta['meta_id'],
331 "key" => $meta['meta_key'],
332 "value" => $meta['meta_value']
333 );
334 }
335
336 return $custom_fields;
337 }
338
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
339 /**
340 * Set custom fields for post.
341 *
342 * @since 2.5.0
343 *
344 * @param int $post_id Post ID.
345 * @param array $fields Custom fields.
346 */
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
347 function set_custom_fields($post_id, $fields) {
348 $post_id = (int) $post_id;
349
350 foreach ( (array) $fields as $meta ) {
351 if ( isset($meta['id']) ) {
352 $meta['id'] = (int) $meta['id'];
353
354 if ( isset($meta['key']) ) {
355 update_meta($meta['id'], $meta['key'], $meta['value']);
356 }
357 else {
358 delete_meta($meta['id']);
359 }
360 }
361 else {
362 $_POST['metakeyinput'] = $meta['key'];
363 $_POST['metavalue'] = $meta['value'];
364 add_meta($post_id);
365 }
366 }
367 }
630cd82 Custom fields support for xmlrpc from josephscott. fixes #5148
ryan authored Dec 19, 2007
368
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
369 /**
370 * Setup blog options property.
371 *
372 * Passes property through 'xmlrpc_blog_options' filter.
373 *
374 * @since 2.6.0
375 */
c678502 Add XMLRPC options api. See #7123 props josephscott.
westi authored Jun 17, 2008
376 function initialise_blog_option_info( ) {
377 global $wp_version;
378
379 $this->blog_options = array(
380 // Read only options
381 'software_name' => array(
382 'desc' => __( 'Software Name' ),
383 'readonly' => true,
384 'value' => 'WordPress'
385 ),
386 'software_version' => array(
387 'desc' => __( 'Software Version' ),
388 'readonly' => true,
389 'value' => $wp_version
390 ),
391 'blog_url' => array(
392 'desc' => __( 'Blog URL' ),
393 'readonly' => true,
394 'option' => 'siteurl'
395 ),
396
397 // Updatable options
398 'time_zone' => array(
399 'desc' => __( 'Time Zone' ),
400 'readonly' => false,
401 'option' => 'gmt_offset'
402 ),
403 'blog_title' => array(
404 'desc' => __( 'Blog Title' ),
405 'readonly' => false,
406 'option' => 'blogname'
407 ),
408 'blog_tagline' => array(
409 'desc' => __( 'Blog Tagline' ),
410 'readonly' => false,
411 'option' => 'blogdescription'
412 ),
413 'date_format' => array(
414 'desc' => __( 'Date Format' ),
415 'readonly' => false,
416 'option' => 'date_format'
417 ),
418 'time_format' => array(
419 'desc' => __( 'Time Format' ),
420 'readonly' => false,
421 'option' => 'time_format'
422 )
423 );
424
425 $this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options );
426 }
427
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
428 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
429 * Retrieve the blogs of the user.
430 *
431 * @since 2.6.0
432 *
433 * @param array $args Method parameters.
434 * @return array
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
435 */
436 function wp_getUsersBlogs( $args ) {
437 // If this isn't on WPMU then just use blogger_getUsersBlogs
438 if( !function_exists( 'is_site_admin' ) ) {
439 array_unshift( $args, 1 );
440 return $this->blogger_getUsersBlogs( $args );
441 }
442
443 $this->escape( $args );
444
445 $username = $args[0];
446 $password = $args[1];
447
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
448 if ( !$user = $this->login($username, $password) ) {
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
449 return $this->error;
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
450 }
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
451
452 do_action( 'xmlrpc_call', 'wp.getUsersBlogs' );
453
454 $blogs = (array) get_blogs_of_user( $user->ID );
455 $struct = array( );
456
457 foreach( $blogs as $blog ) {
458 // Don't include blogs that aren't hosted at this site
bdde119 wp_getUsersBlogs() fix from josephscott. fixes #8255
ryan authored Nov 19, 2008
459 if( $blog->site_id != $current_site->id )
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
460 continue;
461
462 $blog_id = $blog->userblog_id;
463 switch_to_blog($blog_id);
464 $is_admin = current_user_can('level_8');
465
466 $struct[] = array(
467 'isAdmin' => $is_admin,
468 'url' => get_option( 'home' ) . '/',
469 'blogid' => $blog_id,
470 'blogName' => get_option( 'blogname' ),
70fa2b1 Fix path to xmlrpc. Props MidnighToker. fixes #9516
ryan authored Apr 14, 2009
471 'xmlrpc' => site_url( 'xmlrpc.php' )
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
472 );
bdde119 wp_getUsersBlogs() fix from josephscott. fixes #8255
ryan authored Nov 19, 2008
473
474 restore_current_blog( );
94eea94 wp.getUsersBlogs from josephscott. fixes #7130
ryan authored Jun 12, 2008
475 }
476
477 return $struct;
478 }
479
480 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
481 * Retrieve page.
482 *
483 * @since 2.2.0
484 *
485 * @param array $args Method parameters.
486 * @return array
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
487 */
488 function wp_getPage($args) {
489 $this->escape($args);
490
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
491 $blog_id = (int) $args[0];
492 $page_id = (int) $args[1];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
493 $username = $args[2];
494 $password = $args[3];
495
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
496 if ( !$user = $this->login($username, $password) ) {
497 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
498 }
499
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
500 if( !current_user_can( 'edit_page', $page_id ) )
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
501 return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
502
3177977 '>"
westi authored Dec 23, 2007
503 do_action('xmlrpc_call', 'wp.getPage');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
504
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
505 // Lookup page info.
506 $page = get_page($page_id);
507
508 // If we found the page then format the data.
509 if($page->ID && ($page->post_type == "page")) {
510 // Get all of the page content and link.
511 $full_page = get_extended($page->post_content);
512 $link = post_permalink($page->ID);
513
d162935 WP XML-RPC API enhancements.
ryan authored Jan 26, 2007
514 // Get info the page parent if there is one.
515 $parent_title = "";
516 if(!empty($page->post_parent)) {
517 $parent = get_page($page->post_parent);
518 $parent_title = $parent->post_title;
519 }
520
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
521 // Determine comment and ping settings.
4754d22 Use comments_open() and pings_open(). Props coffee2code. fixes #9557
ryan authored Apr 17, 2009
522 $allow_comments = comments_open($page->ID) ? 1 : 0;
523 $allow_pings = pings_open($page->ID) ? 1 : 0;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
524
525 // Format page date.
1354d06 Don't localize dates where not appropriate. Props Denis-de-Bernardy, …
ryan authored May 14, 2009
526 $page_date = mysql2date("Ymd\TH:i:s", $page->post_date, false);
527 $page_date_gmt = mysql2date("Ymd\TH:i:s", $page->post_date_gmt, false);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
528
529 // Pull the categories info together.
530 $categories = array();
531 foreach(wp_get_post_categories($page->ID) as $cat_id) {
532 $categories[] = get_cat_name($cat_id);
533 }
534
d162935 WP XML-RPC API enhancements.
ryan authored Jan 26, 2007
535 // Get the author info.
536 $author = get_userdata($page->post_author);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
537
5d69e51 Expose page template functionality via XML-RPC. Props josephscott. fi…
ryan authored May 6, 2008
538 $page_template = get_post_meta( $page->ID, '_wp_page_template', true );
539 if( empty( $page_template ) )
540 $page_template = 'default';
541
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
542 $page_struct = array(
d162935 WP XML-RPC API enhancements.
ryan authored Jan 26, 2007
543 "dateCreated" => new IXR_Date($page_date),
544 "userid" => $page->post_author,
545 "page_id" => $page->ID,
546 "page_status" => $page->post_status,
547 "description" => $full_page["main"],
548 "title" => $page->post_title,
549 "link" => $link,
550 "permaLink" => $link,
551 "categories" => $categories,
552 "excerpt" => $page->post_excerpt,
553 "text_more" => $full_page["extended"],
554 "mt_allow_comments" => $allow_comments,
555 "mt_allow_pings" => $allow_pings,
556 "wp_slug" => $page->post_name,
557 "wp_password" => $page->post_password,
e71e25d XMLRPC API updates.
ryan authored Feb 1, 2007
558 "wp_author" => $author->display_name,
d162935 WP XML-RPC API enhancements.
ryan authored Jan 26, 2007
559 "wp_page_parent_id" => $page->post_parent,
560 "wp_page_parent_title" => $parent_title,
561 "wp_page_order" => $page->menu_order,
16c4e7b More XMLRPC updates from Joseph Scott.
ryan authored Feb 2, 2007
562 "wp_author_id" => $author->ID,
d55ac97 Send dateCreated as local blog time, add date_created_gmt with GMT va…
markjaquith authored Aug 17, 2007
563 "wp_author_display_name" => $author->display_name,
630cd82 Custom fields support for xmlrpc from josephscott. fixes #5148
ryan authored Dec 19, 2007
564 "date_created_gmt" => new IXR_Date($page_date_gmt),
5d69e51 Expose page template functionality via XML-RPC. Props josephscott. fi…
ryan authored May 6, 2008
565 "custom_fields" => $this->get_custom_fields($page_id),
566 "wp_page_template" => $page_template
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
567 );
568
569 return($page_struct);
570 }
571 // If the page doesn't exist indicate that.
572 else {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
573 return(new IXR_Error(404, __("Sorry, no such page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
574 }
575 }
576
577 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
578 * Retrieve Pages.
579 *
580 * @since 2.2.0
581 *
582 * @param array $args Method parameters.
583 * @return array
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
584 */
585 function wp_getPages($args) {
586 $this->escape($args);
587
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
588 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
589 $username = $args[1];
590 $password = $args[2];
9b50d01 XML-RPC wp.getPages Fix: don't restrict to just published pages, prop…
azaozz authored Oct 24, 2008
591 $num_pages = (int) $args[3];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
592
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
593 if ( !$user = $this->login($username, $password) ) {
594 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
595 }
596
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
597 if( !current_user_can( 'edit_pages' ) )
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
598 return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
599
3177977 '>"
westi authored Dec 23, 2007
600 do_action('xmlrpc_call', 'wp.getPages');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
601
9b50d01 XML-RPC wp.getPages Fix: don't restrict to just published pages, prop…
azaozz authored Oct 24, 2008
602 $page_limit = 10;
603 if( isset( $num_pages ) ) {
604 $page_limit = $num_pages;
605 }
606
261f318 Use array instead of query string notation. Prop dd32, kamiyeye. fixe…
ryan authored Jun 6, 2009
607 $pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $page_limit) );
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
608 $num_pages = count($pages);
609
610 // If we have pages, put together their info.
611 if($num_pages >= 1) {
612 $pages_struct = array();
613
614 for($i = 0; $i < $num_pages; $i++) {
615 $page = wp_xmlrpc_server::wp_getPage(array(
616 $blog_id, $pages[$i]->ID, $username, $password
617 ));
618 $pages_struct[] = $page;
619 }
620
621 return($pages_struct);
622 }
623 // If no pages were found return an error.
624 else {
84cda2c XMLRPC fixes from Joseph Scott. 404 for invalid post ids. Return empt…
ryan authored Mar 25, 2007
625 return(array());
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
626 }
627 }
628
629 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
630 * Create new page.
631 *
632 * @since 2.2.0
633 *
634 * @param array $args Method parameters.
635 * @return unknown
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
636 */
637 function wp_newPage($args) {
715ea73 editPage and newPage escaping fixes from Joseph.
ryan authored Feb 12, 2007
638 // Items not escaped here will be escaped in newPost.
639 $username = $this->escape($args[1]);
640 $password = $this->escape($args[2]);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
641 $page = $args[3];
642 $publish = $args[4];
643
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
644 if ( !$user = $this->login($username, $password) ) {
645 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
646 }
647
3177977 '>"
westi authored Dec 23, 2007
648 do_action('xmlrpc_call', 'wp.newPage');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
649
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
650 // Make sure the user is allowed to add new pages.
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
651 if(!current_user_can("publish_pages")) {
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
652 return(new IXR_Error(401, __("Sorry, you cannot add new pages.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
653 }
654
655 // Mark this as content for a page.
656 $args[3]["post_type"] = "page";
657
658 // Let mw_newPost do all of the heavy lifting.
659 return($this->mw_newPost($args));
660 }
661
662 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
663 * Delete page.
664 *
665 * @since 2.2.0
666 *
667 * @param array $args Method parameters.
668 * @return bool True, if success.
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
669 */
670 function wp_deletePage($args) {
671 $this->escape($args);
672
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
673 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
674 $username = $args[1];
675 $password = $args[2];
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
676 $page_id = (int) $args[3];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
677
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
678 if ( !$user = $this->login($username, $password) ) {
679 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
680 }
681
3177977 '>"
westi authored Dec 23, 2007
682 do_action('xmlrpc_call', 'wp.deletePage');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
683
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
684 // Get the current page based on the page_id and
685 // make sure it is a page and not a post.
686 $actual_page = wp_get_single_post($page_id, ARRAY_A);
687 if(
688 !$actual_page
689 || ($actual_page["post_type"] != "page")
690 ) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
691 return(new IXR_Error(404, __("Sorry, no such page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
692 }
693
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
694 // Make sure the user can delete pages.
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
695 if(!current_user_can("delete_page", $page_id)) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
696 return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
697 }
698
699 // Attempt to delete the page.
700 $result = wp_delete_post($page_id);
701 if(!$result) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
702 return(new IXR_Error(500, __("Failed to delete the page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
703 }
704
705 return(true);
706 }
707
708 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
709 * Edit page.
710 *
711 * @since 2.2.0
712 *
713 * @param array $args Method parameters.
714 * @return unknown
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
715 */
716 function wp_editPage($args) {
715ea73 editPage and newPage escaping fixes from Joseph.
ryan authored Feb 12, 2007
717 // Items not escaped here will be escaped in editPost.
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
718 $blog_id = (int) $args[0];
ae7fa6c Cast to int after escaping. Props Joseph Scott.
ryan authored Apr 3, 2007
719 $page_id = (int) $this->escape($args[1]);
715ea73 editPage and newPage escaping fixes from Joseph.
ryan authored Feb 12, 2007
720 $username = $this->escape($args[2]);
721 $password = $this->escape($args[3]);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
722 $content = $args[4];
723 $publish = $args[5];
724
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
725 if ( !$user = $this->login($username, $password) ) {
726 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
727 }
728
3177977 '>"
westi authored Dec 23, 2007
729 do_action('xmlrpc_call', 'wp.editPage');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
730
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
731 // Get the page data and make sure it is a page.
732 $actual_page = wp_get_single_post($page_id, ARRAY_A);
733 if(
734 !$actual_page
735 || ($actual_page["post_type"] != "page")
736 ) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
737 return(new IXR_Error(404, __("Sorry, no such page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
738 }
739
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
740 // Make sure the user is allowed to edit pages.
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
741 if(!current_user_can("edit_page", $page_id)) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
742 return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
743 }
744
745 // Mark this as content for a page.
746 $content["post_type"] = "page";
747
748 // Arrange args in the way mw_editPost understands.
749 $args = array(
750 $page_id,
751 $username,
752 $password,
753 $content,
754 $publish
755 );
756
757 // Let mw_editPost do all of the heavy lifting.
758 return($this->mw_editPost($args));
759 }
760
761 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
762 * Retrieve page list.
763 *
764 * @since 2.2.0
765 *
766 * @param array $args Method parameters.
767 * @return unknown
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
768 */
769 function wp_getPageList($args) {
770 global $wpdb;
771
772 $this->escape($args);
773
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
774 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
775 $username = $args[1];
776 $password = $args[2];
777
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
778 if ( !$user = $this->login($username, $password) ) {
779 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
780 }
781
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
782 if( !current_user_can( 'edit_pages' ) )
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
783 return new IXR_Error( 401, __( 'Sorry, you cannot edit pages.' ) );
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
784
3177977 '>"
westi authored Dec 23, 2007
785 do_action('xmlrpc_call', 'wp.getPageList');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
786
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
787 // Get list of pages ids and titles
788 $page_list = $wpdb->get_results("
789 SELECT ID page_id,
d162935 WP XML-RPC API enhancements.
ryan authored Jan 26, 2007
790 post_title page_title,
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
791 post_parent page_parent_id,
d55ac97 Send dateCreated as local blog time, add date_created_gmt with GMT va…
markjaquith authored Aug 17, 2007
792 post_date_gmt,
793 post_date
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
794 FROM {$wpdb->posts}
795 WHERE post_type = 'page'
796 ORDER BY ID
797 ");
798
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
799 // The date needs to be formated properly.
800 $num_pages = count($page_list);
801 for($i = 0; $i < $num_pages; $i++) {
1354d06 Don't localize dates where not appropriate. Props Denis-de-Bernardy, …
ryan authored May 14, 2009
802 $post_date = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date, false);
803 $post_date_gmt = mysql2date("Ymd\TH:i:s", $page_list[$i]->post_date_gmt, false);
d55ac97 Send dateCreated as local blog time, add date_created_gmt with GMT va…
markjaquith authored Aug 17, 2007
804
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
805 $page_list[$i]->dateCreated = new IXR_Date($post_date);
d55ac97 Send dateCreated as local blog time, add date_created_gmt with GMT va…
markjaquith authored Aug 17, 2007
806 $page_list[$i]->date_created_gmt = new IXR_Date($post_date_gmt);
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
807
be8f80d Use GMT in XML-RPC dateCreated fields. Props Joseph Scott. fixes #415…
ryan authored Apr 22, 2007
808 unset($page_list[$i]->post_date_gmt);
d55ac97 Send dateCreated as local blog time, add date_created_gmt with GMT va…
markjaquith authored Aug 17, 2007
809 unset($page_list[$i]->post_date);
fea2a6e xmlrpc updates from Joseph Scott.
ryan authored Feb 22, 2007
810 }
811
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
812 return($page_list);
813 }
814
815 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
816 * Retrieve authors list.
817 *
818 * @since 2.2.0
819 *
820 * @param array $args Method parameters.
821 * @return array
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
822 */
823 function wp_getAuthors($args) {
824
825 $this->escape($args);
826
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
827 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
828 $username = $args[1];
829 $password = $args[2];
830
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
831 if ( !$user = $this->login($username, $password) ) {
832 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
833 }
834
2490ec4 Limit what getAuthors exposes. Props josephscott for the patch and xk…
ryan authored Dec 26, 2007
835 if(!current_user_can("edit_posts")) {
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
836 return(new IXR_Error(401, __("Sorry, you cannot edit posts on this blog.")));
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
837 }
2490ec4 Limit what getAuthors exposes. Props josephscott for the patch and xk…
ryan authored Dec 26, 2007
838
3177977 '>"
westi authored Dec 23, 2007
839 do_action('xmlrpc_call', 'wp.getAuthors');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
840
2490ec4 Limit what getAuthors exposes. Props josephscott for the patch and xk…
ryan authored Dec 26, 2007
841 $authors = array();
842 foreach( (array) get_users_of_blog() as $row ) {
843 $authors[] = array(
844 "user_id" => $row->user_id,
845 "user_login" => $row->user_login,
846 "display_name" => $row->display_name
847 );
848 }
849
850 return($authors);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
851 }
852
853 /**
f72a4ce List post tags via XMLRPC. Props josephscott. fixes #7744
ryan authored Oct 13, 2008
854 * Get list of all tags
855 *
856 * @since 2.7
857 *
858 * @param array $args Method parameters.
859 * @return array
860 */
861 function wp_getTags( $args ) {
862 $this->escape( $args );
863
864 $blog_id = (int) $args[0];
865 $username = $args[1];
866 $password = $args[2];
867
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
868 if ( !$user = $this->login($username, $password) ) {
f72a4ce List post tags via XMLRPC. Props josephscott. fixes #7744
ryan authored Oct 13, 2008
869 return $this->error;
870 }
871
872 if( !current_user_can( 'edit_posts' ) ) {
873 return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this blog in order to view tags.' ) );
874 }
875
876 do_action( 'xmlrpc_call', 'wp.getKeywords' );
877
878 $tags = array( );
879
880 if( $all_tags = get_tags( ) ) {
881 foreach( (array) $all_tags as $tag ) {
882 $struct['tag_id'] = $tag->term_id;
883 $struct['name'] = $tag->name;
884 $struct['count'] = $tag->count;
885 $struct['slug'] = $tag->slug;
119b39c deprecate wp_specialchars() in favor of esc_html(). Encode quotes for…
markjaquith authored May 18, 2009
886 $struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) );
887 $struct['rss_url'] = esc_html( get_tag_feed_link( $tag->term_id ) );
f72a4ce List post tags via XMLRPC. Props josephscott. fixes #7744
ryan authored Oct 13, 2008
888
889 $tags[] = $struct;
890 }
891 }
892
893 return $tags;
894 }
895
896 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
897 * Create new category.
898 *
899 * @since 2.2.0
900 *
901 * @param array $args Method parameters.
902 * @return int Category ID.
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
903 */
904 function wp_newCategory($args) {
905 $this->escape($args);
906
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
907 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
908 $username = $args[1];
909 $password = $args[2];
910 $category = $args[3];
911
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
912 if ( !$user = $this->login($username, $password) ) {
913 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
914 }
915
3177977 '>"
westi authored Dec 23, 2007
916 do_action('xmlrpc_call', 'wp.newCategory');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
917
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
918 // Make sure the user is allowed to add a category.
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
919 if(!current_user_can("manage_categories")) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
920 return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
921 }
922
923 // If no slug was provided make it empty so that
924 // WordPress will generate one.
925 if(empty($category["slug"])) {
926 $category["slug"] = "";
927 }
928
929 // If no parent_id was provided make it empty
930 // so that it will be a top level page (no parent).
c8997ff Reverse logic.
ryan authored Feb 22, 2007
931 if ( !isset($category["parent_id"]) )
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
932 $category["parent_id"] = "";
933
934 // If no description was provided make it empty.
935 if(empty($category["description"])) {
936 $category["description"] = "";
937 }
2f09416 Trim empty lines. Nothing but newline.
ryan authored Jun 14, 2007
938
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
939 $new_category = array(
940 "cat_name" => $category["name"],
941 "category_nicename" => $category["slug"],
942 "category_parent" => $category["parent_id"],
943 "category_description" => $category["description"]
944 );
945
3d21925 Ryan slays the dragon. (Some of these return WP_Error objects.)
matt authored Mar 23, 2007
946 $cat_id = wp_insert_category($new_category);
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
947 if(!$cat_id) {
e273f11 Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997
ryan authored Apr 1, 2007
948 return(new IXR_Error(500, __("Sorry, the new category failed.")));
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
949 }
950
951 return($cat_id);
952 }
953
954 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
955 * Remove category.
956 *
957 * @since 2.5.0
958 *
959 * @param array $args Method parameters.
960 * @return mixed See {@link wp_delete_category()} for return info.
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
961 */
962 function wp_deleteCategory($args) {
963 $this->escape($args);
964
965 $blog_id = (int) $args[0];
966 $username = $args[1];
967 $password = $args[2];
968 $category_id = (int) $args[3];
969
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
970 if ( !$user = $this->login($username, $password) ) {
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
971 return $this->error;
972 }
973
3177977 '>"
westi authored Dec 23, 2007
974 do_action('xmlrpc_call', 'wp.deleteCategory');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
975
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
976 if( !current_user_can("manage_categories") ) {
fc943e2 Grammar fixes from takayukister and thenlich. fixes #5992
ryan authored Feb 25, 2008
977 return new IXR_Error( 401, __( "Sorry, you do not have the right to delete a category." ) );
00d334c wp.deleteCategory xmlrpc method from josephscott. fixes #4599
ryan authored Dec 19, 2007
978 }
979
980 return wp_delete_category( $category_id );
981 }
982
983 /**
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
984 * Retrieve category list.
985 *
986 * @since 2.2.0
987 *
988 * @param array $args Method parameters.
989 * @return array
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
990 */
991 function wp_suggestCategories($args) {
992 $this->escape($args);
993
7602d17 (int)er the dragon.
matt authored Mar 23, 2007
994 $blog_id = (int) $args[0];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
995 $username = $args[1];
996 $password = $args[2];
997 $category = $args[3];
070d2fd Int cast. Props to Alexander Concha for the find, Joseph Scott for th…
markjaquith authored May 28, 2007
998 $max_results = (int) $args[4];
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
999
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1000 if ( !$user = $this->login($username, $password) ) {
1001 return $this->error;
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
1002 }
1003
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1004 if( !current_user_can( 'edit_posts' ) )
9f9769b Add some more actions to xmlrpc. Fixes #5686 props joesephscott.
westi authored Jan 18, 2008
1005 return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts to this blog in order to view categories.' ) );
c36d1c9 Some xmlrpc cap checks from josephscott.
ryan authored Dec 27, 2007
1006
3177977 '>"
westi authored Dec 23, 2007
1007 do_action('xmlrpc_call', 'wp.suggestCategories');
53db776 Add xmlrpc_call actions. Cleanup some whitespace.
ryan authored Dec 23, 2007
1008
fc8d883 Fix wp.suggestCategories return values. Props josephscott. fixes #5406
ryan authored Dec 19, 2007
1009 $category_suggestions = array();
7217266 AND get_terms() field queries
ryan authored Jul 17, 2007
1010 $args = array('get' => 'all', 'number' => $max_results, 'name__like' => $category);
fc8d883 Fix wp.suggestCategories return values. Props josephscott. fixes #5406
ryan authored Dec 19, 2007
1011 foreach ( (array) get_categories($args) as $cat ) {
1012 $category_suggestions[] = array(
1013 "category_id" => $cat->cat_ID,
1014 "category_name" => $cat->cat_name
1015 );
1016 }
9af6317 WP XML-RPC API
ryan authored Jan 24, 2007
1017
1018 return($category_suggestions);
1019 }
1020
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1021 /**
1022 * Retrieve comment.
1023 *
1024 * @since 2.7.0
1025 *
1026 * @param array $args Method parameters.
1027 * @return array
1028 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1029 function wp_getComment($args) {
1030 $this->escape($args);
1031
1032 $blog_id = (int) $args[0];
1033 $username = $args[1];
1034 $password = $args[2];
1035 $comment_id = (int) $args[3];
1036
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1037 if ( !$user = $this->login($username, $password) ) {
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1038 return $this->error;
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1039 }
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1040
1041 if ( !current_user_can( 'moderate_comments' ) )
1042 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
1043
1044 do_action('xmlrpc_call', 'wp.getComment');
1045
1046 if ( ! $comment = get_comment($comment_id) )
1047 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1048
1049 // Format page date.
1354d06 Don't localize dates where not appropriate. Props Denis-de-Bernardy, …
ryan authored May 14, 2009
1050 $comment_date = mysql2date("Ymd\TH:i:s", $comment->comment_date, false);
1051 $comment_date_gmt = mysql2date("Ymd\TH:i:s", $comment->comment_date_gmt, false);
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1052
1053 if ( 0 == $comment->comment_approved )
1054 $comment_status = 'hold';
1055 else if ( 'spam' == $comment->comment_approved )
1056 $comment_status = 'spam';
0a37661 Ensure we support custom comment approval statuses over xmlrpc. Fixes…
westi authored Sep 25, 2008
1057 else if ( 1 == $comment->comment_approved )
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1058 $comment_status = 'approve';
0a37661 Ensure we support custom comment approval statuses over xmlrpc. Fixes…
westi authored Sep 25, 2008
1059 else
1060 $comment_status = $comment->comment_approved;
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1061
1062 $link = get_comment_link($comment);
1063
1064 $comment_struct = array(
1065 "date_created_gmt" => new IXR_Date($comment_date_gmt),
1066 "user_id" => $comment->user_id,
1067 "comment_id" => $comment->comment_ID,
1068 "parent" => $comment->comment_parent,
1069 "status" => $comment_status,
1070 "content" => $comment->comment_content,
1071 "link" => $link,
1072 "post_id" => $comment->comment_post_ID,
1073 "post_title" => get_the_title($comment->comment_post_ID),
24b304f Typo fix. Props josephscott. see #7446
ryan authored Aug 21, 2008
1074 "author" => $comment->comment_author,
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1075 "author_url" => $comment->comment_author_url,
1076 "author_email" => $comment->comment_author_email,
1077 "author_ip" => $comment->comment_author_IP,
1d72687 Add the comment type to the data wp.getComment returns. Fixes #8486 p…
westi authored Dec 4, 2008
1078 "type" => $comment->comment_type,
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1079 );
1080
1081 return $comment_struct;
1082 }
1083
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1084 /**
1085 * Retrieve comments.
1086 *
1087 * @since 2.7.0
1088 *
1089 * @param array $args Method parameters.
1090 * @return array
1091 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1092 function wp_getComments($args) {
1093 $this->escape($args);
1094
1095 $blog_id = (int) $args[0];
1096 $username = $args[1];
1097 $password = $args[2];
1098 $struct = $args[3];
1099
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1100 if ( !$user = $this->login($username, $password) ) {
1101 return $this->error;
1102 }
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1103
1104 if ( !current_user_can( 'moderate_comments' ) )
83f674b Banishing ASCII quotes and apostrophes, props demetris, fixes #9655
azaozz authored May 5, 2009
1105 return new IXR_Error( 401, __( 'Sorry, you cannot edit comments.' ) );
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1106
1107 do_action('xmlrpc_call', 'wp.getComments');
1108
1109 if ( isset($struct['status']) )
1110 $status = $struct['status'];
1111 else
1112 $status = '';
1113
1114 $post_id = '';
1115 if ( isset($struct['post_id']) )
1116 $post_id = absint($struct['post_id']);
1117
1118 $offset = 0;
1119 if ( isset($struct['offset']) )
1120 $offset = absint($struct['offset']);
1121
1122 $number = 10;
1123 if ( isset($struct['number']) )
1124 $number = absint($struct['number']);
1125
1126 $comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
1127 $num_comments = count($comments);
1128
1129 if ( ! $num_comments )
1130 return array();
1131
1132 $comments_struct = array();
1133
1134 for ( $i = 0; $i < $num_comments; $i++ ) {
1135 $comment = wp_xmlrpc_server::wp_getComment(array(
1136 $blog_id, $username, $password, $comments[$i]->comment_ID,
1137 ));
1138 $comments_struct[] = $comment;
1139 }
1140
1141 return $comments_struct;
1142 }
1143
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1144 /**
1145 * Remove comment.
1146 *
1147 * @since 2.7.0
1148 *
1149 * @param array $args Method parameters.
1150 * @return mixed {@link wp_delete_comment()}
1151 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1152 function wp_deleteComment($args) {
1153 $this->escape($args);
1154
1155 $blog_id = (int) $args[0];
1156 $username = $args[1];
1157 $password = $args[2];
1158 $comment_ID = (int) $args[3];
1159
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1160 if ( !$user = $this->login($username, $password) ) {
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1161 return $this->error;
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1162 }
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1163
1164 if ( !current_user_can( 'moderate_comments' ) )
1165 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
1166
1167 do_action('xmlrpc_call', 'wp.deleteComment');
1168
1169 if ( ! get_comment($comment_ID) )
1170 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1171
1172 return wp_delete_comment($comment_ID);
1173 }
1174
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1175 /**
1176 * Edit comment.
1177 *
1178 * @since 2.7.0
1179 *
1180 * @param array $args Method parameters.
1181 * @return bool True, on success.
1182 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1183 function wp_editComment($args) {
1184 $this->escape($args);
1185
1186 $blog_id = (int) $args[0];
1187 $username = $args[1];
1188 $password = $args[2];
1189 $comment_ID = (int) $args[3];
1190 $content_struct = $args[4];
1191
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1192 if ( !$user = $this->login($username, $password) ) {
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1193 return $this->error;
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1194 }
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1195
1196 if ( !current_user_can( 'moderate_comments' ) )
1197 return new IXR_Error( 403, __( 'You are not allowed to moderate comments on this blog.' ) );
1198
1199 do_action('xmlrpc_call', 'wp.editComment');
1200
1201 if ( ! get_comment($comment_ID) )
1202 return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
1203
1204 if ( isset($content_struct['status']) ) {
1205 $statuses = get_comment_statuses();
1206 $statuses = array_keys($statuses);
1207
1208 if ( ! in_array($content_struct['status'], $statuses) )
1209 return new IXR_Error( 401, __( 'Invalid comment status.' ) );
1210 $comment_approved = $content_struct['status'];
1211 }
1212
1213 // Do some timestamp voodoo
1214 if ( !empty( $content_struct['date_created_gmt'] ) ) {
1215 $dateCreated = str_replace( 'Z', '', $content_struct['date_created_gmt']->getIso() ) . 'Z'; // We know this is supposed to be GMT, so we're going to slap that Z on there by force
1216 $comment_date = get_date_from_gmt(iso8601_to_datetime($dateCreated));
1217 $comment_date_gmt = iso8601_to_datetime($dateCreated, GMT);
1218 }
1219
1220 if ( isset($content_struct['content']) )
1221 $comment_content = $content_struct['content'];
1222
1223 if ( isset($content_struct['author']) )
1224 $comment_author = $content_struct['author'];
1225
1226 if ( isset($content_struct['author_url']) )
1227 $comment_author_url = $content_struct['author_url'];
1228
1229 if ( isset($content_struct['author_email']) )
1230 $comment_author_email = $content_struct['author_email'];
1231
1232 // We've got all the data -- post it:
1233 $comment = compact('comment_ID', 'comment_content', 'comment_approved', 'comment_date', 'comment_date_gmt', 'comment_author', 'comment_author_email', 'comment_author_url');
35b18e5 Trailing whitespace cleanup
ryan authored Aug 9, 2008
1234
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1235 $result = wp_update_comment($comment);
1236 if ( is_wp_error( $result ) )
1237 return new IXR_Error(500, $result->get_error_message());
1238
1239 if ( !$result )
1240 return new IXR_Error(500, __('Sorry, the comment could not be edited. Something wrong happened.'));
1241
1242 return true;
1243 }
1244
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1245 /**
1246 * Create new comment.
1247 *
1248 * @since 2.7.0
1249 *
1250 * @param array $args Method parameters.
1251 * @return mixed {@link wp_new_comment()}
1252 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1253 function wp_newComment($args) {
1254 global $wpdb;
1255
1256 $this->escape($args);
1257
1258 $blog_id = (int) $args[0];
1259 $username = $args[1];
1260 $password = $args[2];
1261 $post = $args[3];
1262 $content_struct = $args[4];
1263
1264 $allow_anon = apply_filters('xmlrpc_allow_anonymous_comments', false);
1265
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1266 $user = $this->login($username, $password);
1267
1268 if ( !$user ) {
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1269 $logged_in = false;
1270 if ( $allow_anon && get_option('comment_registration') )
1271 return new IXR_Error( 403, __( 'You must be registered to comment' ) );
1272 else if ( !$allow_anon )
1273 return $this->error;
1274 } else {
1275 $logged_in = true;
1276 }
1277
1278 if ( is_numeric($post) )
1279 $post_id = absint($post);
1280 else
1281 $post_id = url_to_postid($post);
1282
1283 if ( ! $post_id )
1284 return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1285
1286 if ( ! get_post($post_id) )
1287 return new IXR_Error( 404, __( 'Invalid post ID.' ) );
1288
1289 $comment['comment_post_ID'] = $post_id;
1290
1291 if ( $logged_in ) {
1292 $comment['comment_author'] = $wpdb->escape( $user->display_name );
1293 $comment['comment_author_email'] = $wpdb->escape( $user->user_email );
1294 $comment['comment_author_url'] = $wpdb->escape( $user->user_url );
1295 $comment['user_ID'] = $user->ID;
1296 } else {
1297 $comment['comment_author'] = '';
1298 if ( isset($content_struct['author']) )
1299 $comment['comment_author'] = $content_struct['author'];
08d1442 XMLRPC wp_newComment() fixes. Props josephscott. fixes #8672 for trunk
ryan authored Jan 19, 2009
1300
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1301 $comment['comment_author_email'] = '';
08d1442 XMLRPC wp_newComment() fixes. Props josephscott. fixes #8672 for trunk
ryan authored Jan 19, 2009
1302 if ( isset($content_struct['author_email']) )
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1303 $comment['comment_author_email'] = $content_struct['author_email'];
08d1442 XMLRPC wp_newComment() fixes. Props josephscott. fixes #8672 for trunk
ryan authored Jan 19, 2009
1304
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1305 $comment['comment_author_url'] = '';
08d1442 XMLRPC wp_newComment() fixes. Props josephscott. fixes #8672 for trunk
ryan authored Jan 19, 2009
1306 if ( isset($content_struct['author_url']) )
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1307 $comment['comment_author_url'] = $content_struct['author_url'];
08d1442 XMLRPC wp_newComment() fixes. Props josephscott. fixes #8672 for trunk
ryan authored Jan 19, 2009
1308
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1309 $comment['user_ID'] = 0;
1310
1311 if ( get_option('require_name_email') ) {
1312 if ( 6 > strlen($comment['comment_author_email']) || '' == $comment['comment_author'] )
1313 return new IXR_Error( 403, __( 'Comment author name and email are required' ) );
1314 elseif ( !is_email($comment['comment_author_email']) )
1315 return new IXR_Error( 403, __( 'A valid email address is required' ) );
1316 }
1317 }
1318
95fa29a Reply to comments from admin, first run, see #7435
azaozz authored Aug 24, 2008
1319 $comment['comment_parent'] = isset($content_struct['comment_parent']) ? absint($content_struct['comment_parent']) : 0;
1320
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1321 $comment['comment_content'] = $content_struct['content'];
1322
1323 do_action('xmlrpc_call', 'wp.newComment');
35b18e5 Trailing whitespace cleanup
ryan authored Aug 9, 2008
1324
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1325 return wp_new_comment($comment);
1326 }
1327
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1328 /**
1329 * Retrieve all of the comment status.
1330 *
1331 * @since 2.7.0
1332 *
1333 * @param array $args Method parameters.
1334 * @return array
1335 */
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1336 function wp_getCommentStatusList($args) {
1337 $this->escape( $args );
1338
1339 $blog_id = (int) $args[0];
1340 $username = $args[1];
1341 $password = $args[2];
1342
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1343 if ( !$user = $this->login($username, $password) ) {
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1344 return $this->error;
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1345 }
1b0bfce XML-RPC comments API. see #7446
ryan authored Aug 4, 2008
1346
1347 if ( !current_user_can( 'moderate_comments' ) )
1348 return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
1349
1350 do_action('xmlrpc_call', 'wp.getCommentStatusList');
1351
1352 return get_comment_statuses( );
1353 }
1354
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1355 /**
1356 * Retrieve comment count.
1357 *
1358 * @since 2.5.0
1359 *
1360 * @param array $args Method parameters.
1361 * @return array
1362 */
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1363 function wp_getCommentCount( $args ) {
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1364 $this->escape($args);
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1365
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1366 $blog_id = (int) $args[0];
1367 $username = $args[1];
1368 $password = $args[2];
1369 $post_id = (int) $args[3];
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1370
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1371 if ( !$user = $this->login($username, $password) ) {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
1372 return $this->error;
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1373 }
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1374
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1375 if( !current_user_can( 'edit_posts' ) ) {
428d820 Grammar fix. Props thenlich and hansengel. fixes #5991
ryan authored Feb 25, 2008
1376 return new IXR_Error( 403, __( 'You are not allowed access to details about comments.' ) );
d889837 Trailing whitespace cleanup
ryan authored Feb 5, 2008
1377 }
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1378
9f9769b Add some more actions to xmlrpc. Fixes #5686 props joesephscott.
westi authored Jan 18, 2008
1379 do_action('xmlrpc_call', 'wp.getCommentCount');
1380
94eb722 Use wp_count_comments() in wp.getCommentCount. Props josephscott. fix…
ryan authored May 9, 2008
1381 $count = wp_count_comments( $post_id );
1382 return array(
1383 "approved" => $count->approved,
1384 "awaiting_moderation" => $count->moderated,
1385 "spam" => $count->spam,
1386 "total_comments" => $count->total_comments
1387 );
99b6eff wp.getCommentCount from josephscott. fixes #5463
ryan authored Jan 1, 2008
1388 }
1389
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1390 /**
1391 * Retrieve post statuses.
1392 *
1393 * @since 2.5.0
1394 *
1395 * @param array $args Method parameters.
1396 * @return array
1397 */
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1398 function wp_getPostStatusList( $args ) {
1399 $this->escape( $args );
1400
1401 $blog_id = (int) $args[0];
1402 $username = $args[1];
1403 $password = $args[2];
1404
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1405 if ( !$user = $this->login($username, $password) ) {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
1406 return $this->error;
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1407 }
1408
1409 if( !current_user_can( 'edit_posts' ) ) {
1410 return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
1411 }
1412
9f9769b Add some more actions to xmlrpc. Fixes #5686 props joesephscott.
westi authored Jan 18, 2008
1413 do_action('xmlrpc_call', 'wp.getPostStatusList');
1414
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1415 return get_post_statuses( );
1416 }
1417
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1418 /**
1419 * Retrieve page statuses.
1420 *
1421 * @since 2.5.0
1422 *
1423 * @param array $args Method parameters.
1424 * @return array
1425 */
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1426 function wp_getPageStatusList( $args ) {
1427 $this->escape( $args );
1428
1429 $blog_id = (int) $args[0];
1430 $username = $args[1];
1431 $password = $args[2];
1432
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1433 if ( !$user = $this->login($username, $password) ) {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
1434 return $this->error;
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1435 }
1436
1437 if( !current_user_can( 'edit_posts' ) ) {
a33b080 Typo fix from rnt. fixes #5700
ryan authored Jan 22, 2008
1438 return new IXR_Error( 403, __( 'You are not allowed access to details about this blog.' ) );
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1439 }
1440
9f9769b Add some more actions to xmlrpc. Fixes #5686 props joesephscott.
westi authored Jan 18, 2008
1441 do_action('xmlrpc_call', 'wp.getPageStatusList');
1442
ac2d661 Add xmlrpc methods to discover the valid post and page statuses. See …
westi authored Jan 10, 2008
1443 return get_page_statuses( );
1444 }
1445
eb3e916 Completion and fixes for wp-app, wp-login and xmlrpc inline documenta…
azaozz authored Sep 22, 2008
1446 /**
1447 * Retrieve page templates.
1448 *
1449 * @since 2.6.0
1450 *
1451 * @param array $args Method parameters.
1452 * @return array
1453 */
5d69e51 Expose page template functionality via XML-RPC. Props josephscott. fi…
ryan authored May 6, 2008
1454 function wp_getPageTemplates( $args ) {
1455 $this->escape( $args );
1456
1457 $blog_id = (int) $args[0];
1458 $username = $args[1];
1459 $password = $args[2];
1460
9ef3298 Use user returned from auth for XML-RPC logins. Props wnorris. fixes …
ryan authored Jan 29, 2009
1461 if ( !$user = $this->login($username, $password) ) {
3f90dc2 More informative error message when remote publishing is disabled. Do…
ryan authored Jun 26, 2008
1462 return $this->error;