Ticket #25621: 25621.3.diff
File 25621.3.diff, 12.2 KB (added by , 7 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 for protected posts. 112 * 113 * This filter is only applied on the front end. 114 * 115 * @since 2.8.0 116 * 117 * @param string $prepend Text displayed before the post title. 118 * Default 'Protected: %s'. 119 */ 110 120 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 111 121 $title = sprintf( $protected_title_format, $title ); 112 122 } else if ( isset( $post->post_status ) && 'private' == $post->post_status ) { 123 /** 124 * Filter the text which prepends the post title of private posts. 125 * 126 * This filter is only applied on the front end. 127 * 128 * @since 2.8.0 129 * 130 * @param string $prepend Text displayed before the post title. 131 * Default 'Private: %s'. 132 */ 113 133 $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) ); 114 134 $title = sprintf( $private_title_format, $title ); 115 135 } 116 136 } 117 137 138 /** 139 * Filter the post title. 140 * 141 * @since 0.71 142 * 143 * @param string $title The post title. 144 * @param int $id The post ID. 145 */ 118 146 return apply_filters( 'the_title', $title, $id ); 119 147 } 120 148 … … 150 178 function get_the_guid( $id = 0 ) { 151 179 $post = get_post($id); 152 180 153 return apply_filters('get_the_guid', $post->guid); 181 /** 182 * Filter the Global Unique Identifier (guid) of the post. 183 * 184 * @since 1.5.0 185 * 186 * @param string $post_guid Global Unique Identifier (guid) of the post. 187 */ 188 return apply_filters( 'get_the_guid', $post->guid ); 154 189 } 155 190 156 191 /** … … 163 198 */ 164 199 function the_content( $more_link_text = null, $strip_teaser = false) { 165 200 $content = get_the_content( $more_link_text, $strip_teaser ); 201 202 /** 203 * Filter the post content. 204 * 205 * @since 0.71 206 * 207 * @param string $content Content of the current post. 208 */ 166 209 $content = apply_filters( 'the_content', $content ); 167 210 $content = str_replace( ']]>', ']]>', $content ); 168 211 echo $content; … … 221 264 $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1]; 222 265 } else { 223 266 if ( ! empty( $more_link_text ) ) 267 268 /** 269 * Filter the Read More link text. 270 * 271 * @since 2.8.0 272 * 273 * @param string $more_link_element Read More link element. 274 * @param string $more_link_text Read More text. 275 */ 224 276 $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 277 $output = force_balance_tags( $output ); 226 278 } … … 251 303 * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt. 252 304 */ 253 305 function the_excerpt() { 254 echo apply_filters('the_excerpt', get_the_excerpt()); 306 307 /** 308 * Filter the displayed post excerpt. 309 * 310 * @since 0.71 311 * 312 * @param string $post_excerpt The post excerpt. 313 */ 314 echo apply_filters( 'the_excerpt', get_the_excerpt() ); 255 315 } 256 316 257 317 /** … … 272 332 return __( 'There is no excerpt because this is a protected post.' ); 273 333 } 274 334 335 /** 336 * Filter the retrieved post excerpt. 337 * 338 * @since 1.2.0 339 * 340 * @param string $post_excerpt The post excerpt. 341 */ 275 342 return apply_filters( 'get_the_excerpt', $post->post_excerpt ); 276 343 } 277 344 … … 384 451 385 452 $classes = array_map('esc_attr', $classes); 386 453 387 return apply_filters('post_class', $classes, $class, $post->ID); 454 /** 455 * Filter the CSS classes for the current post. 456 * 457 * @since 2.7.0 458 * 459 * @param array $classes An array of post classes. 460 * @param string $class A comma-separated list of additional classes added to the post. 461 * @param int $post_id The post ID. 462 */ 463 return apply_filters( 'post_class', $classes, $class, $post->ID ); 388 464 } 389 465 390 466 /** … … 568 644 569 645 $classes = array_map( 'esc_attr', $classes ); 570 646 647 /** 648 * Filter the returned CSS classes for the body of the current post or page. 649 * 650 * @since 2.8.0 651 * 652 * @param array $classes An array of body classes. 653 * @param string $class A comma-separated list of additional classes added to the body. 654 */ 571 655 return apply_filters( 'body_class', $classes, $class ); 572 656 } 573 657 … … 652 736 ); 653 737 654 738 $r = wp_parse_args( $args, $defaults ); 739 740 /** 741 * Filter the arguments used in retrieving page links for paginated posts. 742 * 743 * @since 3.0.0 744 * 745 * @param array $r An array of output format arguments. 746 */ 655 747 $r = apply_filters( 'wp_link_pages_args', $r ); 656 748 extract( $r, EXTR_SKIP ); 657 749 … … 665 757 $link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after; 666 758 if ( $i != $page || ! $more && 1 == $page ) 667 759 $link = _wp_link_page( $i ) . $link . '</a>'; 760 761 /** 762 * Filter the HTML output of individual page number links. 763 * 764 * @since 3.6.0 765 * 766 * @param string $link The page number HTML output. 767 * @param int $i Page number for paginated posts' page links. 768 */ 668 769 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 669 770 $output .= $separator . $link; 670 771 } … … 674 775 $i = $page - 1; 675 776 if ( $i ) { 676 777 $link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>'; 778 779 /** This filter is documented in wp-includes/post-template.php */ 677 780 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 678 781 $output .= $separator . $link; 679 782 } … … 680 783 $i = $page + 1; 681 784 if ( $i <= $numpages ) { 682 785 $link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>'; 786 787 /** This filter is documented in wp-includes/post-template.php */ 683 788 $link = apply_filters( 'wp_link_pages_link', $link, $i ); 684 789 $output .= $separator . $link; 685 790 } … … 687 792 } 688 793 } 689 794 795 /** 796 * Filter the HTML output of page links for paginated posts. 797 * 798 * @since 3.6.0 799 * 800 * @param string $output HTML output of paginated posts' page links. 801 * @param array $args An array of arguments. 802 */ 690 803 $output = apply_filters( 'wp_link_pages', $output, $args ); 691 804 692 805 if ( $echo ) … … 774 887 continue; 775 888 $values = array_map('trim', get_post_custom_values($key)); 776 889 $value = implode($values,', '); 777 echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); 890 891 /** 892 * Filter the HTML output of the li element in the post custom fields list. 893 * 894 * @since 2.2.0 895 * 896 * @param string $html The HTML output for the li element. 897 * @param string $key The meta data key. 898 * @param string $value The meta data value. 899 */ 900 echo apply_filters( 'the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value ); 778 901 } 779 902 echo "</ul>\n"; 780 903 } … … 820 943 $output .= "</select>\n"; 821 944 } 822 945 823 $output = apply_filters('wp_dropdown_pages', $output); 946 /** 947 * Filter the HTML output of a list of pages as a drop down. 948 * 949 * @since 2.1.0 950 * 951 * @param string $output HTML output for drop down list of pages. 952 */ 953 $output = apply_filters( 'wp_dropdown_pages', $output ); 824 954 825 955 if ( $echo ) 826 956 echo $output; … … 857 987 858 988 // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) 859 989 $exclude_array = ( $r['exclude'] ) ? explode(',', $r['exclude']) : array(); 860 $r['exclude'] = implode( ',', apply_filters('wp_list_pages_excludes', $exclude_array) );861 990 991 /** 992 * Filter the array of excluded pages for wp_list_pages(). 993 * 994 * @since 2.1.0 995 * 996 * @param array $exclude_array An array of page IDs to exclude. 997 */ 998 $r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); 999 862 1000 // Query pages. 863 1001 $r['hierarchical'] = 0; 864 1002 $pages = get_pages($r); … … 876 1014 $output .= '</ul></li>'; 877 1015 } 878 1016 879 $output = apply_filters('wp_list_pages', $output, $r); 1017 /** 1018 * Filters the HTML output of the link list of WordPress pages. 1019 * 1020 * @since 1.5.1 1021 * 1022 * @see wp_list_pages() 1023 * 1024 * @param string $output HTML output of the pages list. 1025 * @param array $r An array of arguments. 1026 */ 1027 $output = apply_filters( 'wp_list_pages', $output, $r ); 880 1028 881 1029 if ( $r['echo'] ) 882 1030 echo $output; … … 913 1061 function wp_page_menu( $args = array() ) { 914 1062 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 915 1063 $args = wp_parse_args( $args, $defaults ); 1064 1065 /** 1066 * Filter the arguments passed to wp_page_menu(). 1067 * 1068 * @since 2.7.0 1069 * 1070 * @see wp_page_menu() 1071 * 1072 * @param array $args An array of arguments. 1073 */ 916 1074 $args = apply_filters( 'wp_page_menu_args', $args ); 917 1075 918 1076 $menu = ''; … … 948 1106 $menu = '<ul>' . $menu . '</ul>'; 949 1107 950 1108 $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; 1109 1110 /** 1111 * Filter the HTML output and arguments of wp_page_menu(). 1112 * 1113 * @since 2.7.0 1114 * 1115 * @see wp_page_menu() 1116 * 1117 * @param string $menu The HTML output. 1118 * @param array $args An array of arguments. 1119 */ 951 1120 $menu = apply_filters( 'wp_page_menu', $menu, $args ); 952 1121 if ( $args['echo'] ) 953 1122 echo $menu; … … 1080 1249 $css_class[] = 'current_page_parent'; 1081 1250 } 1082 1251 1252 /** 1253 * Filter the class attribute of the li element in a list of WordPress pages. 1254 * 1255 * @since 2.8.0 1256 * 1257 * @see wp_list_pages() 1258 * 1259 * @param array $css_class An array of CSS classes to be applied 1260 * to each list item. 1261 * @param object $page Page data object. 1262 * @param int $depth Depth of page, used for padding. 1263 * @param array $args An array of arguments. 1264 * @param int $current_page ID of the current page. 1265 */ 1083 1266 $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); 1084 1267 1085 1268 if ( '' === $page->post_title ) … … 1158 1341 $title = sprintf( __( '#%d (no title)' ), $page->ID ); 1159 1342 } 1160 1343 1344 /** 1345 * Filter the page title when creating an HTML drop down list of pages. 1346 * 1347 * @since 3.1.0 1348 * 1349 * @param string $title Page title. 1350 * @param object $page Page data object. 1351 */ 1161 1352 $title = apply_filters( 'list_pages', $title, $page ); 1162 1353 $output .= $pad . esc_html( $title ); 1163 1354 $output .= "</option>\n"; … … 1223 1414 if ( trim( $link_text ) == '' ) 1224 1415 $link_text = $_post->post_title; 1225 1416 1417 /** 1418 * Filter a retrieved attachment page link. 1419 * 1420 * @since 2.7.0 1421 * 1422 * @param string $link_html The page link HTML output. 1423 * @param int $id Post ID. 1424 * @param string $size Image size. Default 'thumbnail'. 1425 * @param bool $permalink Whether to add permalink to image. Default false. 1426 * @param bool $icon Whether to include an icon. Default false. 1427 * @param string|bool $text If string, will be link text. Default false. 1428 */ 1226 1429 return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text ); 1227 1430 } 1228 1431 … … 1245 1448 // show the medium sized image representation of the attachment if available, and link to the raw file 1246 1449 $p .= wp_get_attachment_link(0, 'medium', false); 1247 1450 $p .= '</p>'; 1248 $p = apply_filters('prepend_attachment', $p);1249 1451 1452 /** 1453 * Filter the attachment markup to be prepended to the post content. 1454 * 1455 * @since 2.0.0 1456 * 1457 * @see prepend_attachment() 1458 * 1459 * @param string $p The attachment HTML output. 1460 */ 1461 $p = apply_filters( 'prepend_attachment', $p ); 1462 1250 1463 return "$p\n$content"; 1251 1464 } 1252 1465 … … 1269 1482 <p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p> 1270 1483 <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></form> 1271 1484 '; 1485 1486 /** 1487 * Filter the HTML output for the protected post password form. 1488 * 1489 * @since 2.7.0 1490 * 1491 * @param string $output The password form HTML output. 1492 */ 1272 1493 return apply_filters( 'the_password_form', $output ); 1273 1494 } 1274 1495