Ticket #25376: 25376.5.diff
File 25376.5.diff, 34.0 KB (added by , 11 years ago) |
---|
-
src/wp-includes/post.php
1351 1351 register_taxonomy_for_object_type( $taxonomy, $post_type ); 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 1356 1364 return $args; … … 2401 2409 * disabled, item is already in the trash, or $force_delete is true. 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. 2408 2415 * … … 2422 2429 if ( $post->post_type == 'attachment' ) 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 * @param int $postid Post ID. 2438 */ 2439 do_action( 'before_delete_post', $postid ); 2426 2440 2427 2441 delete_post_meta($postid,'_wp_trash_meta_status'); 2428 2442 delete_post_meta($postid,'_wp_trash_meta_time'); … … 2457 2471 foreach ( $post_meta_ids as $mid ) 2458 2472 delete_metadata_by_mid( 'post', $mid ); 2459 2473 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 */ 2460 2481 do_action( 'delete_post', $postid ); 2461 2482 $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2462 2483 if ( ! $result ) { 2463 2484 return false; 2464 2485 } 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 */ 2465 2494 do_action( 'deleted_post', $postid ); 2466 2495 2467 2496 clean_post_cache( $post ); … … 2473 2502 2474 2503 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); 2475 2504 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 ); 2477 2513 2478 2514 return $post; 2479 2515 } … … 2512 2548 * If trash is disabled, the post or page is permanently deleted. 2513 2549 * 2514 2550 * @since 2.9.0 2515 * @uses do_action() on 'trash_post' before trashing 2516 * @uses do_action() on 'trashed_post' after trashing 2551 * 2517 2552 * @uses wp_delete_post() if trash is disabled 2518 2553 * 2519 2554 * @param int $post_id Post ID. … … 2529 2564 if ( $post['post_status'] == 'trash' ) 2530 2565 return false; 2531 2566 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 ); 2533 2575 2534 2576 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); 2535 2577 add_post_meta($post_id,'_wp_trash_meta_time', time()); … … 2539 2581 2540 2582 wp_trash_post_comments($post_id); 2541 2583 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 ); 2543 2592 2544 2593 return $post; 2545 2594 } … … 2548 2597 * Restores a post or page from the Trash 2549 2598 * 2550 2599 * @since 2.9.0 2551 * @uses do_action() on 'untrash_post' before undeletion2552 * @uses do_action() on 'untrashed_post' after undeletion2553 2600 * 2554 2601 * @param int $post_id Post ID. 2555 2602 * @return mixed False on failure … … 2561 2608 if ( $post['post_status'] != 'trash' ) 2562 2609 return false; 2563 2610 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 ); 2565 2619 2566 2620 $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); 2567 2621 … … 2574 2628 2575 2629 wp_untrash_post_comments($post_id); 2576 2630 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 ); 2578 2639 2579 2640 return $post; 2580 2641 } … … 2583 2644 * Moves comments for a post to the trash 2584 2645 * 2585 2646 * @since 2.9.0 2586 * @uses do_action() on 'trash_post_comments' before trashing2587 * @uses do_action() on 'trashed_post_comments' after trashing2588 2647 * 2589 2648 * @param int|WP_Post $post Optional. Post ID or post object. 2590 2649 * @return mixed False on failure … … 2598 2657 2599 2658 $post_id = $post->ID; 2600 2659 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 ); 2602 2668 2603 2669 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) ); 2604 2670 if ( empty($comments) ) … … 2615 2681 2616 2682 clean_comment_cache( array_keys($statuses) ); 2617 2683 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 ); 2619 2693 2620 2694 return $result; 2621 2695 } … … 2624 2698 * Restore comments for a post from the trash 2625 2699 * 2626 2700 * @since 2.9.0 2627 * @uses do_action() on 'untrash_post_comments' before trashing2628 * @uses do_action() on 'untrashed_post_comments' after trashing2629 2701 * 2630 2702 * @param int|WP_Post $post Optional. Post ID or post object. 2631 2703 * @return mixed False on failure … … 2644 2716 if ( empty($statuses) ) 2645 2717 return true; 2646 2718 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 ); 2648 2727 2649 2728 // Restore each comment to its original status 2650 2729 $group_by_status = array(); … … 2663 2742 2664 2743 delete_post_meta($post_id, '_wp_trash_meta_comments_status'); 2665 2744 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 ); 2667 2753 } 2668 2754 2669 2755 /** … … 2797 2883 * @param array $postarr { 2798 2884 * An array of elements that make up a post to update or insert. 2799 2885 * 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.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. 2815 2901 * } 2816 2902 * @param bool $wp_error Optional. Allow return of WP_Error on failure. 2817 2903 * @return int|WP_Error The post ID on success. The value 0 or WP_Error on failure. … … 2987 3073 else 2988 3074 $post_parent = 0; 2989 3075 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 */ 2991 3086 $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr ); 2992 3087 2993 3088 if ( isset($menu_order) ) … … 3002 3097 3003 3098 // expected_slashed (everything!) 3004 3099 $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 ); 3006 3110 $data = wp_unslash( $data ); 3007 3111 $where = array( 'ID' => $post_ID ); 3008 3112 3009 3113 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 */ 3010 3122 do_action( 'pre_post_update', $post_ID, $data ); 3011 3123 if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) { 3012 3124 if ( $wp_error ) … … 3083 3195 wp_transition_post_status($data['post_status'], $previous_status, $post); 3084 3196 3085 3197 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 ); 3087 3207 $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 */ 3088 3218 do_action( 'post_updated', $post_ID, $post_after, $post_before); 3089 3219 } 3090 3220 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 */ 3091 3233 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 */ 3092 3244 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 */ 3093 3255 do_action( 'wp_insert_post', $post_ID, $post, $update ); 3094 3256 3095 3257 return $post_ID; … … 3159 3321 * 3160 3322 * @since 2.1.0 3161 3323 * @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 3324 * 3164 3325 * @param int|WP_Post $post Post ID or post object. 3165 3326 */ … … 3180 3341 $post->post_status = 'publish'; 3181 3342 wp_transition_post_status( 'publish', $old_status, $post ); 3182 3343 3344 /** This action is documented in wp-includes/post.php */ 3183 3345 do_action( 'edit_post', $post->ID, $post ); 3346 /** This action is documented in wp-includes/post.php */ 3184 3347 do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); 3348 /** This action is documented in wp-includes/post.php */ 3185 3349 do_action( 'save_post', $post->ID, $post, true ); 3350 /** This action is documented in wp-includes/post.php */ 3186 3351 do_action( 'wp_insert_post', $post->ID, $post, true ); 3187 3352 } 3188 3353 … … 3250 3415 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; 3251 3416 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 3252 3417 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 */ 3253 3426 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 3254 3427 $suffix = 2; 3255 3428 do { … … 3262 3435 } elseif ( in_array( $post_type, $hierarchical_post_types ) ) { 3263 3436 if ( 'nav_menu_item' == $post_type ) 3264 3437 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 */ 3267 3443 $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 3444 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 3269 3445 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 */ 3270 3456 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 3457 $suffix = 2; 3272 3458 do { … … 3281 3467 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 3282 3468 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3283 3469 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 */ 3284 3479 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 3285 3480 $suffix = 2; 3286 3481 do { … … 3292 3487 } 3293 3488 } 3294 3489 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 */ 3295 3502 return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ); 3296 3503 } 3297 3504 … … 3433 3640 * parameter and POSTTYPE is post_type post data. 3434 3641 * 3435 3642 * @since 2.3.0 3643 * 3436 3644 * @link http://codex.wordpress.org/Post_Status_Transitions 3437 3645 * 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 *3443 3646 * @param string $new_status Transition to this post status. 3444 3647 * @param string $old_status Previous post status. 3445 3648 * @param object $post Post data. 3446 3649 */ 3447 3650 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); 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 ); 3451 3686 } 3452 3687 3453 3688 // … … 3471 3706 $pung = preg_split('/\s/', $pung); 3472 3707 $pung[] = $uri; 3473 3708 $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 3475 3719 // expected_slashed ($new) 3476 3720 $new = wp_unslash($new); 3477 3721 return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) ); … … 3499 3743 $pung[] = trim( $enclosure[ 0 ] ); 3500 3744 } 3501 3745 } 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 ); 3503 3756 return $pung; 3504 3757 } 3505 3758 … … 3517 3770 $pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id )); 3518 3771 $pung = trim($pung); 3519 3772 $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 ); 3521 3782 return $pung; 3522 3783 } 3523 3784 … … 3535 3796 $to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id )); 3536 3797 $to_ping = sanitize_trackback_urls( $to_ping ); 3537 3798 $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 ); 3539 3808 return $to_ping; 3540 3809 } 3541 3810 … … 3898 4167 if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) { 3899 4168 // Convert to WP_Post instances 3900 4169 $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 ); 3902 4172 return $pages; 3903 4173 } 3904 4174 … … 4028 4298 $pages = $wpdb->get_results($query); 4029 4299 4030 4300 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 ); 4032 4303 return $pages; 4033 4304 } 4034 4305 … … 4070 4341 // Convert to WP_Post instances 4071 4342 $pages = array_map( 'get_post', $pages ); 4072 4343 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 ); 4074 4353 4075 4354 return $pages; 4076 4355 } … … 4132 4411 * 4133 4412 * @since 2.0.0 4134 4413 * @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 4414 * 4138 4415 * @param string|array $object Arguments to override defaults. 4139 4416 * @param string $file Optional filename. … … 4296 4573 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 4297 4574 4298 4575 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 ); 4300 4584 } 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 ); 4302 4594 } 4303 4595 4304 4596 return $post_ID; … … 4316 4608 * 4317 4609 * @since 2.0.0 4318 4610 * @uses $wpdb 4319 * @uses do_action() Calls 'delete_attachment' hook on Attachment ID.4320 4611 * 4321 4612 * @param int $post_id Attachment ID. 4322 4613 * @param bool $force_delete Whether to bypass trash and force deletion. Defaults to false. … … 4350 4641 if ( is_multisite() ) 4351 4642 delete_transient( 'dirsize_cache' ); 4352 4643 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 ); 4354 4652 4355 4653 wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); 4356 4654 wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); … … 4365 4663 foreach ( $post_meta_ids as $mid ) 4366 4664 delete_metadata_by_mid( 'post', $mid ); 4367 4665 4666 /** This action is documented in wp-includes/post.php */ 4368 4667 do_action( 'delete_post', $post_id ); 4369 4668 $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); 4370 4669 if ( ! $result ) { 4371 4670 return false; 4372 4671 } 4672 /** This action is documented in wp-includes/post.php */ 4373 4673 do_action( 'deleted_post', $post_id ); 4374 4674 4375 4675 $uploadpath = wp_upload_dir(); … … 4379 4679 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)) ) { 4380 4680 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 4381 4681 /** 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 ); 4383 4683 @ unlink( path_join($uploadpath['basedir'], $thumbfile) ); 4384 4684 } 4385 4685 } … … 4395 4695 foreach ( $backup_sizes as $size ) { 4396 4696 $del_file = path_join( dirname($meta['file']), $size['file'] ); 4397 4697 /** 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 ); 4399 4699 @ unlink( path_join($uploadpath['basedir'], $del_file) ); 4400 4700 } 4401 4701 } 4402 4702 4403 4703 /** 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 ); 4405 4705 4406 4706 if ( ! empty($file) ) 4407 4707 @ unlink($file); … … 4430 4730 if ( $unfiltered ) 4431 4731 return $data; 4432 4732 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 */ 4433 4742 return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID ); 4434 4743 } 4435 4744 … … 4447 4756 if ( !$post = get_post( $post_id ) ) 4448 4757 return false; 4449 4758 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 */ 4450 4767 if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) 4451 4768 return update_post_meta( $post->ID, '_wp_attachment_metadata', $data ); 4452 4769 else … … 4484 4801 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. 4485 4802 $url = get_the_guid( $post->ID ); 4486 4803 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 */ 4487 4812 $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID ); 4488 4813 4489 4814 if ( empty( $url ) ) … … 4509 4834 4510 4835 $file = get_attached_file( $post->ID ); 4511 4836 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 */ 4513 4846 return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); 4847 } 4514 4848 return false; 4515 4849 } 4516 4850 … … 4538 4872 4539 4873 $url = str_replace(basename($url), basename($thumb), $url); 4540 4874 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 */ 4541 4883 return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID ); 4542 4884 } 4543 4885 … … 4602 4944 $icon_files = wp_cache_get('icon_files'); 4603 4945 4604 4946 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 */ 4605 4954 $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 ) ); 4608 4973 $icon_files = array(); 4609 4974 while ( $dirs ) { 4610 4975 $keys = array_keys( $dirs ); … … 4651 5016 } 4652 5017 } 4653 5018 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 */ 4654 5029 return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type. 4655 5030 } 4656 5031 … … 4731 5106 if ( ! $post_type_obj ) 4732 5107 return $full ? 'WHERE 1 = 0' : ' 1 = 0 '; 4733 5108 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', '' ) ) { 4736 5119 $cap = $post_type_obj->cap->read_private_posts; 5120 } 4737 5121 4738 5122 if ( $full ) { 4739 5123 if ( null === $post_author ) { … … 4777 5161 * 4778 5162 * @since 0.71 4779 5163 * 4780 * @uses apply_filters() Calls 'get_lastpostdate' filter4781 *4782 5164 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. 4783 5165 * @return string The date of the last post. 4784 5166 */ 4785 5167 function 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 */ 4786 5177 return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone ); 4787 5178 } 4788 5179 … … 4794 5185 * 'gmt' is when the last post was modified in GMT time. 4795 5186 * 4796 5187 * @since 1.2.0 4797 * @uses apply_filters() Calls 'get_lastpostmodified' filter4798 5188 * 4799 5189 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. 4800 5190 * @return string The date the post was last modified. … … 4806 5196 if ( $lastpostdate > $lastpostmodified ) 4807 5197 $lastpostmodified = $lastpostdate; 4808 5198 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 */ 4809 5207 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 4810 5208 } 4811 5209 … … 4883 5281 * 4884 5282 * @since 2.0.0 4885 5283 * 4886 * @uses do_action() Calls 'clean_post_cache' on $id before adding children (if any).4887 *4888 5284 * @param int|WP_Post $post Post ID or post object to remove from the cache. 4889 5285 */ 4890 5286 function clean_post_cache( $post ) { … … 4904 5300 4905 5301 wp_cache_delete( 'wp_get_archives', 'general' ); 4906 5302 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 */ 4907 5311 do_action( 'clean_post_cache', $post->ID, $post ); 4908 5312 4909 5313 if ( is_post_type_hierarchical( $post->post_type ) ) … … 4911 5315 4912 5316 if ( 'page' == $post->post_type ) { 4913 5317 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 */ 4914 5326 do_action( 'clean_page_cache', $post->ID ); 4915 5327 } 4916 5328 … … 4992 5404 * 4993 5405 * @since 3.0.0 4994 5406 * 4995 * @uses do_action() Calls 'clean_attachment_cache' on $id.4996 *4997 5407 * @param int $id The attachment ID in the cache to clean 4998 5408 * @param bool $clean_terms optional. Whether to clean terms cache 4999 5409 */ … … 5011 5421 if ( $clean_terms ) 5012 5422 clean_object_term_cache($id, 'attachment'); 5013 5423 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 ); 5015 5432 } 5016 5433 5017 5434 // … … 5024 5441 * @since 2.3.0 5025 5442 * @access private 5026 5443 * @uses $wpdb 5027 * @uses do_action() Calls 'private_to_published' on post ID if this is a 'private_to_published' call.5028 5444 * @uses wp_clear_scheduled_hook() with 'publish_future_post' and post ID. 5029 5445 * 5030 5446 * @param string $new_status New post status … … 5038 5454 // Reset GUID if transitioning to publish and it is empty 5039 5455 if ( '' == get_the_guid($post->ID) ) 5040 5456 $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 */ 5041 5466 do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish 5042 5467 } 5043 5468 … … 5082 5507 * @since 2.3.0 5083 5508 * @access private 5084 5509 * @uses XMLRPC_REQUEST and WP_IMPORTING constants. 5085 * @uses do_action() Calls 'xmlrpc_publish_post' on post ID if XMLRPC_REQUEST is defined.5086 5510 * 5087 5511 * @param int $post_id The ID in the database table of the post being published 5088 5512 */ 5089 5513 function _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 } 5092 5524 5093 5525 if ( defined('WP_IMPORTING') ) 5094 5526 return;