diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index c078b8a6df..b3d57a6f96 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -107,14 +107,44 @@ function get_the_title( $post = 0 ) { if ( ! is_admin() ) { if ( ! empty( $post->post_password ) ) { + + /** + * Filter the text prepended to the post title for protected posts. + * + * The filter is only applied on the front end. + * + * @since 2.8.0 + * + * @param string $prepend Text displayed before the post title. + * Default 'Protected: %s'. + */ $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); $title = sprintf( $protected_title_format, $title ); } else if ( isset( $post->post_status ) && 'private' == $post->post_status ) { + + /** + * Filter the text prepended to the post title of private posts. + * + * The filter is only applied on the front end. + * + * @since 2.8.0 + * + * @param string $prepend Text displayed before the post title. + * Default 'Private: %s'. + */ $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) ); $title = sprintf( $private_title_format, $title ); } } + /** + * Filter the post title. + * + * @since 0.71 + * + * @param string $title The post title. + * @param int $id The post ID. + */ return apply_filters( 'the_title', $title, $id ); } @@ -150,7 +180,14 @@ function the_guid( $id = 0 ) { function get_the_guid( $id = 0 ) { $post = get_post($id); - return apply_filters('get_the_guid', $post->guid); + /** + * Filter the Global Unique Identifier (guid) of the post. + * + * @since 1.5.0 + * + * @param string $post_guid Global Unique Identifier (guid) of the post. + */ + return apply_filters( 'get_the_guid', $post->guid ); } /** @@ -163,6 +200,14 @@ function get_the_guid( $id = 0 ) { */ function the_content( $more_link_text = null, $strip_teaser = false) { $content = get_the_content( $more_link_text, $strip_teaser ); + + /** + * Filter the post content. + * + * @since 0.71 + * + * @param string $content Content of the current post. + */ $content = apply_filters( 'the_content', $content ); $content = str_replace( ']]>', ']]>', $content ); echo $content; @@ -221,6 +266,15 @@ function get_the_content( $more_link_text = null, $strip_teaser = false ) { $output .= '' . $content[1]; } else { if ( ! empty( $more_link_text ) ) + + /** + * Filter the Read More link text. + * + * @since 2.8.0 + * + * @param string $more_link_element Read More link element. + * @param string $more_link_text Read More text. + */ $output .= apply_filters( 'the_content_more_link', ' ID}\" class=\"more-link\">$more_link_text", $more_link_text ); $output = force_balance_tags( $output ); } @@ -248,10 +302,19 @@ function _convert_urlencoded_to_entities( $match ) { * Display the post excerpt. * * @since 0.71 - * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt. */ function the_excerpt() { - echo apply_filters('the_excerpt', get_the_excerpt()); + + /** + * Filter the displayed post excerpt. + * + * @since 0.71 + * + * @see get_the_excerpt() + * + * @param string $post_excerpt The post excerpt. + */ + echo apply_filters( 'the_excerpt', get_the_excerpt() ); } /** @@ -272,6 +335,13 @@ function get_the_excerpt( $deprecated = '' ) { return __( 'There is no excerpt because this is a protected post.' ); } + /** + * Filter the retrieved post excerpt. + * + * @since 1.2.0 + * + * @param string $post_excerpt The post excerpt. + */ return apply_filters( 'get_the_excerpt', $post->post_excerpt ); } @@ -384,7 +454,16 @@ function get_post_class( $class = '', $post_id = null ) { $classes = array_map('esc_attr', $classes); - return apply_filters('post_class', $classes, $class, $post->ID); + /** + * Filter the list of CSS classes for the current post. + * + * @since 2.7.0 + * + * @param array $classes An array of post classes. + * @param string $class A comma-separated list of additional classes added to the post. + * @param int $post_id The post ID. + */ + return apply_filters( 'post_class', $classes, $class, $post->ID ); } /** @@ -568,6 +647,14 @@ function get_body_class( $class = '' ) { $classes = array_map( 'esc_attr', $classes ); + /** + * Filter the list of CSS body classes for the current post or page. + * + * @since 2.8.0 + * + * @param array $classes An array of body classes. + * @param string $class A comma-separated list of additional classes added to the body. + */ return apply_filters( 'body_class', $classes, $class ); } @@ -652,6 +739,14 @@ function wp_link_pages( $args = '' ) { ); $r = wp_parse_args( $args, $defaults ); + + /** + * Filter the arguments used in retrieving page links for paginated posts. + * + * @since 3.0.0 + * + * @param array $r An array of arguments for page links for paginated posts. + */ $r = apply_filters( 'wp_link_pages_args', $r ); extract( $r, EXTR_SKIP ); @@ -665,6 +760,15 @@ function wp_link_pages( $args = '' ) { $link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after; if ( $i != $page || ! $more && 1 == $page ) $link = _wp_link_page( $i ) . $link . ''; + + /** + * Filter the HTML output of individual page number links. + * + * @since 3.6.0 + * + * @param string $link The page number HTML output. + * @param int $i Page number for paginated posts' page links. + */ $link = apply_filters( 'wp_link_pages_link', $link, $i ); $output .= $separator . $link; } @@ -674,12 +778,16 @@ function wp_link_pages( $args = '' ) { $i = $page - 1; if ( $i ) { $link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . ''; + + /** This filter is documented in wp-includes/post-template.php */ $link = apply_filters( 'wp_link_pages_link', $link, $i ); $output .= $separator . $link; } $i = $page + 1; if ( $i <= $numpages ) { $link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . ''; + + /** This filter is documented in wp-includes/post-template.php */ $link = apply_filters( 'wp_link_pages_link', $link, $i ); $output .= $separator . $link; } @@ -687,6 +795,14 @@ function wp_link_pages( $args = '' ) { } } + /** + * Filter the HTML output of page links for paginated posts. + * + * @since 3.6.0 + * + * @param string $output HTML output of paginated posts' page links. + * @param array $args An array of arguments. + */ $output = apply_filters( 'wp_link_pages', $output, $args ); if ( $echo ) @@ -774,7 +890,17 @@ function the_meta() { continue; $values = array_map('trim', get_post_custom_values($key)); $value = implode($values,', '); - echo apply_filters('the_meta_key', "
> element before content. * * @since 2.0.0 - * @uses apply_filters() Calls 'prepend_attachment' hook on HTML content. * * @param string $content * @return string @@ -1258,7 +1463,16 @@ function prepend_attachment($content) { $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); endif; - $p = apply_filters('prepend_attachment', $p); + /** + * Filter the attachment markup to be prepended to the post content. + * + * @since 2.0.0 + * + * @see prepend_attachment() + * + * @param string $p The attachment HTML output. + */ + $p = apply_filters( 'prepend_attachment', $p ); return "$p\n$content"; } @@ -1282,6 +1496,18 @@ function get_the_password_form( $post = 0 ) {
' . __( 'This content is password protected. To view it please enter your password below:' ) . '
'; + + /** + * Filter the HTML output for the protected post password form. + * + * If modifying the password field, please note that the core database schema + * limits the password field to 20 characters regardless of the value of the + * size attribute in the form input. + * + * @since 2.7.0 + * + * @param string $output The password form HTML output. + */ return apply_filters( 'the_password_form', $output ); }