[wp-trac] [WordPress Trac] #10544: Specify tags on new posts through the URL
WordPress Trac
wp-trac at lists.automattic.com
Tue Aug 4 20:21:59 UTC 2009
#10544: Specify tags on new posts through the URL
-------------------------+--------------------------------------------------
Reporter: rvenable | Owner:
Type: enhancement | Status: new
Priority: low | Milestone: Unassigned
Component: Plugins | Version: 2.8.1
Severity: minor | Keywords:
-------------------------+--------------------------------------------------
I want to create links like such: "Add a new post with tag X" with a URL
like this: wp-admin/post-new.php?new_tag=X
Clicking on the link would take you to the Add New Post admin panel with
tag X already added.
Unfortunately, there is no clean way for a plugin to make this work. The
only clean way would be to add a filter on 'terms_to_edit' which adds the
new_tag var to the end of the terms.
Unfortunately, get_terms_to_edit() returns early if there is no post ID
and never reaches the necessary filter:
{{{
function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {
$post_id = (int) $post_id;
if ( !$post_id )
return false; // <------ BAILS OUT EARLY HERE
$tags = wp_get_post_terms($post_id, $taxonomy, array());
if ( !$tags )
return false;
if ( is_wp_error($tags) )
return $tags;
foreach ( $tags as $tag )
$tag_names[] = $tag->name;
$tags_to_edit = join( ',', $tag_names );
$tags_to_edit = esc_attr( $tags_to_edit );
$tags_to_edit = apply_filters( 'terms_to_edit', $tags_to_edit,
$taxonomy ); // <-------- THE FILTER I NEED TO HOOK ONTO TO ADD MY NEW
TAG
return $tags_to_edit;
}
}}}
So, a possible solution would be to still apply the filter when bailing
out on an empty post_id.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10544>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list