Ticket #25505: 25505-patch.diff
File 25505-patch.diff, 30.6 KB (added by , 11 years ago) |
---|
-
wp-includes/post.php
189 189 $file = $uploads['basedir'] . "/$file"; 190 190 if ( $unfiltered ) 191 191 return $file; 192 193 /** 194 * Filter the attachment file path. 195 * 196 * @since 2.1.0 197 * 198 * @param string $file The file path to be filtered. 199 * @param int $attachment_id The ID of the attachment. 200 */ 192 201 return apply_filters( 'get_attached_file', $file, $attachment_id ); 193 202 } 194 203 … … 209 218 if ( !get_post( $attachment_id ) ) 210 219 return false; 211 220 221 /** 222 * Filter the attachment file path before saving. 223 * 224 * @since 2.1.0 225 * 226 * @param string $file The file path to be filtered. 227 * @param int $attachment_id The ID of the attachment. 228 */ 212 229 $file = apply_filters( 'update_attached_file', $file, $attachment_id ); 213 230 if ( $file = _wp_relative_upload_path( $file ) ) 214 231 return update_post_meta( $attachment_id, '_wp_attached_file', $file ); … … 236 253 $new_path = ltrim( $new_path, '/' ); 237 254 } 238 255 256 /** 257 * Filter the attachment file path before saving. 258 * 259 * @since 2.9.0 260 * 261 * @param string $newpath The relative path fo the file. 262 * @param string $path The original absolute path to the file. 263 */ 239 264 return apply_filters( '_wp_relative_upload_path', $new_path, $path ); 240 265 } 241 266 … … 1331 1356 register_taxonomy_for_object_type( $taxonomy, $post_type ); 1332 1357 } 1333 1358 1359 /** 1360 * Fires actions to be run after a post type is registered. 1361 * 1362 * @since 3.3.0 1363 * 1364 * @param string $post_type The slug of the post type registered. 1365 * @param object $args The arguments for the post type registration. 1366 */ 1334 1367 do_action( 'registered_post_type', $post_type, $args ); 1335 1368 1336 1369 return $args; … … 1497 1530 $labels = _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults ); 1498 1531 1499 1532 $post_type = $post_type_object->name; 1533 1534 /** 1535 * Filter the labels for a specific post type. 1536 * 1537 * @since 3.5.0 1538 * 1539 * @param array $labels the labels for the custom post type. 1540 */ 1500 1541 return apply_filters( "post_type_labels_{$post_type}", $labels ); 1501 1542 } 1502 1543 … … 1981 2022 $format_to_edit = array('post_content', 'post_excerpt', 'post_title', 'post_password'); 1982 2023 1983 2024 if ( $prefixed ) { 1984 $value = apply_filters("edit_{$field}", $value, $post_id); 1985 // Old school 1986 $value = apply_filters("{$field_no_prefix}_edit_pre", $value, $post_id); 2025 /** 2026 * Filter and sanitize the value of the prefixed field (for editing). 2027 * 2028 * @since 2.3.0 2029 * 2030 * @param mixed $value The Post Object value to sanitize. 2031 * @param int $post_id The Post ID. 2032 */ 2033 $value = apply_filters( "edit_{$field}", $value, $post_id ); 2034 /** 2035 * Old school method... 2036 * @see edit_{$field} filter above. 2037 */ 2038 $value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id ); 1987 2039 } else { 1988 $value = apply_filters("edit_post_{$field}", $value, $post_id); 2040 /** 2041 * Non prefixed version... 2042 * @see edit_{$field} filter above. 2043 */ 2044 $value = apply_filters( "edit_post_{$field}", $value, $post_id ); 1989 2045 } 1990 2046 1991 2047 if ( in_array($field, $format_to_edit) ) { … … 1998 2054 } 1999 2055 } else if ( 'db' == $context ) { 2000 2056 if ( $prefixed ) { 2001 $value = apply_filters("pre_{$field}", $value); 2002 $value = apply_filters("{$field_no_prefix}_save_pre", $value); 2057 /** 2058 * Filter and sanitize the value of the prefixed field (for database use). 2059 * 2060 * @since 2.3.0 2061 * 2062 * @param mixed $value The Post Object value to sanitize. 2063 */ 2064 $value = apply_filters( "pre_{$field}", $value ); 2065 /** 2066 * Filter value after pre_{$field} is run. 2067 * 2068 * @since 2.3.0 2069 * 2070 * @param mixed $value The Post Object value to sanitize. 2071 */ 2072 $value = apply_filters( "{$field_no_prefix}_save_pre", $value ); 2003 2073 } else { 2004 $value = apply_filters("pre_post_{$field}", $value); 2005 $value = apply_filters("{$field}_pre", $value); 2074 /** 2075 * Non prefixed version... 2076 * @see pre_{$field} filter above 2077 */ 2078 $value = apply_filters( "pre_post_{$field}", $value ); 2079 /** 2080 * Filter value after pre_post_{$field} is run. 2081 * 2082 * @since 2.3.0 2083 * 2084 * @param mixed $value The Post Object value to sanitize. 2085 */ 2086 $value = apply_filters( "{$field}_pre", $value ); 2006 2087 } 2007 2088 } else { 2008 2089 // Use display filters by default. 2009 2090 if ( $prefixed ) 2010 $value = apply_filters($field, $value, $post_id, $context); 2091 /** 2092 * Filter and sanitize the value of the prefixed field (for other contexts). 2093 * 2094 * @since 2.3.0 2095 * 2096 * @param mixed $value The Post Object value to sanitize. 2097 * @param int $post_id The Post ID. 2098 * @param string $context The context to filter for. 2099 */ 2100 $value = apply_filters( $field, $value, $post_id, $context ); 2011 2101 else 2012 $value = apply_filters("post_{$field}", $value, $post_id, $context); 2102 /** 2103 * Non prefixed version... 2104 * @see {$field} filter directly above. 2105 */ 2106 $value = apply_filters( "post_{$field}", $value, $post_id, $context ); 2013 2107 } 2014 2108 2015 2109 if ( 'attribute' == $context ) … … 2181 2275 'video' => array(__('Video'), __('Manage Video'), _n_noop('Video <span class="count">(%s)</span>', 'Video <span class="count">(%s)</span>')), 2182 2276 ); 2183 2277 2184 return apply_filters('post_mime_types', $post_mime_types); 2278 /** 2279 * Filter the default post mime types. 2280 * 2281 * @since 2.5.0 2282 * 2283 * @param array $post_mime_types The array of post mime-types in slug=>labels format. 2284 */ 2285 return apply_filters( 'post_mime_types', $post_mime_types ); 2185 2286 } 2186 2287 2187 2288 /** … … 2299 2400 if ( $post->post_type == 'attachment' ) 2300 2401 return wp_delete_attachment( $postid, $force_delete ); 2301 2402 2302 do_action('before_delete_post', $postid); 2403 /** 2404 * Fire actions to be run before the post is prepped for deletion. 2405 * 2406 * @since 3.2.0 2407 * 2408 * @param int $postid The Post ID. 2409 */ 2410 do_action( 'before_delete_post', $postid ); 2303 2411 2304 2412 delete_post_meta($postid,'_wp_trash_meta_status'); 2305 2413 delete_post_meta($postid,'_wp_trash_meta_time'); … … 2334 2442 foreach ( $post_meta_ids as $mid ) 2335 2443 delete_metadata_by_mid( 'post', $mid ); 2336 2444 2445 /** 2446 * Fires actions to be run JUST before the actual post is deleted. 2447 * 2448 * @since 1.2.1 (possibly earlier) 2449 * 2450 * @param int $postid The Post ID. 2451 */ 2337 2452 do_action( 'delete_post', $postid ); 2453 2454 // Delete the post from the database 2338 2455 $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) ); 2456 2457 /** 2458 * Fires actions to be run JUST after the actual post is deleted. 2459 * 2460 * @since 2.2.0 2461 * 2462 * @param int $postid The Post ID. 2463 */ 2339 2464 do_action( 'deleted_post', $postid ); 2340 2465 2341 2466 clean_post_cache( $post ); … … 2347 2472 2348 2473 wp_clear_scheduled_hook('publish_future_post', array( $postid ) ); 2349 2474 2350 do_action('after_delete_post', $postid); 2475 /** 2476 * Fires actions to run after delete_post has completed. 2477 * 2478 * @since 3.2.0 2479 * 2480 * @param int $postid The Post ID. 2481 */ 2482 do_action( 'after_delete_post', $postid ); 2351 2483 2352 2484 return $post; 2353 2485 } … … 2403 2535 if ( $post['post_status'] == 'trash' ) 2404 2536 return false; 2405 2537 2406 do_action('wp_trash_post', $post_id); 2538 /** 2539 * Fires actions to be run before trashing a post. 2540 * 2541 * @since 3.3.0 2542 * 2543 * @param int $post_id The Post ID. 2544 */ 2545 do_action( 'wp_trash_post', $post_id ); 2407 2546 2408 2547 add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']); 2409 2548 add_post_meta($post_id,'_wp_trash_meta_time', time()); … … 2413 2552 2414 2553 wp_trash_post_comments($post_id); 2415 2554 2416 do_action('trashed_post', $post_id); 2555 /** 2556 * Fires actions to be run after trashing a post. 2557 * 2558 * @since 2.9.0 2559 * 2560 * @param int $post_id The Post ID. 2561 */ 2562 do_action( 'trashed_post', $post_id ); 2417 2563 2418 2564 return $post; 2419 2565 } … … 2435 2581 if ( $post['post_status'] != 'trash' ) 2436 2582 return false; 2437 2583 2438 do_action('untrash_post', $post_id); 2584 /** 2585 * Fires actions to be run before untrashing a post. 2586 * 2587 * @since 3.3.0 2588 * 2589 * @param int $post_id The Post ID. 2590 */ 2591 do_action( 'untrash_post', $post_id ); 2439 2592 2440 2593 $post_status = get_post_meta($post_id, '_wp_trash_meta_status', true); 2441 2594 … … 2448 2601 2449 2602 wp_untrash_post_comments($post_id); 2450 2603 2451 do_action('untrashed_post', $post_id); 2604 /** 2605 * Fires actions to be run after untrashing a post. 2606 * 2607 * @since 2.9.0 2608 * 2609 * @param int $post_id The Post ID. 2610 */ 2611 do_action( 'untrashed_post', $post_id ); 2452 2612 2453 2613 return $post; 2454 2614 } … … 2472 2632 2473 2633 $post_id = $post->ID; 2474 2634 2475 do_action('trash_post_comments', $post_id); 2635 /** 2636 * Fires actions to be run before trashing the post comments. 2637 * 2638 * @since 3.3.0 2639 * 2640 * @param int $post_id The Post ID. 2641 */ 2642 do_action( 'trash_post_comments', $post_id ); 2476 2643 2477 2644 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_ID, comment_approved FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id) ); 2478 2645 if ( empty($comments) ) … … 2489 2656 2490 2657 clean_comment_cache( array_keys($statuses) ); 2491 2658 2492 do_action('trashed_post_comments', $post_id, $statuses); 2659 /** 2660 * Fires actions to be run after trashing the post comments. 2661 * 2662 * @since 2.9.0 2663 * 2664 * @param int $post_id The Post ID. 2665 */ 2666 do_action( 'trashed_post_comments', $post_id, $statuses ); 2493 2667 2494 2668 return $result; 2495 2669 } … … 2518 2692 if ( empty($statuses) ) 2519 2693 return true; 2520 2694 2521 do_action('untrash_post_comments', $post_id); 2695 /** 2696 * Fires actions to be run before untrashing the post comments. 2697 * 2698 * @since 3.3.0 2699 * 2700 * @param int $post_id The Post ID. 2701 */ 2702 do_action( 'untrash_post_comments', $post_id ); 2522 2703 2523 2704 // Restore each comment to its original status 2524 2705 $group_by_status = array(); … … 2537 2718 2538 2719 delete_post_meta($post_id, '_wp_trash_meta_comments_status'); 2539 2720 2540 do_action('untrashed_post_comments', $post_id); 2721 /** 2722 * Fires actions to be run after untrashing the post comments. 2723 * 2724 * @since 2.9.0 2725 * 2726 * @param int $post_id The Post ID. 2727 */ 2728 do_action( 'untrashed_post_comments', $post_id ); 2541 2729 } 2542 2730 2543 2731 /** … … 2738 2926 $maybe_empty = ! $post_content && ! $post_title && ! $post_excerpt && post_type_supports( $post_type, 'editor' ) 2739 2927 && post_type_supports( $post_type, 'title' ) && post_type_supports( $post_type, 'excerpt' ); 2740 2928 2929 /** 2930 * Fitler to modify the $maybe_empty value. Use to force the value to true or false. 2931 * 2932 * @since 3.3.0 2933 * 2934 * @param bool $maybe_empty The current value saying if the post may be empty. 2935 * @param array $postarr The array of post data elements passed to this function. 2936 */ 2741 2937 if ( apply_filters( 'wp_insert_post_empty_content', $maybe_empty, $postarr ) ) { 2742 2938 if ( $wp_error ) 2743 2939 return new WP_Error( 'empty_content', __( 'Content, title, and excerpt are empty.' ) ); … … 2850 3046 $post_parent = 0; 2851 3047 2852 3048 // Check the post_parent to see if it will cause a hierarchy loop 3049 /** 3050 * Filter to test and make sure the post_parent won't cause a heirarchy loop. 3051 * 3052 * @since 3.1.0 3053 * 3054 * @param int $post_parent The intended post_parent value. 3055 * @param int $post_ID The ID of the post being inserted/updated. 3056 * @param array $postarr The modified post array pulling in the modified extracted variables. 3057 * @param array $postarr The original post array passed to the function. 3058 */ 2853 3059 $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr ); 2854 3060 2855 3061 if ( isset($menu_order) ) … … 2864 3070 2865 3071 // expected_slashed (everything!) 2866 3072 $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' ) ); 2867 $data = apply_filters('wp_insert_post_data', $data, $postarr); 3073 3074 /** 3075 * Filter the post data before insertion. 3076 * 3077 * @since 2.7.0 3078 * 3079 * @param array $data The modified post data array. 3080 * @param array $postarr The original post array passed to the function. 3081 */ 3082 $data = apply_filters( 'wp_insert_post_data', $data, $postarr ); 2868 3083 $data = wp_unslash( $data ); 2869 3084 $where = array( 'ID' => $post_ID ); 2870 3085 2871 3086 if ( $update ) { 3087 /** 3088 * Fire actions to be run before the post is updated. 3089 * 3090 * @since 2.5.0 3091 * 3092 * @param int $post_ID The Post ID. 3093 * @param array $data The post data array we're updating with. 3094 */ 2872 3095 do_action( 'pre_post_update', $post_ID, $data ); 2873 3096 if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) { 2874 3097 if ( $wp_error ) … … 2945 3168 wp_transition_post_status($data['post_status'], $previous_status, $post); 2946 3169 2947 3170 if ( $update ) { 2948 do_action('edit_post', $post_ID, $post); 3171 /** 3172 * Fire actions to be run after the post has been edited. 3173 * 3174 * @since 1.2.1 3175 * 3176 * @param int $post_ID The Post ID. 3177 * @param WP_Post $post The Post object (after being updated). 3178 */ 3179 do_action( 'edit_post', $post_ID, $post ); 3180 2949 3181 $post_after = get_post($post_ID); 2950 do_action( 'post_updated', $post_ID, $post_after, $post_before); 3182 3183 /** 3184 * Fire actions to be run after the post has been updated, 3185 * with comparision of the post before and after updating. 3186 * 3187 * @since 3.0.0 3188 * 3189 * @param int $post_ID The Post ID. 3190 * @param WP_Post $post_after The Post object (after being updated). 3191 * @param WP_Post $post_before The Post object (before being updated). 3192 */ 3193 do_action( 'post_updated', $post_ID, $post_after, $post_before ); 2951 3194 } 2952 3195 3196 /** 3197 * Fire actions to be run after updating a post of a specific type. 3198 * 3199 * @since 3.7.0 3200 * 3201 * @param int $post_ID The Post ID. 3202 * @param WP_Post $post The Post object (after being updated). 3203 * @param bool $update Wether or not this was an update vs. an insert. 3204 */ 2953 3205 do_action( "save_post_{$post->post_type}", $post_ID, $post, $update ); 3206 3207 /** 3208 * Fire actions to be run after updating a post. 3209 * 3210 * @since 1.5.2 3211 * 3212 * @param int $post_ID The Post ID. 3213 * @param WP_Post $post The Post object (after being updated). 3214 * @param bool $update Wether or not this was an update vs. an insert. 3215 */ 2954 3216 do_action( 'save_post', $post_ID, $post, $update ); 3217 3218 /** 3219 * Fire actions to be run after wp_insert_post is completed. 3220 * 3221 * @since 2.0 3222 * 3223 * @param int $post_ID The Post ID. 3224 * @param WP_Post $post The Post object (after being updated). 3225 * @param bool $update Wether or not this was an update vs. an insert. 3226 */ 2955 3227 do_action( 'wp_insert_post', $post_ID, $post, $update ); 2956 3228 2957 3229 return $post_ID; … … 3041 3313 $old_status = $post->post_status; 3042 3314 $post->post_status = 'publish'; 3043 3315 wp_transition_post_status( 'publish', $old_status, $post ); 3044 3316 3317 // Duplicate hook 3045 3318 do_action( 'edit_post', $post->ID, $post ); 3319 3320 // Duplicate hook 3046 3321 do_action( "save_post_{$post->post_type}", $post->ID, $post, true ); 3322 3323 // Duplicate hook 3047 3324 do_action( 'save_post', $post->ID, $post, true ); 3325 3326 // Duplicate hook 3048 3327 do_action( 'wp_insert_post', $post->ID, $post, true ); 3049 3328 } 3050 3329 … … 3112 3391 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1"; 3113 3392 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID ) ); 3114 3393 3115 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ) ) { 3394 /** 3395 * Filter to flag the post slug as a bad attachment slug. 3396 * 3397 * @since 3.1.0 3398 * 3399 * @param bool false The default value for the flag. 3400 * @param string $slug The slug to test with. 3401 */ 3402 $slug_is_bad = apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug ); 3403 3404 if ( $post_name_check || in_array( $slug, $feeds ) || $slug_is_bad ) { 3116 3405 $suffix = 2; 3117 3406 do { 3118 3407 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 3129 3418 $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"; 3130 3419 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) ); 3131 3420 3132 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 ) ) { 3421 /** 3422 * Filter to flag the post slug as a bad hierarchical slug. 3423 * 3424 * @since 3.1.0 3425 * 3426 * @param bool false The default value for the flag. 3427 * @param string $slug The slug to test with. 3428 * @param string $post_type The post's type. 3429 * @param int $post_parent The ID of the post's parent. 3430 */ 3431 $slug_is_bad = apply_filters( 'wp_unique_post_slug_is_bad_hierarchical_slug', false, $slug, $post_type, $post_parent ); 3432 3433 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) || $slug_is_bad ) { 3133 3434 $suffix = 2; 3134 3435 do { 3135 3436 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 3143 3444 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d LIMIT 1"; 3144 3445 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID ) ); 3145 3446 3146 if ( $post_name_check || in_array( $slug, $feeds ) || apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ) ) { 3447 /** 3448 * Filter to flag the post slug as a bad flat slug. 3449 * 3450 * @since 3.1.0 3451 * 3452 * @param bool false The default value for the flag. 3453 * @param string $slug The slug to test with. 3454 * @param string $post_type The post's type. 3455 */ 3456 $slug_is_bad = apply_filters( 'wp_unique_post_slug_is_bad_flat_slug', false, $slug, $post_type ); 3457 3458 if ( $post_name_check || in_array( $slug, $feeds ) || $slug_is_bad ) { 3147 3459 $suffix = 2; 3148 3460 do { 3149 3461 $alt_post_name = _truncate_post_slug( $slug, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix"; … … 3154 3466 } 3155 3467 } 3156 3468 3469 /** 3470 * Filter the unique slug for the post. 3471 * 3472 * @since 3.3.0 3473 * 3474 * @param string $slug The unique slug to filter. 3475 * @param int $post_ID The Post ID. 3476 * @param string $post_status The Post status. 3477 * @param string $post_type The Post type. 3478 * @param int $post_parent The Post parent. 3479 * @param string $slug The original slug passed. 3480 */ 3157 3481 return apply_filters( 'wp_unique_post_slug', $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ); 3158 3482 } 3159 3483 … … 3335 3659 $pung = preg_split('/\s/', $pung); 3336 3660 $pung[] = $uri; 3337 3661 $new = implode("\n", $pung); 3338 $new = apply_filters('add_ping', $new); 3662 3663 /** 3664 * Filter the array of "pung" URLs to update with. 3665 * 3666 * @since 2.0.0 3667 * 3668 * @param array $new The updated array of URLs. 3669 */ 3670 $new = apply_filters( 'add_ping', $new ); 3671 3339 3672 // expected_slashed ($new) 3340 3673 $new = wp_unslash($new); 3341 3674 return $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post_id ) ); … … 3363 3696 $pung[] = trim( $enclosure[ 0 ] ); 3364 3697 } 3365 3698 } 3366 $pung = apply_filters('get_enclosed', $pung, $post_id); 3699 3700 /** 3701 * Filter the array of enclosures. 3702 * 3703 * @since 2.0.0 3704 * 3705 * @param array $pung The list of enclosures. 3706 * @param int $post_id The Post ID. 3707 */ 3708 $pung = apply_filters( 'get_enclosed', $pung, $post_id ); 3367 3709 return $pung; 3368 3710 } 3369 3711 … … 3381 3723 $pung = $wpdb->get_var( $wpdb->prepare( "SELECT pinged FROM $wpdb->posts WHERE ID = %d", $post_id )); 3382 3724 $pung = trim($pung); 3383 3725 $pung = preg_split('/\s/', $pung); 3384 $pung = apply_filters('get_pung', $pung); 3726 3727 /** 3728 * Filter the array of "pung" URLs to return. 3729 * 3730 * @since 2.0.0 3731 * 3732 * @param array $new The updated array of URLs. 3733 */ 3734 $pung = apply_filters( 'get_pung', $pung ); 3385 3735 return $pung; 3386 3736 } 3387 3737 … … 3399 3749 $to_ping = $wpdb->get_var( $wpdb->prepare( "SELECT to_ping FROM $wpdb->posts WHERE ID = %d", $post_id )); 3400 3750 $to_ping = sanitize_trackback_urls( $to_ping ); 3401 3751 $to_ping = preg_split('/\s/', $to_ping, -1, PREG_SPLIT_NO_EMPTY); 3402 $to_ping = apply_filters('get_to_ping', $to_ping); 3752 3753 /** 3754 * Filter the list of URLs to be pinged. 3755 * 3756 * @since 2.0.0 3757 * 3758 * @param array $to_ping The list of URLs to ping. 3759 */ 3760 $to_ping = apply_filters( 'get_to_ping', $to_ping ); 3403 3761 return $to_ping; 3404 3762 } 3405 3763 … … 3727 4085 if ( $cache = wp_cache_get( $cache_key, 'posts' ) ) { 3728 4086 // Convert to WP_Post instances 3729 4087 $pages = array_map( 'get_post', $cache ); 3730 $pages = apply_filters('get_pages', $pages, $r); 4088 4089 /** 4090 * Filter the list of pages being fetched. 4091 * 4092 * @since 2.1.0 4093 * 4094 * @param array $pages The array of pages being fetched. 4095 * @param array $r The parsed arguments passed to this function. 4096 */ 4097 $pages = apply_filters( 'get_pages', $pages, $r ); 3731 4098 return $pages; 3732 4099 } 3733 4100 … … 3857 4224 $pages = $wpdb->get_results($query); 3858 4225 3859 4226 if ( empty($pages) ) { 3860 $pages = apply_filters('get_pages', array(), $r); 4227 // Duplicate hook 4228 $pages = apply_filters( 'get_pages', array(), $r ); 3861 4229 return $pages; 3862 4230 } 3863 4231 … … 3896 4264 // Convert to WP_Post instances 3897 4265 $pages = array_map( 'get_post', $pages ); 3898 4266 3899 $pages = apply_filters('get_pages', $pages, $r); 4267 // Duplicate hook 4268 $pages = apply_filters( 'get_pages', $pages, $r ); 3900 4269 3901 4270 return $pages; 3902 4271 } … … 4111 4480 add_post_meta( $post_ID, '_wp_attachment_context', $context, true ); 4112 4481 4113 4482 if ( $update) { 4114 do_action('edit_attachment', $post_ID); 4483 /** 4484 * Fires actions to run after an attachment has been edited. 4485 * 4486 * @since 2.0.0 4487 * 4488 * @param int $post_ID The Post ID. 4489 */ 4490 do_action( 'edit_attachment', $post_ID ); 4115 4491 } else { 4116 do_action('add_attachment', $post_ID); 4492 /** 4493 * Fires actions to run after an attachment has been added. 4494 * 4495 * @since 2.0.0 4496 * 4497 * @param int $post_ID The Post ID. 4498 */ 4499 do_action( 'add_attachment', $post_ID ); 4117 4500 } 4118 4501 4119 4502 return $post_ID; … … 4165 4548 if ( is_multisite() ) 4166 4549 delete_transient( 'dirsize_cache' ); 4167 4550 4168 do_action('delete_attachment', $post_id); 4551 /** 4552 * Fires actions to be run before preperation for attachment deletion. 4553 * 4554 * @since 2.0.0 4555 * 4556 * @param int $post_id The attachment id. 4557 */ 4558 do_action( 'delete_attachment', $post_id ); 4169 4559 4170 4560 wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); 4171 4561 wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type)); … … 4180 4570 foreach ( $post_meta_ids as $mid ) 4181 4571 delete_metadata_by_mid( 'post', $mid ); 4182 4572 4573 // Duplicate hook 4183 4574 do_action( 'delete_post', $post_id ); 4575 4184 4576 $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) ); 4577 4578 // Duplicate hook 4185 4579 do_action( 'deleted_post', $post_id ); 4186 4580 4187 4581 $uploadpath = wp_upload_dir(); … … 4190 4584 // Don't delete the thumb if another attachment uses it 4191 4585 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)) ) { 4192 4586 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 4193 $thumbfile = apply_filters('wp_delete_file', $thumbfile); 4587 4588 /** 4589 * Filter the path of file to delete. 4590 * 4591 * @since 2.1.0 4592 * 4593 * @param string $thumbfile The name of the thumbnail file. 4594 */ 4595 $thumbfile = apply_filters( 'wp_delete_file', $thumbfile ); 4596 4194 4597 @ unlink( path_join($uploadpath['basedir'], $thumbfile) ); 4195 4598 } 4196 4599 } 4197 4600 4198 4601 // remove intermediate and backup images if there are any 4199 4602 foreach ( $intermediate_sizes as $intermediate ) { 4603 // Duplicate hook 4200 4604 $intermediate_file = apply_filters( 'wp_delete_file', $intermediate['path'] ); 4201 4605 @ unlink( path_join($uploadpath['basedir'], $intermediate_file) ); 4202 4606 } … … 4204 4608 if ( is_array($backup_sizes) ) { 4205 4609 foreach ( $backup_sizes as $size ) { 4206 4610 $del_file = path_join( dirname($meta['file']), $size['file'] ); 4207 $del_file = apply_filters('wp_delete_file', $del_file); 4611 // Duplicate hook 4612 $del_file = apply_filters( 'wp_delete_file', $del_file ); 4208 4613 @ unlink( path_join($uploadpath['basedir'], $del_file) ); 4209 4614 } 4210 4615 } 4211 4616 4212 $file = apply_filters('wp_delete_file', $file); 4617 // Duplicate hook 4618 $file = apply_filters( 'wp_delete_file', $file ); 4213 4619 4214 4620 if ( ! empty($file) ) 4215 4621 @ unlink($file); … … 4237 4643 4238 4644 if ( $unfiltered ) 4239 4645 return $data; 4240 4646 4647 /** 4648 * Filter the attachment metadata. 4649 * 4650 * @since 2.1.0 4651 * 4652 * @param array $data The attachment metadata array. 4653 * @param int $post->ID The Post ID. 4654 */ 4241 4655 return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID ); 4242 4656 } 4243 4657 … … 4255 4669 if ( !$post = get_post( $post_id ) ) 4256 4670 return false; 4257 4671 4672 // Duplicate hook 4258 4673 if ( $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ) ) 4259 4674 return update_post_meta( $post->ID, '_wp_attachment_metadata', $data ); 4260 4675 else … … 4292 4707 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. 4293 4708 $url = get_the_guid( $post->ID ); 4294 4709 4710 /** 4711 * Filter the attachment's URL. 4712 * 4713 * @since 2.1.0 4714 * 4715 * @param string $url The attachment URL. 4716 * @param int $post->ID The Post ID. 4717 */ 4295 4718 $url = apply_filters( 'wp_get_attachment_url', $url, $post->ID ); 4296 4719 4297 4720 if ( empty( $url ) ) … … 4318 4741 $file = get_attached_file( $post->ID ); 4319 4742 4320 4743 if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) ) 4744 /** 4745 * Filter the path to the thumbnail file. 4746 * 4747 * @since 2.1.0 4748 * 4749 * @param string $thumbfile The path to the thumbnail file. 4750 * @param int $post->ID The Post ID. 4751 */ 4321 4752 return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID ); 4753 4322 4754 return false; 4323 4755 } 4324 4756 … … 4346 4778 4347 4779 $url = str_replace(basename($url), basename($thumb), $url); 4348 4780 4781 /** 4782 * Filter the URL of the thumbnail file. 4783 * 4784 * @since 2.1.0 4785 * 4786 * @param string $url The URL of the thumbnail. 4787 * @param int $post->ID The Post ID. 4788 */ 4349 4789 return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID ); 4350 4790 } 4351 4791 … … 4410 4850 $icon_files = wp_cache_get('icon_files'); 4411 4851 4412 4852 if ( !is_array($icon_files) ) { 4853 /** 4854 * Filter the path to the icons directory. 4855 * 4856 * @since 2.0.0 4857 * 4858 * @param string The absolute path to the icon directory. 4859 */ 4413 4860 $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' ); 4861 4862 /** 4863 * Filter the URI to the icons directory. 4864 * 4865 * @since 2.0 4866 * 4867 * @param string The URI to the icon directory. 4868 */ 4414 4869 $icon_dir_uri = apply_filters( 'icon_dir_uri', includes_url('images/crystal') ); 4870 4871 /** 4872 * Filter the icon directories array. 4873 * 4874 * @since 2.5.0 4875 * 4876 * @param array The icon directories array. 4877 */ 4415 4878 $dirs = apply_filters( 'icon_dirs', array($icon_dir => $icon_dir_uri) ); 4879 4416 4880 $icon_files = array(); 4417 4881 while ( $dirs ) { 4418 4882 $keys = array_keys( $dirs ); … … 4459 4923 } 4460 4924 } 4461 4925 4926 /** 4927 * Filter the icon mime type. 4928 * 4929 * @since 2.1.0 4930 * 4931 * @param string $icon The path to the icon image. 4932 * @param string $mime The mime type the icon represents. 4933 * @param int $post_id The Post ID. 4934 */ 4462 4935 return apply_filters( 'wp_mime_type_icon', $icon, $mime, $post_id ); // Last arg is 0 if function pass mime type. 4463 4936 } 4464 4937 … … 4539 5012 if ( ! $post_type_obj ) 4540 5013 return $full ? 'WHERE 1 = 0' : ' 1 = 0 '; 4541 5014 4542 // This hook is deprecated. Why you'd want to use it, I dunno. 5015 /** 5016 * Filter for creating the read_private_posts capability. 5017 * 5018 * @deprecated 5019 * 5020 * @since 2.2.0 5021 * 5022 * @param string '' An empty string. 5023 */ 4543 5024 if ( ! $cap = apply_filters( 'pub_priv_sql_capability', '' ) ) 4544 5025 $cap = $post_type_obj->cap->read_private_posts; 4545 5026 … … 4591 5072 * @return string The date of the last post. 4592 5073 */ 4593 5074 function get_lastpostdate($timezone = 'server') { 4594 return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone ); 5075 $date = _get_last_post_time( $timezone, 'date' ); 5076 5077 /** 5078 * Filters the last post date. 5079 * 5080 * @since 2.3.0 5081 * 5082 * @param string $date The date field of the timestamp. 5083 * @param string $timezone The location used to get the time. 5084 */ 5085 return apply_filters( 'get_lastpostdate', $date, $timezone ); 4595 5086 } 4596 5087 4597 5088 /** … … 4613 5104 $lastpostdate = get_lastpostdate($timezone); 4614 5105 if ( $lastpostdate > $lastpostmodified ) 4615 5106 $lastpostmodified = $lastpostdate; 4616 5107 5108 /** 5109 * Filters the last post modified dated. 5110 * 5111 * @since 2.3.0 5112 * 5113 * @param string $lastpostmodified The modified field of the timestamp. 5114 * @param string $timezone The location used to get the time. 5115 */ 4617 5116 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 4618 5117 } 4619 5118 … … 4716 5215 4717 5216 wp_cache_delete( 'wp_get_archives', 'general' ); 4718 5217 5218 /** 5219 * Fires actions to be run once the post cache has been cleaned. 5220 * 5221 * @since 2.5.0 5222 * 5223 * @param int $post->ID The Post ID. 5224 * @param WP_Post The Post object. 5225 */ 4719 5226 do_action( 'clean_post_cache', $post->ID, $post ); 4720 5227 4721 5228 if ( is_post_type_hierarchical( $post->post_type ) ) … … 4723 5230 4724 5231 if ( 'page' == $post->post_type ) { 4725 5232 wp_cache_delete( 'all_page_ids', 'posts' ); 5233 5234 /** 5235 * Fires actions to be run once the page cache has been cleaned. 5236 * 5237 * @since 2.5.0 5238 * 5239 * @param int $post->ID The Post ID. 5240 */ 4726 5241 do_action( 'clean_page_cache', $post->ID ); 4727 5242 } 4728 5243 … … 4829 5344 if ( $clean_terms ) 4830 5345 clean_object_term_cache($id, 'attachment'); 4831 5346 4832 do_action('clean_attachment_cache', $id); 5347 /** 5348 * Fires actions to run once the attachment cache has been cleaned. 5349 * 5350 * @since 3.0.0 5351 * 5352 * @param int $id The attachment ID. 5353 */ 5354 do_action( 'clean_attachment_cache', $id ); 4833 5355 } 4834 5356 4835 5357 // … … 4856 5378 // Reset GUID if transitioning to publish and it is empty 4857 5379 if ( '' == get_the_guid($post->ID) ) 4858 5380 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); 5381 5382 /** 5383 * Fires actions to run once the post status has been changed 5384 * from private to published 5385 * 5386 * @deprecated Use 'private_to_publish' instead. 5387 * 5388 * @since 1.5.2 5389 * 5390 * @param int $post->ID The Post ID. 5391 */ 4859 5392 do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish 4860 5393 } 4861 5394 … … 4901 5434 */ 4902 5435 function _publish_post_hook($post_id) { 4903 5436 if ( defined('XMLRPC_REQUEST') ) 5437 /** 5438 * Fires actions to be run before scheduling, 5439 * provided XMLRPC_REQUEST is defined. 5440 * 5441 * @since 2.1.0 5442 * 5443 * @param int $post_id The Post ID. 5444 */ 4904 5445 do_action('xmlrpc_publish_post', $post_id); 4905 5446 4906 5447 if ( defined('WP_IMPORTING') ) … … 4908 5449 4909 5450 if ( get_option('default_pingback_flag') ) 4910 5451 add_post_meta( $post_id, '_pingme', '1' ); 5452 4911 5453 add_post_meta( $post_id, '_encloseme', '1' ); 4912 5454 4913 5455 wp_schedule_single_event(time(), 'do_pings');