Ticket #2473: functions-post.diff
File functions-post.diff, 4.1 KB (added by , 19 years ago) |
---|
-
functions-post.php
2 2 3 3 /**** DB Functions ****/ 4 4 5 /* 6 * generic function for inserting data into the posts table. 5 /** 6 * Insert or update data in the posts table 7 * @param array $postarr an array of the POSTed data from the Write screen 8 * @return int the post_ID of the inserted or updated post 7 9 */ 8 10 function wp_insert_post($postarr = array()) { 9 11 global $wpdb, $wp_rewrite, $allowedtags, $user_ID; … … 219 221 return $post_ID; 220 222 } 221 223 224 /** 225 * Insert or update an attachment to a post 226 * @param object $object an object of postdata 227 * @param bool $file whether to set the _wp_attached_file postmeta for this post 228 * @param int $post_parent the post_ID of the parent element to this post 229 * @return int the post_ID of the inserted or updated post 230 */ 222 231 function wp_insert_attachment($object, $file = false, $post_parent = 0) { 223 232 global $wpdb, $user_ID; 224 233 … … 359 368 return $post_ID; 360 369 } 361 370 371 /** 372 * Remove an attachment, and delete any associated on-disk files (including thumbnails) 373 * @param int $postid the post_ID of the attachment to remove 374 * @return mixed the post object from which the attachment was deleted, or boolean false on error 375 */ 376 362 377 function wp_delete_attachment($postid) { 363 378 global $wpdb; 364 379 $postid = (int) $postid; … … 394 409 return $post; 395 410 } 396 411 412 /** 413 * Select a single post from the database and includes the categories to which that post belongs 414 * @param int $postid the post_ID of the post to return 415 * @param constant $mode Whether to return an OBJECT or an ARRAY 416 * @return mixed returns either an OBJECT or an ARRAY, as defined by $mode 417 */ 397 418 function wp_get_single_post($postid = 0, $mode = OBJECT) { 398 419 global $wpdb; 399 420 … … 410 431 return $post; 411 432 } 412 433 434 ** 435 * Return some number of recent posts 436 * @param int $num the number of posts to return 437 * @return array returns an array of posts sorted descending by date, or an empty array in case of failure 438 */ 439 413 440 function wp_get_recent_posts($num = 10) { 414 441 global $wpdb; 415 442 … … 424 451 return $result?$result:array(); 425 452 } 426 453 454 ** 455 * Update a post 456 * @param array $postarr the post data to update 457 * @return int returns the post_ID of the updated post (as returned by wp_insert_post()) 458 */ 427 459 function wp_update_post($postarr = array()) { 428 460 global $wpdb; 429 461 … … 464 496 return wp_insert_post($postarr); 465 497 } 466 498 499 ** 500 * Sets a post's status to "publish" 501 * @param int $post_id The post_ID of the post to publish 502 * @return int Returns the post_ID of the published post, or null if no change was performed 503 */ 467 504 function wp_publish_post($post_id) { 468 505 $post = get_post($post_id); 469 506 … … 476 513 return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id)); 477 514 } 478 515 516 /** 517 * Returns an array of categories to which a specific post is assigned 518 * @param int $blogid The ID of the blog that owns the post (used only for WPMU) 519 * @param int $post_ID the post_ID of the post who's categories are being selected 520 * @return array returns an array of category IDs 521 */ 479 522 function wp_get_post_cats($blogid = '1', $post_ID = 0) { 480 523 global $wpdb; 481 524 … … 492 535 return array_unique($result); 493 536 } 494 537 538 /** 539 * 540 * @param int $blogid the ID of the blog (used for WPMU) 541 * @param int $post_ID the post_ID for the post who's categories are being set 542 * @param array $post_categories an array of categories to which the post will be assigned 543 * @return none 544 */ 495 545 function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) { 496 546 global $wpdb; 497 547 // If $post_categories isn't already an array, make it one: … … 545 595 } 546 596 } // wp_set_post_cats() 547 597 598 /** 599 * Delete a post from the database 600 * @param int $post_id the post_id of the post to delete 601 * @return mixed an object containing the contents of the deleted post, or boolean false if nothing was deleted 602 */ 548 603 function wp_delete_post($postid = 0) { 549 604 global $wpdb, $wp_rewrite; 550 605 $postid = (int) $postid;