159
171
* @param callable $name Method to call.
160
172
* @param array $arguments Arguments to pass when calling.
161
* @return mixed|bool Return value of the callback, false otherwise.
173
* @return array|IXR_Error|false Return value of the callback, false otherwise.
163
175
public function __call( $name, $arguments ) {
164
176
if ( '_multisite_getUsersBlogs' === $name ) {
191
* @param array $args Method Parameters.
205
* @param array $args {
206
* Method arguments. Note: arguments must be ordered as documented.
208
* @type int $number1 A number to add.
209
* @type int $number2 A second number to add.
211
* @return int Sum of the two given numbers.
194
public function addTwoNumbers($args) {
213
public function addTwoNumbers( $args ) {
195
214
$number1 = $args[0];
196
215
$number2 = $args[1];
197
216
return $number1 + $number2;
584
609
* Checks if the method received at least the minimum number of arguments.
588
614
* @param string|array $args Sanitize single string or array of strings.
589
* @param int $count Minimum number of arguments.
590
* @return boolean if $args contains at least $count arguments.
615
* @param int $count Minimum number of arguments.
616
* @return bool if `$args` contains at least $count arguments.
592
618
protected function minimum_args( $args, $count ) {
593
619
if ( count( $args ) < $count ) {
604
630
* @access protected
606
* @param object $taxonomy The unprepared taxonomy data
607
* @param array $fields The subset of taxonomy fields to return
608
* @return array The prepared taxonomy data
632
* @param object $taxonomy The unprepared taxonomy data.
633
* @param array $fields The subset of taxonomy fields to return.
634
* @return array The prepared taxonomy data.
610
636
protected function _prepare_taxonomy( $taxonomy, $fields ) {
611
637
$_taxonomy = array(
647
673
* @access protected
649
* @param array|object $term The unprepared term data
650
* @return array The prepared term data
675
* @param array|object $term The unprepared term data.
676
* @return array The prepared term data.
652
678
protected function _prepare_term( $term ) {
654
if ( ! is_array( $_term) )
680
if ( ! is_array( $_term ) )
655
681
$_term = get_object_vars( $_term );
657
683
// For integers which may be larger than XML-RPC supports ensure we return strings.
711
737
* @access protected
713
* @param array $post The unprepared post data
714
* @param array $fields The subset of post type fields to return
715
* @return array The prepared post data
739
* @param array $post The unprepared post data.
740
* @param array $fields The subset of post type fields to return.
741
* @return array The prepared post data.
717
743
protected function _prepare_post( $post, $fields ) {
718
// holds the data for this post. built up based on $fields
744
// Holds the data for this post. built up based on $fields.
719
745
$_post = array( 'post_id' => strval( $post['ID'] ) );
721
// prepare common post fields
747
// Prepare common post fields.
722
748
$post_fields = array(
723
749
'post_title' => $post['post_title'],
724
750
'post_date' => $this->_convert_date( $post['post_date'] ),
750
776
$post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size );
753
// Consider future posts as published
779
// Consider future posts as published.
754
780
if ( $post_fields['post_status'] === 'future' )
755
781
$post_fields['post_status'] = 'publish';
757
// Fill in blank post format
783
// Fill in blank post format.
758
784
$post_fields['post_format'] = get_post_format( $post['ID'] );
759
785
if ( empty( $post_fields['post_format'] ) )
760
786
$post_fields['post_format'] = 'standard';
762
// Merge requested $post_fields fields into $_post
788
// Merge requested $post_fields fields into $_post.
763
789
if ( in_array( 'post', $fields ) ) {
764
790
$_post = array_merge( $_post, $post_fields );
810
836
* @access protected
812
* @param object $post_type Post type object
813
* @param array $fields The subset of post fields to return
814
* @return array The prepared post type data
838
* @param object $post_type Post type object.
839
* @param array $fields The subset of post fields to return.
840
* @return array The prepared post type data.
816
842
protected function _prepare_post_type( $post_type, $fields ) {
817
843
$_post_type = array(
860
886
* @access protected
862
* @param object $media_item The unprepared media item data
863
* @param string $thumbnail_size The image size to use for the thumbnail URL
864
* @return array The prepared media item data
888
* @param object $media_item The unprepared media item data.
889
* @param string $thumbnail_size The image size to use for the thumbnail URL.
890
* @return array The prepared media item data.
866
892
protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
867
893
$_media_item = array(
1029
1055
* @access protected
1031
* @param WP_User $user The unprepared user object
1032
* @param array $fields The subset of user fields to return
1033
* @return array The prepared user data
1057
* @param WP_User $user The unprepared user object.
1058
* @param array $fields The subset of user fields to return.
1059
* @return array The prepared user data.
1035
1061
protected function _prepare_user( $user, $fields ) {
1036
1062
$_user = array( 'user_id' => strval( $user->ID ) );
1080
* @param array $args Method parameters. Contains:
1081
* - int $blog_id (unused)
1082
* - string $username
1083
* - string $password
1084
* - array $content_struct
1085
* $content_struct can contain:
1086
* - post_type (default: 'post')
1087
* - post_status (default: 'draft')
1092
* - post_date_gmt | post_date
1095
* - comment_status - can be 'open' | 'closed'
1096
* - ping_status - can be 'open' | 'closed'
1098
* - post_thumbnail - ID of a media item to use as the post thumbnail/featured image
1099
* - custom_fields - array, with each element containing 'key' and 'value'
1100
* - terms - array, with taxonomy names as keys and arrays of term IDs as values
1101
* - terms_names - array, with taxonomy names as keys and arrays of term names as values
1103
* - any other fields supported by wp_insert_post()
1104
* @return string|IXR_Error post_id
1106
* @link http://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures.
1108
* @param array $args {
1109
* Method arguments. Note: top-level arguments must be ordered as documented.
1111
* @type int $blog_id Blog ID (unused).
1112
* @type string $username Username.
1113
* @type string $password Password.
1114
* @type array $content_struct {
1115
* Content struct for adding a new post. See wp_insert_post() for information on
1116
* additional post fields
1118
* @type string $post_type Post type. Default 'post'.
1119
* @type string $post_status Post status. Default 'draft'
1120
* @type string $post_title Post title.
1121
* @type int $post_author Post author ID.
1122
* @type string $post_excerpt Post excerpt.
1123
* @type string $post_content Post content.
1124
* @type string $post_date_gmt Post date in GMT.
1125
* @type string $post_date Post date.
1126
* @type string $post_password Post password (20-character limit).
1127
* @type string $comment_status Post comment enabled status. Accepts 'open' or 'closed'.
1128
* @type string $ping_status Post ping status. Accepts 'open' or 'closed'.
1129
* @type bool $sticky Whether the post should be sticky. Automatically false if
1130
* `$post_status` is 'private'.
1131
* @type int $post_thumbnail ID of an image to use as the post thumbnail/featured image.
1132
* @type array $custom_fields Array of meta key/value pairs to add to the post.
1133
* @type array $terms Associative array with taxonomy names as keys and arrays
1134
* of term IDs as values.
1135
* @type array $terms_names Associative array with taxonomy names as keys and arrays
1136
* of term names as values.
1137
* @type array $enclosure {
1138
* Array of feed enclosure data to add to post meta.
1140
* @type string $url URL for the feed enclosure.
1141
* @type int $length Size in bytes of the enclosure.
1142
* @type string $type Mime-type for the enclosure.
1146
* @return int|IXR_Error Post ID on success, IXR_Error instance otherwise.
1106
1148
public function wp_newPost( $args ) {
1107
1149
if ( ! $this->minimum_args( $args, 4 ) )
1154
* Helper method for wp_newPost and wp_editPost, containing shared logic.
1196
* Encapsulate the logic for sticking a post
1197
* and determining if the user has permission to do so
1202
* @param array $post_data
1203
* @param bool $update
1204
* @return void|IXR_Error
1206
private function _toggle_sticky( $post_data, $update = false ) {
1207
$post_type = get_post_type_object( $post_data['post_type'] );
1209
// Private and password-protected posts cannot be stickied.
1210
if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) {
1211
// Error if the client tried to stick the post, otherwise, silently unstick.
1212
if ( ! empty( $post_data['sticky'] ) ) {
1213
return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) );
1217
unstick_post( $post_data['ID'] );
1219
} elseif ( isset( $post_data['sticky'] ) ) {
1220
if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
1221
return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) );
1224
$sticky = wp_validate_boolean( $post_data['sticky'] );
1226
stick_post( $post_data['ID'] );
1228
unstick_post( $post_data['ID'] );
1234
* Helper method for wp_newPost() and wp_editPost(), containing shared logic.
1157
* @uses wp_insert_post()
1159
* @param WP_User $user The post author if post_author isn't set in $content_struct.
1239
* @see wp_insert_post()
1241
* @param WP_User $user The post author if post_author isn't set in $content_struct.
1160
1242
* @param array|IXR_Error $content_struct Post data to insert.
1243
* @return IXR_Error|string
1162
1245
protected function _insert_post( $user, $content_struct ) {
1163
1246
$defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0,
1224
1307
if ( isset( $post_data['ping_status'] ) && $post_data['ping_status'] != 'open' && $post_data['ping_status'] != 'closed' )
1225
1308
unset( $post_data['ping_status'] );
1227
// Do some timestamp voodoo
1310
// Do some timestamp voodoo.
1228
1311
if ( ! empty( $post_data['post_date_gmt'] ) ) {
1229
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
1312
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
1230
1313
$dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
1231
1314
} elseif ( ! empty( $post_data['post_date'] ) ) {
1232
1315
$dateCreated = $post_data['post_date']->getIso();
1242
1325
$post_ID = $post_data['ID'];
1244
1327
if ( $post_data['post_type'] == 'post' ) {
1245
// Private and password-protected posts cannot be stickied.
1246
if ( $post_data['post_status'] == 'private' || ! empty( $post_data['post_password'] ) ) {
1247
// Error if the client tried to stick the post, otherwise, silently unstick.
1248
if ( ! empty( $post_data['sticky'] ) )
1249
return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) );
1251
unstick_post( $post_ID );
1252
} elseif ( isset( $post_data['sticky'] ) ) {
1253
if ( ! current_user_can( $post_type->cap->edit_others_posts ) )
1254
return new IXR_Error( 401, __( 'Sorry, you are not allowed to stick this post.' ) );
1255
if ( $post_data['sticky'] )
1256
stick_post( $post_ID );
1258
unstick_post( $post_ID );
1328
$error = $this->_toggle_sticky( $post_data, $update );
1262
1334
if ( isset( $post_data['post_thumbnail'] ) ) {
1263
// empty value deletes, non-empty value adds/updates
1335
// empty value deletes, non-empty value adds/updates.
1264
1336
if ( ! $post_data['post_thumbnail'] )
1265
1337
delete_post_thumbnail( $post_ID );
1266
1338
elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) )
1275
1347
if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) {
1276
1348
$post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' );
1278
// accumulate term IDs from terms and terms_names
1350
// Accumulate term IDs from terms and terms_names.
1279
1351
$terms = array();
1281
// first validate the terms specified by ID
1353
// First validate the terms specified by ID.
1282
1354
if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) {
1283
1355
$taxonomies = array_keys( $post_data['terms'] );
1285
// validating term ids
1357
// Validating term ids.
1286
1358
foreach ( $taxonomies as $taxonomy ) {
1287
1359
if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) )
1288
1360
return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
1314
1386
if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->assign_terms ) )
1315
1387
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
1317
// for hierarchical taxonomies, we can't assign a term when multiple terms in the hierarchy share the same name
1390
* For hierarchical taxonomies, we can't assign a term when multiple terms
1391
* in the hierarchy share the same name.
1318
1393
$ambiguous_terms = array();
1319
1394
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
1320
1395
$tax_term_names = get_terms( $taxonomy, array( 'fields' => 'names', 'hide_empty' => false ) );
1322
// count the number of terms with the same name
1397
// Count the number of terms with the same name.
1323
1398
$tax_term_names_count = array_count_values( $tax_term_names );
1325
// filter out non-ambiguous term names
1400
// Filter out non-ambiguous term names.
1326
1401
$ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') );
1328
1403
$ambiguous_terms = array_keys( $ambiguous_tax_term_counts );
1336
1411
$term = get_term_by( 'name', $term_name, $taxonomy );
1338
1413
if ( ! $term ) {
1339
// term doesn't exist, so check that the user is allowed to create new terms
1414
// Term doesn't exist, so check that the user is allowed to create new terms.
1340
1415
if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->edit_terms ) )
1341
1416
return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) );
1343
// create the new term
1418
// Create the new term.
1344
1419
$term_info = wp_insert_term( $term_name, $taxonomy );
1345
1420
if ( is_wp_error( $term_info ) )
1346
1421
return new IXR_Error( 500, $term_info->get_error_message() );
1356
1431
$post_data['tax_input'] = $terms;
1357
1432
unset( $post_data['terms'], $post_data['terms_names'] );
1359
// do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'
1434
// Do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'.
1360
1435
unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] );
1406
* @param array $args Method parameters. Contains:
1407
* - int $blog_id (unused)
1408
* - string $username
1409
* - string $password
1411
* - array $content_struct
1412
* @return bool|IXR_Error true on success
1481
* @param array $args {
1482
* Method arguments. Note: arguments must be ordered as documented.
1484
* @type int $blog_id Blog ID (unused).
1485
* @type string $username Username.
1486
* @type string $password Password.
1487
* @type int $post_id Post ID.
1488
* @type array $content_struct Extra content arguments.
1490
* @return true|IXR_Error True on success, IXR_Error on failure.
1414
1492
public function wp_editPost( $args ) {
1415
1493
if ( ! $this->minimum_args( $args, 5 ) )
1443
// convert the date field back to IXR form
1521
// Convert the date field back to IXR form.
1444
1522
$post['post_date'] = $this->_convert_date( $post['post_date'] );
1446
// ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
1447
// since _insert_post will ignore the non-GMT date if the GMT date is set
1525
* Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
1526
* since _insert_post() will ignore the non-GMT date if the GMT date is set.
1448
1528
if ( $post['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) )
1449
1529
unset( $post['post_date_gmt'] );
1468
* @uses wp_delete_post()
1469
* @param array $args Method parameters. Contains:
1470
* - int $blog_id (unused)
1471
* - string $username
1472
* - string $password
1474
* @return bool|IXR_Error true on success
1548
* @see wp_delete_post()
1550
* @param array $args {
1551
* Method arguments. Note: arguments must be ordered as documented.
1553
* @type int $blog_id Blog ID (unused).
1554
* @type string $username Username.
1555
* @type string $password Password.
1556
* @type int $post_id Post ID.
1558
* @return true|IXR_Error True on success, IXR_Error instance on failure.
1476
1560
public function wp_deletePost( $args ) {
1477
1561
if ( ! $this->minimum_args( $args, 4 ) )
1518
1602
* groups are 'post' (all basic fields), 'taxonomies', 'custom_fields',
1519
1603
* and 'enclosure'.
1522
* @param array $args Method parameters. Contains:
1523
* - int $blog_id (unused)
1524
* - string $username
1525
* - string $password
1527
* - array $fields optional
1607
* @param array $args {
1608
* Method arguments. Note: arguments must be ordered as documented.
1610
* @type int $blog_id Blog ID (unused).
1611
* @type string $username Username.
1612
* @type string $password Password.
1613
* @type int $post_id Post ID.
1614
* @type array $fields The subset of post type fields to return.
1528
1616
* @return array|IXR_Error Array contains (based on $fields parameter):
1530
1618
* - 'post_title'
1598
* The optional $filter parameter modifies the query used to retrieve posts.
1599
* Accepted keys are 'post_type', 'post_status', 'number', 'offset',
1600
* 'orderby', and 'order'.
1602
* The optional $fields parameter specifies what fields will be included
1603
* in the response array.
1605
* @uses wp_get_recent_posts()
1606
* @see wp_getPost() for more on $fields
1607
* @see get_posts() for more on $filter values
1609
* @param array $args Method parameters. Contains:
1610
* - int $blog_id (unused)
1611
* - string $username
1612
* - string $password
1613
* - array $filter optional
1614
* - array $fields optional
1686
* @see wp_get_recent_posts()
1687
* @see wp_getPost() for more on `$fields`
1688
* @see get_posts() for more on `$filter` values
1690
* @param array $args {
1691
* Method arguments. Note: arguments must be ordered as documented.
1693
* @type int $blog_id Blog ID (unused).
1694
* @type string $username Username.
1695
* @type string $password Password.
1696
* @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'post_type',
1697
* 'post_status', 'number', 'offset', 'orderby', and 'order'.
1698
* Default empty array.
1699
* @type array $fields Optional. The subset of post type fields to return in the response array.
1615
1701
* @return array|IXR_Error Array contains a collection of posts.
1617
1703
public function wp_getPosts( $args ) {
1698
* @uses wp_insert_term()
1699
* @param array $args Method parameters. Contains:
1700
* - int $blog_id (unused)
1701
* - string $username
1702
* - string $password
1703
* - array $content_struct
1704
* The $content_struct must contain:
1707
* Also, it can optionally contain:
1711
* @return string|IXR_Error term_id
1784
* @see wp_insert_term()
1786
* @param array $args {
1787
* Method arguments. Note: arguments must be ordered as documented.
1789
* @type int $blog_id Blog ID (unused).
1790
* @type string $username Username.
1791
* @type string $password Password.
1792
* @type array $content_struct Content struct for adding a new term. The struct must contain
1793
* the term 'name' and 'taxonomy'. Optional accepted values include
1794
* 'parent', 'description', and 'slug'.
1796
* @return int|IXR_Error The term ID on success, or an IXR_Error object on failure.
1713
1798
public function wp_newTerm( $args ) {
1714
1799
if ( ! $this->minimum_args( $args, 4 ) )
1784
* @uses wp_update_term()
1785
* @param array $args Method parameters. Contains:
1786
* - int $blog_id (unused)
1787
* - string $username
1788
* - string $password
1790
* - array $content_struct
1791
* The $content_struct must contain:
1793
* Also, it can optionally contain:
1798
* @return bool|IXR_Error True, on success.
1869
* @see wp_update_term()
1871
* @param array $args {
1872
* Method arguments. Note: arguments must be ordered as documented.
1874
* @type int $blog_id Blog ID (unused).
1875
* @type string $username Username.
1876
* @type string $password Password.
1877
* @type int $term_id Term ID.
1878
* @type array $content_struct Content struct for editing a term. The struct must contain the
1879
* term ''taxonomy'. Optional accepted values include 'name', 'parent',
1880
* 'description', and 'slug'.
1882
* @return true|IXR_Error True on success, IXR_Error instance on failure.
1800
1884
public function wp_editTerm( $args ) {
1801
1885
if ( ! $this->minimum_args( $args, 5 ) )
1883
* @uses wp_delete_term()
1884
* @param array $args Method parameters. Contains:
1885
* - int $blog_id (unused)
1886
* - string $username
1887
* - string $password
1888
* - string $taxnomy_name
1890
* @return boolean|IXR_Error If it suceeded true else a reason why not
1967
* @see wp_delete_term()
1969
* @param array $args {
1970
* Method arguments. Note: arguments must be ordered as documented.
1972
* @type int $blog_id Blog ID (unused).
1973
* @type string $username Username.
1974
* @type string $password Password.
1975
* @type string $taxnomy_name Taxonomy name.
1976
* @type int $term_id Term ID.
1978
* @return bool|IXR_Error True on success, IXR_Error instance on failure.
1892
1980
public function wp_deleteTerm( $args ) {
1893
1981
if ( ! $this->minimum_args( $args, 5 ) )
1942
* @param array $args Method parameters. Contains:
1943
* - int $blog_id (unused)
1944
* - string $username
1945
* - string $password
1946
* - string $taxonomy
1948
* @return array|IXR_Error Array contains:
2031
* @param array $args {
2032
* Method arguments. Note: arguments must be ordered as documented.
2034
* @type int $blog_id Blog ID (unused).
2035
* @type string $username Username.
2036
* @type string $password Password.
2037
* @type string $taxnomy Taxonomy name.
2038
* @type string $term_id Term ID.
2040
* @return array|IXR_Error IXR_Error on failure, array on success, containing:
2000
2092
* The optional $filter parameter modifies the query used to retrieve terms.
2001
2093
* Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.
2004
* @param array $args Method parameters. Contains:
2005
* - int $blog_id (unused)
2006
* - string $username
2007
* - string $password
2008
* - string $taxonomy
2009
* - array $filter optional
2010
* @return array|IXR_Error terms
2097
* @param array $args {
2098
* Method arguments. Note: arguments must be ordered as documented.
2100
* @type int $blog_id Blog ID (unused).
2101
* @type string $username Username.
2102
* @type string $password Password.
2103
* @type string $taxnomy Taxonomy name.
2104
* @type array $filter Optional. Modifies the query used to retrieve posts. Accepts 'number',
2105
* 'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array.
2107
* @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise.
2012
2109
public function wp_getTerms( $args ) {
2013
2110
if ( ! $this->minimum_args( $args, 4 ) )
2079
* @uses get_taxonomy()
2080
* @param array $args Method parameters. Contains:
2081
* - int $blog_id (unused)
2082
* - string $username
2083
* - string $password
2084
* - string $taxonomy
2085
* @return array|IXR_Error (@see get_taxonomy())
2176
* @see get_taxonomy()
2178
* @param array $args {
2179
* Method arguments. Note: arguments must be ordered as documented.
2181
* @type int $blog_id Blog ID (unused).
2182
* @type string $username Username.
2183
* @type string $password Password.
2184
* @type string $taxnomy Taxonomy name.
2185
* @type array $fields Optional. Array of taxonomy fields to limit to in the return.
2186
* Accepts 'labels', 'cap', 'menu', and 'object_type'.
2187
* Default empty array.
2189
* @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise.
2087
2191
public function wp_getTaxonomy( $args ) {
2088
2192
if ( ! $this->minimum_args( $args, 4 ) )
2133
* @uses get_taxonomies()
2134
* @param array $args Method parameters. Contains:
2135
* - int $blog_id (unused)
2136
* - string $username
2137
* - string $password
2138
* @return array taxonomies
2237
* @see get_taxonomies()
2239
* @param array $args {
2240
* Method arguments. Note: arguments must be ordered as documented.
2242
* @type int $blog_id Blog ID (unused).
2243
* @type string $username Username.
2244
* @type string $password Password.
2245
* @type array $filter Optional. An array of arguments for retrieving taxonomies.
2246
* @type array $fields Optional. The subset of taxonomy fields to return.
2248
* @return array|IXR_Error An associative array of taxonomy data with returned fields determined
2249
* by `$fields`, or an IXR_Error instance on failure.
2140
2251
public function wp_getTaxonomies( $args ) {
2141
2252
if ( ! $this->minimum_args( $args, 3 ) )
2188
2299
* groups are 'basic' and 'all'.
2190
2301
* @uses get_userdata()
2191
* @param array $args Method parameters. Contains:
2192
* - int $blog_id (unused)
2193
* - string $username
2194
* - string $password
2196
* - array $fields optional
2303
* @param array $args {
2304
* Method arguments. Note: arguments must be ordered as documented.
2306
* @type int $blog_id (unused)
2307
* @type string $username
2308
* @type string $password
2309
* @type int $user_id
2310
* @type array $fields (optional)
2197
2312
* @return array|IXR_Error Array contains (based on $fields parameter):
2262
2377
* @uses get_users()
2263
2378
* @see wp_getUser() for more on $fields and return values
2265
* @param array $args Method parameters. Contains:
2266
* - int $blog_id (unused)
2267
* - string $username
2268
* - string $password
2269
* - array $filter optional
2270
* - array $fields optional
2380
* @param array $args {
2381
* Method arguments. Note: arguments must be ordered as documented.
2383
* @type int $blog_id (unused)
2384
* @type string $username
2385
* @type string $password
2386
* @type array $filter (optional)
2387
* @type array $fields (optional)
2271
2389
* @return array|IXR_Error users data
2273
2391
public function wp_getUsers( $args ) {
2333
2451
* Retrieve information about the requesting user.
2335
2453
* @uses get_userdata()
2336
* @param array $args Method parameters. Contains:
2337
* - int $blog_id (unused)
2338
* - string $username
2339
* - string $password
2340
* - array $fields optional
2455
* @param array $args {
2456
* Method arguments. Note: arguments must be ordered as documented.
2458
* @type int $blog_id (unused)
2459
* @type string $username
2460
* @type string $password
2461
* @type array $fields (optional)
2341
2463
* @return array|IXR_Error (@see wp_getUser)
2343
2465
public function wp_getProfile( $args ) {
2453
* @param array $args Method parameters. Contains:
2454
* - blog_id (unused)
2578
* @param array $args {
2579
* Method arguments. Note: arguments must be ordered as documented.
2581
* @type int $blog_id (unused)
2582
* @type int $page_id
2583
* @type string $username
2584
* @type string $password
2458
2586
* @return array|IXR_Error
2460
public function wp_getPage($args) {
2461
$this->escape($args);
2588
public function wp_getPage( $args ) {
2589
$this->escape( $args );
2463
$page_id = (int) $args[1];
2464
$username = $args[2];
2465
$password = $args[3];
2591
$page_id = (int) $args[1];
2592
$username = $args[2];
2593
$password = $args[3];
2467
2595
if ( !$user = $this->login($username, $password) ) {
2468
2596
return $this->error;
2496
* @param array $args Method parameters. Contains:
2497
* - blog_id (unused)
2624
* @param array $args {
2625
* Method arguments. Note: arguments must be ordered as documented.
2627
* @type int $blog_id (unused)
2628
* @type string $username
2629
* @type string $password
2630
* @type int $num_pages
2501
2632
* @return array|IXR_Error
2503
public function wp_getPages($args) {
2504
$this->escape($args);
2634
public function wp_getPages( $args ) {
2635
$this->escape( $args );
2506
$username = $args[1];
2507
$password = $args[2];
2508
$num_pages = isset($args[3]) ? (int) $args[3] : 10;
2637
$username = $args[1];
2638
$password = $args[2];
2639
$num_pages = isset($args[3]) ? (int) $args[3] : 10;
2510
2641
if ( !$user = $this->login($username, $password) )
2511
2642
return $this->error;
2542
* @param array $args Method parameters. See {@link wp_xmlrpc_server::mw_newPost()}
2673
* @see wp_xmlrpc_server::mw_newPost()
2675
* @param array $args {
2676
* Method arguments. Note: arguments must be ordered as documented.
2678
* @type int $blog_id (unused)
2679
* @type string $username
2680
* @type string $password
2681
* @type array $content_struct
2543
2683
* @return int|IXR_Error
2545
public function wp_newPage($args) {
2685
public function wp_newPage( $args ) {
2546
2686
// Items not escaped here will be escaped in newPost.
2547
$username = $this->escape($args[1]);
2548
$password = $this->escape($args[2]);
2687
$username = $this->escape( $args[1] );
2688
$password = $this->escape( $args[2] );
2550
2690
if ( !$user = $this->login($username, $password) )
2551
2691
return $this->error;
2568
* @param array $args Method parameters.
2569
* @return bool|IXR_Error True, if success.
2708
* @param array $args {
2709
* Method arguments. Note: arguments must be ordered as documented.
2711
* @type int $blog_id (unused)
2712
* @type string $username
2713
* @type string $password
2714
* @type int $page_id
2716
* @return true|IXR_Error True, if success.
2571
public function wp_deletePage($args) {
2572
$this->escape($args);
2718
public function wp_deletePage( $args ) {
2719
$this->escape( $args );
2574
$username = $args[1];
2575
$password = $args[2];
2576
$page_id = (int) $args[3];
2721
$username = $args[1];
2722
$password = $args[2];
2723
$page_id = (int) $args[3];
2578
2725
if ( !$user = $this->login($username, $password) )
2579
2726
return $this->error;
2617
* @param array $args Method parameters.
2764
* @param array $args {
2765
* Method arguments. Note: arguments must be ordered as documented.
2767
* @type int $blog_id (unused)
2768
* @type int $page_id
2769
* @type string $username
2770
* @type string $password
2771
* @type string $content
2772
* @type string $publish
2618
2774
* @return array|IXR_Error
2620
public function wp_editPage($args) {
2621
// Items not escaped here will be escaped in editPost.
2622
$page_id = (int) $this->escape($args[1]);
2623
$username = $this->escape($args[2]);
2624
$password = $this->escape($args[3]);
2625
$content = $args[4];
2626
$publish = $args[5];
2628
if ( !$user = $this->login($username, $password) )
2776
public function wp_editPage( $args ) {
2777
// Items will be escaped in mw_editPost.
2778
$page_id = (int) $args[1];
2779
$username = $args[2];
2780
$password = $args[3];
2781
$content = $args[4];
2782
$publish = $args[5];
2784
$escaped_username = $this->escape( $username );
2785
$escaped_password = $this->escape( $password );
2787
if ( !$user = $this->login( $escaped_username, $escaped_password ) ) {
2629
2788
return $this->error;
2631
2791
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
2632
2792
do_action( 'xmlrpc_call', 'wp.editPage' );
2664
* @param array $args Method parameters.
2824
* @global wpdb $wpdb
2826
* @param array $args {
2827
* Method arguments. Note: arguments must be ordered as documented.
2829
* @type int $blog_id (unused)
2830
* @type string $username
2831
* @type string $password
2665
2833
* @return array|IXR_Error
2667
public function wp_getPageList($args) {
2835
public function wp_getPageList( $args ) {
2670
$this->escape($args);
2838
$this->escape( $args );
2672
$username = $args[1];
2673
$password = $args[2];
2840
$username = $args[1];
2841
$password = $args[2];
2675
2843
if ( !$user = $this->login($username, $password) )
2676
2844
return $this->error;
2716
* @param array $args Method parameters.
2884
* @param array $args {
2885
* Method arguments. Note: arguments must be ordered as documented.
2887
* @type int $blog_id (unused)
2888
* @type string $username
2889
* @type string $password
2717
2891
* @return array|IXR_Error
2719
public function wp_getAuthors($args) {
2721
$this->escape($args);
2723
$username = $args[1];
2724
$password = $args[2];
2893
public function wp_getAuthors( $args ) {
2894
$this->escape( $args );
2896
$username = $args[1];
2897
$password = $args[2];
2726
2899
if ( !$user = $this->login($username, $password) )
2727
2900
return $this->error;
2794
* @param array $args Method parameters.
2973
* @param array $args {
2974
* Method arguments. Note: arguments must be ordered as documented.
2976
* @type int $blog_id (unused)
2977
* @type string $username
2978
* @type string $password
2979
* @type array $category
2795
2981
* @return int|IXR_Error Category ID.
2797
public function wp_newCategory($args) {
2798
$this->escape($args);
2983
public function wp_newCategory( $args ) {
2984
$this->escape( $args );
2800
$username = $args[1];
2801
$password = $args[2];
2802
$category = $args[3];
2986
$username = $args[1];
2987
$password = $args[2];
2988
$category = $args[3];
2804
2990
if ( !$user = $this->login($username, $password) )
2805
2991
return $this->error;
2863
* @param array $args Method parameters.
3049
* @param array $args {
3050
* Method arguments. Note: arguments must be ordered as documented.
3052
* @type int $blog_id (unused)
3053
* @type string $username
3054
* @type string $password
3055
* @type int $category_id
2864
3057
* @return bool|IXR_Error See {@link wp_delete_term()} for return info.
2866
public function wp_deleteCategory($args) {
2867
$this->escape($args);
3059
public function wp_deleteCategory( $args ) {
3060
$this->escape( $args );
2869
$username = $args[1];
2870
$password = $args[2];
2871
$category_id = (int) $args[3];
3062
$username = $args[1];
3063
$password = $args[2];
3064
$category_id = (int) $args[3];
2873
3066
if ( !$user = $this->login($username, $password) )
2874
3067
return $this->error;
2904
* @param array $args Method parameters.
3097
* @param array $args {
3098
* Method arguments. Note: arguments must be ordered as documented.
3100
* @type int $blog_id (unused)
3101
* @type string $username
3102
* @type string $password
3103
* @type array $category
3104
* @type int $max_results
2905
3106
* @return array|IXR_Error
2907
public function wp_suggestCategories($args) {
2908
$this->escape($args);
3108
public function wp_suggestCategories( $args ) {
3109
$this->escape( $args );
2910
$username = $args[1];
2911
$password = $args[2];
2912
$category = $args[3];
2913
$max_results = (int) $args[4];
3111
$username = $args[1];
3112
$password = $args[2];
3113
$category = $args[3];
3114
$max_results = (int) $args[4];
2915
3116
if ( !$user = $this->login($username, $password) )
2916
3117
return $this->error;
2982
* @param array $args Method parameters.
3190
* @param array $args {
3191
* Method arguments. Note: arguments must be ordered as documented.
3193
* @type int $blog_id (unused)
3194
* @type string $username
3195
* @type string $password
3196
* @type array $struct
2983
3198
* @return array|IXR_Error Contains a collection of comments. See {@link wp_xmlrpc_server::wp_getComment()} for a description of each item contents
2985
public function wp_getComments($args) {
2986
$this->escape($args);
3200
public function wp_getComments( $args ) {
3201
$this->escape( $args );
2988
$username = $args[1];
2989
$password = $args[2];
2990
$struct = isset( $args[3] ) ? $args[3] : array();
3203
$username = $args[1];
3204
$password = $args[2];
3205
$struct = isset( $args[3] ) ? $args[3] : array();
2992
3207
if ( !$user = $this->login($username, $password) )
2993
3208
return $this->error;
3015
3230
if ( isset($struct['number']) )
3016
3231
$number = absint($struct['number']);
3018
$comments = get_comments( array('status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
3233
$comments = get_comments( array( 'status' => $status, 'post_id' => $post_id, 'offset' => $offset, 'number' => $number ) );
3020
3235
$comments_struct = array();
3022
foreach ( $comments as $comment ) {
3023
$comments_struct[] = $this->_prepare_comment( $comment );
3236
if ( is_array( $comments ) ) {
3237
foreach ( $comments as $comment ) {
3238
$comments_struct[] = $this->_prepare_comment( $comment );
3026
3242
return $comments_struct;
3093
3312
* - 'author_email'
3095
3314
* - 'date_created_gmt'
3096
* - 'status'. Common statuses are 'approve', 'hold', 'spam'. See {@link get_comment_statuses()} for more details
3315
* - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details
3100
* @param array $args Contains:
3101
* - blog_id (unused)
3106
* @return bool|IXR_Error True, on success.
3319
* @param array $args {
3320
* Method arguments. Note: arguments must be ordered as documented.
3322
* @type int $blog_id (unused)
3323
* @type string $username
3324
* @type string $password
3325
* @type int $comment_ID
3326
* @type array $content_struct
3328
* @return true|IXR_Error True, on success.
3108
public function wp_editComment($args) {
3109
$this->escape($args);
3330
public function wp_editComment( $args ) {
3331
$this->escape( $args );
3111
3333
$username = $args[1];
3112
3334
$password = $args[2];
3563
3841
* The defaults are as follows:
3564
3842
* - 'number' - Default is 5. Total number of media items to retrieve.
3565
* - 'offset' - Default is 0. See {@link WP_Query::query()} for more.
3843
* - 'offset' - Default is 0. See WP_Query::query() for more.
3566
3844
* - 'parent_id' - Default is ''. The post where the media item is attached. Empty string shows all media items. 0 shows unattached media items.
3567
3845
* - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf')
3571
* @param array $args Method parameters. Contains:
3572
* - blog_id (unused)
3576
* @return array|IXR_Error Contains a collection of media items. See {@link wp_xmlrpc_server::wp_getMediaItem()} for a description of each item contents
3849
* @param array $args {
3850
* Method arguments. Note: arguments must be ordered as documented.
3852
* @type int $blog_id (unused)
3853
* @type string $username
3854
* @type string $password
3855
* @type array $struct
3857
* @return array|IXR_Error Contains a collection of media items. See wp_xmlrpc_server::wp_getMediaItem() for a description of each item contents
3578
3859
public function wp_getMediaLibrary($args) {
3579
3860
$this->escape($args);
3610
* Retrieves a list of post formats used by the site
3614
* @param array $args Method parameters. Contains:
3615
* - blog_id (unused)
3618
* @return array|IXR_Error
3891
* Retrieves a list of post formats used by the site.
3895
* @param array $args {
3896
* Method arguments. Note: arguments must be ordered as documented.
3898
* @type int $blog_id (unused)
3899
* @type string $username
3900
* @type string $password
3902
* @return array|IXR_Error List of post formats, otherwise IXR_Error object.
3620
3904
public function wp_getPostFormats( $args ) {
3621
3905
$this->escape( $args );
3660
* @uses get_post_type_object()
3661
* @param array $args Method parameters. Contains:
3662
* - int $blog_id (unused)
3663
* - string $username
3664
* - string $password
3665
* - string $post_type_name
3944
* @see get_post_type_object()
3946
* @param array $args {
3947
* Method arguments. Note: arguments must be ordered as documented.
3949
* @type int $blog_id (unused)
3950
* @type string $username
3951
* @type string $password
3952
* @type string $post_type_name
3953
* @type array $fields (optional)
3667
3955
* @return array|IXR_Error Array contains:
3669
3957
* - 'description'
3705
3993
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
3706
3994
do_action( 'xmlrpc_call', 'wp.getPostType' );
3708
if( ! post_type_exists( $post_type_name ) )
3996
if ( ! post_type_exists( $post_type_name ) )
3709
3997
return new IXR_Error( 403, __( 'Invalid post type' ) );
3711
3999
$post_type = get_post_type_object( $post_type_name );
3713
if( ! current_user_can( $post_type->cap->edit_posts ) )
4001
if ( ! current_user_can( $post_type->cap->edit_posts ) )
3714
4002
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post type.' ) );
3716
4004
return $this->_prepare_post_type( $post_type, $fields );
3724
* @uses get_post_types()
3725
* @param array $args Method parameters. Contains:
3726
* - int $blog_id (unused)
3727
* - string $username
3728
* - string $password
4012
* @see get_post_types()
4014
* @param array $args {
4015
* Method arguments. Note: arguments must be ordered as documented.
4017
* @type int $blog_id (unused)
4018
* @type string $username
4019
* @type string $password
4020
* @type array $filter (optional)
4021
* @type array $fields (optional)
3731
4023
* @return array|IXR_Error
3733
4025
public function wp_getPostTypes( $args ) {
3778
4070
* @uses wp_get_post_revisions()
3779
4071
* @see wp_getPost() for more on $fields
3781
* @param array $args Method parameters. Contains:
3782
* - int $blog_id (unused)
3783
* - string $username
3784
* - string $password
4073
* @param array $args {
4074
* Method arguments. Note: arguments must be ordered as documented.
4076
* @type int $blog_id (unused)
4077
* @type string $username
4078
* @type string $password
4079
* @type int $post_id
4080
* @type array $fields (optional)
3787
4082
* @return array|IXR_Error contains a collection of posts.
3789
4084
public function wp_getRevisions( $args ) {
3817
4112
do_action( 'xmlrpc_call', 'wp.getRevisions' );
3819
4114
if ( ! $post = get_post( $post_id ) )
3820
return new IXR_Error( 404, __( 'Invalid post ID' ) );
4115
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
3822
4117
if ( ! current_user_can( 'edit_post', $post_id ) )
3823
4118
return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
3855
4150
* @uses wp_restore_post_revision()
3857
* @param array $args Method parameters. Contains:
3858
* - int $blog_id (unused)
3859
* - string $username
3860
* - string $password
4152
* @param array $args {
4153
* Method arguments. Note: arguments must be ordered as documented.
4155
* @type int $blog_id (unused)
4156
* @type string $username
4157
* @type string $password
4158
* @type int $revision_id
3862
4160
* @return bool|IXR_Error false if there was an error restoring, true if success.
3864
4162
public function wp_restoreRevision( $args ) {
3878
4176
do_action( 'xmlrpc_call', 'wp.restoreRevision' );
3880
4178
if ( ! $revision = wp_get_post_revision( $revision_id ) )
3881
return new IXR_Error( 404, __( 'Invalid post ID' ) );
4179
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
3883
4181
if ( wp_is_post_autosave( $revision ) )
3884
return new IXR_Error( 404, __( 'Invalid post ID' ) );
4182
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
3886
4184
if ( ! $post = get_post( $revision->post_parent ) )
3887
return new IXR_Error( 404, __( 'Invalid post ID' ) );
4185
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
3889
4187
if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
3890
4188
return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
3981
* @param array $args Method parameters.
4285
* @param array $args {
4286
* Method arguments. Note: arguments must be ordered as documented.
4288
* @type int $blog_id (unused)
4289
* @type string $username
4290
* @type string $password
3982
4292
* @return array|IXR_Error
3984
public function blogger_getUserInfo($args) {
3986
$this->escape($args);
4294
public function blogger_getUserInfo( $args ) {
4295
$this->escape( $args );
3988
4297
$username = $args[1];
3989
$password = $args[2];
4298
$password = $args[2];
3991
4300
if ( !$user = $this->login($username, $password) )
3992
4301
return $this->error;
4016
* @param array $args Method parameters.
4325
* @param array $args {
4326
* Method arguments. Note: arguments must be ordered as documented.
4328
* @type int $blog_id (unused)
4329
* @type int $post_ID
4330
* @type string $username
4331
* @type string $password
4017
4333
* @return array|IXR_Error
4019
public function blogger_getPost($args) {
4021
$this->escape($args);
4023
$post_ID = (int) $args[1];
4335
public function blogger_getPost( $args ) {
4336
$this->escape( $args );
4338
$post_ID = (int) $args[1];
4024
4339
$username = $args[2];
4025
$password = $args[3];
4340
$password = $args[3];
4027
4342
if ( !$user = $this->login($username, $password) )
4028
4343
return $this->error;
4061
* @param array $args Method parameters.
4376
* @param array $args {
4377
* Method arguments. Note: arguments must be ordered as documented.
4379
* @type string $appkey (unused)
4380
* @type int $blog_id (unused)
4381
* @type string $username
4382
* @type string $password
4383
* @type int $numberposts (optional)
4062
4385
* @return array|IXR_Error
4064
public function blogger_getRecentPosts($args) {
4387
public function blogger_getRecentPosts( $args ) {
4066
4389
$this->escape($args);
4068
4391
// $args[0] = appkey - ignored
4069
4392
$username = $args[2];
4070
$password = $args[3];
4393
$password = $args[3];
4071
4394
if ( isset( $args[4] ) )
4072
4395
$query = array( 'numberposts' => absint( $args[4] ) );
4142
* @param array $args Method parameters.
4465
* @param array $args {
4466
* Method arguments. Note: arguments must be ordered as documented.
4468
* @type string $appkey (unused)
4469
* @type int $blog_id (unused)
4470
* @type string $username
4471
* @type string $password
4472
* @type string $content
4473
* @type string $publish
4143
4475
* @return int|IXR_Error
4145
public function blogger_newPost($args) {
4147
$this->escape($args);
4477
public function blogger_newPost( $args ) {
4478
$this->escape( $args );
4149
4480
$username = $args[2];
4150
$password = $args[3];
4151
$content = $args[4];
4152
$publish = $args[5];
4481
$password = $args[3];
4482
$content = $args[4];
4483
$publish = $args[5];
4154
4485
if ( !$user = $this->login($username, $password) )
4155
4486
return $this->error;
4204
* @param array $args Method parameters.
4205
* @return bool|IXR_Error true when done.
4535
* @param array $args {
4536
* Method arguments. Note: arguments must be ordered as documented.
4538
* @type int $blog_id (unused)
4539
* @type int $post_ID
4540
* @type string $username
4541
* @type string $password
4542
* @type string $content
4544
* @return true|IXR_Error true when done.
4207
4546
public function blogger_editPost( $args ) {
4209
4548
$this->escape($args);
4211
$post_ID = (int) $args[1];
4212
$username = $args[2];
4213
$password = $args[3];
4214
$content = $args[4];
4550
$post_ID = (int) $args[1];
4551
$username = $args[2];
4552
$password = $args[3];
4553
$content = $args[4];
4216
4555
if ( ! $user = $this->login( $username, $password ) ) {
4217
4556
return $this->error;
4271
* @param array $args Method parameters.
4272
* @return bool|IXR_Error True when post is deleted.
4610
* @param array $args {
4611
* Method arguments. Note: arguments must be ordered as documented.
4613
* @type int $blog_id (unused)
4614
* @type int $post_ID
4615
* @type string $username
4616
* @type string $password
4618
* @return true|IXR_Error True when post is deleted.
4274
public function blogger_deletePost($args) {
4275
$this->escape($args);
4620
public function blogger_deletePost( $args ) {
4621
$this->escape( $args );
4277
$post_ID = (int) $args[1];
4278
$username = $args[2];
4279
$password = $args[3];
4623
$post_ID = (int) $args[1];
4624
$username = $args[2];
4625
$password = $args[3];
4281
4627
if ( !$user = $this->login($username, $password) )
4282
4628
return $this->error;
4344
* @param array $args Method parameters. Contains:
4345
* - blog_id (unused)
4690
* @param array $args {
4691
* Method arguments. Note: arguments must be ordered as documented.
4693
* @type int $blog_id (unused)
4694
* @type string $username
4695
* @type string $password
4696
* @type array $content_struct
4697
* @type int $publish
4350
4699
* @return int|IXR_Error
4352
4701
public function mw_newPost($args) {
4353
4702
$this->escape($args);
4355
$username = $args[1];
4356
$password = $args[2];
4704
$username = $args[1];
4705
$password = $args[2];
4357
4706
$content_struct = $args[3];
4358
$publish = isset( $args[4] ) ? $args[4] : 0;
4707
$publish = isset( $args[4] ) ? $args[4] : 0;
4360
4709
if ( !$user = $this->login($username, $password) )
4361
4710
return $this->error;
4581
4930
// Only posts can be sticky
4582
4931
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
4583
if ( $content_struct['sticky'] == true )
4584
stick_post( $post_ID );
4585
elseif ( $content_struct['sticky'] == false )
4586
unstick_post( $post_ID );
4933
$data['sticky'] = $content_struct['sticky'];
4934
$error = $this->_toggle_sticky( $data );
4589
4940
if ( isset($content_struct['custom_fields']) )
4678
* @param array $args Method parameters.
5031
* @param array $args {
5032
* Method arguments. Note: arguments must be ordered as documented.
5034
* @type int $blog_id (unused)
5035
* @type string $username
5036
* @type string $password
5037
* @type array $content_struct
5038
* @type int $publish
4679
5040
* @return bool|IXR_Error True on success.
4681
public function mw_editPost($args) {
4683
$this->escape($args);
5042
public function mw_editPost( $args ) {
5043
$this->escape( $args );
4685
5045
$post_ID = (int) $args[0];
4686
5046
$username = $args[1];
4697
5057
$postdata = get_post( $post_ID, ARRAY_A );
4699
// If there is no post data for the give post id, stop
4700
// now and return an error. Other wise a new post will be
4701
// created (which was the old behavior).
5060
* If there is no post data for the give post id, stop now and return an error.
5061
* Otherwise a new post will be created (which was the old behavior).
4702
5063
if ( ! $postdata || empty( $postdata[ 'ID' ] ) )
4703
5064
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
4891
5252
$to_ping = implode(' ', $to_ping);
4894
// Do some timestamp voodoo
5255
// Do some timestamp voodoo.
4895
5256
if ( !empty( $content_struct['date_created_gmt'] ) )
4896
// We know this is supposed to be GMT, so we're going to slap that Z on there by force
5257
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
4897
5258
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
4898
5259
elseif ( !empty( $content_struct['dateCreated']) )
4899
5260
$dateCreated = $content_struct['dateCreated']->getIso();
4906
5267
$post_date_gmt = $postdata['post_date_gmt'];
4909
// We've got all the data -- post it:
5270
// We've got all the data -- post it.
4910
5271
$newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input', 'page_template');
4912
5273
$result = wp_update_post($newpost, true);
4919
5280
// Only posts can be sticky
4920
5281
if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) {
4921
if ( $content_struct['sticky'] == true )
4922
stick_post( $post_ID );
4923
elseif ( $content_struct['sticky'] == false )
4924
unstick_post( $post_ID );
5283
$data['sticky'] = $content_struct['sticky'];
5284
$data['post_type'] = 'post';
5285
$error = $this->_toggle_sticky( $data, true );
4927
5291
if ( isset($content_struct['custom_fields']) )
4928
5292
$this->set_custom_fields($post_ID, $content_struct['custom_fields']);
4930
5294
if ( isset ( $content_struct['wp_post_thumbnail'] ) ) {
4931
// empty value deletes, non-empty value adds/updates
5296
// Empty value deletes, non-empty value adds/updates.
4932
5297
if ( empty( $content_struct['wp_post_thumbnail'] ) ) {
4933
5298
delete_post_thumbnail( $post_ID );
4938
5303
unset( $content_struct['wp_post_thumbnail'] );
4941
// Handle enclosures
5306
// Handle enclosures.
4942
5307
$thisEnclosure = isset($content_struct['enclosure']) ? $content_struct['enclosure'] : null;
4943
5308
$this->add_enclosure_if_new($post_ID, $thisEnclosure);
4945
5310
$this->attach_uploads( $ID, $post_content );
4947
// Handle post formats if assigned, validation is handled
4948
// earlier in this function
5312
// Handle post formats if assigned, validation is handled earlier in this function.
4949
5313
if ( isset( $content_struct['wp_post_format'] ) )
4950
5314
set_post_format( $post_ID, $content_struct['wp_post_format'] );
4970
* @param array $args Method parameters.
5334
* @param array $args {
5335
* Method arguments. Note: arguments must be ordered as documented.
5337
* @type int $blog_id (unused)
5338
* @type int $post_ID
5339
* @type string $username
5340
* @type string $password
4971
5342
* @return array|IXR_Error
4973
public function mw_getPost($args) {
4975
$this->escape($args);
4977
$post_ID = (int) $args[0];
4978
$username = $args[1];
4979
$password = $args[2];
5344
public function mw_getPost( $args ) {
5345
$this->escape( $args );
5347
$post_ID = (int) $args[0];
5348
$username = $args[1];
5349
$password = $args[2];
4981
5351
if ( !$user = $this->login($username, $password) )
4982
5352
return $this->error;
5207
* @param array $args Method parameters.
5583
* @param array $args {
5584
* Method arguments. Note: arguments must be ordered as documented.
5586
* @type int $blog_id (unused)
5587
* @type string $username
5588
* @type string $password
5208
5590
* @return array|IXR_Error
5210
public function mw_getCategories($args) {
5212
$this->escape($args);
5214
$username = $args[1];
5215
$password = $args[2];
5592
public function mw_getCategories( $args ) {
5593
$this->escape( $args );
5595
$username = $args[1];
5596
$password = $args[2];
5217
5598
if ( !$user = $this->login($username, $password) )
5218
5599
return $this->error;
5255
* @param array $args Method parameters.
5636
* @global wpdb $wpdb
5638
* @param array $args {
5639
* Method arguments. Note: arguments must be ordered as documented.
5641
* @type int $blog_id (unused)
5642
* @type string $username
5643
* @type string $password
5256
5646
* @return array|IXR_Error
5258
public function mw_newMediaObject($args) {
5648
public function mw_newMediaObject( $args ) {
5261
$username = $this->escape($args[1]);
5262
$password = $this->escape($args[2]);
5651
$username = $this->escape( $args[1] );
5652
$password = $this->escape( $args[2] );
5265
5655
$name = sanitize_file_name( $data['name'] );
5266
5656
$type = $data['type'];
5422
* @param array $args Method parameters.
5818
* @param array $args {
5819
* Method arguments. Note: arguments must be ordered as documented.
5821
* @type int $blog_id (unused)
5822
* @type string $username
5823
* @type string $password
5423
5825
* @return array|IXR_Error
5425
public function mt_getCategoryList($args) {
5427
$this->escape($args);
5429
$username = $args[1];
5430
$password = $args[2];
5827
public function mt_getCategoryList( $args ) {
5828
$this->escape( $args );
5830
$username = $args[1];
5831
$password = $args[2];
5432
5833
if ( !$user = $this->login($username, $password) )
5433
5834
return $this->error;
5461
* @param array $args Method parameters.
5862
* @param array $args {
5863
* Method arguments. Note: arguments must be ordered as documented.
5865
* @type int $post_ID
5866
* @type string $username
5867
* @type string $password
5462
5869
* @return array|IXR_Error
5464
public function mt_getPostCategories($args) {
5466
$this->escape($args);
5468
$post_ID = (int) $args[0];
5469
$username = $args[1];
5470
$password = $args[2];
5871
public function mt_getPostCategories( $args ) {
5872
$this->escape( $args );
5874
$post_ID = (int) $args[0];
5875
$username = $args[1];
5876
$password = $args[2];
5472
5878
if ( !$user = $this->login($username, $password) )
5473
5879
return $this->error;
5505
* @param array $args Method parameters.
5506
* @return bool|IXR_Error True on success.
5911
* @param array $args {
5912
* Method arguments. Note: arguments must be ordered as documented.
5914
* @type int $post_ID
5915
* @type string $username
5916
* @type string $password
5917
* @type array $categories
5919
* @return true|IXR_Error True on success.
5508
public function mt_setPostCategories($args) {
5510
$this->escape($args);
5512
$post_ID = (int) $args[0];
5513
$username = $args[1];
5921
public function mt_setPostCategories( $args ) {
5922
$this->escape( $args );
5924
$post_ID = (int) $args[0];
5925
$username = $args[1];
5514
5926
$password = $args[2];
5515
$categories = $args[3];
5927
$categories = $args[3];
5517
5929
if ( !$user = $this->login($username, $password) )
5518
5930
return $this->error;
5544
* @param array $args Method parameters.
5545
5956
* @return array
5547
public function mt_supportedMethods($args) {
5958
public function mt_supportedMethods() {
5549
5959
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5550
5960
do_action( 'xmlrpc_call', 'mt.supportedMethods' );
5552
$supported_methods = array();
5553
foreach ( $this->methods as $key => $value ) {
5554
$supported_methods[] = $key;
5557
return $supported_methods;
5962
return array_keys( $this->methods );
5561
5966
* Retrieve an empty array because we don't support per-post text filters.
5565
* @param array $args Method parameters.
5567
public function mt_supportedTextFilters($args) {
5970
public function mt_supportedTextFilters() {
5568
5971
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5569
5972
do_action( 'xmlrpc_call', 'mt.supportedTextFilters' );
5586
* @param array $args Method parameters.
5989
* @global wpdb $wpdb
5991
* @param int $post_ID
5587
5992
* @return array|IXR_Error
5589
public function mt_getTrackbackPings($args) {
5994
public function mt_getTrackbackPings( $post_ID ) {
5593
$post_ID = intval($args);
5595
5997
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5596
5998
do_action( 'xmlrpc_call', 'mt.getTrackbackPings' );
5629
* @param array $args Method parameters.
6031
* @param array $args {
6032
* Method arguments. Note: arguments must be ordered as documented.
6034
* @type int $post_ID
6035
* @type string $username
6036
* @type string $password
5630
6038
* @return int|IXR_Error
5632
public function mt_publishPost($args) {
5634
$this->escape($args);
5636
$post_ID = (int) $args[0];
5637
$username = $args[1];
5638
$password = $args[2];
6040
public function mt_publishPost( $args ) {
6041
$this->escape( $args );
6043
$post_ID = (int) $args[0];
6044
$username = $args[1];
6045
$password = $args[2];
5640
6047
if ( !$user = $this->login($username, $password) )
5641
6048
return $this->error;
5674
* @param array $args Method parameters.
6079
* @global wpdb $wpdb
6080
* @global string $wp_version
6082
* @param array $args {
6083
* Method arguments. Note: arguments must be ordered as documented.
6085
* @type string $pagelinkedfrom
6086
* @type string $pagelinkedto
5675
6088
* @return string|IXR_Error
5677
public function pingback_ping($args) {
6090
public function pingback_ping( $args ) {
6091
global $wpdb, $wp_version;
5680
6093
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5681
6094
do_action( 'xmlrpc_call', 'pingback.ping' );
5683
$this->escape($args);
5685
$pagelinkedfrom = $args[0];
5686
$pagelinkedto = $args[1];
5688
$pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom);
5689
$pagelinkedto = str_replace('&', '&', $pagelinkedto);
5690
$pagelinkedto = str_replace('&', '&', $pagelinkedto);
6096
$this->escape( $args );
6098
$pagelinkedfrom = str_replace( '&', '&', $args[0] );
6099
$pagelinkedto = str_replace( '&', '&', $args[1] );
6100
$pagelinkedto = str_replace( '&', '&', $pagelinkedto );
5693
6103
* Filter the pingback source URI.
5766
6176
$remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
5768
6178
/** This filter is documented in wp-includes/class-http.php */
5769
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $GLOBALS['wp_version'] . '; ' . get_bloginfo( 'url' ) );
6179
$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) );
5771
6181
// Let's check the remote site
5772
6182
$http_api_args = array(
5880
* @param array $args Method parameters.
6290
* @global wpdb $wpdb
6292
* @param string $url
5881
6293
* @return array|IXR_Error
5883
public function pingback_extensions_getPingbacks($args) {
6295
public function pingback_extensions_getPingbacks( $url ) {
5887
6298
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
5888
6299
do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' );
5890
$this->escape($args);
6301
$url = $this->escape( $url );
5894
6303
$post_ID = url_to_postid($url);
5895
6304
if ( !$post_ID ) {