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.
| Line | Code |
|---|---|
| 2428 | * @since 3.0.0. |
| 2429 | * |
| 2430 | * @param int $id A post or blog id. Default is 0, which means the current post or blog. |
| 2431 | * @param string $context Whether the id is a 'blog' id, 'post' id, or 'media' id. If 'post', the post_type of the post is consulted. If 'query', the current query is consulted to determine the id and context. Default is 'post'. |
| 2432 | * @param bool $allow_slugs Whether to allow post slugs in the shortlink. It is up to the plugin how and whether to honor this. |
| 2433 | * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled. |
| 2434 | */ |
| 2435 | function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { |
| 2436 | // Allow plugins to short-circuit this function. |
| 2437 | $shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs); |
| 2438 | if ( false !== $shortlink ) |
| 2439 | return $shortlink; |
| 2440 | |
| 2441 | global $wp_query; |
| 2442 | $post_id = 0; |
| 2443 | if ( 'query' == $context && is_singular() ) { |
| 2444 | $post_id = $wp_query->get_queried_object_id(); |
| 2445 | $post = get_post( $post_id ); |
| 2446 | } elseif ( 'post' == $context ) { |