Changeset 5302
- Timestamp:
- 04/24/2007 11:21:56 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r5282 r5302 111 111 112 112 // get permalink from post ID 113 function post_permalink($post_id = 0, $ mode = '') { // $mode legacy113 function post_permalink($post_id = 0, $deprecated = '') { 114 114 return get_permalink($post_id); 115 115 } … … 275 275 } 276 276 277 function edit_post_link($link = 'Edit This', $before = '', $after = '') { 277 function get_edit_post_link( $id = 0 ) { 278 $post = &get_post( $id ); 279 280 if ( $post->post_type == 'attachment' ) 281 return; 282 elseif ( $post->post_type == 'page' ) { 283 if ( !current_user_can( 'edit_page', $post->ID ) ) 284 return; 285 286 $file = 'page'; 287 } else { 288 if ( !current_user_can( 'edit_post', $post->ID ) ) 289 return; 290 291 $file = 'post'; 292 } 293 294 return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID ); 295 } 296 297 function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { 278 298 global $post; 279 280 if ( is_attachment() ) 299 300 $link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>'; 301 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; 302 } 303 304 function get_edit_comment_link( $comment_id = 0 ) { 305 $comment = &get_comment( $comment_id ); 306 $post = &get_post( $comment->comment_post_ID ); 307 308 if ( $post->post_type == 'attachment' ) 281 309 return; 282 283 if( $post->post_type == 'page' ) { 284 if ( ! current_user_can('edit_page', $post->ID) ) 310 elseif ( $post->post_type == 'page' ) 311 if ( !current_user_can( 'edit_page', $post->ID ) ) 285 312 return; 286 $file = 'page'; 287 } else { 288 if ( ! current_user_can('edit_post', $post->ID) ) 313 else 314 if ( !current_user_can( 'edit_post', $post->ID ) ) 289 315 return; 290 $file = 'post'; 291 } 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 = '') { 298 global $post, $comment; 299 300 if( $post->post_type == 'page' ){ 301 if ( ! current_user_can('edit_page', $post->ID) ) 302 return; 303 } else { 304 if ( ! current_user_can('edit_post', $post->ID) ) 305 return; 306 } 307 308 $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&c=$comment->comment_ID"; 309 echo $before . "<a href='$location'>$link</a>" . $after; 316 317 $location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&c=' . $comment->comment_ID; 318 return apply_filters( 'get_edit_comment_link', $location ); 319 } 320 321 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { 322 global $comment; 323 324 $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>'; 325 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; 310 326 } 311 327
Note: See TracChangeset
for help on using the changeset viewer.