From 763828ed104971cd3544507a21cce54c278040f2 Mon Sep 17 00:00:00 2001 From: rob1n Date: Mon, 16 Apr 2007 23:53:34 +0000 Subject: [PATCH] Add get_edit_comment_link() and get_edit_post_link(). fixes #4153 git-svn-id: http://svn.automattic.com/wordpress/trunk@5275 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 42 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index f41b7224b1..1255398f81 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -274,39 +274,49 @@ 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 = '') { +function get_edit_post_link( $link = 'Edit This' ) { global $post; - - if ( is_attachment() ) + + if ( is_attachment() ) { return; - - if( $post->post_type == 'page' ) { - if ( ! current_user_can('edit_page', $post->ID) ) + } + + if ( $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'; } + + return 'ID"; - echo $before . "$link" . $after; +function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { + echo $before . get_edit_post_link( $link ) . $after; } -function edit_comment_link($link = 'Edit This', $before = '', $after = '') { +function get_edit_comment_link( $link = 'Edit This' ) { global $post, $comment; - - if( $post->post_type == 'page' ){ - if ( ! current_user_can('edit_page', $post->ID) ) + + if ( $post->post_type == 'page' ) { + if ( !current_user_can( 'edit_page', $post->ID ) ) { return; + } } else { - if ( ! current_user_can('edit_post', $post->ID) ) + if ( !current_user_can( 'edit_post', $post->ID ) ) { return; + } } + + return '' . $link . ''; +} - $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 = '' ) { + echo $before . get_edit_comment_link( $link ) . $after; } // Navigation links