Make WordPress Core

Ticket #25621: post-template.diff

File post-template.diff, 12.3 KB (added by Toru, 10 years ago)
  • src/wp-includes/post-template.php

     
    107107
    108108        if ( ! is_admin() ) {
    109109                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                         */
    110117                        $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );
    111118                        $title = sprintf( $protected_title_format, $title );
    112119                } 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                         */
    113127                        $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );
    114128                        $title = sprintf( $private_title_format, $title );
    115129                }
    116130        }
    117131
     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         */
    118140        return apply_filters( 'the_title', $title, $id );
    119141}
    120142
     
    150172function get_the_guid( $id = 0 ) {
    151173        $post = get_post($id);
    152174
    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 );
    154183}
    155184
    156185/**
     
    163192 */
    164193function the_content( $more_link_text = null, $strip_teaser = false) {
    165194        $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         */
    166202        $content = apply_filters( 'the_content', $content );
    167203        $content = str_replace( ']]>', ']]>', $content );
    168204        echo $content;
     
    221257                        $output .= '<span id="more-' . $post->ID . '"></span>' . $content[1];
    222258                } else {
    223259                        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                                 */
    224267                                $output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink() . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
    225268                        $output = force_balance_tags( $output );
    226269                }
     
    251294 * @uses apply_filters() Calls 'the_excerpt' hook on post excerpt.
    252295 */
    253296function the_excerpt() {
    254         echo apply_filters('the_excerpt', get_the_excerpt());
     297        echo apply_filters( 'the_excerpt', get_the_excerpt() );
    255298}
    256299
    257300/**
     
    272315                return __( 'There is no excerpt because this is a protected post.' );
    273316        }
    274317
     318        /**
     319         * Filter the retrieved post excerpt.
     320         *
     321         * @since  1.5.2
     322         *
     323         * @param string $post->post_excerpt The post excerpt.
     324         */
    275325        return apply_filters( 'get_the_excerpt', $post->post_excerpt );
    276326}
    277327
     
    379429
    380430        $classes = array_map('esc_attr', $classes);
    381431
    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 );
    383442}
    384443
    385444/**
     
    563622
    564623        $classes = array_map( 'esc_attr', $classes );
    565624
     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         */
    566633        return apply_filters( 'body_class', $classes, $class );
    567634}
    568635
     
    650717        );
    651718
    652719        $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         */
    653727        $r = apply_filters( 'wp_link_pages_args', $r );
    654728        extract( $r, EXTR_SKIP );
    655729
     
    663737                                $link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after;
    664738                                if ( $i != $page || ! $more && 1 == $page )
    665739                                        $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                                 */
    666748                                $link = apply_filters( 'wp_link_pages_link', $link, $i );
    667749                                $output .= $separator . $link;
    668750                        }
     
    672754                        $i = $page - 1;
    673755                        if ( $i ) {
    674756                                $link = _wp_link_page( $i ) . $link_before . $previouspagelink . $link_after . '</a>';
     757                                //duplicate_hook
    675758                                $link = apply_filters( 'wp_link_pages_link', $link, $i );
    676759                                $output .= $separator . $link;
    677760                        }
    678761                        $i = $page + 1;
    679762                        if ( $i <= $numpages ) {
    680763                                $link = _wp_link_page( $i ) . $link_before . $nextpagelink . $link_after . '</a>';
     764                                //duplicate_hook
    681765                                $link = apply_filters( 'wp_link_pages_link', $link, $i );
    682766                                $output .= $separator . $link;
    683767                        }
     
    685769                }
    686770        }
    687771
     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         */
    688780        $output = apply_filters( 'wp_link_pages', $output, $args );
    689781
    690782        if ( $echo )
     
    759851                                continue;
    760852                        $values = array_map('trim', get_post_custom_values($key));
    761853                        $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 );
    763864                }
    764865                echo "</ul>\n";
    765866        }
     
    805906                $output .= "</select>\n";
    806907        }
    807908
    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 );
    809917
    810918        if ( $echo )
    811919                echo $output;
     
    842950
    843951        // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array)
    844952        $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 ) );
    846961
    847962        // Query pages.
    848963        $r['hierarchical'] = 0;
     
    861976                        $output .= '</ul></li>';
    862977        }
    863978
    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 );
    865988
    866989        if ( $r['echo'] )
    867990                echo $output;
     
    8981021function wp_page_menu( $args = array() ) {
    8991022        $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
    9001023        $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         */
    9011031        $args = apply_filters( 'wp_page_menu_args', $args );
    9021032
    9031033        $menu = '';
     
    9331063                $menu = '<ul>' . $menu . '</ul>';
    9341064
    9351065        $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         */
    9361074        $menu = apply_filters( 'wp_page_menu', $menu, $args );
    9371075        if ( $args['echo'] )
    9381076                echo $menu;
     
    10661204                        $css_class[] = 'current_page_parent';
    10671205                }
    10681206
     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                 */
    10691218                $css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
    10701219
    10711220                if ( '' === $page->post_title )
    10721221                        $page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );
    10731222
     1223                //duplicate_hook
    10741224                $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>';
    10751225
    10761226                if ( !empty($show_date) ) {
     
    11381288                if ( $page->ID == $args['selected'] )
    11391289                        $output .= ' selected="selected"';
    11401290                $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                 */
    11411299                $title = apply_filters( 'list_pages', $page->post_title, $page );
    11421300                $output .= $pad . esc_html( $title );
    11431301                $output .= "</option>\n";
     
    11811339 * @param string|bool $text Optional, default is false. If string, then will be link text.
    11821340 * @return string HTML content.
    11831341 */
    1184 function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
     1342function apply( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) {
    11851343        $id = intval( $id );
    11861344        $_post = get_post( $id );
    11871345
     
    12031361        if ( trim( $link_text ) == '' )
    12041362                $link_text = $_post->post_title;
    12051363
     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         */
    12061375        return apply_filters( 'wp_get_attachment_link', "<a href='$url'>$link_text</a>", $id, $size, $permalink, $icon, $text );
    12071376}
    12081377
     
    12251394        // show the medium sized image representation of the attachment if available, and link to the raw file
    12261395        $p .= wp_get_attachment_link(0, 'medium', false);
    12271396        $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 );
    12291405
    12301406        return "$p\n$content";
    12311407}
     
    12501426        <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>
    12511427        </form>
    12521428        ';
     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         */
    12531436        return apply_filters( 'the_password_form', $output );
    12541437}
    12551438