Make WordPress Core

Changeset 28590


Ignore:
Timestamp:
05/27/2014 01:42:27 PM (11 years ago)
Author:
SergeyBiryukov
Message:

Pass anchor text to 'edit_post_link' and 'edit_comment_link' filters.

props kwight.
fixes #28373.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/link-template.php

    r28575 r28590  
    11971197 * @since 1.0.0
    11981198 *
    1199  * @param string $link Optional. Anchor text.
     1199 * @param string $text Optional. Anchor text.
    12001200 * @param string $before Optional. Display before edit link.
    12011201 * @param string $after Optional. Display after edit link.
    12021202 * @param int $id Optional. Post ID.
    12031203 */
    1204 function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) {
    1205     if ( !$post = get_post( $id ) )
     1204function edit_post_link( $text = null, $before = '', $after = '', $id = 0 ) {
     1205    if ( ! $post = get_post( $id ) ) {
    12061206        return;
    1207 
    1208     if ( !$url = get_edit_post_link( $post->ID ) )
     1207    }
     1208
     1209    if ( ! $url = get_edit_post_link( $post->ID ) ) {
    12091210        return;
    1210 
    1211     if ( null === $link )
    1212         $link = __('Edit This');
    1213 
    1214     $link = '<a class="post-edit-link" href="' . $url . '">' . $link . '</a>';
     1211    }
     1212
     1213    if ( null === $text ) {
     1214        $text = __( 'Edit This' );
     1215    }
     1216
     1217    $link = '<a class="post-edit-link" href="' . $url . '">' . $text . '</a>';
    12151218
    12161219    /**
     
    12211224     * @param string $link    Anchor tag for the edit link.
    12221225     * @param int    $post_id Post ID.
    1223      */
    1224     echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
     1226     * @param string $text    Anchor text.
     1227     */
     1228    echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after;
    12251229}
    12261230
     
    12981302 * @since 1.0.0
    12991303 *
    1300  * @param string $link Optional. Anchor text.
     1304 * @param string $text Optional. Anchor text.
    13011305 * @param string $before Optional. Display before edit link.
    13021306 * @param string $after Optional. Display after edit link.
    13031307 */
    1304 function edit_comment_link( $link = null, $before = '', $after = '' ) {
     1308function edit_comment_link( $text = null, $before = '', $after = '' ) {
    13051309    global $comment;
    13061310
    1307     if ( !current_user_can( 'edit_comment', $comment->comment_ID ) )
     1311    if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
    13081312        return;
    1309 
    1310     if ( null === $link )
    1311         $link = __('Edit This');
    1312 
    1313     $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $link . '</a>';
     1313    }
     1314
     1315    if ( null === $text ) {
     1316        $text = __( 'Edit This' );
     1317    }
     1318
     1319    $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '">' . $text . '</a>';
    13141320
    13151321    /**
     
    13201326     * @param string $link       Anchor tag for the edit link.
    13211327     * @param int    $comment_id Comment ID.
    1322      */
    1323     echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
     1328     * @param string $text       Anchor text.
     1329     */
     1330    echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after;
    13241331}
    13251332
Note: See TracChangeset for help on using the changeset viewer.