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 |
---|---|
2352 |
|
2353 | if ( ! post_type_exists( $type ) ) |
2354 | return new stdClass; |
2355 |
|
2356 | $cache_key = _count_posts_cache_key( $type, $perm ); |
2357 |
|
2358 | $counts = wp_cache_get( $cache_key, 'counts' ); |
2359 | if ( false !== $counts ) { |
2360 | /** This filter is documented in wp-includes/post.php */ |
2361 | return apply_filters( 'wp_count_posts', $counts, $type, $perm ); |
2362 | } |
2363 |
|
2364 | $query = "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s"; |
2365 | if ( 'readable' == $perm && is_user_logged_in() ) { |
2366 | $post_type_object = get_post_type_object($type); |
2367 | if ( ! current_user_can( $post_type_object->cap->read_private_posts ) ) { |
2368 | $query .= $wpdb->prepare( " AND (post_status != 'private' OR ( post_author = %d AND post_status = 'private' ))", |
2369 | get_current_user_id() |
2370 | ); |
Line | Code |
2387 | * |
2388 | * @since 3.7.0 |
2389 | * |
2390 | * @param object $counts An object containing the current post_type's post |
2391 | * counts by status. |
2392 | * @param string $type Post type. |
2393 | * @param string $perm The permission to determine if the posts are 'readable' |
2394 | * by the current user. |
2395 | */ |
2396 | return apply_filters( 'wp_count_posts', $counts, $type, $perm ); |
2397 | } |
2398 |
|
2399 | /** |
2400 | * Count number of attachments for the mime type(s). |
2401 | * |
2402 | * If you set the optional mime_type parameter, then an array will still be |
2403 | * returned, but will only have the item you are looking for. It does not give |
2404 | * you the number of attachments that are children of a post. You can get that |
2405 | * by counting the number of children that post has. |