Make WordPress Core

Ticket #25376: 25376.5.diff

File 25376.5.diff, 34.0 KB (added by DrewAPicture, 11 years ago)

Second pass: Part II.

  • src/wp-includes/post.php

     
    13511351                register_taxonomy_for_object_type( $taxonomy, $post_type );
    13521352        }
    13531353
     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         */
    13541362        do_action( 'registered_post_type', $post_type, $args );
    13551363
    13561364        return $args;
     
    24012409 * disabled, item is already in the trash, or $force_delete is true.
    24022410 *
    24032411 * @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 *
    24062413 * @uses wp_delete_attachment() if post type is 'attachment'.
    24072414 * @uses wp_trash_post() if item should be trashed.
    24082415 *
     
    24222429        if ( $post->post_type == 'attachment' )
    24232430                return wp_delete_attachment( $postid, $force_delete );
    24242431
    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         * @param int $postid Post ID.
     2438         */
     2439        do_action( 'before_delete_post', $postid );
    24262440
    24272441        delete_post_meta($postid,'_wp_trash_meta_status');
    24282442        delete_post_meta($postid,'_wp_trash_meta_time');
     
    24572471        foreach ( $post_meta_ids as $mid )
    24582472                delete_metadata_by_mid( 'post', $mid );
    24592473
     2474        /**
     2475         * Fires immediately before a post is deleted from the database.
     2476         *
     2477         * @since 1.2.0
     2478         *
     2479         * @param int $postid Post ID.
     2480         */
    24602481        do_action( 'delete_post', $postid );
    24612482        $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
    24622483        if ( ! $result ) {
    24632484                return false;
    24642485        }
     2486
     2487        /**
     2488         * Fires immediately after a post is deleted from the database.
     2489         *
     2490         * @since 2.2.0
     2491         *
     2492         * @param int $postid Post ID.
     2493         */
    24652494        do_action( 'deleted_post', $postid );
    24662495
    24672496        clean_post_cache( $post );
     
    24732502
    24742503        wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
    24752504
    2476         do_action('after_delete_post', $postid);
     2505        /**
     2506         * Fires after a post is deleted, at the conclusion of wp_delete_post().
     2507         *
     2508         * @since 3.2.0
     2509         *
     2510         * @param int $postid Post ID.
     2511         */
     2512        do_action( 'after_delete_post', $postid );
    24772513
    24782514        return $post;
    24792515}
     
    25122548 * If trash is disabled, the post or page is permanently deleted.
    25132549 *
    25142550 * @since 2.9.0
    2515  * @uses do_action() on 'trash_post' before trashing
    2516  * @uses do_action() on 'trashed_post' after trashing
     2551 *
    25172552 * @uses wp_delete_post() if trash is disabled
    25182553 *
    25192554 * @param int $post_id Post ID.
     
    25292564        if ( $post['post_status'] == 'trash' )
    25302565                return false;
    25312566
    2532         do_action('wp_trash_post', $post_id);
     2567        /**
     2568         * Fires before a post is sent to the trash.
     2569         *
     2570         * @since 3.3.0
     2571         *
     2572         * @param int $post_id Post ID.
     2573         */
     2574        do_action( 'wp_trash_post', $post_id );
    25332575
    25342576        add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
    25352577        add_post_meta($post_id,'_wp_trash_meta_time', time());
     
    25392581
    25402582        wp_trash_post_comments($post_id);
    25412583
    2542         do_action('trashed_post', $post_id);
     2584        /**
     2585         * Fires after a post is sent to the trash.
     2586         *
     2587         * @since 2.9.0
     2588         *
     2589         * @param int $post_id Post ID.
     2590         */
     2591        do_action( 'trashed_post', $post_id );
    25432592
    25442593        return $post;
    25452594}
     
    25482597 * Restores a post or page from the Trash
    25492598 *
    25502599 * @since 2.9.0
    2551  * @uses do_action() on 'untrash_post' before undeletion
    2552  * @uses do_action() on 'untrashed_post' after undeletion
    25532600 *
    25542601 * @param int $post_id Post ID.
    25552602 * @return mixed False on failure
     
    25612608        if ( $post['post_status'] != 'trash' )
    25622609                return false;
    25632610
    2564         do_action('untrash_post', $post_id);
     2611        /**
     2612         * Fires before a post is restored from the trash.
     2613         *
     2614         * @since 2.9.0
     2615         *
     2616         * @param int $post_id Post ID.
     2617         */
     2618        do_action( 'untrash_post', $post_id );
    25652619
    25662620        $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true);
    25672621
     
    25742628
    25752629        wp_untrash_post_comments($post_id);
    25762630
    2577         do_action('untrashed_post', $post_id);
     2631        /**
     2632         * Fires after a post is restored from the trash.
     2633         *
     2634         * @since 2.9.0
     2635         *
     2636         * @param int $post_id Post ID.
     2637         */
     2638        do_action( 'untrashed_post', $post_id );
    25782639
    25792640        return $post;
    25802641}
     
    25832644 * Moves comments for a post to the trash
    25842645 *
    25852646 * @since 2.9.0
    2586  * @uses do_action() on 'trash_post_comments' before trashing
    2587  * @uses do_action() on 'trashed_post_comments' after trashing
    25882647 *
    25892648 * @param int|WP_Post $post Optional. Post ID or post object.
    25902649 * @return mixed False on failure
     
    25982657
    25992658        $post_id = $post->ID;
    26002659
    2601         do_action('trash_post_comments', $post_id);
     2660        /**
     2661         * Fires before comments are sent to the trash.
     2662         *
     2663         * @since 2.9.0
     2664         *
     2665         * @param int $post_id Post ID.
     2666         */
     2667        do_action( 'trash_post_comments', $post_id );
    26022668
    26032669        $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) );
    26042670        if ( empty($comments) )
     
    26152681
    26162682        clean_comment_cache( array_keys($statuses) );
    26172683
    2618         do_action('trashed_post_comments', $post_id, $statuses);
     2684        /**
     2685         * Fires after comments are sent to the trash.
     2686         *
     2687         * @since 2.9.0
     2688         *
     2689         * @param int   $post_id  Post ID.
     2690         * @param array $statuses Array of comment statuses.
     2691         */
     2692        do_action( 'trashed_post_comments', $post_id, $statuses );
    26192693
    26202694        return $result;
    26212695}
     
    26242698 * Restore comments for a post from the trash
    26252699 *
    26262700 * @since 2.9.0
    2627  * @uses do_action() on 'untrash_post_comments' before trashing
    2628  * @uses do_action() on 'untrashed_post_comments' after trashing
    26292701 *
    26302702 * @param int|WP_Post $post Optional. Post ID or post object.
    26312703 * @return mixed False on failure
     
    26442716        if ( empty($statuses) )
    26452717                return true;
    26462718
    2647         do_action('untrash_post_comments', $post_id);
     2719        /**
     2720         * Fires before comments are restored from the trash.
     2721         *
     2722         * @since 2.9.0
     2723         *
     2724         * @param int $post_id Post ID.
     2725         */
     2726        do_action( 'untrash_post_comments', $post_id );
    26482727
    26492728        // Restore each comment to its original status
    26502729        $group_by_status = array();
     
    26632742
    26642743        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
    26652744
    2666         do_action('untrashed_post_comments', $post_id);
     2745        /**
     2746         * Fires after comments are restored from the trash.
     2747         *
     2748         * @since 2.9.0
     2749         *
     2750         * @param int $post_id Post ID.
     2751         */
     2752        do_action( 'untrashed_post_comments', $post_id );
    26672753}
    26682754
    26692755/**
     
    27972883 * @param array $postarr {
    27982884 *     An array of elements that make up a post to update or insert.
    27992885 *
    2800  *     @type int    'ID'                    The post ID. If equal to something other than 0, the post with that ID will
    2801  *                                          be updated. Default 0.
    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  *                                          Default empty string.
    2811  *     @type string 'post_password          The 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.
     2886 *     @type int    $ID                    The post ID. If equal to something other than 0, the post with that ID will
     2887 *                                         be updated. Default 0.
     2888 *     @type string $post_status           The post status. Default 'draft'.
     2889 *     @type string $post_type             The post type. Default 'post'.
     2890 *     @type int    $post_author           The ID of the user who added the post. Default the current user ID.
     2891 *     @type bool   $ping_status           Whether the post can accept pings. Default value of 'default_ping_status' option.
     2892 *     @type int    $post_parent           Set this for the post it belongs to, if any. Default 0.
     2893 *     @type int    $menu_order            The order it is displayed. Default 0.
     2894 *     @type string $to_ping               Space or carriage return-separated list of URLs to ping. Default empty string.
     2895 *     @type string $pinged                Space or carriage return-separated list of URLs that have been pinged.
     2896 *                                         Default empty string.
     2897 *     @type string $post_password         The password to access the post. Default empty string.
     2898 *     @type string $guid'                 Global Unique ID for referencing the post.
     2899 *     @type string $post_content_filtered The filtered post content. Default empty string.
     2900 *     @type string $post_excerpt          The post excerpt. Default empty string.
    28152901 * }
    28162902 * @param bool  $wp_error Optional. Allow return of WP_Error on failure.
    28172903 * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure.
     
    29873073        else
    29883074                $post_parent = 0;
    29893075
    2990         // Check the post_parent to see if it will cause a hierarchy loop
     3076        /**
     3077         * Filter the post parent -- used to check for and prevent hierarchy loops.
     3078         *
     3079         * @since 3.1.0
     3080         *
     3081         * @param int   $post_parent Post parent ID.
     3082         * @param int   $post_ID     Post ID.
     3083         * @param array $new_postarr Array of parsed post data.
     3084         * @param array $postarr     Array of sanitized, but otherwise unmodified post data.
     3085         */
    29913086        $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
    29923087
    29933088        if ( isset($menu_order) )
     
    30023097
    30033098        // expected_slashed (everything!)
    30043099        $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);
     3100
     3101        /**
     3102         * Filter slashed post data just before it is inserted into the database.
     3103         *
     3104         * @since 2.7.0
     3105         *
     3106         * @param array $data    Array of slashed post data.
     3107         * @param array $postarr Array of sanitized, but otherwise unmodified post data.
     3108         */
     3109        $data = apply_filters( 'wp_insert_post_data', $data, $postarr );
    30063110        $data = wp_unslash( $data );
    30073111        $where = array( 'ID' => $post_ID );
    30083112
    30093113        if ( $update ) {
     3114                /**
     3115                 * Fires immediately before an existing post is updated in the database.
     3116                 *
     3117                 * @since 2.5.0
     3118                 *
     3119                 * @param int   $post_ID Post ID.
     3120                 * @param array $data    Array of unslashed post data.
     3121                 */
    30103122                do_action( 'pre_post_update', $post_ID, $data );
    30113123                if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
    30123124                        if ( $wp_error )
     
    30833195        wp_transition_post_status($data['post_status'], $previous_status, $post);
    30843196
    30853197        if ( $update ) {
    3086                 do_action('edit_post', $post_ID, $post);
     3198                /**
     3199                 * Fires once an existing post has been updated.
     3200                 *
     3201                 * @since 1.2.0
     3202                 *
     3203                 * @param int     $post_ID Post ID.
     3204                 * @param WP_Post $post    Post object.
     3205                 */
     3206                do_action( 'edit_post', $post_ID, $post );
    30873207                $post_after = get_post($post_ID);
     3208
     3209                /**
     3210                 * Fires once an existing post has been updated.
     3211                 *
     3212                 * @since 3.0.0
     3213                 *
     3214                 * @param int     $post_ID      Post ID.
     3215                 * @param WP_Post $post_after   Post object following the update.
     3216                 * @param WP_Post $post_before  Post object before the update.
     3217                 */
    30883218                do_action( 'post_updated', $post_ID, $post_after, $post_before);
    30893219        }
    30903220
     3221        /**
     3222         * Fires once a post has been saved.
     3223         *
     3224         * The dynamic portion of the hook name, $post->post_type, refers to
     3225         * the post type slug.
     3226         *
     3227         * @since 3.7.0
     3228         *
     3229         * @param int     $post_ID Post ID.
     3230         * @param WP_Post $post    Post object.
     3231         * @param bool    $update  Whether this is an existing post being updated or not.
     3232         */
    30913233        do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
     3234
     3235        /**
     3236         * Fires once a post has been saved.
     3237         *
     3238         * @since 1.5.0
     3239         *
     3240         * @param int     $post_ID Post ID.
     3241         * @param WP_Post $post    Post object.
     3242         * @param bool    $update  Whether this is an existing post being updated or not.
     3243         */
    30923244        do_action( 'save_post', $post_ID, $post, $update );
     3245
     3246        /**
     3247         * Fires once a post has been saved.
     3248         *
     3249         * @since 2.0.0
     3250         *
     3251         * @param int     $post_ID Post ID.
     3252         * @param WP_Post $post    Post object.
     3253         * @param bool    $update  Whether this is an existing post being updated or not.
     3254         */
    30933255        do_action( 'wp_insert_post', $post_ID, $post, $update );
    30943256
    30953257        return $post_ID;
     
    31593321 *
    31603322 * @since 2.1.0
    31613323 * @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.
    31633324 *
    31643325 * @param int|WP_Post $post Post ID or post object.
    31653326 */
     
    31803341        $post->post_status = 'publish';
    31813342        wp_transition_post_status( 'publish', $old_status, $post );
    31823343
     3344        /** This action is documented in wp-includes/post.php */
    31833345        do_action( 'edit_post', $post->ID, $post );
     3346        /** This action is documented in wp-includes/post.php */
    31843347        do_action( "save_post_{$post->post_type}", $post->ID, $post, true );
     3348        /** This action is documented in wp-includes/post.php */
    31853349        do_action( 'save_post', $post->ID, $post, true );
     3350        /** This action is documented in wp-includes/post.php */
    31863351        do_action( 'wp_insert_post', $post->ID, $post, true );
    31873352}
    31883353
     
    32503415                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
    32513416                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) );
    32523417
     3418                /**
     3419                 * Filter whether the post slug would serve as a poor attachment slug.
     3420                 *
     3421                 * @since 3.1.0
     3422                 *
     3423                 * @param bool   $bad_slug Whether the slug would be bad as an attachment slug.
     3424                 * @param string $slug     The post slug.
     3425                 */
    32533426                if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) {
    32543427                        $suffix = 2;
    32553428                        do {
     
    32623435        } elseif ( in_array( $post_type, $hierarchical_post_types ) ) {
    32633436                if ( 'nav_menu_item' == $post_type )
    32643437                        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.
     3438
     3439                /*
     3440                 * Page slugs must be unique within their own trees. Pages are in a separate
     3441                 * namespace than posts so page slugs are allowed to overlap post slugs.
     3442                 */
    32673443                $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";
    32683444                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    32693445
     3446                /**
     3447                 * Filter whether the post slug would serve as a poor hierarchical post slug.
     3448                 *
     3449                 * @since 3.1.0
     3450                 *
     3451                 * @param bool   $bad_slug    Whether the post slug would be bad in a hierarchical post context.
     3452                 * @param string $slug        The post slug.
     3453                 * @param string $post_type   Post type.
     3454                 * @param int    $post_parent Post parent ID.
     3455                 */
    32703456                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 ) ) {
    32713457                        $suffix = 2;
    32723458                        do {
     
    32813467                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1";
    32823468                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) );
    32833469
     3470                /**
     3471                 * Filter whether the unique post slug would be bad as a flat slug.
     3472                 *
     3473                 * @since 3.1.0
     3474                 *
     3475                 * @param bool   $bad_slug  Whether the post slug would be bad as a flat slug.
     3476                 * @param string $slug      The post slug.
     3477                 * @param string $post_type Post type.
     3478                 */
    32843479                if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) {
    32853480                        $suffix = 2;
    32863481                        do {
     
    32923487                }
    32933488        }
    32943489
     3490        /**
     3491         * Filter the unique post slug.
     3492         *
     3493         * @since 3.3.0
     3494         *
     3495         * @param string $slug          The post slug.
     3496         * @param int    $post_ID       Post ID.
     3497         * @param string $post_status   The post status.
     3498         * @param string $post_type     Post type.
     3499         * @param int    $post_parent   Post parent ID
     3500         * @param string $original_slug The original post slug.
     3501         */
    32953502        return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug );
    32963503}
    32973504
     
    34333640 * parameter and POSTTYPE is post_type post data.
    34343641 *
    34353642 * @since 2.3.0
     3643 *
    34363644 * @link http://codex.wordpress.org/Post_Status_Transitions
    34373645 *
    3438  * @uses do_action() Calls 'transition_post_status' on $new_status, $old_status and
    3439  *  $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  *
    34433646 * @param string $new_status Transition to this post status.
    34443647 * @param string $old_status Previous post status.
    34453648 * @param object $post Post data.
    34463649 */
    34473650function 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);
     3651        /**
     3652         * Fires when a post is transitioned from one status to another.
     3653         *
     3654         * @since 2.3.0
     3655         *
     3656         * @param string  $new_status New post status.
     3657         * @param string  $old_status Old post status.
     3658         * @param WP_Post $post       Post object.
     3659         */
     3660        do_action( 'transition_post_status', $new_status, $old_status, $post );
     3661
     3662        /**
     3663         * Fires when a post is transitioned from one status to another.
     3664         *
     3665         * The dynamic portions of the hook name, $new_status and $old status,
     3666         * refer to the old and new post statuses, respectively.
     3667         *
     3668         * @since 2.3.0
     3669         *
     3670         * @param WP_Post $post Post object.
     3671         */
     3672        do_action( "{$old_status}_to_{$new_status}", $post );
     3673
     3674        /**
     3675         * Fires when a post is transitioned from one status to another.
     3676         *
     3677         * The dynamic portions of the hook name, $new_status and $post->post_type,
     3678         * refer to the new post status and post type, respectively.
     3679         *
     3680         * @since 2.3.0
     3681         *
     3682         * @param int     $post_id Post ID.
     3683         * @param WP_Post $post    Post object.
     3684         */
     3685        do_action( "{$new_status}_{$post->post_type}", $post->ID, $post );
    34513686}
    34523687
    34533688//
     
    34713706        $pung = preg_split('/\s/', $pung);
    34723707        $pung[] = $uri;
    34733708        $new = implode("\n", $pung);
    3474         $new = apply_filters('add_ping', $new);
     3709
     3710        /**
     3711         * Filter the new ping URL to add for the given post.
     3712         *
     3713         * @since 2.0.0
     3714         *
     3715         * @param string $new New ping URL to add.
     3716         */
     3717        $new = apply_filters( 'add_ping', $new );
     3718
    34753719        // expected_slashed ($new)
    34763720        $new = wp_unslash($new);
    34773721        return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) );
     
    34993743                        $pung[] = trim( $enclosure[ 0 ] );
    35003744                }
    35013745        }
    3502         $pung = apply_filters('get_enclosed', $pung, $post_id);
     3746
     3747        /**
     3748         * Filter the list of enclosures already enclosed for the given post.
     3749         *
     3750         * @since 2.0.0
     3751         *
     3752         * @param array $pung    Array of enclosures for the given post.
     3753         * @param int   $post_id Post ID.
     3754         */
     3755        $pung = apply_filters( 'get_enclosed', $pung, $post_id );
    35033756        return $pung;
    35043757}
    35053758
     
    35173770        $pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id ));
    35183771        $pung = trim($pung);
    35193772        $pung = preg_split('/\s/', $pung);
    3520         $pung = apply_filters('get_pung', $pung);
     3773
     3774        /**
     3775         * Filter the list of already-pinged URLs for the given post.
     3776         *
     3777         * @since 2.0.0
     3778         *
     3779         * @param array $pung Array of URLs already pinged for the given post.
     3780         */
     3781        $pung = apply_filters( 'get_pung', $pung );
    35213782        return $pung;
    35223783}
    35233784
     
    35353796        $to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id ));
    35363797        $to_ping = sanitize_trackback_urls( $to_ping );
    35373798        $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY);
    3538         $to_ping = apply_filters('get_to_ping',  $to_ping);
     3799
     3800        /**
     3801         * Filter the list of URLs yet to ping for the given post.
     3802         *
     3803         * @since 2.0.0
     3804         *
     3805         * @param array $to_ping List of URLs yet to ping.
     3806         */
     3807        $to_ping = apply_filters( 'get_to_ping',  $to_ping );
    35393808        return $to_ping;
    35403809}
    35413810
     
    38984167        if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) {
    38994168                // Convert to WP_Post instances
    39004169                $pages = array_map( 'get_post', $cache );
    3901                 $pages = apply_filters('get_pages', $pages, $r);
     4170                /** This filter is documented in wp-includes/post.php */
     4171                $pages = apply_filters( 'get_pages', $pages, $r );
    39024172                return $pages;
    39034173        }
    39044174
     
    40284298        $pages = $wpdb->get_results($query);
    40294299
    40304300        if ( empty($pages) ) {
    4031                 $pages = apply_filters('get_pages', array(), $r);
     4301                /** This filter is documented in wp-includes/post.php */
     4302                $pages = apply_filters( 'get_pages', array(), $r );
    40324303                return $pages;
    40334304        }
    40344305
     
    40704341        // Convert to WP_Post instances
    40714342        $pages = array_map( 'get_post', $pages );
    40724343
    4073         $pages = apply_filters('get_pages', $pages, $r);
     4344        /**
     4345         * Filter the retrieved list of pages.
     4346         *
     4347         * @since 2.1.0
     4348         *
     4349         * @param array $pages List of pages to retrieve.
     4350         * @param array $r     Array of get_pages() arguments.
     4351         */
     4352        $pages = apply_filters( 'get_pages', $pages, $r );
    40744353
    40754354        return $pages;
    40764355}
     
    41324411 *
    41334412 * @since 2.0.0
    41344413 * @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.
    41374414 *
    41384415 * @param string|array $object Arguments to override defaults.
    41394416 * @param string $file Optional filename.
     
    42964573                add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    42974574
    42984575        if ( $update) {
    4299                 do_action('edit_attachment', $post_ID);
     4576                /**
     4577                 * Fires once an existing attachment has been updated.
     4578                 *
     4579                 * @since 2.0.0
     4580                 *
     4581                 * @param int $post_ID Attachment ID.
     4582                 */
     4583                do_action( 'edit_attachment', $post_ID );
    43004584        } else {
    4301                 do_action('add_attachment', $post_ID);
     4585
     4586                /**
     4587                 * Fires once an attachment has been added.
     4588                 *
     4589                 * @since 2.0.0
     4590                 *
     4591                 * @param int $post_ID Attachment ID.
     4592                 */
     4593                do_action( 'add_attachment', $post_ID );
    43024594        }
    43034595
    43044596        return $post_ID;
     
    43164608 *
    43174609 * @since 2.0.0
    43184610 * @uses $wpdb
    4319  * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.
    43204611 *
    43214612 * @param int $post_id Attachment ID.
    43224613 * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false.
     
    43504641        if ( is_multisite() )
    43514642                delete_transient( 'dirsize_cache' );
    43524643
    4353         do_action('delete_attachment', $post_id);
     4644        /**
     4645         * Fires before an attachment is deleted, at the start of wp_delete_attachment().
     4646         *
     4647         * @since 2.0.0
     4648         *
     4649         * @param int $post_id Attachment ID.
     4650         */
     4651        do_action( 'delete_attachment', $post_id );
    43544652
    43554653        wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
    43564654        wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
     
    43654663        foreach ( $post_meta_ids as $mid )
    43664664                delete_metadata_by_mid( 'post', $mid );
    43674665
     4666        /** This action is documented in wp-includes/post.php */
    43684667        do_action( 'delete_post', $post_id );
    43694668        $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
    43704669        if ( ! $result ) {
    43714670                return false;
    43724671        }
     4672        /** This action is documented in wp-includes/post.php */
    43734673        do_action( 'deleted_post', $post_id );
    43744674
    43754675        $uploadpath = wp_upload_dir();
     
    43794679                if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $meta['thumb'] . '%', $post_id)) ) {
    43804680                        $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
    43814681                        /** This filter is documented in wp-admin/custom-header.php */
    4382                         $thumbfile = apply_filters('wp_delete_file', $thumbfile);
     4682                        $thumbfile = apply_filters( 'wp_delete_file', $thumbfile );
    43834683                        @ unlink( path_join($uploadpath['basedir'], $thumbfile) );
    43844684                }
    43854685        }
     
    43954695                foreach ( $backup_sizes as $size ) {
    43964696                        $del_file = path_join( dirname($meta['file']), $size['file'] );
    43974697                        /** This filter is documented in wp-admin/custom-header.php */
    4398                         $del_file = apply_filters('wp_delete_file', $del_file);
     4698                        $del_file = apply_filters( 'wp_delete_file', $del_file );
    43994699                        @ unlink( path_join($uploadpath['basedir'], $del_file) );
    44004700                }
    44014701        }
    44024702
    44034703        /** This filter is documented in wp-admin/custom-header.php */
    4404         $file = apply_filters('wp_delete_file', $file);
     4704        $file = apply_filters( 'wp_delete_file', $file );
    44054705
    44064706        if ( ! empty($file) )
    44074707                @ unlink($file);
     
    44304730        if ( $unfiltered )
    44314731                return $data;
    44324732
     4733        /**
     4734         * Filter the attachment meta data.
     4735         *
     4736         * @since 2.1.0
     4737         *
     4738         * @param array|bool $data    Array of meta data for the given attachment, or false
     4739         *                            if the object does not exist..
     4740         * @param int        $post_id Attachment ID.
     4741         */
    44334742        return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
    44344743}
    44354744
     
    44474756        if ( !$post = get_post( $post_id ) )
    44484757                return false;
    44494758
     4759        /**
     4760         * Filter the updated attachment meta data.
     4761         *
     4762         * @since 2.1.0
     4763         *
     4764         * @param array $data    Array of updated attachment meta data.
     4765         * @param int   $post_id Attachment ID.
     4766         */
    44504767        if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) )
    44514768                return update_post_meta( $post->ID, '_wp_attachment_metadata', $data );
    44524769        else
     
    44844801        if ( empty($url) ) //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recommended to rely upon this.
    44854802                $url = get_the_guid( $post->ID );
    44864803
     4804        /**
     4805         * Filter the attachment URL.
     4806         *
     4807         * @since 2.1.0
     4808         *
     4809         * @param string $url     URL for the given attachment.
     4810         * @param int    $post_id Attachment ID.
     4811         */
    44874812        $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID );
    44884813
    44894814        if ( empty( $url ) )
     
    45094834
    45104835        $file = get_attached_file( $post->ID );
    45114836
    4512         if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
     4837        if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) {
     4838                /**
     4839                 * Filter the attachment thumbnail file path.
     4840                 *
     4841                 * @since 2.1.0
     4842                 *
     4843                 * @param string $thumbfile File path to the attachment thumbnail.
     4844                 * @param int    $post_id   Attachment ID.
     4845                 */
    45134846                return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
     4847        }
    45144848        return false;
    45154849}
    45164850
     
    45384872
    45394873        $url = str_replace(basename($url), basename($thumb), $url);
    45404874
     4875        /**
     4876         * Filter the attachment thumbnail URL.
     4877         *
     4878         * @since 2.1.0
     4879         *
     4880         * @param string $url     URL for the attachment thumbnail.
     4881         * @param int    $post_id Attachment ID.
     4882         */
    45414883        return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
    45424884}
    45434885
     
    46024944                $icon_files = wp_cache_get('icon_files');
    46034945
    46044946                if ( !is_array($icon_files) ) {
     4947                        /**
     4948                         * Filter the icon directory path.
     4949                         *
     4950                         * @since 2.0.0
     4951                         *
     4952                         * @param string $path Icon directory absolute path.
     4953                         */
    46054954                        $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) );
     4955
     4956                        /**
     4957                         * Filter the icon directory URI.
     4958                         *
     4959                         * @since 2.0.0
     4960                         *
     4961                         * @param string $uri Icon directory URI.
     4962                         */
     4963                        $icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url( 'images/media' ) );
     4964
     4965                        /**
     4966                         * Filter the list of icon directory URIs.
     4967                         *
     4968                         * @since 2.5.0
     4969                         *
     4970                         * @param array $uris List of icon directory URIs.
     4971                         */
     4972                        $dirs = apply_filters( 'icon_dirs', array( $icon_dir => $icon_dir_uri ) );
    46084973                        $icon_files = array();
    46094974                        while ( $dirs ) {
    46104975                                $keys = array_keys( $dirs );
     
    46515016                }
    46525017        }
    46535018
     5019        /**
     5020         * Filter the mime type icon.
     5021         *
     5022         * @since 2.1.0
     5023         *
     5024         * @param string $icon    Path to the mime type icon.
     5025         * @param string $mime    Mime type.
     5026         * @param int    $post_id Attachment ID. Will equal 0 if the function passed
     5027         *                        the mime type.
     5028         */
    46545029        return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type.
    46555030}
    46565031
     
    47315106        if ( ! $post_type_obj )
    47325107                return $full ? 'WHERE 1 = 0' : ' 1 = 0 ';
    47335108
    4734         // This hook is deprecated. Why you'd want to use it, I dunno.
    4735         if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) )
     5109        /**
     5110         * Filter the capability to read private posts for a custom post type
     5111         * when generating SQL for getting posts by author.
     5112         *
     5113         * @since 2.2.0
     5114         * @deprecated 3.2.0 The hook transitioned from "somewhat useless" to "totally useless".
     5115         *
     5116         * @param string $cap Capability.
     5117         */
     5118        if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) {
    47365119                $cap = $post_type_obj->cap->read_private_posts;
     5120        }
    47375121
    47385122        if ( $full ) {
    47395123                if ( null === $post_author ) {
     
    47775161 *
    47785162 * @since 0.71
    47795163 *
    4780  * @uses apply_filters() Calls 'get_lastpostdate' filter
    4781  *
    47825164 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
    47835165 * @return string The date of the last post.
    47845166 */
    47855167function get_lastpostdate($timezone = 'server') {
     5168        /**
     5169         * Filter the date the last post was published.
     5170         *
     5171         * @since 2.3.0
     5172         *
     5173         * @param string $date     Date the last post was published. Likely values are 'gmt',
     5174         *                         'blog', or 'server'.
     5175         * @param string $timezone Location to use for getting the post published date.
     5176         */
    47865177        return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone );
    47875178}
    47885179
     
    47945185 * 'gmt' is when the last post was modified in GMT time.
    47955186 *
    47965187 * @since 1.2.0
    4797  * @uses apply_filters() Calls 'get_lastpostmodified' filter
    47985188 *
    47995189 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
    48005190 * @return string The date the post was last modified.
     
    48065196        if ( $lastpostdate > $lastpostmodified )
    48075197                $lastpostmodified = $lastpostdate;
    48085198
     5199        /**
     5200         * Filter the date the last post was modified.
     5201         *
     5202         * @since 2.3.0
     5203         *
     5204         * @param string $lastpostmodified Date the last post was modified.
     5205         * @param string $timezone         Location to use for getting the post modified date.
     5206         */
    48095207        return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone );
    48105208}
    48115209
     
    48835281 *
    48845282 * @since 2.0.0
    48855283 *
    4886  * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).
    4887  *
    48885284 * @param int|WP_Post $post Post ID or post object to remove from the cache.
    48895285 */
    48905286function clean_post_cache( $post ) {
     
    49045300
    49055301        wp_cache_delete( 'wp_get_archives', 'general' );
    49065302
     5303        /**
     5304         * Fires immediately after the given post's cache is cleaned.
     5305         *
     5306         * @since 2.5.0
     5307         *
     5308         * @param int     $post_id Post ID.
     5309         * @param WP_Post $post    Post object.
     5310         */
    49075311        do_action( 'clean_post_cache', $post->ID, $post );
    49085312
    49095313        if ( is_post_type_hierarchical( $post->post_type ) )
     
    49115315
    49125316        if ( 'page' == $post->post_type ) {
    49135317                wp_cache_delete( 'all_page_ids', 'posts' );
     5318
     5319                /**
     5320                 * Fires immediately after the given page's cache is cleaned.
     5321                 *
     5322                 * @since 2.5.0
     5323                 *
     5324                 * @param int $post_id Post ID.
     5325                 */
    49145326                do_action( 'clean_page_cache', $post->ID );
    49155327        }
    49165328
     
    49925404 *
    49935405 * @since 3.0.0
    49945406 *
    4995  * @uses do_action() Calls 'clean_attachment_cache' on $id.
    4996  *
    49975407 * @param int $id The attachment ID in the cache to clean
    49985408 * @param bool $clean_terms optional. Whether to clean terms cache
    49995409 */
     
    50115421        if ( $clean_terms )
    50125422                clean_object_term_cache($id, 'attachment');
    50135423
    5014         do_action('clean_attachment_cache', $id);
     5424        /**
     5425         * Fires after the given attachment's cache is cleaned.
     5426         *
     5427         * @since 3.0.0
     5428         *
     5429         * @param int $id Attachment ID.
     5430         */
     5431        do_action( 'clean_attachment_cache', $id );
    50155432}
    50165433
    50175434//
     
    50245441 * @since 2.3.0
    50255442 * @access private
    50265443 * @uses $wpdb
    5027  * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call.
    50285444 * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID.
    50295445 *
    50305446 * @param string $new_status New post status
     
    50385454                // Reset GUID if transitioning to publish and it is empty
    50395455                if ( '' == get_the_guid($post->ID) )
    50405456                        $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) );
     5457
     5458                /**
     5459                 * Fires when a post's status is transitioned from private to published.
     5460                 *
     5461                 * @since 1.5.0
     5462                 * @deprecated 2.3.0 Use the 'private_to_publish' hook instead.
     5463                 *
     5464                 * @param int $post_id Post ID.
     5465                 */
    50415466                do_action('private_to_published', $post->ID);  // Deprecated, use private_to_publish
    50425467        }
    50435468
     
    50825507 * @since 2.3.0
    50835508 * @access private
    50845509 * @uses XMLRPC_REQUEST and WP_IMPORTING constants.
    5085  * @uses do_action() Calls 'xmlrpc_publish_post' on post ID if XMLRPC_REQUEST is defined.
    50865510 *
    50875511 * @param int $post_id The ID in the database table of the post being published
    50885512 */
    50895513function _publish_post_hook($post_id) {
    5090         if ( defined('XMLRPC_REQUEST') )
    5091                 do_action('xmlrpc_publish_post', $post_id);
     5514        if ( defined('XMLRPC_REQUEST') ) {
     5515                /**
     5516                 * Fires when _publish_post_hook() is called during an XML-RPC request.
     5517                 *
     5518                 * @since 2.1.0
     5519                 *
     5520                 * @param int $post_id Post ID.
     5521                 */
     5522                do_action( 'xmlrpc_publish_post', $post_id );
     5523        }
    50925524
    50935525        if ( defined('WP_IMPORTING') )
    50945526                return;