Ticket #27716: 27716.2.patch
File 27716.2.patch, 33.3 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() { 15 /** 16 * Filter the display of the permalink for the current post. 17 * 18 * @since 1.5.0 19 * 20 * @param string $permalink The permalink for the current post. 21 */ 16 22 echo esc_url( apply_filters( 'the_permalink', get_permalink() ) ); 17 23 } 18 24 … … 38 44 else 39 45 $string = untrailingslashit($string); 40 46 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 43 $string = apply_filters('user_trailingslashit', $string, $type_of_url); 47 /** 48 * Filter the trailing slashed string, depending on whether the site is set 49 * to use training slashes. 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 */ 58 $string = apply_filters( 'user_trailingslashit', $string, $type_of_url ); 44 59 return $string; 45 60 } 46 61 … … 129 144 130 145 $permalink = get_option('permalink_structure'); 131 146 132 $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); 147 /** 148 * Filter the permalink structure for a post before token replacement occurs. 149 * 150 * Only applies to posts with post_type of 'post'. 151 * 152 * @since 3.0.0 153 * 154 * @param string $permalink The site's permalink structure. 155 * @param WP_Post $post The post in question. 156 * @param bool $leavename Whether to keep the post name. 157 */ 158 $permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename ); 133 159 134 160 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending', 'auto-draft')) ) { 135 161 $unixtime = strtotime($post->post_date); … … 139 165 $cats = get_the_category($post->ID); 140 166 if ( $cats ) { 141 167 usort($cats, '_usort_terms_by_ID'); // order by ID 168 169 /** 170 * Filter the category that gets used in the %category% permalink token. 171 * 172 * @since 3.5.0 173 * 174 * @param stdClass $cat The category to use in the permalink. 175 * @param array $cats Array of all categories associated with the post. 176 * @param WP_Post $post The post in question. 177 */ 142 178 $category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post ); 179 143 180 $category_object = get_term( $category_object, 'category' ); 144 181 $category = $category_object->slug; 145 182 if ( $parent = $category_object->parent ) … … 179 216 } else { // if they're not using the fancy permalink option 180 217 $permalink = home_url('?p=' . $post->ID); 181 218 } 182 return apply_filters('post_link', $permalink, $post, $leavename); 219 220 /** 221 * Filter the permalink for a post. 222 * 223 * Only applies to posts with post_type of 'post'. 224 * 225 * @since 1.5.0 226 * 227 * @param string $permalink The post's permalink. 228 * @param WP_Post $post The post in question. 229 * @param bool $leavename Whether to keep the post name. 230 */ 231 return apply_filters( 'post_link', $permalink, $post, $leavename ); 183 232 } 184 233 185 234 /** … … 223 272 $post_link = home_url($post_link); 224 273 } 225 274 226 return apply_filters('post_type_link', $post_link, $post, $leavename, $sample); 275 /** 276 * Filter the permalink for a post with a custom post type. 277 * 278 * @since 3.0.0 279 * 280 * @param string $post_link The post's permalink. 281 * @param WP_Post $post The post in question. 282 * @param bool $leavename Whether to keep the post name. 283 * @param bool $sample Is it a sample permalink. 284 */ 285 return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample ); 227 286 } 228 287 229 288 /** … … 262 321 else 263 322 $link = _get_page_link( $post, $leavename, $sample ); 264 323 324 /** 325 * Filter the permalink for a page. 326 * 327 * @since 1.5.0 328 * 329 * @param string $link The page's permalink. 330 * @param int $post_id The ID of the page. 331 * @param bool $sample Is it a sample permalink. 332 */ 265 333 return apply_filters( 'page_link', $link, $post->ID, $sample ); 266 334 } 267 335 … … 298 366 $link = home_url( '?page_id=' . $post->ID ); 299 367 } 300 368 369 /** 370 * Filter the permalink for a non-page_on_front page. 371 * 372 * @since 2.1.0 373 * 374 * @param string $link The page's permalink. 375 * @param int $post_id The ID of the page. 376 */ 301 377 return apply_filters( '_get_page_link', $link, $post->ID ); 302 378 } 303 379 … … 341 417 if ( ! $link ) 342 418 $link = home_url( '/?attachment_id=' . $post->ID ); 343 419 420 /** 421 * Filter the permalink for an attachment. 422 * 423 * @since 2.0.0 424 * 425 * @param string $link The attachment's permalink. 426 * @param int $post_id Attachment ID. 427 */ 344 428 return apply_filters( 'attachment_link', $link, $post->ID ); 345 429 } 346 430 … … 359 443 $yearlink = $wp_rewrite->get_year_permastruct(); 360 444 if ( !empty($yearlink) ) { 361 445 $yearlink = str_replace('%year%', $year, $yearlink); 362 return apply_filters('year_link', home_url( user_trailingslashit($yearlink, 'year') ), $year);446 $yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) ); 363 447 } else { 364 return apply_filters('year_link', home_url('?m=' . $year), $year);448 $yearlink = home_url( '?m=' . $year ); 365 449 } 450 451 /** 452 * Filter the year archive permalink. 453 * 454 * @since 1.5.0 455 * 456 * @param string $yearlink Permalink for the year archive. 457 * @param int $year Year for the archive. 458 */ 459 return apply_filters( 'year_link', $yearlink, $year ); 366 460 } 367 461 368 462 /** … … 384 478 if ( !empty($monthlink) ) { 385 479 $monthlink = str_replace('%year%', $year, $monthlink); 386 480 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); 387 return apply_filters('month_link', home_url( user_trailingslashit($monthlink, 'month') ), $year, $month);481 $monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) ); 388 482 } else { 389 return apply_filters('month_link', home_url( '?m=' . $year . zeroise($month, 2) ), $year, $month);483 $monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) ); 390 484 } 485 486 /** 487 * Filter the month archive permalink. 488 * 489 * @since 1.5.0 490 * 491 * @param string $monthlink Permalink for the month archive. 492 * @param int $year Year for the archive. 493 * @param int $month The month for the archive. 494 */ 495 return apply_filters( 'month_link', $monthlink, $year, $month ); 391 496 } 392 497 393 498 /** … … 414 519 $daylink = str_replace('%year%', $year, $daylink); 415 520 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); 416 521 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); 417 return apply_filters('day_link', home_url( user_trailingslashit($daylink, 'day') ), $year, $month, $day);522 $daylink = home_url( user_trailingslashit( $daylink, 'day' ) ); 418 523 } else { 419 return apply_filters('day_link', home_url( '?m=' . $year . zeroise($month, 2) . zeroise($day, 2) ), $year, $month, $day);524 $daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) ); 420 525 } 526 527 /** 528 * Filter the day archive permalink. 529 * 530 * @since 1.5.0 531 * 532 * @param string $daylink Permalink for the day archive. 533 * @param int $year Year for the archive. 534 * @param int $month Month for the archive. 535 * @param int $day The day for the archive. 536 */ 537 return apply_filters( 'day_link', $daylink, $year, $month, $day ); 421 538 } 422 539 423 540 /** … … 430 547 */ 431 548 function the_feed_link( $anchor, $feed = '' ) { 432 549 $link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>'; 550 551 /** 552 * Filter the feed link anchor tag. 553 * 554 * @since 3.0.0 555 * 556 * @param string $link The complete anchor tag for a feed link. 557 * @param string $feed The feed type, or an empty string for the 558 * default feed type. 559 */ 433 560 echo apply_filters( 'the_feed_link', $link, $feed ); 434 561 } 435 562 … … 467 594 $output = home_url("?feed={$feed}"); 468 595 } 469 596 470 return apply_filters('feed_link', $output, $feed); 597 /** 598 * Filter the feed type permalink. 599 * 600 * @since 1.5.0 601 * 602 * @param string $output The feed permalink. 603 * @param string $feed Feed type. 604 */ 605 return apply_filters( 'feed_link', $output, $feed ); 471 606 } 472 607 473 608 /** … … 506 641 $url = add_query_arg( array( 'feed' => $feed, 'p' => $post_id ), home_url( '/' ) ); 507 642 } 508 643 509 return apply_filters('post_comments_feed_link', $url); 644 /** 645 * Filter the post comments feed permalink. 646 * 647 * @since 1.5.1 648 * 649 * @param string $url Post comments feed permalink. 650 */ 651 return apply_filters( 'post_comments_feed_link', $url ); 510 652 } 511 653 512 654 /** … … 528 670 if ( empty($link_text) ) 529 671 $link_text = __('Comments Feed'); 530 672 673 /** 674 * Filter the post comment feed link anchor tag. 675 * 676 * @since 2.8.0 677 * 678 * @param string $link The complete anchor tag for the comment feed link. 679 * @param int $post_id Post ID. 680 * @param string $feed The feed type, or an empty string for the default feed type. 681 */ 531 682 echo apply_filters( 'post_comments_feed_link_html', "<a href='$url'>$link_text</a>", $post_id, $feed ); 532 683 } 533 684 … … 562 713 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 563 714 } 564 715 565 $link = apply_filters('author_feed_link', $link, $feed); 716 /** 717 * Filter the feed link for a given author. 718 * 719 * @since 1.5.1 720 * 721 * @param string $link The author feed link. 722 * @param string $feed Feed type. 723 */ 724 $link = apply_filters( 'author_feed_link', $link, $feed ); 566 725 567 726 return $link; 568 727 } … … 629 788 $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); 630 789 } 631 790 632 if ( 'category' == $taxonomy ) 791 if ( 'category' == $taxonomy ) { 792 /** 793 * Filter the category feed link. 794 * 795 * @since 1.5.1 796 * 797 * @param string $link The category feed link. 798 * @param string $feed Feed type. 799 */ 633 800 $link = apply_filters( 'category_feed_link', $link, $feed ); 634 elseif ( 'post_tag' == $taxonomy ) 801 } elseif ( 'post_tag' == $taxonomy ) { 802 /** 803 * Filter the post tag feed link. 804 * 805 * @since 2.3.0 806 * 807 * @param string $link The tag feed link. 808 * @param string $feed Feed type. 809 */ 635 810 $link = apply_filters( 'tag_feed_link', $link, $feed ); 636 else 811 } else { 812 /** 813 * Filter the feed link for a taxonomy other than 'category' or 'post_tag'. 814 * 815 * @since 3.0.0 816 * 817 * @param string $link The taxonomy feed link. 818 * @param string $feed Feed type. 819 * @param string $feed The taxonomy name. 820 */ 637 821 $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); 822 } 638 823 639 824 return $link; 640 825 } … … 662 847 * @return string 663 848 */ 664 849 function get_edit_tag_link( $tag_id, $taxonomy = 'post_tag' ) { 850 /** 851 * Filter the edit link for a tag (or term in another taxonomy). 852 * 853 * @since 2.7.0 854 * 855 * @param string $link The term edit link. 856 */ 665 857 return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag_id, $taxonomy ) ); 666 858 } 667 859 … … 678 870 */ 679 871 function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) { 680 872 $link = edit_term_link( $link, '', '', $tag, false ); 873 874 /** 875 * Filter the anchor tag for the edit link for a tag (or term in another taxonomy). 876 * 877 * @since 2.7.0 878 * 879 * @param string $link The anchor tag for the edit link. 880 */ 681 881 echo $before . apply_filters( 'edit_tag_link', $link ) . $after; 682 882 } 683 883 … … 709 909 710 910 $location = add_query_arg( $args, admin_url( 'edit-tags.php' ) ); 711 911 912 /** 913 * Filter the edit link for a term. 914 * 915 * @since 3.1.0 916 * 917 * @param string $location The edit link. 918 * @param int $term_id Term ID. 919 * @param string $taxonomy Taxonomy name. 920 * @param string $object_type The object type (eg. the post type). 921 */ 712 922 return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type ); 713 923 } 714 924 … … 738 948 $link = __('Edit This'); 739 949 740 950 $link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>'; 951 952 /** 953 * Filter the anchor tag for the edit link of a term. 954 * 955 * @since 3.1.0 956 * 957 * @param string $link The anchor tag for the edit link. 958 * @param int $term_id Term ID. 959 */ 741 960 $link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after; 742 961 743 962 if ( $echo ) … … 773 992 $link = home_url( user_trailingslashit( $link, 'search' ) ); 774 993 } 775 994 995 /** 996 * Filter the search permalink. 997 * 998 * @since 3.0.0 999 * 1000 * @param string $link Search permalink. 1001 * @param string $search The URL-encoded search term. 1002 */ 776 1003 return apply_filters( 'search_link', $link, $search ); 777 1004 } 778 1005 … … 801 1028 $link .= "feed/$feed/"; 802 1029 } 803 1030 804 $link = apply_filters('search_feed_link', $link, $feed, 'posts'); 1031 /** 1032 * Filter the search feed link. 1033 * 1034 * @since 2.5.0 1035 * 1036 * @param string $link Search feed link. 1037 * @param string $feed Feed type. 1038 * @param string $type The search type. One of 'posts' or 'comments'. 1039 */ 1040 $link = apply_filters( 'search_feed_link', $link, $feed, 'posts' ); 805 1041 806 1042 return $link; 807 1043 } … … 830 1066 else 831 1067 $link = add_query_arg('withcomments', 1, $link); 832 1068 1069 /** This filter is documented in wp-includes/link-template.php */ 833 1070 $link = apply_filters('search_feed_link', $link, $feed, 'comments'); 834 1071 835 1072 return $link; … … 862 1099 $link = home_url( '?post_type=' . $post_type ); 863 1100 } 864 1101 1102 /** 1103 * Filter the post type archive permalink. 1104 * 1105 * @since 3.1.0 1106 * 1107 * @param string $link The post type archive permalink. 1108 * @param string $post_type Post type name. 1109 */ 865 1110 return apply_filters( 'post_type_archive_link', $link, $post_type ); 866 1111 } 867 1112 … … 892 1137 $link = add_query_arg( 'feed', $feed, $link ); 893 1138 } 894 1139 1140 /** 1141 * Filter the post type archive feed link. 1142 * 1143 * @since 3.1.0 1144 * 1145 * @param string $link The post type archive feed link. 1146 * @param string $feed Feed type. 1147 */ 895 1148 return apply_filters( 'post_type_archive_feed_link', $link, $feed ); 896 1149 } 897 1150 … … 925 1178 if ( !current_user_can( 'edit_post', $post->ID ) ) 926 1179 return; 927 1180 928 return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context ); 1181 /** 1182 * Filter the post edit link. 1183 * 1184 * @since 2.3.0 1185 * 1186 * @param string $link The edit link. 1187 * @param int $post_id Post ID. 1188 * @param string $context The link context. If set to 'display' then ampersands 1189 * are encoded. 1190 */ 1191 return apply_filters( 'get_edit_post_link', admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) ), $post->ID, $context ); 929 1192 } 930 1193 931 1194 /** … … 950 1213 951 1214 $post_type_obj = get_post_type_object( $post->post_type ); 952 1215 $link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>'; 1216 1217 /** 1218 * Filter the post edit link anchor tag. 1219 * 1220 * @since 2.3.0 1221 * 1222 * @param string $link Anchor tag for the edit link. 1223 * @param int $post_id Post ID. 1224 */ 953 1225 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; 954 1226 } 955 1227 … … 983 1255 984 1256 $delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) ); 985 1257 1258 /** 1259 * Filter the post delete link. 1260 * 1261 * @since 2.9.0 1262 * 1263 * @param string $link The delete link. 1264 * @param int $post_id Post ID. 1265 * @param bool $force_delete Whether to bypass the trash and force deletion. Default false. 1266 */ 986 1267 return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete ); 987 1268 } 988 1269 … … 1001 1282 return; 1002 1283 1003 1284 $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID; 1285 1286 /** 1287 * Filter the comment edit link. 1288 * 1289 * @since 2.3.0 1290 * 1291 * @param string $location The edit link. 1292 */ 1004 1293 return apply_filters( 'get_edit_comment_link', $location ); 1005 1294 } 1006 1295 … … 1023 1312 $link = __('Edit This'); 1024 1313 1025 1314 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>'; 1315 1316 /** 1317 * Filter the comment edit link anchor tag. 1318 * 1319 * @since 2.3.0 1320 * 1321 * @param string $link Anchor tag for the edit link. 1322 * @param int $comment_id Comment ID. 1323 */ 1026 1324 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; 1027 1325 } 1028 1326 … … 1041 1339 return; 1042 1340 1043 1341 $location = admin_url('link.php?action=edit&link_id=') . $link->link_id; 1342 1343 /** 1344 * Filter the bookmark (link) edit link. 1345 * 1346 * @since 2.7.0 1347 * 1348 * @param string $location The edit link. 1349 * @param int $link_id Bookmark ID. 1350 */ 1044 1351 return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id ); 1045 1352 } 1046 1353 … … 1064 1371 $link = __('Edit This'); 1065 1372 1066 1373 $link = '<a href="' . get_edit_bookmark_link( $bookmark ) . '">' . $link . '</a>'; 1374 1375 /** 1376 * Filter the bookmark edit link anchor tag. 1377 * 1378 * @since 2.7.0 1379 * 1380 * @param string $link Anchor tag for the edit link. 1381 * @param int $link_id Bookmark ID. 1382 */ 1067 1383 echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after; 1068 1384 } 1069 1385 … … 1092 1408 else 1093 1409 $link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) ); 1094 1410 1411 /** 1412 * Filter the user edit link. 1413 * 1414 * @since 3.5.0 1415 * 1416 * @param string $link The edit link. 1417 * @param int $user_id User ID. 1418 */ 1095 1419 return apply_filters( 'get_edit_user_link', $link, $user->ID ); 1096 1420 } 1097 1421 … … 1189 1513 $op = $previous ? '<' : '>'; 1190 1514 $order = $previous ? 'DESC' : 'ASC'; 1191 1515 1516 /** 1517 * Filter the JOIN clause in the SQL for an adjacent post query. 1518 * 1519 * The dynamic portion of the hook name, $adjacent, refers to the type 1520 * of adjacency, 'next' or 'previous'. 1521 * 1522 * @since 2.5.0 1523 * 1524 * @param string $join The JOIN clause in the SQL. 1525 * @param bool $in_same_term Whether post should be in a same taxonomy term. 1526 * @param array $excluded_terms Array of excluded term IDs. 1527 */ 1192 1528 $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms ); 1529 1530 /** 1531 * Filter the WHERE clause in the SQL for an adjacent post query. 1532 * 1533 * The dynamic portion of the hook name, $adjacent, refers to the type 1534 * of adjacency, 'next' or 'previous'. 1535 * 1536 * @since 2.5.0 1537 * 1538 * @param string $where The WHERE clause in the SQL. 1539 * @param bool $in_same_term Whether post should be in a same taxonomy term. 1540 * @param array $excluded_terms Array of excluded term IDs. 1541 */ 1193 1542 $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 ); 1543 1544 /** 1545 * Filter the ORDER BY clause in the SQL for an adjacent post query. 1546 * 1547 * The dynamic portion of the hook name, $adjacent, refers to the type 1548 * of adjacency, 'next' or 'previous'. 1549 * 1550 * @since 2.5.0 1551 * 1552 * @param string $order_by The ORDER BY clause in the SQL. 1553 */ 1194 1554 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); 1195 1555 1196 1556 $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort"; … … 1252 1612 $link .= "' href='" . get_permalink( $post ) . "' />\n"; 1253 1613 1254 1614 $adjacent = $previous ? 'previous' : 'next'; 1615 1616 /** 1617 * Filter the adjacent post relational link. 1618 * 1619 * The dynamic portion of the hook name, $adjacent, refers to the type 1620 * of adjacency, 'next' or 'previous'. 1621 * 1622 * @since 2.8.0 1623 * 1624 * @param string $link The relational link. 1625 */ 1255 1626 return apply_filters( "{$adjacent}_post_rel_link", $link ); 1256 1627 } 1257 1628 … … 1464 1835 1465 1836 /** This filter is documented in wp-includes/post-template.php */ 1466 1837 $title = apply_filters( 'the_title', $title, $post->ID ); 1838 1467 1839 $date = mysql2date( get_option( 'date_format' ), $post->post_date ); 1468 1840 $rel = $previous ? 'prev' : 'next'; 1469 1841 … … 1477 1849 1478 1850 $adjacent = $previous ? 'previous' : 'next'; 1479 1851 1852 /** 1853 * Filter the adjacent post link. 1854 * 1855 * The dynamic portion of the hook name, $adjacent, refers to the type 1856 * of adjacency, 'next' or 'previous'. 1857 * 1858 * @since 2.6.0 1859 * 1860 * @param string $output The adjacent post link. 1861 * @param string $format Link anchor format. 1862 * @param string $link Link permalink format. 1863 * @param WP_Post $post The adjacent post. 1864 */ 1480 1865 return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post ); 1481 1866 } 1482 1867 … … 1559 1944 $result = $base . $request . $query_string; 1560 1945 } 1561 1946 1562 $result = apply_filters('get_pagenum_link', $result); 1947 /** 1948 * Filter the page number link for the current request. 1949 * 1950 * @since 2.5.0 1951 * 1952 * @param string $result The page number link. 1953 */ 1954 $result = apply_filters( 'get_pagenum_link', $result ); 1563 1955 1564 1956 if ( $escape ) 1565 1957 return esc_url( $result ); … … 1630 2022 $label = __( 'Next Page »' ); 1631 2023 1632 2024 if ( !is_single() && ( $nextpage <= $max_page ) ) { 2025 /** 2026 * Filter the anchor tag attributes for the next posts page link. 2027 * 2028 * @since 2.7.0 2029 * 2030 * @param string $attributes Attributes for the anchor tag. 2031 */ 1633 2032 $attr = apply_filters( 'next_posts_link_attributes', '' ); 2033 1634 2034 return '<a href="' . next_posts( $max_page, false ) . "\" $attr>" . preg_replace('/&([^#])(?![a-z]{1,8};)/i', '&$1', $label) . '</a>'; 1635 2035 } 1636 2036 } … … 1701 2101 $label = __( '« Previous Page' ); 1702 2102 1703 2103 if ( !is_single() && $paged > 1 ) { 2104 /** 2105 * Filter the anchor tag attributes for the previous posts page link. 2106 * 2107 * @since 2.7.0 2108 * 2109 * @param string $attributes Attributes for the anchor tag. 2110 */ 1704 2111 $attr = apply_filters( 'previous_posts_link_attributes', '' ); 1705 2112 return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&$1', $label ) .'</a>'; 1706 2113 } … … 1802 2209 1803 2210 $result .= '#comments'; 1804 2211 1805 $result = apply_filters('get_comments_pagenum_link', $result); 2212 /** 2213 * Filter the comments page number link for the current request. 2214 * 2215 * @since 2.7.0 2216 * 2217 * @param string $result The comments page number link. 2218 */ 2219 $result = apply_filters( 'get_comments_pagenum_link', $result ); 1806 2220 1807 2221 return $result; 1808 2222 } … … 1838 2252 if ( empty($label) ) 1839 2253 $label = __('Newer Comments »'); 1840 2254 2255 /** 2256 * Filter the anchor tag attributes for the next comments page link. 2257 * 2258 * @since 2.7.0 2259 * 2260 * @param string $attributes Attributes for the anchor tag. 2261 */ 1841 2262 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 2263 } 1843 2264 … … 1875 2296 if ( empty($label) ) 1876 2297 $label = __('« Older Comments'); 1877 2298 2299 /** 2300 * Filter the anchor tag attributes for the previous comments page link. 2301 * 2302 * @since 2.7.0 2303 * 2304 * @param string $attributes Attributes for the anchor tag. 2305 */ 1878 2306 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 2307 } 1880 2308 … … 1956 2384 1957 2385 $link = str_replace(array("\r", "\n", "\t"), '', $link); 1958 2386 1959 return apply_filters('shortcut_link', $link); 2387 /** 2388 * Filter the Press This bookmarklet link. 2389 * 2390 * @since 2.6.0 2391 * 2392 * @param string $link The Press This bookmarklet link. 2393 */ 2394 return apply_filters( 'shortcut_link', $link ); 1960 2395 } 1961 2396 1962 2397 /** … … 2015 2450 if ( $path && is_string( $path ) ) 2016 2451 $url .= '/' . ltrim( $path, '/' ); 2017 2452 2453 /** 2454 * Filter the home URL. 2455 * 2456 * @since 3.0.0 2457 * 2458 * @param string $url The complete home URL including scheme and path. 2459 * @param string $path Path relative to the home URL. Blank string if no path is specified. 2460 * @param string|null $orig_scheme Scheme to give the home URL context. Accepts 'http', 'https', 'relative' or null. 2461 * @param int|null $blog_id Blog ID, or null for the current blog. 2462 */ 2018 2463 return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id ); 2019 2464 } 2020 2465 … … 2025 2470 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is 2026 2471 * overridden. 2027 2472 * 2028 * @since 2.6.02473 * @since 3.0.0 2029 2474 * 2030 2475 * @uses get_site_url() 2031 2476 * … … 2065 2510 if ( $path && is_string( $path ) ) 2066 2511 $url .= '/' . ltrim( $path, '/' ); 2067 2512 2513 /** 2514 * Filter the site URL. 2515 * 2516 * @since 2.7.0 2517 * 2518 * @param string $url The complete site URL including scheme and path. 2519 * @param string $path Path relative to the site URL. Blank string if no path is specified. 2520 * @param string|null $scheme Scheme to give the site URL context. Accepts 'http', 'https', 'login', 2521 * 'login_post', 'admin', 'relative' or null. 2522 * @param int|null $blog_id Blog ID, or null for the current blog. 2523 */ 2068 2524 return apply_filters( 'site_url', $url, $path, $scheme, $blog_id ); 2069 2525 } 2070 2526 … … 2097 2553 if ( $path && is_string( $path ) ) 2098 2554 $url .= ltrim( $path, '/' ); 2099 2555 2556 /** 2557 * Filter the admin area URL. 2558 * 2559 * @since 2.8.0 2560 * 2561 * @param string $url The complete admin area URL including scheme and path. 2562 * @param string $path Path relative to the admin area URL. Blank string if no path is specified. 2563 * @param int|null $blog_id Blog ID, or null for the current blog. 2564 */ 2100 2565 return apply_filters( 'admin_url', $url, $path, $blog_id ); 2101 2566 } 2102 2567 … … 2115 2580 if ( $path && is_string( $path ) ) 2116 2581 $url .= ltrim($path, '/'); 2117 2582 2118 return apply_filters('includes_url', $url, $path); 2583 /** 2584 * Filter the URL to the includes directory. 2585 * 2586 * @since 2.8.0 2587 * 2588 * @param string $url The complete URL to the includes directory including scheme and path. 2589 * @param string $path Path relative to the URL to the wp-includes directory. Blank string 2590 * if no path is specified. 2591 */ 2592 return apply_filters( 'includes_url', $url, $path ); 2119 2593 } 2120 2594 2121 2595 /** … … 2132 2606 if ( $path && is_string( $path ) ) 2133 2607 $url .= '/' . ltrim($path, '/'); 2134 2608 2135 return apply_filters('content_url', $url, $path); 2609 /** 2610 * Filter the URL to the content directory. 2611 * 2612 * @since 2.8.0 2613 * 2614 * @param string $url The complete URL to the content directory including scheme and path. 2615 * @param string $path Path relative to the URL to the content directory. Blank string 2616 * if no path is specified. 2617 */ 2618 return apply_filters( 'content_url', $url, $path); 2136 2619 } 2137 2620 2138 2621 /** … … 2170 2653 if ( $path && is_string( $path ) ) 2171 2654 $url .= '/' . ltrim($path, '/'); 2172 2655 2173 return apply_filters('plugins_url', $url, $path, $plugin); 2656 /** 2657 * Filter the URL to the plugins directory. 2658 * 2659 * @since 2.8.0 2660 * 2661 * @param string $url The complete URL to the plugins directory including scheme and path. 2662 * @param string $path Path relative to the URL to the plugins directory. Blank string 2663 * if no path is specified. 2664 * @param string $plugin The plugin file path to be relative to. Blank string if no plugin 2665 * is specified. 2666 */ 2667 return apply_filters( 'plugins_url', $url, $path, $plugin ); 2174 2668 } 2175 2669 2176 2670 /** … … 2200 2694 if ( $path && is_string( $path ) ) 2201 2695 $url .= ltrim( $path, '/' ); 2202 2696 2697 /** 2698 * Filter the network site URL. 2699 * 2700 * @since 3.0.0 2701 * 2702 * @param string $url The complete network site URL including scheme and path. 2703 * @param string $path Path relative to the network site URL. Blank string if 2704 * no path is specified. 2705 * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https', 2706 * 'relative' or null. 2707 */ 2203 2708 return apply_filters( 'network_site_url', $url, $path, $scheme ); 2204 2709 } 2205 2710 … … 2234 2739 if ( $path && is_string( $path ) ) 2235 2740 $url .= ltrim( $path, '/' ); 2236 2741 2742 /** 2743 * Filter the network home URL. 2744 * 2745 * @since 3.0.0 2746 * 2747 * @param string $url The complete network home URL including scheme and path. 2748 * @param string $path Path relative to the network home URL. Blank string 2749 * if no path is specified. 2750 * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https', 2751 * 'relative' or null. 2752 */ 2237 2753 return apply_filters( 'network_home_url', $url, $path, $orig_scheme); 2238 2754 } 2239 2755 … … 2255 2771 if ( $path && is_string( $path ) ) 2256 2772 $url .= ltrim($path, '/'); 2257 2773 2258 return apply_filters('network_admin_url', $url, $path); 2774 /** 2775 * Filter the network admin URL. 2776 * 2777 * @since 3.0.0 2778 * 2779 * @param string $url The complete network admin URL including scheme and path. 2780 * @param string $path Path relative to the network admin URL. Blank string if 2781 * no path is specified. 2782 */ 2783 return apply_filters( 'network_admin_url', $url, $path ); 2259 2784 } 2260 2785 2261 2786 /** … … 2273 2798 if ( $path && is_string( $path ) ) 2274 2799 $url .= ltrim($path, '/'); 2275 2800 2276 return apply_filters('user_admin_url', $url, $path); 2801 /** 2802 * Filter the user admin URL for the current user. 2803 * 2804 * @since 3.1.0 2805 * 2806 * @param string $url The complete URL including scheme and path. 2807 * @param string $path Path relative to the URL. Blank string if 2808 * no path is specified. 2809 */ 2810 return apply_filters( 'user_admin_url', $url, $path ); 2277 2811 } 2278 2812 2279 2813 /** … … 2328 2862 $url = preg_replace( '#^\w+://#', $scheme . '://', $url ); 2329 2863 } 2330 2864 2865 /** 2866 * Filter the resulting URL after setting the scheme. 2867 * 2868 * @since 3.4.0 2869 * 2870 * @param string $url The complete URL including scheme and path. 2871 * @param string $scheme Scheme applied to the URL. One of 'http', 'https', or 'relative'. 2872 * @param string $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login', 2873 * 'login_post', 'admin', 'rpc', or 'relative'. 2874 */ 2331 2875 return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme ); 2332 2876 } 2333 2877 … … 2366 2910 } 2367 2911 } 2368 2912 2913 /** 2914 * Filter the dashboard URL for a user. 2915 * 2916 * @since 3.1.0 2917 * 2918 * @param string $url The complete URL including scheme and path. 2919 * @param int $user_id The user ID. 2920 * @param string $path Path relative to the URL. Blank string if no path is specified. 2921 * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', 2922 * 'login_post', 'admin', 'relative' or null. 2923 */ 2369 2924 return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme); 2370 2925 } 2371 2926 … … 2389 2944 else 2390 2945 $url = get_dashboard_url( $user_id, 'profile.php', $scheme ); 2391 2946 2947 /** 2948 * Filter the URL for a user's profile editor. 2949 * 2950 * @since 3.1.0 2951 * 2952 * @param string $url The complete URL including scheme and path. 2953 * @param int $user_id The user ID. 2954 * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', 2955 * 'login_post', 'admin', 'relative' or null. 2956 */ 2392 2957 return apply_filters( 'edit_profile_url', $url, $user_id, $scheme); 2393 2958 } 2394 2959 … … 2429 2994 * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks are not enabled. 2430 2995 */ 2431 2996 function wp_get_shortlink($id = 0, $context = 'post', $allow_slugs = true) { 2432 // Allow plugins to short-circuit this function. 2433 $shortlink = apply_filters('pre_get_shortlink', false, $id, $context, $allow_slugs); 2997 /** 2998 * Filter whether to preempt generating a shortlink for the given post. 2999 * 3000 * Passing a truthy value to the filter will effectively short-circuit the 3001 * shortlink-generation process, returning that value instead. 3002 * 3003 * @since 3.0.0 3004 * 3005 * @param bool|string $return Short-circuit return value. Either false or a URL string. 3006 * @param int $id Post ID, or 0 for the current post. 3007 * @param string $context The context for the link. One of 'post' or 'query', 3008 * @param bool $allow_slugs Whether to allow post slugs in the shortlink. 3009 */ 3010 $shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs ); 3011 2434 3012 if ( false !== $shortlink ) 2435 3013 return $shortlink; 2436 3014 … … 2458 3036 } 2459 3037 } 2460 3038 2461 return apply_filters('get_shortlink', $shortlink, $id, $context, $allow_slugs); 3039 /** 3040 * Filter the shortlink for a post. 3041 * 3042 * @since 3.0.0 3043 * 3044 * @param string $shortlink Shortlink URL. 3045 * @param int $id Post ID, or 0 for the current post. 3046 * @param string $context The context for the link. One of 'post' or 'query', 3047 * @param bool $allow_slugs Whether to allow post slugs in the shortlink. Not used by default. 3048 */ 3049 return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs ); 2462 3050 } 2463 3051 2464 3052 /** … … 2527 3115 2528 3116 if ( !empty( $shortlink ) ) { 2529 3117 $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; 3118 3119 /** 3120 * Filter the shortlink anchor tag for a post. 3121 * 3122 * @since 3.0.0 3123 * 3124 * @param string $link Shortlink anchor tag. 3125 * @param string $shortlink Shortlink URL. 3126 * @param string $text Shortlink's text. 3127 * @param string $title Shortlink's title attribute. 3128 */ 2530 3129 $link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title ); 2531 3130 echo $before, $link, $after; 2532 3131 }