get_edit_*_link() functions. fixes #4153
git-svn-id: http://svn.automattic.com/wordpress/trunk@5302 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c03e74ab48
commit
534eeaf7bc
|
@ -110,7 +110,7 @@ function get_permalink($id = 0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get permalink from post ID
|
// 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);
|
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);
|
return apply_filters('post_comments_feed_link', $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit_post_link($link = 'Edit This', $before = '', $after = '') {
|
function get_edit_post_link( $id = 0 ) {
|
||||||
global $post;
|
$post = &get_post( $id );
|
||||||
|
|
||||||
if ( is_attachment() )
|
if ( $post->post_type == 'attachment' )
|
||||||
|
return;
|
||||||
|
elseif ( $post->post_type == 'page' ) {
|
||||||
|
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( $post->post_type == 'page' ) {
|
|
||||||
if ( ! current_user_can('edit_page', $post->ID) )
|
|
||||||
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 apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID );
|
||||||
echo $before . "<a href=\"$location\">$link</a>" . $after;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function edit_comment_link($link = 'Edit This', $before = '', $after = '') {
|
function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||||
global $post, $comment;
|
global $post;
|
||||||
|
|
||||||
if( $post->post_type == 'page' ){
|
$link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
|
||||||
if ( ! current_user_can('edit_page', $post->ID) )
|
echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
|
||||||
return;
|
}
|
||||||
} else {
|
|
||||||
if ( ! current_user_can('edit_post', $post->ID) )
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$location = get_option('siteurl') . "/wp-admin/comment.php?action=editcomment&c=$comment->comment_ID";
|
function get_edit_comment_link( $comment_id = 0 ) {
|
||||||
echo $before . "<a href='$location'>$link</a>" . $after;
|
$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 ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
$location = get_bloginfo( 'wpurl' ) . '/wp-admin/comment.php?action=editcomment&c=' . $comment->comment_ID;
|
||||||
|
return apply_filters( 'get_edit_comment_link', $location );
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||||
|
global $comment;
|
||||||
|
|
||||||
|
$link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
|
||||||
|
echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigation links
|
// Navigation links
|
||||||
|
|
Loading…
Reference in New Issue