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
This commit is contained in:
parent
02cfbbe93b
commit
763828ed10
|
@ -274,39 +274,49 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') {
|
||||||
return apply_filters('post_comments_feed_link', $url);
|
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;
|
global $post;
|
||||||
|
|
||||||
if ( is_attachment() )
|
if ( is_attachment() ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( $post->post_type == 'page' ) {
|
if ( $post->post_type == 'page' ) {
|
||||||
if ( ! current_user_can('edit_page', $post->ID) )
|
if ( !current_user_can( 'edit_page', $post->ID ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$file = 'page';
|
$file = 'page';
|
||||||
} else {
|
} else {
|
||||||
if ( ! current_user_can('edit_post', $post->ID) )
|
if ( !current_user_can( 'edit_post', $post->ID ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$file = 'post';
|
$file = 'post';
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = get_option('siteurl') . "/wp-admin/{$file}.php?action=edit&post=$post->ID";
|
return '<a href="' . get_option( 'wpurl' ) . '/wp-admin/' . $file '.php?action=edit&post=' . $post->ID . '>' . $link . '</a>' . $after;
|
||||||
echo $before . "<a href=\"$location\">$link</a>" . $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;
|
global $post, $comment;
|
||||||
|
|
||||||
if( $post->post_type == 'page' ){
|
if ( $post->post_type == 'page' ) {
|
||||||
if ( ! current_user_can('edit_page', $post->ID) )
|
if ( !current_user_can( 'edit_page', $post->ID ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( ! current_user_can('edit_post', $post->ID) )
|
if ( !current_user_can( 'edit_post', $post->ID ) ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&c=$comment->comment_ID";
|
return '<a href="' . get_option( 'siteurl' ) . '/wp-admin/comment.php?action=editcomment&c=' . $comment->comment_ID . '">' . $link . '</a>';
|
||||||
echo $before . "<a href='$location'>$link</a>" . $after;
|
}
|
||||||
|
|
||||||
|
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||||
|
echo $before . get_edit_comment_link( $link ) . $after;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigation links
|
// Navigation links
|
||||||
|
|
Loading…
Reference in New Issue