Make WordPress Core

Changeset 5275


Ignore:
Timestamp:
04/16/2007 11:53:34 PM (19 years ago)
Author:
rob1n
Message:

Add get_edit_comment_link() and get_edit_post_link(). fixes #4153

File:
1 edited

Legend:

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

    r5260 r5275  
    275275}
    276276
    277 function edit_post_link($link = 'Edit This', $before = '', $after = '') {
     277function get_edit_post_link( $link = 'Edit This' ) {
    278278    global $post;
    279 
    280     if ( is_attachment() )
     279   
     280    if ( is_attachment() ) {
    281281        return;
    282 
    283     if( $post->post_type == 'page' ) {
    284         if ( ! current_user_can('edit_page', $post->ID) )
     282    }
     283   
     284    if ( $post->post_type == 'page' ) {
     285        if ( !current_user_can( 'edit_page', $post->ID ) ) {
    285286            return;
     287        }
    286288        $file = 'page';
    287289    } else {
    288         if ( ! current_user_can('edit_post', $post->ID) )
     290        if ( !current_user_can( 'edit_post', $post->ID ) ) {
    289291            return;
     292        }
    290293        $file = 'post';
    291294    }
    292 
    293     $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID";
    294     echo $before . "<a href=\"$location\">$link</a>" . $after;
    295 }
    296 
    297 function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
     295   
     296    return '<a href="' . get_option( 'wpurl' ) . '/wp-admin/' . $file '.php?action=edit&amp;post=' . $post->ID . '>' . $link . '</a>' . $after;
     297
     298function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
     299    echo $before . get_edit_post_link( $link ) . $after;
     300}
     301
     302function get_edit_comment_link( $link = 'Edit This' ) {
    298303    global $post, $comment;
    299 
    300     if( $post->post_type == 'page' ){
    301         if ( ! current_user_can('edit_page', $post->ID) )
     304   
     305    if ( $post->post_type == 'page' ) {
     306        if ( !current_user_can( 'edit_page', $post->ID ) ) {
    302307            return;
    303     } else {
    304         if ( ! current_user_can('edit_post', $post->ID) )
     308        }
     309    } else {
     310        if ( !current_user_can( 'edit_post', $post->ID ) ) {
    305311            return;
    306     }
    307 
    308     $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&amp;c=$comment->comment_ID";
    309     echo $before . "<a href='$location'>$link</a>" . $after;
     312        }
     313    }
     314   
     315    return '<a href="' . get_option( 'siteurl' ) . '/wp-admin/comment.php?action=editcomment&amp;c=' . $comment->comment_ID . '">' . $link . '</a>';
     316}
     317
     318function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
     319    echo $before . get_edit_comment_link( $link ) . $after;
    310320}
    311321
Note: See TracChangeset for help on using the changeset viewer.