Changeset 28106
- Timestamp:
- 04/13/2014 11:05:20 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r28042 r28106 1352 1352 } 1353 1353 1354 /** 1355 * Fires after a post type is registered. 1356 * 1357 * @since 3.3.0 1358 * 1359 * @param string $post_type Post type. 1360 * @param array $args Arguments used to register the post type. 1361 */ 1354 1362 do_action( 'registered_post_type', $post_type, $args ); 1355 1363 … … 2402 2410 * 2403 2411 * @since 1.0.0 2404 * @uses do_action() on 'delete_post' before deletion unless post type is 'attachment'. 2405 * @uses do_action() on 'deleted_post' after deletion unless post type is 'attachment'. 2412 * 2406 2413 * @uses wp_delete_attachment() if post type is 'attachment'. 2407 2414 * @uses wp_trash_post() if item should be trashed. … … 2423 2430 return wp_delete_attachment( $postid, $force_delete ); 2424 2431 2425 do_action('before_delete_post', $postid); 2432 /** 2433 * Fires before a post is deleted, at the start of wp_delete_post(). 2434 * 2435 * @since 3.2.0 2436 * 2437 * @see wp_delete_post() 2438 * 2439 * @param int $postid Post ID. 2440 */ 2441 do_action( 'before_delete_post', $postid ); 2426 2442 2427 2443 delete_post_meta($postid,'_wp_trash_meta_status'); … … 2458 2474 delete_metadata_by_mid( 'post', $mid ); 2459 2475 2476 /** 2477 * Fires immediately before a post is deleted from the database. 2478 * 2479 * @since 1.2.0 2480 * 2481 * @param int $postid Post ID. 2482 */ 2460 2483 do_action( 'delete_post', $postid ); 2461 2484 $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); … … 2463 2486 return false; 2464 2487 } 2488 2489 /** 2490 * Fires immediately after a post is deleted from the database. 2491 * 2492 * @since 2.2.0 2493 * 2494 * @param int $postid Post ID. 2495 */ 2465 2496 do_action( 'deleted_post', $postid ); 2466 2497 … … 2474 2505 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); 2475 2506 2476 do_action('after_delete_post', $postid); 2507 /** 2508 * Fires after a post is deleted, at the conclusion of wp_delete_post(). 2509 * 2510 * @since 3.2.0 2511 * 2512 * @see wp_delete_post() 2513 * 2514 * @param int $postid Post ID. 2515 */ 2516 do_action( 'after_delete_post', $postid ); 2477 2517 2478 2518 return $post; … … 2513 2553 * 2514 2554 * @since 2.9.0 2515 * @uses do_action() on 'trash_post' before trashing 2516 * @uses do_action() on 'trashed_post' after trashing 2555 * 2517 2556 * @uses wp_delete_post() if trash is disabled 2518 2557 * … … 2530 2569 return false; 2531 2570 2532 do_action('wp_trash_post', $post_id); 2571 /** 2572 * Fires before a post is sent to the trash. 2573 * 2574 * @since 3.3.0 2575 * 2576 * @param int $post_id Post ID. 2577 */ 2578 do_action( 'wp_trash_post', $post_id ); 2533 2579 2534 2580 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); … … 2540 2586 wp_trash_post_comments($post_id); 2541 2587 2542 do_action('trashed_post', $post_id); 2588 /** 2589 * Fires after a post is sent to the trash. 2590 * 2591 * @since 2.9.0 2592 * 2593 * @param int $post_id Post ID. 2594 */ 2595 do_action( 'trashed_post', $post_id ); 2543 2596 2544 2597 return $post; … … 2549 2602 * 2550 2603 * @since 2.9.0 2551 * @uses do_action() on 'untrash_post' before undeletion2552 * @uses do_action() on 'untrashed_post' after undeletion2553 2604 * 2554 2605 * @param int $post_id Post ID. … … 2562 2613 return false; 2563 2614 2564 do_action('untrash_post', $post_id); 2615 /** 2616 * Fires before a post is restored from the trash. 2617 * 2618 * @since 2.9.0 2619 * 2620 * @param int $post_id Post ID. 2621 */ 2622 do_action( 'untrash_post', $post_id ); 2565 2623 2566 2624 $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); … … 2575 2633 wp_untrash_post_comments($post_id); 2576 2634 2577 do_action('untrashed_post', $post_id); 2635 /** 2636 * Fires after a post is restored from the trash. 2637 * 2638 * @since 2.9.0 2639 * 2640 * @param int $post_id Post ID. 2641 */ 2642 do_action( 'untrashed_post', $post_id ); 2578 2643 2579 2644 return $post; … … 2584 2649 * 2585 2650 * @since 2.9.0 2586 * @uses do_action() on 'trash_post_comments' before trashing2587 * @uses do_action() on 'trashed_post_comments' after trashing2588 2651 * 2589 2652 * @param int|WP_Post $post Optional. Post ID or post object. … … 2599 2662 $post_id = $post->ID; 2600 2663 2601 do_action('trash_post_comments', $post_id); 2664 /** 2665 * Fires before comments are sent to the trash. 2666 * 2667 * @since 2.9.0 2668 * 2669 * @param int $post_id Post ID. 2670 */ 2671 do_action( 'trash_post_comments', $post_id ); 2602 2672 2603 2673 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) ); … … 2616 2686 clean_comment_cache( array_keys($statuses) ); 2617 2687 2618 do_action('trashed_post_comments', $post_id, $statuses); 2688 /** 2689 * Fires after comments are sent to the trash. 2690 * 2691 * @since 2.9.0 2692 * 2693 * @param int $post_id Post ID. 2694 * @param array $statuses Array of comment statuses. 2695 */ 2696 do_action( 'trashed_post_comments', $post_id, $statuses ); 2619 2697 2620 2698 return $result; … … 2625 2703 * 2626 2704 * @since 2.9.0 2627 * @uses do_action() on 'untrash_post_comments' before trashing2628 * @uses do_action() on 'untrashed_post_comments' after trashing2629 2705 * 2630 2706 * @param int|WP_Post $post Optional. Post ID or post object. … … 2645 2721 return true; 2646 2722 2647 do_action('untrash_post_comments', $post_id); 2723 /** 2724 * Fires before comments are restored for a post from the trash. 2725 * 2726 * @since 2.9.0 2727 * 2728 * @param int $post_id Post ID. 2729 */ 2730 do_action( 'untrash_post_comments', $post_id ); 2648 2731 2649 2732 // Restore each comment to its original status … … 2664 2747 delete_post_meta($post_id, '_wp_trash_meta_comments_status'); 2665 2748 2666 do_action('untrashed_post_comments', $post_id); 2749 /** 2750 * Fires after comments are restored for a post from the trash. 2751 * 2752 * @since 2.9.0 2753 * 2754 * @param int $post_id Post ID. 2755 */ 2756 do_action( 'untrashed_post_comments', $post_id ); 2667 2757 } 2668 2758 … … 2798 2888 * An array of elements that make up a post to update or insert. 2799 2889 * 2800 * @type int 'ID'The post ID. If equal to something other than 0, the post with that ID will2801 * 2802 * @type string 'post_status'The post status. Default 'draft'.2803 * @type string 'post_type'The post type. Default 'post'.2804 * @type int 'post_author'The ID of the user who added the post. Default the current user ID.2805 * @type bool 'ping_status'Whether the post can accept pings. Default value of 'default_ping_status' option.2806 * @type int 'post_parent'Set this for the post it belongs to, if any. Default 0.2807 * @type int 'menu_order'The order it is displayed. Default 0.2808 * @type string 'to_ping'Space or carriage return-separated list of URLs to ping. Default empty string.2809 * @type string 'pinged'Space or carriage return-separated list of URLs that have been pinged.2810 * 2811 * @type string 'post_passwordThe password to access the post. Default empty string.2812 * @type string 'guid'Global Unique ID for referencing the post.2813 * @type string 'post_content_filtered'The filtered post content. Default empty string.2814 * @type string 'post_excerpt'The post excerpt. Default empty string.2890 * @type int $ID The post ID. If equal to something other than 0, the post with that ID will 2891 * be updated. Default 0. 2892 * @type string $post_status The post status. Default 'draft'. 2893 * @type string $post_type The post type. Default 'post'. 2894 * @type int $post_author The ID of the user who added the post. Default the current user ID. 2895 * @type bool $ping_status Whether the post can accept pings. Default value of 'default_ping_status' option. 2896 * @type int $post_parent Set this for the post it belongs to, if any. Default 0. 2897 * @type int $menu_order The order it is displayed. Default 0. 2898 * @type string $to_ping Space or carriage return-separated list of URLs to ping. Default empty string. 2899 * @type string $pinged Space or carriage return-separated list of URLs that have been pinged. 2900 * Default empty string. 2901 * @type string $post_password The password to access the post. Default empty string. 2902 * @type string $guid' Global Unique ID for referencing the post. 2903 * @type string $post_content_filtered The filtered post content. Default empty string. 2904 * @type string $post_excerpt The post excerpt. Default empty string. 2815 2905 * } 2816 2906 * @param bool $wp_error Optional. Allow return of WP_Error on failure. … … 2988 3078 $post_parent = 0; 2989 3079 2990 // Check the post_parent to see if it will cause a hierarchy loop 3080 /** 3081 * Filter the post parent -- used to check for and prevent hierarchy loops. 3082 * 3083 * @since 3.1.0 3084 * 3085 * @param int $post_parent Post parent ID. 3086 * @param int $post_ID Post ID. 3087 * @param array $new_postarr Array of parsed post data. 3088 * @param array $postarr Array of sanitized, but otherwise unmodified post data. 3089 */ 2991 3090 $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr ); 2992 3091 … … 3003 3102 // expected_slashed (everything!) 3004 3103 $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) ); 3005 $data = apply_filters('wp_insert_post_data', $data, $postarr); 3104 3105 /** 3106 * Filter slashed post data just before it is inserted into the database. 3107 * 3108 * @since 2.7.0 3109 * 3110 * @param array $data Array of slashed post data. 3111 * @param array $postarr Array of sanitized, but otherwise unmodified post data. 3112 */ 3113 $data = apply_filters( 'wp_insert_post_data', $data, $postarr ); 3006 3114 $data = wp_unslash( $data ); 3007 3115 $where = array( 'ID' => $post_ID ); 3008 3116 3009 3117 if ( $update ) { 3118 /** 3119 * Fires immediately before an existing post is updated in the database. 3120 * 3121 * @since 2.5.0 3122 * 3123 * @param int $post_ID Post ID. 3124 * @param array $data Array of unslashed post data. 3125 */ 3010 3126 do_action( 'pre_post_update', $post_ID, $data ); 3011 3127 if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) { … … 3084 3200 3085 3201 if ( $update ) { 3086 do_action('edit_post', $post_ID, $post); 3202 /** 3203 * Fires once an existing post has been updated. 3204 * 3205 * @since 1.2.0 3206 * 3207 * @param int $post_ID Post ID. 3208 * @param WP_Post $post Post object. 3209 */ 3210 do_action( 'edit_post', $post_ID, $post ); 3087 3211 $post_after = get_post($post_ID); 3212 3213 /** 3214 * Fires once an existing post has been updated. 3215 * 3216 * @since 3.0.0 3217 * 3218 * @param int $post_ID Post ID. 3219 * @param WP_Post $post_after Post object following the update. 3220 * @param WP_Post $post_before Post object before the update. 3221 */ 3088 3222 do_action( 'post_updated', $post_ID, $post_after, $post_before); 3089 3223 } 3090 3224 3225 /** 3226 * Fires once a post has been saved. 3227 * 3228 * The dynamic portion of the hook name, $post->post_type, refers to 3229 * the post type slug. 3230 * 3231 * @since 3.7.0 3232 * 3233 * @param int $post_ID Post ID. 3234 * @param WP_Post $post Post object. 3235 * @param bool $update Whether this is an existing post being updated or not. 3236 */ 3091 3237 do_action( "save_post_{$post->post_type}", $post_ID, $post, $update ); 3238 3239 /** 3240 * Fires once a post has been saved. 3241 * 3242 * @since 1.5.0 3243 * 3244 * @param int $post_ID Post ID. 3245 * @param WP_Post $post Post object. 3246 * @param bool $update Whether this is an existing post being updated or not. 3247 */ 3092 3248 do_action( 'save_post', $post_ID, $post, $update ); 3249 3250 /** 3251 * Fires once a post has been saved. 3252 * 3253 * @since 2.0.0 3254 * 3255 * @param int $post_ID Post ID. 3256 * @param WP_Post $post Post object. 3257 * @param bool $update Whether this is an existing post being updated or not. 3258 */ 3093 3259 do_action( 'wp_insert_post', $post_ID, $post, $update ); 3094 3260 … … 3160 3326 * @since 2.1.0 3161 3327 * @uses $wpdb 3162 * @uses do_action() Calls 'edit_post', 'save_post_{$post_type}', 'save_post' and 'wp_insert_post' on post_id and post data.3163 3328 * 3164 3329 * @param int|WP_Post $post Post ID or post object. … … 3181 3346 wp_transition_post_status( 'publish', $old_status, $post ); 3182 3347 3348 /** This action is documented in wp-includes/post.php */ 3183 3349 do_action( 'edit_post', $post->ID, $post ); 3350 /** This action is documented in wp-includes/post.php */ 3184 3351 do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); 3352 /** This action is documented in wp-includes/post.php */ 3185 3353 do_action( 'save_post', $post->ID, $post, true ); 3354 /** This action is documented in wp-includes/post.php */ 3186 3355 do_action( 'wp_insert_post', $post->ID, $post, true ); 3187 3356 } … … 3251 3420 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 3252 3421 3422 /** 3423 * Filter whether the post slug would make a bad attachment slug. 3424 * 3425 * @since 3.1.0 3426 * 3427 * @param bool $bad_slug Whether the slug would be bad as an attachment slug. 3428 * @param string $slug The post slug. 3429 */ 3253 3430 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 3254 3431 $suffix = 2; … … 3263 3440 if ( 'nav_menu_item' == $post_type ) 3264 3441 return $slug; 3265 // Page slugs must be unique within their own trees. Pages are in a separate 3266 // namespace than posts so page slugs are allowed to overlap post slugs. 3442 3443 /* 3444 * Page slugs must be unique within their own trees. Pages are in a separate 3445 * namespace than posts so page slugs are allowed to overlap post slugs. 3446 */ 3267 3447 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1"; 3268 3448 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 3269 3449 3450 /** 3451 * Filter whether the post slug would make a bad hierarchical post slug. 3452 * 3453 * @since 3.1.0 3454 * 3455 * @param bool $bad_slug Whether the post slug would be bad in a hierarchical post context. 3456 * @param string $slug The post slug. 3457 * @param string $post_type Post type. 3458 * @param int $post_parent Post parent ID. 3459 */ 3270 3460 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ) ) { 3271 3461 $suffix = 2; … … 3282 3472 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3283 3473 3474 /** 3475 * Filter whether the post slug would be bad as a flat slug. 3476 * 3477 * @since 3.1.0 3478 * 3479 * @param bool $bad_slug Whether the post slug would be bad as a flat slug. 3480 * @param string $slug The post slug. 3481 * @param string $post_type Post type. 3482 */ 3284 3483 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 3285 3484 $suffix = 2; … … 3293 3492 } 3294 3493 3494 /** 3495 * Filter the unique post slug. 3496 * 3497 * @since 3.3.0 3498 * 3499 * @param string $slug The post slug. 3500 * @param int $post_ID Post ID. 3501 * @param string $post_status The post status. 3502 * @param string $post_type Post type. 3503 * @param int $post_parent Post parent ID 3504 * @param string $original_slug The original post slug. 3505 */ 3295 3506 return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ); 3296 3507 } … … 3434 3645 * 3435 3646 * @since 2.3.0 3647 * 3436 3648 * @link http://codex.wordpress.org/Post_Status_Transitions 3437 *3438 * @uses do_action() Calls 'transition_post_status' on $new_status, $old_status and3439 * $post if there is a status change.3440 * @uses do_action() Calls '{$old_status}_to_{$new_status}' on $post if there is a status change.3441 * @uses do_action() Calls '{$new_status}_{$post->post_type}' on post ID and $post.3442 3649 * 3443 3650 * @param string $new_status Transition to this post status. … … 3446 3653 */ 3447 3654 function wp_transition_post_status($new_status, $old_status, $post) { 3448 do_action('transition_post_status', $new_status, $old_status, $post); 3449 do_action("{$old_status}_to_{$new_status}", $post); 3450 do_action("{$new_status}_{$post->post_type}", $post->ID, $post); 3655 /** 3656 * Fires when a post is transitioned from one status to another. 3657 * 3658 * @since 2.3.0 3659 * 3660 * @param string $new_status New post status. 3661 * @param string $old_status Old post status. 3662 * @param WP_Post $post Post object. 3663 */ 3664 do_action( 'transition_post_status', $new_status, $old_status, $post ); 3665 3666 /** 3667 * Fires when a post is transitioned from one status to another. 3668 * 3669 * The dynamic portions of the hook name, $new_status and $old status, 3670 * refer to the old and new post statuses, respectively. 3671 * 3672 * @since 2.3.0 3673 * 3674 * @param WP_Post $post Post object. 3675 */ 3676 do_action( "{$old_status}_to_{$new_status}", $post ); 3677 3678 /** 3679 * Fires when a post is transitioned from one status to another. 3680 * 3681 * The dynamic portions of the hook name, $new_status and $post->post_type, 3682 * refer to the new post status and post type, respectively. 3683 * 3684 * @since 2.3.0 3685 * 3686 * @param int $post_id Post ID. 3687 * @param WP_Post $post Post object. 3688 */ 3689 do_action( "{$new_status}_{$post->post_type}", $post->ID, $post ); 3451 3690 } 3452 3691 … … 3472 3711 $pung[] = $uri; 3473 3712 $new = implode("\n", $pung); 3474 $new = apply_filters('add_ping', $new); 3713 3714 /** 3715 * Filter the new ping URL to add for the given post. 3716 * 3717 * @since 2.0.0 3718 * 3719 * @param string $new New ping URL to add. 3720 */ 3721 $new = apply_filters( 'add_ping', $new ); 3722 3475 3723 // expected_slashed ($new) 3476 3724 $new = wp_unslash($new); … … 3500 3748 } 3501 3749 } 3502 $pung = apply_filters('get_enclosed', $pung, $post_id); 3750 3751 /** 3752 * Filter the list of enclosures already enclosed for the given post. 3753 * 3754 * @since 2.0.0 3755 * 3756 * @param array $pung Array of enclosures for the given post. 3757 * @param int $post_id Post ID. 3758 */ 3759 $pung = apply_filters( 'get_enclosed', $pung, $post_id ); 3503 3760 return $pung; 3504 3761 } … … 3518 3775 $pung = trim($pung); 3519 3776 $pung = preg_split('/\s/', $pung); 3520 $pung = apply_filters('get_pung', $pung); 3777 3778 /** 3779 * Filter the list of already-pinged URLs for the given post. 3780 * 3781 * @since 2.0.0 3782 * 3783 * @param array $pung Array of URLs already pinged for the given post. 3784 */ 3785 $pung = apply_filters( 'get_pung', $pung ); 3521 3786 return $pung; 3522 3787 } … … 3536 3801 $to_ping = sanitize_trackback_urls( $to_ping ); 3537 3802 $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY); 3538 $to_ping = apply_filters('get_to_ping', $to_ping); 3803 3804 /** 3805 * Filter the list of URLs yet to ping for the given post. 3806 * 3807 * @since 2.0.0 3808 * 3809 * @param array $to_ping List of URLs yet to ping. 3810 */ 3811 $to_ping = apply_filters( 'get_to_ping', $to_ping ); 3539 3812 return $to_ping; 3540 3813 } … … 3899 4172 // Convert to WP_Post instances 3900 4173 $pages = array_map( 'get_post', $cache ); 3901 $pages = apply_filters('get_pages', $pages, $r); 4174 /** This filter is documented in wp-includes/post.php */ 4175 $pages = apply_filters( 'get_pages', $pages, $r ); 3902 4176 return $pages; 3903 4177 } … … 4029 4303 4030 4304 if ( empty($pages) ) { 4031 $pages = apply_filters('get_pages', array(), $r); 4305 /** This filter is documented in wp-includes/post.php */ 4306 $pages = apply_filters( 'get_pages', array(), $r ); 4032 4307 return $pages; 4033 4308 } … … 4071 4346 $pages = array_map( 'get_post', $pages ); 4072 4347 4073 $pages = apply_filters('get_pages', $pages, $r); 4348 /** 4349 * Filter the retrieved list of pages. 4350 * 4351 * @since 2.1.0 4352 * 4353 * @param array $pages List of pages to retrieve. 4354 * @param array $r Array of get_pages() arguments. 4355 */ 4356 $pages = apply_filters( 'get_pages', $pages, $r ); 4074 4357 4075 4358 return $pages; … … 4133 4416 * @since 2.0.0 4134 4417 * @uses $wpdb 4135 * @uses do_action() Calls 'edit_attachment' on $post_ID if this is an update.4136 * @uses do_action() Calls 'add_attachment' on $post_ID if this is not an update.4137 4418 * 4138 4419 * @param string|array $object Arguments to override defaults. … … 4297 4578 4298 4579 if ( $update) { 4299 do_action('edit_attachment', $post_ID); 4580 /** 4581 * Fires once an existing attachment has been updated. 4582 * 4583 * @since 2.0.0 4584 * 4585 * @param int $post_ID Attachment ID. 4586 */ 4587 do_action( 'edit_attachment', $post_ID ); 4300 4588 } else { 4301 do_action('add_attachment', $post_ID); 4589 4590 /** 4591 * Fires once an attachment has been added. 4592 * 4593 * @since 2.0.0 4594 * 4595 * @param int $post_ID Attachment ID. 4596 */ 4597 do_action( 'add_attachment', $post_ID ); 4302 4598 } 4303 4599 … … 4317 4613 * @since 2.0.0 4318 4614 * @uses $wpdb 4319 * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.4320 4615 * 4321 4616 * @param int $post_id Attachment ID. … … 4351 4646 delete_transient( 'dirsize_cache' ); 4352 4647 4353 do_action('delete_attachment', $post_id); 4648 /** 4649 * Fires before an attachment is deleted, at the start of wp_delete_attachment(). 4650 * 4651 * @since 2.0.0 4652 * 4653 * @param int $post_id Attachment ID. 4654 */ 4655 do_action( 'delete_attachment', $post_id ); 4354 4656 4355 4657 wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); … … 4366 4668 delete_metadata_by_mid( 'post', $mid ); 4367 4669 4670 /** This action is documented in wp-includes/post.php */ 4368 4671 do_action( 'delete_post', $post_id ); 4369 4672 $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); … … 4371 4674 return false; 4372 4675 } 4676 /** This action is documented in wp-includes/post.php */ 4373 4677 do_action( 'deleted_post', $post_id ); 4374 4678 … … 4380 4684 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 4381 4685 /** This filter is documented in wp-admin/custom-header.php */ 4382 $thumbfile = apply_filters( 'wp_delete_file', $thumbfile);4686 $thumbfile = apply_filters( 'wp_delete_file', $thumbfile ); 4383 4687 @ unlink( path_join($uploadpath['basedir'], $thumbfile) ); 4384 4688 } … … 4396 4700 $del_file = path_join( dirname($meta['file']), $size['file'] ); 4397 4701 /** This filter is documented in wp-admin/custom-header.php */ 4398 $del_file = apply_filters( 'wp_delete_file', $del_file);4702 $del_file = apply_filters( 'wp_delete_file', $del_file ); 4399 4703 @ unlink( path_join($uploadpath['basedir'], $del_file) ); 4400 4704 } … … 4402 4706 4403 4707 /** This filter is documented in wp-admin/custom-header.php */ 4404 $file = apply_filters( 'wp_delete_file', $file);4708 $file = apply_filters( 'wp_delete_file', $file ); 4405 4709 4406 4710 if ( ! empty($file) ) … … 4431 4735 return $data; 4432 4736 4737 /** 4738 * Filter the attachment meta data. 4739 * 4740 * @since 2.1.0 4741 * 4742 * @param array|bool $data Array of meta data for the given attachment, or false 4743 * if the object does not exist. 4744 * @param int $post_id Attachment ID. 4745 */ 4433 4746 return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID ); 4434 4747 } … … 4448 4761 return false; 4449 4762 4763 /** 4764 * Filter the updated attachment meta data. 4765 * 4766 * @since 2.1.0 4767 * 4768 * @param array $data Array of updated attachment meta data. 4769 * @param int $post_id Attachment ID. 4770 */ 4450 4771 if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) 4451 4772 return update_post_meta( $post->ID, '_wp_attachment_metadata', $data ); … … 4485 4806 $url = get_the_guid( $post->ID ); 4486 4807 4808 /** 4809 * Filter the attachment URL. 4810 * 4811 * @since 2.1.0 4812 * 4813 * @param string $url URL for the given attachment. 4814 * @param int $post_id Attachment ID. 4815 */ 4487 4816 $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID ); 4488 4817 … … 4510 4839 $file = get_attached_file( $post->ID ); 4511 4840 4512 if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) 4841 if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) { 4842 /** 4843 * Filter the attachment thumbnail file path. 4844 * 4845 * @since 2.1.0 4846 * 4847 * @param string $thumbfile File path to the attachment thumbnail. 4848 * @param int $post_id Attachment ID. 4849 */ 4513 4850 return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); 4851 } 4514 4852 return false; 4515 4853 } … … 4539 4877 $url = str_replace(basename($url), basename($thumb), $url); 4540 4878 4879 /** 4880 * Filter the attachment thumbnail URL. 4881 * 4882 * @since 2.1.0 4883 * 4884 * @param string $url URL for the attachment thumbnail. 4885 * @param int $post_id Attachment ID. 4886 */ 4541 4887 return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID ); 4542 4888 } … … 4603 4949 4604 4950 if ( !is_array($icon_files) ) { 4951 /** 4952 * Filter the icon directory path. 4953 * 4954 * @since 2.0.0 4955 * 4956 * @param string $path Icon directory absolute path. 4957 */ 4605 4958 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ); 4606 $icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url('images/media') ); 4607 $dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) ); 4959 4960 /** 4961 * Filter the icon directory URI. 4962 * 4963 * @since 2.0.0 4964 * 4965 * @param string $uri Icon directory URI. 4966 */ 4967 $icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url( 'images/media' ) ); 4968 4969 /** 4970 * Filter the list of icon directory URIs. 4971 * 4972 * @since 2.5.0 4973 * 4974 * @param array $uris List of icon directory URIs. 4975 */ 4976 $dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) ); 4608 4977 $icon_files = array(); 4609 4978 while ( $dirs ) { … … 4652 5021 } 4653 5022 4654 return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type. 5023 /** 5024 * Filter the mime type icon. 5025 * 5026 * @since 2.1.0 5027 * 5028 * @param string $icon Path to the mime type icon. 5029 * @param string $mime Mime type. 5030 * @param int $post_id Attachment ID. Will equal 0 if the function passed 5031 * the mime type. 5032 */ 5033 return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); 4655 5034 } 4656 5035 … … 4732 5111 return $full ? 'WHERE 1 = 0' : ' 1 = 0 '; 4733 5112 4734 // This hook is deprecated. Why you'd want to use it, I dunno. 4735 if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) 5113 /** 5114 * Filter the capability to read private posts for a custom post type 5115 * when generating SQL for getting posts by author. 5116 * 5117 * @since 2.2.0 5118 * @deprecated 3.2.0 The hook transitioned from "somewhat useless" to "totally useless". 5119 * 5120 * @param string $cap Capability. 5121 */ 5122 if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) { 4736 5123 $cap = $post_type_obj->cap->read_private_posts; 5124 } 4737 5125 4738 5126 if ( $full ) { … … 4778 5166 * @since 0.71 4779 5167 * 4780 * @uses apply_filters() Calls 'get_lastpostdate' filter4781 *4782 5168 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. 4783 5169 * @return string The date of the last post. 4784 5170 */ 4785 5171 function get_lastpostdate($timezone = 'server') { 5172 /** 5173 * Filter the date the last post was published. 5174 * 5175 * @since 2.3.0 5176 * 5177 * @param string $date Date the last post was published. Likely values are 'gmt', 5178 * 'blog', or 'server'. 5179 * @param string $timezone Location to use for getting the post published date. 5180 */ 4786 5181 return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone ); 4787 5182 } … … 4795 5190 * 4796 5191 * @since 1.2.0 4797 * @uses apply_filters() Calls 'get_lastpostmodified' filter4798 5192 * 4799 5193 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. … … 4807 5201 $lastpostmodified = $lastpostdate; 4808 5202 5203 /** 5204 * Filter the date the last post was modified. 5205 * 5206 * @since 2.3.0 5207 * 5208 * @param string $lastpostmodified Date the last post was modified. 5209 * @param string $timezone Location to use for getting the post modified date. 5210 */ 4809 5211 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 4810 5212 } … … 4884 5286 * @since 2.0.0 4885 5287 * 4886 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).4887 *4888 5288 * @param int|WP_Post $post Post ID or post object to remove from the cache. 4889 5289 */ … … 4905 5305 wp_cache_delete( 'wp_get_archives', 'general' ); 4906 5306 5307 /** 5308 * Fires immediately after the given post's cache is cleaned. 5309 * 5310 * @since 2.5.0 5311 * 5312 * @param int $post_id Post ID. 5313 * @param WP_Post $post Post object. 5314 */ 4907 5315 do_action( 'clean_post_cache', $post->ID, $post ); 4908 5316 … … 4912 5320 if ( 'page' == $post->post_type ) { 4913 5321 wp_cache_delete( 'all_page_ids', 'posts' ); 5322 5323 /** 5324 * Fires immediately after the given page's cache is cleaned. 5325 * 5326 * @since 2.5.0 5327 * 5328 * @param int $post_id Post ID. 5329 */ 4914 5330 do_action( 'clean_page_cache', $post->ID ); 4915 5331 } … … 4993 5409 * @since 3.0.0 4994 5410 * 4995 * @uses do_action() Calls 'clean_attachment_cache' on $id.4996 *4997 5411 * @param int $id The attachment ID in the cache to clean 4998 5412 * @param bool $clean_terms optional. Whether to clean terms cache … … 5012 5426 clean_object_term_cache($id, 'attachment'); 5013 5427 5014 do_action('clean_attachment_cache', $id); 5428 /** 5429 * Fires after the given attachment's cache is cleaned. 5430 * 5431 * @since 3.0.0 5432 * 5433 * @param int $id Attachment ID. 5434 */ 5435 do_action( 'clean_attachment_cache', $id ); 5015 5436 } 5016 5437 … … 5025 5446 * @access private 5026 5447 * @uses $wpdb 5027 * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call.5028 5448 * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID. 5029 5449 * … … 5039 5459 if ( '' == get_the_guid($post->ID) ) 5040 5460 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); 5041 do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish 5461 5462 /** 5463 * Fires when a post's status is transitioned from private to published. 5464 * 5465 * @since 1.5.0 5466 * @deprecated 2.3.0 Use 'private_to_publish' instead. 5467 * 5468 * @param int $post_id Post ID. 5469 */ 5470 do_action('private_to_published', $post->ID); 5042 5471 } 5043 5472 … … 5083 5512 * @access private 5084 5513 * @uses XMLRPC_REQUEST and WP_IMPORTING constants. 5085 * @uses do_action() Calls 'xmlrpc_publish_post' on post ID if XMLRPC_REQUEST is defined.5086 5514 * 5087 5515 * @param int $post_id The ID in the database table of the post being published 5088 5516 */ 5089 5517 function _publish_post_hook($post_id) { 5090 if ( defined('XMLRPC_REQUEST') ) 5091 do_action('xmlrpc_publish_post', $post_id); 5518 if ( defined( 'XMLRPC_REQUEST' ) ) { 5519 /** 5520 * Fires when _publish_post_hook() is called during an XML-RPC request. 5521 * 5522 * @since 2.1.0 5523 * 5524 * @param int $post_id Post ID. 5525 */ 5526 do_action( 'xmlrpc_publish_post', $post_id ); 5527 } 5092 5528 5093 5529 if ( defined('WP_IMPORTING') )
Note: See TracChangeset
for help on using the changeset viewer.