Ticket #25621: post-template.2.diff
File post-template.2.diff, 13.7 KB (added by , 10 years ago) |
---|
-
src/wp-includes/post-template.php
107 107 108 108 if ( ! is_admin() ) { 109 109 if ( ! empty( $post->post_password ) ) { 110 /** 111 * Filter the text which prepends the post title of protected posts. 112 * 113 * By default, this filter returns 'Protected: %s', where %s specifier is replaced with post title. This filter only apply on the front-end. 114 * 115 * @since 2.8.0 116 */ 110 117 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 111 118 $title = sprintf( $protected_title_format, $title ); 112 119 } else if ( isset( $post->post_status ) && 'private' == $post->post_status ) { 120 /** 121 * Filter the text which prepends the post title of private posts. 122 * 123 * By default, this filter returns 'Private: %s', where %s specifier is replaced with post title. This filter only apply on the front-end. 124 * 125 * @since 2.8.0 126 */ 113 127 $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) ); 114 128 $title = sprintf( $private_title_format, $title ); 115 129 } 116 130 } 117 131 132 /** 133 * Filter the post title. 134 * 135 * @since 1.2.1 136 * 137 * @param string $title Post title. 138 * @param int $id Post ID. 139 */ 118 140 return apply_filters( 'the_title', $title, $id ); 119 141 } 120 142 … … 150 172 function get_the_guid( $id = 0 ) { 151 173 $post = get_post($id); 152 174 153 return apply_filters('get_the_guid', $post->guid); 175 /** 176 * Filter the Global Unique Identifier (guid) of the post. 177 * 178 * @since 1.5.2 179 * 180 * @param string $post_guid Global Unique Identifier (guid) of the post. 181 */ 182 return apply_filters( 'get_the_guid', $post->guid ); 154 183 } 155 184 156 185 /** … … 159 188 * @since 0.71 160 189 * 161 190 * @param string $more_link_text Optional. Content for when there is more text. 162 * @param bool $strip_teaserOptional. Strip teaser content before the more text. Default is false.191 * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. 163 192 */ 164 193 function the_content( $more_link_text = null, $strip_teaser = false) { 165 194 $content = get_the_content( $more_link_text, $strip_teaser ); 195 /** 196 * Filter the post content. 197 * 198 * @since 1.2.1 199 * 200 * @param string $content Content of the current post. 201 */ 166 202 $content = apply_filters( 'the_content', $content ); 167 203 $content = str_replace( ']]>', ']]>', $content ); 168 204 echo $content; … … 221 257 $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1]; 222 258 } else { 223 259 if ( ! empty( $more_link_text ) ) 260 /** 261 * Filter the Read More link. 262 * 263 * @since 2.8.0 264 * 265 * @param string $more_link_text Read More link element. 266 */ 224 267 $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); 225 268 $output = force_balance_tags( $output ); 226 269 } … … 248 291 * Display the post excerpt. 249 292 * 250 293 * @since 0.71 294 * 251 295 * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt. 252 296 */ 253 297 function the_excerpt() { 254 echo apply_filters( 'the_excerpt', get_the_excerpt());298 echo apply_filters( 'the_excerpt', get_the_excerpt() ); 255 299 } 256 300 257 301 /** … … 272 316 return __( 'There is no excerpt because this is a protected post.' ); 273 317 } 274 318 319 /** 320 * Filter the post excerpt. 321 * 322 * @since 1.5.2 323 * 324 * @param string $post_excerpt Post excerpt. 325 */ 275 326 return apply_filters( 'get_the_excerpt', $post->post_excerpt ); 276 327 } 277 328 … … 379 430 380 431 $classes = array_map('esc_attr', $classes); 381 432 382 return apply_filters('post_class', $classes, $class, $post->ID); 433 /** 434 * Filter the CSS classes for the current post. 435 * 436 * @since 2.7.0 437 * 438 * @param array $classes An array of post classes. 439 * @param string $class A comma-separated list of additional classes added to the post. 440 * @param int $post_id Post ID. 441 */ 442 return apply_filters( 'post_class', $classes, $class, $post->ID ); 383 443 } 384 444 385 445 /** … … 563 623 564 624 $classes = array_map( 'esc_attr', $classes ); 565 625 626 /** 627 * Filter the returned CSS classes for the body of current post or page. 628 * 629 * @since 2.7.0 630 * 631 * @param array $classes An array of body classes. 632 * @param string $class A comma-separated list of additional classes added to the body. 633 */ 566 634 return apply_filters( 'body_class', $classes, $class ); 567 635 } 568 636 … … 650 718 ); 651 719 652 720 $r = wp_parse_args( $args, $defaults ); 721 /** 722 * Filter the arguments used in retrieving page links for paginated posts 723 * 724 * @since 3.0.0 725 * 726 * @param array $r Overwrite the output format defaults. 727 */ 653 728 $r = apply_filters( 'wp_link_pages_args', $r ); 654 729 extract( $r, EXTR_SKIP ); 655 730 … … 663 738 $link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after; 664 739 if ( $i != $page || ! $more && 1 == $page ) 665 740 $link = _wp_link_page( $i ) . $link . '</a>'; 741 /** 742 * Filter the HTML output of individual page number links, in paginated posts' page links. 743 * 744 * @since 3.6.0 745 * 746 * @param string $link 747 * @param int $i Page number for paginated posts' page links. 748 */ 666 749 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 667 750 $output .= $separator . $link; 668 751 } … … 672 755 $i = $page - 1; 673 756 if ( $i ) { 674 757 $link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>'; 758 /** This filter is documented in wp-includes/post-template.php */ 675 759 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 676 760 $output .= $separator . $link; 677 761 } 678 762 $i = $page + 1; 679 763 if ( $i <= $numpages ) { 680 764 $link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>'; 765 /** This filter is documented in wp-includes/post-template.php */ 681 766 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 682 767 $output .= $separator . $link; 683 768 } … … 685 770 } 686 771 } 687 772 773 /** 774 * Filter the HTML output of page-links for paginated posts. 775 * 776 * @since 3.6.0 777 * 778 * @param string $output HTML output of paginated posts' page-links. 779 * @param array $args Arguments. 780 */ 688 781 $output = apply_filters( 'wp_link_pages', $output, $args ); 689 782 690 783 if ( $echo ) … … 759 852 continue; 760 853 $values = array_map('trim', get_post_custom_values($key)); 761 854 $value = implode($values,', '); 762 echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); 855 /** 856 * Filter the HTML output of post custom fields list. 857 * 858 * This filters each li element of post custom fields list, which is an output of the_meta() function. Function the_meta() output in unordered list format. 859 * 860 * The default format: 861 * 862 * <li><span class='post-meta-key'>$key:</span> $value</li>\n 863 * 864 * @since 2.2.0 865 * 866 * @param string $key Key of the meta-data. 867 * @param string $value Value of the meta-data. 868 */ 869 echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value ); 763 870 } 764 871 echo "</ul>\n"; 765 872 } … … 805 912 $output .= "</select>\n"; 806 913 } 807 914 808 $output = apply_filters('wp_dropdown_pages', $output); 915 /** 916 * Filters the output of list of pages as dropdown (select list). 917 * 918 * @since 2.1.0 919 * 920 * @param string $output HTML dropdown list of pages. 921 */ 922 $output = apply_filters( 'wp_dropdown_pages', $output ); 809 923 810 924 if ( $echo ) 811 925 echo $output; … … 842 956 843 957 // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) 844 958 $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array(); 845 $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) ); 959 /** 960 * Filter an array of excluded pages for wp_list_pages(). 961 * 962 * @since 2.1.0 963 * 964 * @param array $exclude_array Array of Page IDs to exclude from wp_list_pages() output. 965 */ 966 $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); 846 967 847 968 // Query pages. 848 969 $r['hierarchical'] = 0; … … 861 982 $output .= '</ul></li>'; 862 983 } 863 984 864 $output = apply_filters('wp_list_pages', $output, $r); 985 /** 986 * Filters the HTML output of the link list of WordPress Pages. 987 * 988 * Function wp_list_pages() displays a list of WordPress Pages as a link list. Filter wp_list_pages filters HTML output of this function wp_list_pages(). 989 * 990 * @since 1.5.2 991 * 992 * @param string $output HTML output of the pages list. 993 * @param array $r Array of arguments { 994 * @see wp_list_pages() 995 * } 996 */ 997 $output = apply_filters( 'wp_list_pages', $output, $r ); 865 998 866 999 if ( $r['echo'] ) 867 1000 echo $output; … … 898 1031 function wp_page_menu( $args = array() ) { 899 1032 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 900 1033 $args = wp_parse_args( $args, $defaults ); 1034 /** 1035 * Filter the arguments passed to wp_page_menu(). 1036 * 1037 * @since 2.7.0 1038 * 1039 * @param array $args An array of arguments { 1040 * @see wp_page_menu() 1041 * } 1042 */ 901 1043 $args = apply_filters( 'wp_page_menu_args', $args ); 902 1044 903 1045 $menu = ''; … … 933 1075 $menu = '<ul>' . $menu . '</ul>'; 934 1076 935 1077 $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; 1078 /** 1079 * Filter the output and arguments of wp_page_menu(). 1080 * 1081 * @since 2.7.0 1082 * 1083 * @param string $menu HTML output. 1084 * @param array $args An array of arguments { 1085 * @see wp_page_menu() 1086 * } 1087 */ 936 1088 $menu = apply_filters( 'wp_page_menu', $menu, $args ); 937 1089 if ( $args['echo'] ) 938 1090 echo $menu; … … 1066 1218 $css_class[] = 'current_page_parent'; 1067 1219 } 1068 1220 1221 /** 1222 * Filters the class attribute of li element in a list of WordPress Pages. 1223 * 1224 * Function wp_list_pages() displays a list of WordPress pages as a nested unordered link list, by default. Each li element has one or more classes applied. page_css_class filters these classes applied to each li elements. 1225 * 1226 * @since 2.8.0 1227 * 1228 * @param array $css_class An array of CSS classes to be applied to each list item. 1229 * @param object $page Page data object. 1230 * @param int $depth Depth of page, used for padding. 1231 * @param array $args An array of arguments. 1232 * @param int $current_page Page ID. 1233 */ 1069 1234 $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); 1070 1235 1071 1236 if ( '' === $page->post_title ) 1072 1237 $page->post_title = sprintf( __( '#%d (no title)' ), $page->ID ); 1073 1238 1074 1239 /** This filter is documented in wp-includes/post-template.php */ 1075 1240 $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . apply_filters( 'the_title', $page->post_title, $page->ID ) . $link_after . '</a>'; 1076 1241 … … 1139 1304 if ( $page->ID == $args['selected'] ) 1140 1305 $output .= ' selected="selected"'; 1141 1306 $output .= '>'; 1307 /** 1308 * Filters Page title of page list, retrieved by Walker::start_el(), used when creating HTML dropdown list of pages. 1309 * 1310 * @since 3.1.0 1311 * 1312 * @param string $page->post_title Page title. 1313 * @param object $page Page data object. 1314 */ 1142 1315 $title = apply_filters( 'list_pages', $page->post_title, $page ); 1143 1316 $output .= $pad . esc_html( $title ); 1144 1317 $output .= "</option>\n"; … … 1182 1355 * @param string|bool $text Optional, default is false. If string, then will be link text. 1183 1356 * @return string HTML content. 1184 1357 */ 1185 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {1358 function apply( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) { 1186 1359 $id = intval( $id ); 1187 1360 $_post = get_post( $id ); 1188 1361 … … 1204 1377 if ( trim( $link_text ) == '' ) 1205 1378 $link_text = $_post->post_title; 1206 1379 1380 /** 1381 * Filters a retrieved attachment page link. 1382 * 1383 * @since 2.7.0 1384 * 1385 * @param int $id Post ID. 1386 * @param string $size Size of an image, either array or string. Default is 'thumbnail'. 1387 * @param bool $permalink Whether to add permalink to image. Default is false. 1388 * @param bool $icon Whether to include an icon. Default is false. 1389 * @param string|bool $text If string, then will be link text. Default is false. 1390 */ 1207 1391 return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text ); 1208 1392 } 1209 1393 … … 1226 1410 // show the medium sized image representation of the attachment if available, and link to the raw file 1227 1411 $p .= wp_get_attachment_link(0, 'medium', false); 1228 1412 $p .= '</p>'; 1229 $p = apply_filters('prepend_attachment', $p); 1413 /** 1414 * Filter attachment markup to be prepended to post content. 1415 * 1416 * Function prepend_attachment() output attachment link with medium sized representation, wrapped with <p class="attachment"> attribute. Filter prepend_attachmnet filters this HTML output. 1417 * 1418 * @since 2.0.0 1419 * 1420 * @param string $p HTML output containing medium sized image representation of the attachment with a link to the raw file, wrapped with <p class="attachment"> attribute. 1421 */ 1422 $p = apply_filters( 'prepend_attachment', $p ); 1230 1423 1231 1424 return "$p\n$content"; 1232 1425 } … … 1251 1444 <p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__( 'Submit' ) . '" /></p> 1252 1445 </form> 1253 1446 '; 1447 /** 1448 * Filter the output of protected post password form. 1449 * 1450 * @since 2.7.0 1451 * 1452 * @param string $output HTML output of protected post password form. 1453 */ 1254 1454 return apply_filters( 'the_password_form', $output ); 1255 1455 } 1256 1456