Opened 3 years ago
Last modified 3 years ago
#14113 new enhancement
Function that could improve the current edit_post_link()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Template | Version: | 3.0 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: |
Description
Basicly this function is the same than edit_post_link() but some little differences which can make it more useful for developers. So far it has two advantages:
1) The edit link can be easily returned.
2) It's possible to choose a class for link tags.
// Returned
function wp_get_edit_link($args = '') {
$defaults = array(
'link' => null,
'before' => '',
'after' => '',
'id' => 0,
'class' => 'post-edit-link'
);
$r = wp_parse_args($args, $predet);
extract($r);
if ( !$post = &get_post($id) )
return;
if ( !$url = get_edit_post_link($post->ID) )
return;
if (null === $link)
$link = __('Edit This');
$post_type_obj = get_post_type_object($post->post_type);
$link = '<a class="'. $class .'" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
return $before . apply_filters('get_edit_link' , $link , $post->ID) . $after;
}
// Echoed
function wp_edit_link($args = '') {
echo wp_get_edit_link($args);
}
Example using the function:
Returning:
<?php
$var = get_wp_edit_link('before=<span class="my-edit-class">&after=</span>&class=my-link-class&link=Edit me!');
echo $var;
?>
Echoing:
<?php wp_edit_link('before=<span class="my-edit-class">&after=</span>&class=my-link-class&link=Edit me!'); ?>
Results on:
<span class="my-edit-class"><a class="my-link-class" href="http://url.to/post.html">Edit me!</a></span>
Change History (4)
comment:1
metacortex — 3 years ago
comment:2
metacortex — 3 years ago
- Version set to 3.0
- Keywords needs-patch added
Can you provide a patch?
Note: See
TracTickets for help on using
tickets.

I made a mistake. The string:
Showld be