Changeset 32565 for trunk/src/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 05/23/2015 07:46:45 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r32564 r32565 734 734 * @access protected 735 735 * 736 * @param array $post The unprepared post data737 * @param array $fields The subset of post type fields to return 738 * @return array The prepared post data 736 * @param array $post The unprepared post data. 737 * @param array $fields The subset of post type fields to return. 738 * @return array The prepared post data. 739 739 */ 740 740 protected function _prepare_post( $post, $fields ) { 741 // holds the data for this post. built up based on $fields741 // Holds the data for this post. built up based on $fields. 742 742 $_post = array( 'post_id' => strval( $post['ID'] ) ); 743 743 744 // prepare common post fields744 // Prepare common post fields. 745 745 $post_fields = array( 746 746 'post_title' => $post['post_title'], … … 766 766 ); 767 767 768 // Thumbnail 768 // Thumbnail. 769 769 $post_fields['post_thumbnail'] = array(); 770 770 $thumbnail_id = get_post_thumbnail_id( $post['ID'] ); … … 774 774 } 775 775 776 // Consider future posts as published 776 // Consider future posts as published. 777 777 if ( $post_fields['post_status'] === 'future' ) 778 778 $post_fields['post_status'] = 'publish'; 779 779 780 // Fill in blank post format 780 // Fill in blank post format. 781 781 $post_fields['post_format'] = get_post_format( $post['ID'] ); 782 782 if ( empty( $post_fields['post_format'] ) ) 783 783 $post_fields['post_format'] = 'standard'; 784 784 785 // Merge requested $post_fields fields into $_post 785 // Merge requested $post_fields fields into $_post. 786 786 if ( in_array( 'post', $fields ) ) { 787 787 $_post = array_merge( $_post, $post_fields ); … … 833 833 * @access protected 834 834 * 835 * @param object $post_type Post type object 836 * @param array $fields The subset of post fields to return837 * @return array The prepared post type data 835 * @param object $post_type Post type object. 836 * @param array $fields The subset of post fields to return. 837 * @return array The prepared post type data. 838 838 */ 839 839 protected function _prepare_post_type( $post_type, $fields ) { … … 883 883 * @access protected 884 884 * 885 * @param object $media_item The unprepared media item data886 * @param string $thumbnail_size The image size to use for the thumbnail URL 887 * @return array The prepared media item data 885 * @param object $media_item The unprepared media item data. 886 * @param string $thumbnail_size The image size to use for the thumbnail URL. 887 * @return array The prepared media item data. 888 888 */ 889 889 protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) { … … 922 922 * @access protected 923 923 * 924 * @param object $page The unprepared page data 925 * @return array The prepared page data 924 * @param object $page The unprepared page data. 925 * @return array The prepared page data. 926 926 */ 927 927 protected function _prepare_page( $page ) { … … 1003 1003 * @access protected 1004 1004 * 1005 * @param object $comment The unprepared comment data 1006 * @return array The prepared comment data 1005 * @param object $comment The unprepared comment data. 1006 * @return array The prepared comment data. 1007 1007 */ 1008 1008 protected function _prepare_comment( $comment ) { … … 1052 1052 * @access protected 1053 1053 * 1054 * @param WP_User $user The unprepared user object1055 * @param array $fields The subset of user fields to return1056 * @return array The prepared user data 1054 * @param WP_User $user The unprepared user object. 1055 * @param array $fields The subset of user fields to return. 1056 * @return array The prepared user data. 1057 1057 */ 1058 1058 protected function _prepare_user( $user, $fields ) { … … 1177 1177 1178 1178 /** 1179 * Helper method for wp_newPost and wp_editPost, containing shared logic.1179 * Helper method for wp_newPost() and wp_editPost(), containing shared logic. 1180 1180 * 1181 1181 * @since 3.4.0 1182 * @uses wp_insert_post() 1183 * 1184 * @param WP_User $user The post author if post_author isn't set in $content_struct. 1182 * @access protected 1183 * 1184 * @see wp_insert_post() 1185 * 1186 * @param WP_User $user The post author if post_author isn't set in $content_struct. 1185 1187 * @param array|IXR_Error $content_struct Post data to insert. 1186 1188 * @return IXR_Error|string … … 1251 1253 unset( $post_data['ping_status'] ); 1252 1254 1253 // Do some timestamp voodoo 1255 // Do some timestamp voodoo. 1254 1256 if ( ! empty( $post_data['post_date_gmt'] ) ) { 1255 // We know this is supposed to be GMT, so we're going to slap that Z on there by force 1257 // We know this is supposed to be GMT, so we're going to slap that Z on there by force. 1256 1258 $dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z'; 1257 1259 } elseif ( ! empty( $post_data['post_date'] ) ) { … … 1287 1289 1288 1290 if ( isset( $post_data['post_thumbnail'] ) ) { 1289 // empty value deletes, non-empty value adds/updates 1291 // empty value deletes, non-empty value adds/updates. 1290 1292 if ( ! $post_data['post_thumbnail'] ) 1291 1293 delete_post_thumbnail( $post_ID ); … … 1302 1304 $post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' ); 1303 1305 1304 // accumulate term IDs from terms and terms_names1306 // Accumulate term IDs from terms and terms_names. 1305 1307 $terms = array(); 1306 1308 1307 // first validate the terms specified by ID1309 // First validate the terms specified by ID. 1308 1310 if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) { 1309 1311 $taxonomies = array_keys( $post_data['terms'] ); 1310 1312 1311 // validating term ids1313 // Validating term ids. 1312 1314 foreach ( $taxonomies as $taxonomy ) { 1313 1315 if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) ) … … 1330 1332 } 1331 1333 1332 // now validate terms specified by name1334 // Now validate terms specified by name. 1333 1335 if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) { 1334 1336 $taxonomies = array_keys( $post_data['terms_names'] ); … … 1341 1343 return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) ); 1342 1344 1343 // for hierarchical taxonomies, we can't assign a term when multiple terms in the hierarchy share the same name 1345 /* 1346 * For hierarchical taxonomies, we can't assign a term when multiple terms 1347 * in the hierarchy share the same name. 1348 */ 1344 1349 $ambiguous_terms = array(); 1345 1350 if ( is_taxonomy_hierarchical( $taxonomy ) ) { 1346 1351 $tax_term_names = get_terms( $taxonomy, array( 'fields' => 'names', 'hide_empty' => false ) ); 1347 1352 1348 // count the number of terms with the same name1353 // Count the number of terms with the same name. 1349 1354 $tax_term_names_count = array_count_values( $tax_term_names ); 1350 1355 1351 // filter out non-ambiguous term names1356 // Filter out non-ambiguous term names. 1352 1357 $ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') ); 1353 1358 … … 1363 1368 1364 1369 if ( ! $term ) { 1365 // term doesn't exist, so check that the user is allowed to create new terms1370 // Term doesn't exist, so check that the user is allowed to create new terms. 1366 1371 if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->edit_terms ) ) 1367 1372 return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) ); 1368 1373 1369 // create the new term1374 // Create the new term. 1370 1375 $term_info = wp_insert_term( $term_name, $taxonomy ); 1371 1376 if ( is_wp_error( $term_info ) ) … … 1383 1388 unset( $post_data['terms'], $post_data['terms_names'] ); 1384 1389 } else { 1385 // do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'1390 // Do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'. 1386 1391 unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] ); 1387 1392 } … … 1396 1401 } 1397 1402 1398 // Handle enclosures 1403 // Handle enclosures. 1399 1404 $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null; 1400 1405 $this->add_enclosure_if_new( $post_ID, $enclosure ); … … 1433 1438 * Method parameters, in this order: 1434 1439 * 1435 * @type int $blog_id (unused)1436 * @type string $username 1437 * @type string $password 1438 * @type int $post_id 1439 * @type array $content_struct 1440 * @type int $blog_id Blog ID (unused). 1441 * @type string $username Username. 1442 * @type string $password Password. 1443 * @type int $post_id Post ID. 1444 * @type array $content_struct Extra content arguments. 1440 1445 * } 1441 * @return true|IXR_Error true on success1446 * @return true|IXR_Error True on success, IXR_Error on failure. 1442 1447 */ 1443 1448 public function wp_editPost( $args ) {
Note: See TracChangeset
for help on using the changeset viewer.