| 41 | | } |
|---|
| 42 | | |
|---|
| 43 | | function get_tag_link( $tag_id ) { |
|---|
| 44 | | global $wp_rewrite; |
|---|
| 45 | | $catlink = $wp_rewrite->get_tag_permastruct(); |
|---|
| 46 | | |
|---|
| 47 | | $category = &get_category($tag_id); |
|---|
| 48 | | $category_nicename = $category->category_nicename; |
|---|
| 49 | | |
|---|
| 50 | | if ( empty($catlink) ) { |
|---|
| 51 | | $file = get_option('home') . '/'; |
|---|
| 52 | | $catlink = $file . '?tag=' . $category_nicename; |
|---|
| 53 | | } else { |
|---|
| 54 | | |
|---|
| 55 | | $catlink = str_replace('%tag%', $category_nicename, $catlink); |
|---|
| 56 | | $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); |
|---|
| 57 | | } |
|---|
| 58 | | return apply_filters('tag_link', $catlink, $tag_id); |
|---|
| 181 | | function get_the_tags( $before, $sep, $after ) { |
|---|
| 182 | | global $post; |
|---|
| 183 | | if ( !$post ) |
|---|
| 184 | | return false; // in-the-loop function |
|---|
| 185 | | |
|---|
| 186 | | $tags = wp_get_post_tags( $post->ID ); |
|---|
| 187 | | if ( empty( $tags ) ) |
|---|
| 188 | | return false; |
|---|
| 189 | | |
|---|
| 190 | | $return = $before; |
|---|
| 191 | | foreach ( $tags as $tag ) |
|---|
| 192 | | $tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>'; |
|---|
| 193 | | |
|---|
| 194 | | $tag_links = join( $sep, $tag_links ); |
|---|
| 195 | | $tag_links = apply_filters( 'the_tags', $tag_links ); |
|---|
| 196 | | $return .= $tag_links; |
|---|
| 197 | | |
|---|
| 198 | | $return .= $after; |
|---|
| 199 | | return $return; |
|---|
| 200 | | } |
|---|
| 201 | | |
|---|
| 202 | | function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { |
|---|
| 203 | | echo get_the_tags( $before, $sep, $after ); |
|---|
| 204 | | } |
|---|
| 205 | | |
|---|
| | 369 | // |
|---|
| | 370 | // Tags |
|---|
| | 371 | // |
|---|
| | 372 | |
|---|
| | 373 | function get_tag_link( $tag_id ) { |
|---|
| | 374 | global $wp_rewrite; |
|---|
| | 375 | $catlink = $wp_rewrite->get_tag_permastruct(); |
|---|
| | 376 | |
|---|
| | 377 | $category = &get_category($tag_id); |
|---|
| | 378 | $category_nicename = $category->category_nicename; |
|---|
| | 379 | |
|---|
| | 380 | if ( empty($catlink) ) { |
|---|
| | 381 | $file = get_option('home') . '/'; |
|---|
| | 382 | $catlink = $file . '?tag=' . $category_nicename; |
|---|
| | 383 | } else { |
|---|
| | 384 | |
|---|
| | 385 | $catlink = str_replace('%tag%', $category_nicename, $catlink); |
|---|
| | 386 | $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); |
|---|
| | 387 | } |
|---|
| | 388 | return apply_filters('tag_link', $catlink, $tag_id); |
|---|
| | 389 | } |
|---|
| | 390 | |
|---|
| | 391 | function get_the_tags( $id = 0 ) { |
|---|
| | 392 | global $post; |
|---|
| | 393 | |
|---|
| | 394 | $id = (int) $id; |
|---|
| | 395 | |
|---|
| | 396 | if ( ! $id && ! in_the_loop() ) |
|---|
| | 397 | return false; // in-the-loop function |
|---|
| | 398 | |
|---|
| | 399 | if ( !$id ) |
|---|
| | 400 | $id = (int) $post->ID; |
|---|
| | 401 | |
|---|
| | 402 | $tags = wp_get_post_tags( $id ); |
|---|
| | 403 | $tags = apply_filters( 'get_the_tags', $tags ); |
|---|
| | 404 | if ( empty( $tags ) ) |
|---|
| | 405 | return false; |
|---|
| | 406 | return $tags; |
|---|
| | 407 | } |
|---|
| | 408 | |
|---|
| | 409 | function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { |
|---|
| | 410 | $tags = get_the_tags(); |
|---|
| | 411 | |
|---|
| | 412 | if ( empty( $tags ) ) |
|---|
| | 413 | return false; |
|---|
| | 414 | |
|---|
| | 415 | $tag_list = $before; |
|---|
| | 416 | foreach ( $tags as $tag ) |
|---|
| | 417 | $tag_links[] = '<a href="' . get_tag_link($tag->cat_ID) . '">' . $tag->cat_name . '</a>'; |
|---|
| | 418 | |
|---|
| | 419 | $tag_links = join( $sep, $tag_links ); |
|---|
| | 420 | $tag_links = apply_filters( 'the_tags', $tag_links ); |
|---|
| | 421 | $tag_list .= $tag_links; |
|---|
| | 422 | |
|---|
| | 423 | $tag_list .= $after; |
|---|
| | 424 | |
|---|
| | 425 | echo $tag_list; |
|---|
| | 426 | } |
|---|
| | 427 | |
|---|