Ticket #27716: 27716.patch
File 27716.patch, 31.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/link-template.php
10 10 * Display the permalink for the current post. 11 11 * 12 12 * @since 1.2.0 13 * @uses apply_filters() Calls 'the_permalink' filter on the permalink string.14 13 */ 15 14 function the_permalink() { 16 echo esc_url( apply_filters( 'the_permalink', get_permalink() ) ); 15 $permalink = get_permalink(); 16 /** 17 * Filter the display of the permalink for the current post. 18 * 19 * @since 1.5.0 20 * 21 * @param string $permalink The permalink for the current post. 22 */ 23 echo esc_url( apply_filters( 'the_permalink', $permalink ) ); 17 24 } 18 25 19 26 /** … … 38 45 else 39 46 $string = untrailingslashit($string); 40 47 41 // Note that $type_of_url can be one of following: 42 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged, post_type_archive 48 /** 49 * Filter a URL which has had user trailing slashing applied to it. 50 * 51 * @since 2.2.0 52 * 53 * @param string $string URL with or without a trailing slash. 54 * @param string $type_of_url The type of URL being considered. Accepts 'single', 'single_trackback', 55 * 'single_feed', 'single_paged', 'feed', 'category', 'page', 'year', 56 * 'month', 'day', 'paged', 'post_type_archive'. 57 */ 43 58 $string = apply_filters('user_trailingslashit', $string, $type_of_url); 44 59 return $string; 45 60 } … … 129 144 130 145 $permalink = get_option('permalink_structure'); 131 146 147 /** 148 * Filter the permalink structure for a post before token replacement occurs. 149 * Only applies to posts with post_type of 'post'. 150 * 151 * @since 3.0.0 152 * 153 * @param string $permalink The site's permalink structure. 154 * @param WP_Post $post The post in question. 155 * @param bool $leavename Whether to keep the post name. 156 */ 132 157 $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); 133 158 134 159 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { … … 139 164 $cats = get_the_category($post->ID); 140 165 if ( $cats ) { 141 166 usort($cats, '_usort_terms_by_ID'); // order by ID 167 /** 168 * Filter the category that gets used in the %category% token of the permalink for a post. 169 * 170 * @since 3.5.0 171 * 172 * @param stdClass $cat The category to use in the permalink. 173 * @param array $cats Array of all categories associated with the post. 174 * @param WP_Post $post The post in question. 175 */ 142 176 $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); 143 177 $category_object = get_term( $category_object, 'category' ); 144 178 $category = $category_object->slug; … … 179 213 } else { // if they're not using the fancy permalink option 180 214 $permalink = home_url('?p=' . $post->ID); 181 215 } 216 /** 217 * Filter the permalink for a post. 218 * Only applies to posts with post_type of 'post'. 219 * 220 * @since 3.0.0 221 * 222 * @param string $permalink The post's permalink. 223 * @param WP_Post $post The post in question. 224 * @param bool $leavename Whether to keep the post name. 225 */ 182 226 return apply_filters('post_link', $permalink, $post, $leavename); 183 227 } 184 228 … … 223 267 $post_link = home_url($post_link); 224 268 } 225 269 270 /** 271 * Filter the permalink for a post with a custom post type. 272 * 273 * @since 3.0.0 274 * 275 * @param string $post_link The post's permalink. 276 * @param WP_Post $post The post in question. 277 * @param bool $leavename Whether to keep the post name. 278 * @param bool $sample Is it a sample permalink. 279 */ 226 280 return apply_filters('post_type_link', $post_link, $post, $leavename, $sample); 227 281 } 228 282 … … 262 316 else 263 317 $link = _get_page_link( $post, $leavename, $sample ); 264 318 319 /** 320 * Filter the permalink for a page. 321 * 322 * @since 2.1.0 323 * 324 * @param string $link The page's permalink. 325 * @param int $post_id The ID of the page. 326 * @param bool $sample Is it a sample permalink. 327 */ 265 328 return apply_filters( 'page_link', $link, $post->ID, $sample ); 266 329 } 267 330 … … 298 361 $link = home_url( '?page_id=' . $post->ID ); 299 362 } 300 363 364 /** 365 * Filter the permalink for a page. Does not get called for the page set to page_on_front. 366 * 367 * @since 1.5.0 368 * 369 * @param string $link The page's permalink. 370 * @param int $post_id The ID of the page. 371 */ 301 372 return apply_filters( '_get_page_link', $link, $post->ID ); 302 373 } 303 374 … … 341 412 if ( ! $link ) 342 413 $link = home_url( '/?attachment_id=' . $post->ID ); 343 414 415 /** 416 * Filter the permalink for an attachment. 417 * 418 * @since 2.1.0 419 * 420 * @param string $link The attachment's permalink. 421 * @param int $post_id The ID of the attachment. 422 */ 344 423 return apply_filters( 'attachment_link', $link, $post->ID ); 345 424 } 346 425 … … 359 438 $yearlink = $wp_rewrite->get_year_permastruct(); 360 439 if ( !empty($yearlink) ) { 361 440 $yearlink = str_replace('%year%', $year, $yearlink); 362 return apply_filters('year_link', home_url( user_trailingslashit($yearlink, 'year') ), $year);441 $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); 363 442 } else { 364 return apply_filters('year_link', home_url('?m=' . $year), $year);443 $yearlink = home_url( '?m=' . $year ); 365 444 } 445 /** 446 * Filter the permalink for a year archive. 447 * 448 * @since 1.5.0 449 * 450 * @param string $yearlink The permalink for the year archive. 451 * @param int $year The year for the archive. 452 */ 453 return apply_filters( 'year_link', $yearlink, $year ); 366 454 } 367 455 368 456 /** … … 384 472 if ( !empty($monthlink) ) { 385 473 $monthlink = str_replace('%year%', $year, $monthlink); 386 474 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 387 return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);475 $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); 388 476 } else { 389 return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);477 $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); 390 478 } 479 /** 480 * Filter the permalink for a month archive. 481 * 482 * @since 1.5.0 483 * 484 * @param string $monthlink The permalink for the month archive. 485 * @param int $year The year for the archive. 486 * @param int $month The month for the archive. 487 */ 488 return apply_filters( 'month_link', $monthlink, $year, $month ); 391 489 } 392 490 393 491 /** … … 414 512 $daylink = str_replace('%year%', $year, $daylink); 415 513 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 416 514 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 417 return apply_filters('day_link', home_url( user_trailingslashit($daylink, 'day') ), $year, $month, $day);515 $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); 418 516 } else { 419 return apply_filters('day_link', home_url( '?m=' . $year . zeroise($month, 2) . zeroise($day, 2) ), $year, $month, $day);517 $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); 420 518 } 519 /** 520 * Filter the permalink for a day archive. 521 * 522 * @since 1.5.0 523 * 524 * @param string $daylink The permalink for the day archive. 525 * @param int $year The year for the archive. 526 * @param int $month The month for the archive. 527 * @param int $day The day for the archive. 528 */ 529 return apply_filters( 'day_link', $daylink, $year, $month, $day ); 530 421 531 } 422 532 423 533 /** … … 430 540 */ 431 541 function the_feed_link( $anchor, $feed = '' ) { 432 542 $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; 543 /** 544 * Filter the anchor tag for a feed link. 545 * 546 * @since 3.0.0 547 * 548 * @param string $link The complete anchor tag for a feed link. 549 * @param string $feed The feed type, or an empty string for the default feed type. 550 */ 433 551 echo apply_filters( 'the_feed_link', $link, $feed ); 434 552 } 435 553 … … 467 585 $output = home_url("?feed={$feed}"); 468 586 } 469 587 588 /** 589 * Filter the permalink for a feed type. 590 * 591 * @since 1.5.0 592 * 593 * @param string $output The feed permalink. 594 * @param string $feed The feed type. 595 */ 470 596 return apply_filters('feed_link', $output, $feed); 471 597 } 472 598 … … 506 632 $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); 507 633 } 508 634 635 /** 636 * Filter the permalink for the post comments feed. 637 * 638 * @since 2.2.0 639 * 640 * @param string $url The post comments feed permalink. 641 */ 509 642 return apply_filters('post_comments_feed_link', $url); 510 643 } 511 644 … … 528 661 if ( empty($link_text) ) 529 662 $link_text = __('Comments Feed'); 530 663 664 /** 665 * Filter the anchor tag for the comment feed link for a post. 666 * 667 * @since 2.8.0 668 * 669 * @param string $link The complete anchor tag for the comment feed link. 670 * @param int $post_id The post ID. 671 * @param string $feed The feed type, or an empty string for the default feed type. 672 */ 531 673 echo apply_filters( 'post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed ); 532 674 } 533 675 … … 562 704 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 563 705 } 564 706 707 /** 708 * Filter the feed link for a given author. 709 * 710 * @since 2.8.0 711 * 712 * @param string $link The author feed link. 713 * @param string $feed The feed type. 714 */ 565 715 $link = apply_filters('author_feed_link', $link, $feed); 566 716 567 717 return $link; … … 629 779 $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); 630 780 } 631 781 632 if ( 'category' == $taxonomy ) 782 if ( 'category' == $taxonomy ) { 783 /** 784 * Filter the feed link for a category. 785 * 786 * @since 2.8.0 787 * 788 * @param string $link The category feed link. 789 * @param string $feed The feed type. 790 */ 633 791 $link = apply_filters( 'category_feed_link', $link, $feed ); 634 elseif ( 'post_tag' == $taxonomy ) 792 } elseif ( 'post_tag' == $taxonomy ) { 793 /** 794 * Filter the feed link for a post tag. 795 * 796 * @since 2.8.0 797 * 798 * @param string $link The tag feed link. 799 * @param string $feed The feed type. 800 */ 635 801 $link = apply_filters( 'tag_feed_link', $link, $feed ); 636 else 802 } else { 803 /** 804 * Filter the feed link for a taxonomy other than 'category' or 'post_tag'. 805 * 806 * @since 2.8.0 807 * 808 * @param string $link The taxonomy feed link. 809 * @param string $feed The feed type. 810 * @param string $feed The taxonomy name. 811 */ 637 812 $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); 813 } 638 814 639 815 return $link; 640 816 } … … 662 838 * @return string 663 839 */ 664 840 function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { 841 /** 842 * Filter the edit link for a tag (or term in another taxonomy). 843 * 844 * @since 2.7.0 845 * 846 * @param string $link The edit link. 847 */ 665 848 return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) ); 666 849 } 667 850 … … 678 861 */ 679 862 function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { 680 863 $link = edit_term_link( $link, '', '', $tag, false ); 864 /** 865 * Filter the anchor tag for the edit link for a tag (or term in another taxonomy). 866 * 867 * @since 2.7.0 868 * 869 * @param string $link The anchor tag for the edit link. 870 */ 681 871 echo $before . apply_filters( 'edit_tag_link', $link ) . $after; 682 872 } 683 873 … … 709 899 710 900 $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); 711 901 902 /** 903 * Filter the edit link for a term. 904 * 905 * @since 3.1.0 906 * 907 * @param string $location The edit link. 908 * @param int $term_id The term ID. 909 * @param string $taxonomy The taxonomy name. 910 * @param string $object_type The object type (eg. the post type). 911 */ 712 912 return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); 713 913 } 714 914 … … 738 938 $link = __('Edit This'); 739 939 740 940 $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; 941 /** 942 * Filter the anchor tag for the edit link for a term. 943 * 944 * @since 3.1.0 945 * 946 * @param string $link The anchor tag for the edit link. 947 * @param int $term_id The term ID. 948 */ 741 949 $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; 742 950 743 951 if ( $echo ) … … 773 981 $link = home_url( user_trailingslashit( $link, 'search' ) ); 774 982 } 775 983 984 /** 985 * Filter the permalink for a search. 986 * 987 * @since 3.0.0 988 * 989 * @param string $link The search permalink. 990 * @param string $search The URL-encoded search term. 991 */ 776 992 return apply_filters( 'search_link', $link, $search ); 777 993 } 778 994 … … 801 1017 $link .= "feed/$feed/"; 802 1018 } 803 1019 1020 /** 1021 * Filter the feed link for a search. 1022 * 1023 * @since 2.5.0 1024 * 1025 * @param string $link The search feed link. 1026 * @param string $feed The feed type. 1027 * @param string $type The search type. One of 'posts' or 'comments'. 1028 */ 804 1029 $link = apply_filters('search_feed_link', $link, $feed, 'posts'); 805 1030 806 1031 return $link; … … 830 1055 else 831 1056 $link = add_query_arg('withcomments', 1, $link); 832 1057 1058 /** 1059 * Filter the feed link for a search. 1060 * 1061 * @since 2.5.0 1062 * 1063 * @param string $link The search feed link. 1064 * @param string $feed The feed type. 1065 * @param string $type The search type. One of 'posts' or 'comments'. 1066 */ 833 1067 $link = apply_filters('search_feed_link', $link, $feed, 'comments'); 834 1068 835 1069 return $link; … … 862 1096 $link = home_url( '?post_type=' . $post_type ); 863 1097 } 864 1098 1099 /** 1100 * Filter the permalink for a post type archive. 1101 * 1102 * @since 3.1.0 1103 * 1104 * @param string $link The post type archive permalink. 1105 * @param string $post_type The post type name. 1106 */ 865 1107 return apply_filters( 'post_type_archive_link', $link, $post_type ); 866 1108 } 867 1109 … … 892 1134 $link = add_query_arg( 'feed', $feed, $link ); 893 1135 } 894 1136 1137 /** 1138 * Filter the feed link for a post type archive. 1139 * 1140 * @since 3.1.0 1141 * 1142 * @param string $link The post type archive feed link. 1143 * @param string $feed The feed ty[e. 1144 */ 895 1145 return apply_filters( 'post_type_archive_feed_link', $link, $feed ); 896 1146 } 897 1147 … … 925 1175 if ( !current_user_can( 'edit_post', $post->ID ) ) 926 1176 return; 927 1177 1178 /** 1179 * Filter the edit link for a post. 1180 * 1181 * @since 2.3.0 1182 * 1183 * @param string $link The edit link. 1184 * @param int $post_id The post ID. 1185 * @param string $context The link context. If set to 'display' then ampersands are encoded. 1186 */ 928 1187 return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 929 1188 } 930 1189 … … 950 1209 951 1210 $post_type_obj = get_post_type_object( $post->post_type ); 952 1211 $link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>'; 1212 /** 1213 * Filter the anchor tag for the edit link for a post. 1214 * 1215 * @since 2.3.0 1216 * 1217 * @param string $link The anchor tag for the edit link. 1218 * @param int $post_id The post ID. 1219 */ 953 1220 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; 954 1221 } 955 1222 … … 983 1250 984 1251 $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); 985 1252 1253 /** 1254 * Filter the delete link for a post. 1255 * 1256 * @since 2.9.0 1257 * 1258 * @param string $link The delete link. 1259 * @param int $post_id The post ID. 1260 * @param bool $force_delete Whether to bypass trash and force deletion. 1261 */ 986 1262 return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); 987 1263 } 988 1264 … … 1001 1277 return; 1002 1278 1003 1279 $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; 1280 /** 1281 * Filter the edit link for a comment. 1282 * 1283 * @since 2.3.0 1284 * 1285 * @param string $location The edit link. 1286 */ 1004 1287 return apply_filters( 'get_edit_comment_link', $location ); 1005 1288 } 1006 1289 … … 1023 1306 $link = __('Edit This'); 1024 1307 1025 1308 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>'; 1309 /** 1310 * Filter the anchor tag for the edit link for a comment. 1311 * 1312 * @since 2.3.0 1313 * 1314 * @param string $link The anchor tag for the edit link. 1315 * @param int $comment_id The comment ID. 1316 */ 1026 1317 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; 1027 1318 } 1028 1319 … … 1041 1332 return; 1042 1333 1043 1334 $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; 1335 /** 1336 * Filter the edit link for a bookmark (link). 1337 * 1338 * @since 2.3.0 1339 * 1340 * @param string $location The edit link. 1341 * @param int $link_id The bookmark ID. 1342 */ 1044 1343 return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); 1045 1344 } 1046 1345 … … 1064 1363 $link = __('Edit This'); 1065 1364 1066 1365 $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>'; 1366 /** 1367 * Filter the anchor tag for the edit link for a bookmark. 1368 * 1369 * @since 2.3.0 1370 * 1371 * @param string $link The anchor tag for the edit link. 1372 * @param int $link_id The bookmark ID. 1373 */ 1067 1374 echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; 1068 1375 } 1069 1376 … … 1092 1399 else 1093 1400 $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); 1094 1401 1402 /** 1403 * Filter the edit link for a user. 1404 * 1405 * @since 2.3.0 1406 * 1407 * @param string $link The edit link. 1408 * @param int $user_id The user ID. 1409 */ 1095 1410 return apply_filters( 'get_edit_user_link', $link, $user->ID ); 1096 1411 } 1097 1412 … … 1189 1504 $op = $previous ? '<' : '>'; 1190 1505 $order = $previous ? 'DESC' : 'ASC'; 1191 1506 1507 /** 1508 * Filter the JOIN clause in the SQL for an adjacent post query. 1509 * 1510 * Filter name can be `get_previous_post_join` or `get_next_post_join`. 1511 * 1512 * @since 2.1.0 1513 * 1514 * @param string $join The JOIN clause in the SQL. 1515 * @param bool $in_same_term Whether post should be in a same taxonomy term. 1516 * @param array $excluded_terms Array of excluded term IDs. 1517 */ 1192 1518 $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms ); 1519 /** 1520 * Filter the WHERE clause in the SQL for an adjacent post query. 1521 * 1522 * Filter name can be `get_previous_post_where` or `get_next_post_where`. 1523 * 1524 * @since 2.1.0 1525 * 1526 * @param string $where The WHERE clause in the SQL. 1527 * @param bool $in_same_term Whether post should be in a same taxonomy term. 1528 * @param array $excluded_terms Array of excluded term IDs. 1529 */ 1193 1530 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_terms_sql", $current_post_date, $post->post_type), $in_same_term, $excluded_terms ); 1531 /** 1532 * Filter the ORDER BY clause in the SQL for an adjacent post query. 1533 * 1534 * Filter name can be `get_previous_post_sort` or `get_next_post_sort`. 1535 * 1536 * @since 2.1.0 1537 * 1538 * @param string $order_by The ORDER BY clause in the SQL. 1539 */ 1194 1540 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); 1195 1541 1196 1542 $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; … … 1252 1598 $link .= "' href='" . get_permalink( $post ) . "' />\n"; 1253 1599 1254 1600 $adjacent = $previous ? 'previous' : 'next'; 1601 /** 1602 * Filter the adjacent post relational link. 1603 * 1604 * Filter name can be `previous_post_rel_link` or `next_post_rel_link`. 1605 * 1606 * @since 2.8.0 1607 * 1608 * @param string $link The relational link. 1609 */ 1255 1610 return apply_filters( "{$adjacent}_post_rel_link", $link ); 1256 1611 } 1257 1612 … … 1477 1832 1478 1833 $adjacent = $previous ? 'previous' : 'next'; 1479 1834 1835 /** 1836 * Filter the adjacent post link. 1837 * 1838 * Filter name can be `previous_post_link` or `next_post_link`. 1839 * 1840 * @since 2.8.0 1841 * 1842 * @param string $output The adjacent post link. 1843 * @param string $format Link anchor format. 1844 * @param string $link Link permalink format. 1845 * @param WP_Post $post The adjacent post. 1846 */ 1480 1847 return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post ); 1481 1848 } 1482 1849 … … 1559 1926 $result = $base . $request . $query_string; 1560 1927 } 1561 1928 1929 /** 1930 * Filter the page number link for the current request. 1931 * 1932 * @since 2.5.0 1933 * 1934 * @param string $result The page number link. 1935 */ 1562 1936 $result = apply_filters('get_pagenum_link', $result); 1563 1937 1564 1938 if ( $escape ) … … 1630 2004 $label = __( 'Next Page »' ); 1631 2005 1632 2006 if ( !is_single() && ( $nextpage <= $max_page ) ) { 2007 /** 2008 * Filter the attributes on the anchor tag for the next posts page link. 2009 * 2010 * @since 2.7.0 2011 * 2012 * @param string $attributes Attributes for the anchor tag. 2013 */ 1633 2014 $attr = apply_filters( 'next_posts_link_attributes', '' ); 1634 2015 return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>'; 1635 2016 } … … 1701 2082 $label = __( '« Previous Page' ); 1702 2083 1703 2084 if ( !is_single() && $paged > 1 ) { 2085 /** 2086 * Filter the attributes on the anchor tag for the previous posts page link. 2087 * 2088 * @since 2.7.0 2089 * 2090 * @param string $attributes Attributes for the anchor tag. 2091 */ 1704 2092 $attr = apply_filters( 'previous_posts_link_attributes', '' ); 1705 2093 return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'</a>'; 1706 2094 } … … 1802 2190 1803 2191 $result .= '#comments'; 1804 2192 2193 /** 2194 * Filter the comments page number link for the current request. 2195 * 2196 * @since 2.7.0 2197 * 2198 * @param string $result The comments page number link. 2199 */ 1805 2200 $result = apply_filters('get_comments_pagenum_link', $result); 1806 2201 1807 2202 return $result; … … 1838 2233 if ( empty($label) ) 1839 2234 $label = __('Newer Comments »'); 1840 2235 2236 /** 2237 * Filter the attributes on the anchor tag for the next comments page link. 2238 * 2239 * @since 2.7.0 2240 * 2241 * @param string $attributes Attributes for the anchor tag. 2242 */ 1841 2243 return '<a href="' . esc_url( get_comments_pagenum_link( $nextpage, $max_page ) ) . '" ' . apply_filters( 'next_comments_link_attributes', '' ) . '>'. preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; 1842 2244 } 1843 2245 … … 1875 2277 if ( empty($label) ) 1876 2278 $label = __('« Older Comments'); 1877 2279 2280 /** 2281 * Filter the attributes on the anchor tag for the previous comments page link. 2282 * 2283 * @since 2.7.0 2284 * 2285 * @param string $attributes Attributes for the anchor tag. 2286 */ 1878 2287 return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) .'</a>'; 1879 2288 } 1880 2289 … … 1956 2365 1957 2366 $link = str_replace(array("\r", "\n", "\t"), '', $link); 1958 2367 2368 /** 2369 * Filter the Press This bookmarklet link 2370 * 2371 * @since 2.6.0 2372 * 2373 * @param string $link The Press This bookmarklet link. 2374 */ 1959 2375 return apply_filters('shortcut_link', $link); 1960 2376 } 1961 2377 … … 2014 2430 2015 2431 if ( $path && is_string( $path ) ) 2016 2432 $url .= '/' . ltrim( $path, '/' ); 2017 2433 /** 2434 * Filter the home URL. 2435 * 2436 * @since 3.0.0 2437 * 2438 * @param string $url The complete home URL including scheme and path. 2439 * @param string $path Path relative to the home URL. Blank string if no path is specified. 2440 * @param string|null $orig_scheme Scheme to give the home URL context. Accepts 'http', 'https', 'relative' or null. 2441 * @param int|null $blog_id Blog ID, or null for the current blog. 2442 */ 2018 2443 return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); 2019 2444 } 2020 2445 … … 2025 2450 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is 2026 2451 * overridden. 2027 2452 * 2028 * @since 2.6.02453 * @since 3.0.0 2029 2454 * 2030 2455 * @uses get_site_url() 2031 2456 * … … 2065 2490 if ( $path && is_string( $path ) ) 2066 2491 $url .= '/' . ltrim( $path, '/' ); 2067 2492 2493 /** 2494 * Filter the site URL. 2495 * 2496 * @since 3.0.0 2497 * 2498 * @param string $url The complete site URL including scheme and path. 2499 * @param string $path Path relative to the site URL. Blank string if no path is specified. 2500 * @param string|null $scheme Scheme to give the site URL context. Accepts 'http', 'https', 'login', 2501 * 'login_post', 'admin', 'relative' or null. 2502 * @param int|null $blog_id Blog ID, or null for the current blog. 2503 */ 2068 2504 return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); 2069 2505 } 2070 2506 … … 2097 2533 if ( $path && is_string( $path ) ) 2098 2534 $url .= ltrim( $path, '/' ); 2099 2535 2536 /** 2537 * Filter the admin area URL. 2538 * 2539 * @since 3.0.0 2540 * 2541 * @param string $url The complete admin area URL including scheme and path. 2542 * @param string $path Path relative to the admin area URL. Blank string if no path is specified. 2543 * @param int|null $blog_id Blog ID, or null for the current blog. 2544 */ 2100 2545 return apply_filters( 'admin_url', $url, $path, $blog_id ); 2101 2546 } 2102 2547 … … 2115 2560 if ( $path && is_string( $path ) ) 2116 2561 $url .= ltrim($path, '/'); 2117 2562 2563 /** 2564 * Filter the URL to the wp-includes directory. 2565 * 2566 * @since 2.8.0 2567 * 2568 * @param string $url The complete URL to the wp-includes directory including scheme and path. 2569 * @param string $path Path relative to the URL to the wp-includes directory. Blank string if no path is specified. 2570 */ 2118 2571 return apply_filters('includes_url', $url, $path); 2119 2572 } 2120 2573 … … 2132 2585 if ( $path && is_string( $path ) ) 2133 2586 $url .= '/' . ltrim($path, '/'); 2134 2587 2588 /** 2589 * Filter the URL to the content directory. 2590 * 2591 * @since 2.8.0 2592 * 2593 * @param string $url The complete URL to the content directory including scheme and path. 2594 * @param string $path Path relative to the URL to the content directory. Blank string if no path is specified. 2595 */ 2135 2596 return apply_filters('content_url', $url, $path); 2136 2597 } 2137 2598 … … 2170 2631 if ( $path && is_string( $path ) ) 2171 2632 $url .= '/' . ltrim($path, '/'); 2172 2633 2634 /** 2635 * Filter the URL to the plugins directory. 2636 * 2637 * @since 2.8.0 2638 * 2639 * @param string $url The complete URL to the plugins directory including scheme and path. 2640 * @param string $path Path relative to the URL to the plugins directory. Blank string if no path is specified. 2641 * @param string $plugin The plugin file path to be relative to. Blank string if no plugin is specified. 2642 */ 2173 2643 return apply_filters('plugins_url', $url, $path, $plugin); 2174 2644 } 2175 2645 … … 2200 2670 if ( $path && is_string( $path ) ) 2201 2671 $url .= ltrim( $path, '/' ); 2202 2672 2673 /** 2674 * Filter the network site URL. 2675 * 2676 * @since 3.0.0 2677 * 2678 * @param string $url The complete network site URL including scheme and path. 2679 * @param string $path Path relative to the network site URL. Blank string if no path is specified. 2680 * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https', 'relative' or null. 2681 */ 2203 2682 return apply_filters( 'network_site_url', $url, $path, $scheme ); 2204 2683 } 2205 2684 … … 2234 2713 if ( $path && is_string( $path ) ) 2235 2714 $url .= ltrim( $path, '/' ); 2236 2715 2716 /** 2717 * Filter the network home URL. 2718 * 2719 * @since 3.0.0 2720 * 2721 * @param string $url The complete network home URL including scheme and path. 2722 * @param string $path Path relative to the network home URL. Blank string if no path is specified. 2723 * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https', 'relative' or null. 2724 */ 2237 2725 return apply_filters( 'network_home_url', $url, $path, $orig_scheme); 2238 2726 } 2239 2727 … … 2255 2743 if ( $path && is_string( $path ) ) 2256 2744 $url .= ltrim($path, '/'); 2257 2745 2746 /** 2747 * Filter the network admin URL. 2748 * 2749 * @since 3.0.0 2750 * 2751 * @param string $url The complete network admin URL including scheme and path. 2752 * @param string $path Path relative to the network admin URL. Blank string if no path is specified. 2753 */ 2258 2754 return apply_filters('network_admin_url', $url, $path); 2259 2755 } 2260 2756 … … 2273 2769 if ( $path && is_string( $path ) ) 2274 2770 $url .= ltrim($path, '/'); 2275 2771 2772 /** 2773 * Filter the user admin URL for the current user. 2774 * 2775 * @since 3.0.0 2776 * 2777 * @param string $url The complete URL including scheme and path. 2778 * @param string $path Path relative to the URL. Blank string if no path is specified. 2779 */ 2276 2780 return apply_filters('user_admin_url', $url, $path); 2277 2781 } 2278 2782 … … 2328 2832 $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); 2329 2833 } 2330 2834 2835 /** 2836 * Filter the resulting URL after setting the scheme. 2837 * 2838 * @since 3.4.0 2839 * 2840 * @param string $url The complete URL including scheme and path. 2841 * @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'. 2842 * @param string $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', 'login_post', 'admin', 'rpc', or 'relative'. 2843 */ 2331 2844 return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); 2332 2845 } 2333 2846 … … 2366 2879 } 2367 2880 } 2368 2881 2882 /** 2883 * Filter the dashboard URL for a user. 2884 * 2885 * @since 3.1.0 2886 * 2887 * @param string $url The complete URL including scheme and path. 2888 * @param int $user_id The user ID. 2889 * @param string $path Path relative to the URL. Blank string if no path is specified. 2890 * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', 2891 * 'login_post', 'admin', 'relative' or null. 2892 */ 2369 2893 return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme); 2370 2894 } 2371 2895 … … 2389 2913 else 2390 2914 $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); 2391 2915 2916 /** 2917 * Filter the URL for a user's profile editor. 2918 * 2919 * @since 3.1.0 2920 * 2921 * @param string $url The complete URL including scheme and path. 2922 * @param int $user_id The user ID. 2923 * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', 2924 * 'login_post', 'admin', 'relative' or null. 2925 */ 2392 2926 return apply_filters( 'edit_profile_url', $url, $user_id, $scheme); 2393 2927 } 2394 2928 … … 2429 2963 * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled. 2430 2964 */ 2431 2965 function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { 2432 // Allow plugins to short-circuit this function. 2966 /** 2967 * Short-circuit the generation of a shortlink for a post. 2968 * 2969 * @since 3.0.0 2970 * 2971 * @param bool|string $return The short-circuit return value. Either false or a URL string. 2972 * @param int $id The post ID, or 0 for the current post. 2973 * @param string $context The context for the link. One of 'post' or 'query', 2974 * @param bool $allow_slugs Whether to allow post slugs in the shortlink. 2975 */ 2433 2976 $shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs); 2434 2977 if ( false !== $shortlink ) 2435 2978 return $shortlink; … … 2458 3001 } 2459 3002 } 2460 3003 3004 /** 3005 * Filter the shortlink for a post. 3006 * 3007 * @since 3.0.0 3008 * 3009 * @param string $shortlink The shortlink URL. 3010 * @param int $id The post ID, or 0 for the current post. 3011 * @param string $context The context for the link. One of 'post' or 'query', 3012 * @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default. 3013 */ 2461 3014 return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs); 2462 3015 } 2463 3016 … … 2527 3080 2528 3081 if ( !empty( $shortlink ) ) { 2529 3082 $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; 3083 /** 3084 * Filter the anchor tag for the shortlink to a post. 3085 * 3086 * @since 3.0.0 3087 * 3088 * @param string $link The shortlink anchor tag. 3089 * @param string $shortlink The shortlink URL. 3090 * @param string $text The shortlink's text. 3091 * @param string $title The shortlink's title attribute. 3092 */ 2530 3093 $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); 2531 3094 echo $before, $link, $after; 2532 3095 }