Ticket #25621: post-template.diff
File post-template.diff, 12.3 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 prepend the post title of protected posts. 112 * 113 * @since 2.8.0 114 * 115 * By default, this filter returns 'Protected: %s', where %s specifier is replaced with post title. 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 prepend the post title of private posts. 122 * 123 * @since 2.8.0 124 * 125 * By default, this filter returns 'Private: %s', where %s specifier is replaced with post title. 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 /** … … 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 Link text of the Read More link. 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 } … … 251 294 * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt. 252 295 */ 253 296 function the_excerpt() { 254 echo apply_filters( 'the_excerpt', get_the_excerpt());297 echo apply_filters( 'the_excerpt', get_the_excerpt() ); 255 298 } 256 299 257 300 /** … … 272 315 return __( 'There is no excerpt because this is a protected post.' ); 273 316 } 274 317 318 /** 319 * Filter the retrieved post excerpt. 320 * 321 * @since 1.5.2 322 * 323 * @param string $post->post_excerpt The post excerpt. 324 */ 275 325 return apply_filters( 'get_the_excerpt', $post->post_excerpt ); 276 326 } 277 327 … … 379 429 380 430 $classes = array_map('esc_attr', $classes); 381 431 382 return apply_filters('post_class', $classes, $class, $post->ID); 432 /** 433 * Filter the returned CSS classes for the current post. 434 * 435 * @since 2.7.0 436 * 437 * @param array $classes An array of post classes. 438 * @param string $class A comma-separated list of additional classes added to the post. 439 * @param int $post->ID The post ID. 440 */ 441 return apply_filters( 'post_class', $classes, $class, $post->ID ); 383 442 } 384 443 385 444 /** … … 563 622 564 623 $classes = array_map( 'esc_attr', $classes ); 565 624 625 /** 626 * Filter the returned CSS classes for the body of current post or page. 627 * 628 * @since 2.7.0 629 * 630 * @param array $classes An array of body classes. 631 * @param string $class A comma-separated list of additional classes added to the body. 632 */ 566 633 return apply_filters( 'body_class', $classes, $class ); 567 634 } 568 635 … … 650 717 ); 651 718 652 719 $r = wp_parse_args( $args, $defaults ); 720 /** 721 * Filter the arguments used in retrieving page links for paginated posts 722 * 723 * @since 3.0.0 724 * 725 * @param array $r Overwrite the output format defaults. 726 */ 653 727 $r = apply_filters( 'wp_link_pages_args', $r ); 654 728 extract( $r, EXTR_SKIP ); 655 729 … … 663 737 $link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after; 664 738 if ( $i != $page || ! $more && 1 == $page ) 665 739 $link = _wp_link_page( $i ) . $link . '</a>'; 740 /** 741 * Filter the HTML output of individual page number links, in paginated posts' page links. 742 * 743 * @since 3.6.0 744 * 745 * @param string $link 746 * @param int $i Page number for paginated posts' page links. 747 */ 666 748 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 667 749 $output .= $separator . $link; 668 750 } … … 672 754 $i = $page - 1; 673 755 if ( $i ) { 674 756 $link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>'; 757 //duplicate_hook 675 758 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 676 759 $output .= $separator . $link; 677 760 } 678 761 $i = $page + 1; 679 762 if ( $i <= $numpages ) { 680 763 $link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>'; 764 //duplicate_hook 681 765 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 682 766 $output .= $separator . $link; 683 767 } … … 685 769 } 686 770 } 687 771 772 /** 773 * Filter the HTML output of page-links for paginated posts. 774 * 775 * @since 3.6.0 776 * 777 * @param string $output HTML output of paginated posts' page-links. 778 * @param array $args Arguments. 779 */ 688 780 $output = apply_filters( 'wp_link_pages', $output, $args ); 689 781 690 782 if ( $echo ) … … 759 851 continue; 760 852 $values = array_map('trim', get_post_custom_values($key)); 761 853 $value = implode($values,', '); 762 echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); 854 /** 855 * Filter the list item HTML content of, display 856 * Filter the output of custom fields meta-data of current post. 857 * 858 * @since 2.2.0 859 * 860 * @param string $key Key of the meta-data. 861 * @param string $value Value of the meta-data. 862 */ 863 echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value ); 763 864 } 764 865 echo "</ul>\n"; 765 866 } … … 805 906 $output .= "</select>\n"; 806 907 } 807 908 808 $output = apply_filters('wp_dropdown_pages', $output); 909 /** 910 * Filters the output of list of pages as dropdown (select list). 911 * 912 * @since 2.1.0 913 * 914 * @param string $output HTML dropdown list of pages. 915 */ 916 $output = apply_filters( 'wp_dropdown_pages', $output ); 809 917 810 918 if ( $echo ) 811 919 echo $output; … … 842 950 843 951 // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) 844 952 $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array(); 845 $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) ); 953 /** 954 * Filter an array of excluded pages for wp_list_pages(). 955 * 956 * @since 2.1.0 957 * 958 * @param array $exclude_array Array of Page IDs to exclude from wp_list_pages() output. 959 */ 960 $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); 846 961 847 962 // Query pages. 848 963 $r['hierarchical'] = 0; … … 861 976 $output .= '</ul></li>'; 862 977 } 863 978 864 $output = apply_filters('wp_list_pages', $output, $r); 979 /** 980 * Filter wp_list_pages. 981 * 982 * @since 1.5.2 983 * 984 * @param string $output HTML output of the pages list. 985 * @param array $r Array of arguments. @see wp_list_pages() 986 */ 987 $output = apply_filters( 'wp_list_pages', $output, $r ); 865 988 866 989 if ( $r['echo'] ) 867 990 echo $output; … … 898 1021 function wp_page_menu( $args = array() ) { 899 1022 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 900 1023 $args = wp_parse_args( $args, $defaults ); 1024 /** 1025 * Filter the arguments passed to wp_page_menu(). 1026 * 1027 * @since 2.7.0 1028 * 1029 * @param array $args An array of arguments. @see wp_page_menu() 1030 */ 901 1031 $args = apply_filters( 'wp_page_menu_args', $args ); 902 1032 903 1033 $menu = ''; … … 933 1063 $menu = '<ul>' . $menu . '</ul>'; 934 1064 935 1065 $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; 1066 /** 1067 * Filter the output and arguments of wp_page_menu(). 1068 * 1069 * @since 2.7.0 1070 * 1071 * @param string $menu HTML output. 1072 * @param array $args An array of arguments. @see wp_page_menu() 1073 */ 936 1074 $menu = apply_filters( 'wp_page_menu', $menu, $args ); 937 1075 if ( $args['echo'] ) 938 1076 echo $menu; … … 1066 1204 $css_class[] = 'current_page_parent'; 1067 1205 } 1068 1206 1207 /** 1208 * Filters CSS classes applied to each list items of page list created by wp_list_pages(). 1209 * 1210 * @since 2.8.0 1211 * 1212 * @param array $css_class An array of CSS classes to be applied to each list item. 1213 * @param object $page Page data object. 1214 * @param int $depth Depth of page, used for padding. 1215 * @param array $args An array of arguments. 1216 * @param int $current_page Page ID. 1217 */ 1069 1218 $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); 1070 1219 1071 1220 if ( '' === $page->post_title ) 1072 1221 $page->post_title = sprintf( __( '#%d (no title)' ), $page->ID ); 1073 1222 1223 //duplicate_hook 1074 1224 $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>'; 1075 1225 1076 1226 if ( !empty($show_date) ) { … … 1138 1288 if ( $page->ID == $args['selected'] ) 1139 1289 $output .= ' selected="selected"'; 1140 1290 $output .= '>'; 1291 /** 1292 * Filters Page title of page list, retrieved by Walker::start_el(), used when creating HTML dropdown list of pages. 1293 * 1294 * @since 3.1.0 1295 * 1296 * @param string $page->post_title Page title. 1297 * @param object $page Page data object. 1298 */ 1141 1299 $title = apply_filters( 'list_pages', $page->post_title, $page ); 1142 1300 $output .= $pad . esc_html( $title ); 1143 1301 $output .= "</option>\n"; … … 1181 1339 * @param string|bool $text Optional, default is false. If string, then will be link text. 1182 1340 * @return string HTML content. 1183 1341 */ 1184 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {1342 function apply( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) { 1185 1343 $id = intval( $id ); 1186 1344 $_post = get_post( $id ); 1187 1345 … … 1203 1361 if ( trim( $link_text ) == '' ) 1204 1362 $link_text = $_post->post_title; 1205 1363 1364 /** 1365 * Filters a retrieved attachment page link 1366 * 1367 * @since 2.7.0 1368 * 1369 * @param int $id Post ID. 1370 * @param string $size Size of an image, either array or string. Default is 'thumbnail'. 1371 * @param bool $permalink Whether to add permalink to image. Default is false. 1372 * @param bool $icon Whether to include an icon. Default is false. 1373 * @param string|bool $text If string, then will be link text. Default is false. 1374 */ 1206 1375 return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text ); 1207 1376 } 1208 1377 … … 1225 1394 // show the medium sized image representation of the attachment if available, and link to the raw file 1226 1395 $p .= wp_get_attachment_link(0, 'medium', false); 1227 1396 $p .= '</p>'; 1228 $p = apply_filters('prepend_attachment', $p); 1397 /** 1398 * Filters HTML output of attachment link with medium sized representation, wrapped with <p class="attachment"> attribute. 1399 * 1400 * @since 2.0.0 1401 * 1402 * @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. 1403 */ 1404 $p = apply_filters( 'prepend_attachment', $p ); 1229 1405 1230 1406 return "$p\n$content"; 1231 1407 } … … 1250 1426 <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> 1251 1427 </form> 1252 1428 '; 1429 /** 1430 * Filter the output of protected post password form. 1431 * 1432 * @since 2.7.0 1433 * 1434 * @param string $output HTML output of protected post password form. 1435 */ 1253 1436 return apply_filters( 'the_password_form', $output ); 1254 1437 } 1255 1438