From b0e84dde884f16b671431530863c5b3ffce40087 Mon Sep 17 00:00:00 2001 From: rob1n Date: Tue, 24 Apr 2007 23:21:56 +0000 Subject: [PATCH] get_edit_*_link() functions. fixes #4153 git-svn-id: https://develop.svn.wordpress.org/trunk@5302 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/link-template.php | 58 ++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index f41b7224b1..0b45c7a422 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -110,7 +110,7 @@ function get_permalink($id = 0) { } // get permalink from post ID -function post_permalink($post_id = 0, $mode = '') { // $mode legacy +function post_permalink($post_id = 0, $deprecated = '') { return get_permalink($post_id); } @@ -274,39 +274,55 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { return apply_filters('post_comments_feed_link', $url); } -function edit_post_link($link = 'Edit This', $before = '', $after = '') { - global $post; - - if ( is_attachment() ) +function get_edit_post_link( $id = 0 ) { + $post = &get_post( $id ); + + if ( $post->post_type == 'attachment' ) return; - - if( $post->post_type == 'page' ) { - if ( ! current_user_can('edit_page', $post->ID) ) + elseif ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) return; + $file = 'page'; } else { - if ( ! current_user_can('edit_post', $post->ID) ) + if ( !current_user_can( 'edit_post', $post->ID ) ) return; + $file = 'post'; } - - $location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID"; - echo $before . "$link" . $after; + + return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID ); } -function edit_comment_link($link = 'Edit This', $before = '', $after = '') { - global $post, $comment; +function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { + global $post; + + $link = '' . $link . ''; + echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; +} - if( $post->post_type == 'page' ){ - if ( ! current_user_can('edit_page', $post->ID) ) +function get_edit_comment_link( $comment_id = 0 ) { + $comment = &get_comment( $comment_id ); + $post = &get_post( $comment->comment_post_ID ); + + if ( $post->post_type == 'attachment' ) + return; + elseif ( $post->post_type == 'page' ) + if ( !current_user_can( 'edit_page', $post->ID ) ) return; - } else { - if ( ! current_user_can('edit_post', $post->ID) ) + else + if ( !current_user_can( 'edit_post', $post->ID ) ) return; - } + + $location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&c=' . $comment->comment_ID; + return apply_filters( 'get_edit_comment_link', $location ); +} - $location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&c=$comment->comment_ID"; - echo $before . "$link" . $after; +function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { + global $comment; + + $link = '' . $link . ''; + echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; } // Navigation links