WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 3017 | if ( false !== $counts ) { |
| 3018 | // We may have cached this before every status was registered. |
| 3019 | foreach ( get_post_stati() as $status ) { |
| 3020 | if ( ! isset( $counts->{$status} ) ) { |
| 3021 | $counts->{$status} = 0; |
| 3022 | } |
| 3023 | } |
| 3024 | |
| 3025 | /** This filter is documented in wp-includes/post.php */ |
| 3026 | return apply_filters( 'wp_count_posts', $counts, $type, $perm ); |
| 3027 | } |
| 3028 | |
| 3029 | $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; |
| 3030 | |
| 3031 | if ( 'readable' === $perm && is_user_logged_in() ) { |
| 3032 | $post_type_object = get_post_type_object( $type ); |
| 3033 | if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) { |
| 3034 | $query .= $wpdb->prepare( |
| 3035 | " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", |
| Line | Code |
| 3055 | * |
| 3056 | * @since 3.7.0 |
| 3057 | * |
| 3058 | * @param stdClass $counts An object containing the current post_type's post |
| 3059 | * counts by status. |
| 3060 | * @param string $type Post type. |
| 3061 | * @param string $perm The permission to determine if the posts are 'readable' |
| 3062 | * by the current user. |
| 3063 | */ |
| 3064 | return apply_filters( 'wp_count_posts', $counts, $type, $perm ); |
| 3065 | } |
| 3066 | |
| 3067 | /** |
| 3068 | * Count number of attachments for the mime type(s). |
| 3069 | * |
| 3070 | * If you set the optional mime_type parameter, then an array will still be |
| 3071 | * returned, but will only have the item you are looking for. It does not give |
| 3072 | * you the number of attachments that are children of a post. You can get that |
| 3073 | * by counting the number of children that post has. |