I am working on an issue-based publishing system for a friend of mine. So far I have created a custom taxonomy called "Issue"; added several custom fields to the custom taxonomy (like "Issue number", "PDF URL" and "Is Published?"); and expanded the taxonomy management page with additional columns to show these custom term data.
Now I want to implement a convenient method to publish (and unpublish) the individual issues. My plan is to add an additional custom column to the taxonomy management page which contains "Publish" and "Unpublish" buttons. So I tried to populate the custom column with a form which contains hidden data fields and a visible submit button; basically I duplicated the functionality of the default term edit form, and put it in the table cells.
The problem is that the whole taxonomy management table is wrapped in a form, called "posts-filter", and forms cannot be nested. So my solution doesn't work properly.
Is there a proper solution for adding such buttons to a custom column? Any suggestions are welcomed!
An image for clarification: http://img845.imageshack.us/img845/669/customcol.png
add_filter("manage_issue_custom_column", 'manage_issue_columns', 10, 3);
// The function that manages the custom columns
function manage_issue_columns($out, $column_name, $issue_id) {
$issue = get_term($issue_id, 'issue');
switch ($column_name) {
case 'issue_pdf_url':
$term_meta = get_option( "taxonomy_term_$issue_id" );
if ( isset( $term_meta["issue_pdf_url"] ) ){
$out .= $term_meta["issue_pdf_url"];
}
break;
case 'issue_num':
$term_meta = get_option( "taxonomy_term_$issue_id" );
if ( isset( $term_meta["issue_num"] ) ){
$out .= $term_meta["issue_num"];
}
break;
//This is the column where I need to add buttons
case 'issue_published':
$term_meta = get_option( "taxonomy_term_$issue_id" );
$term_object = get_term($issue_id, "issue");
if ( isset( $term_meta["issue_published"] ) && $term_meta["issue_published"] == "yes" ){
//This is the form which shows the publishing buttons; not working due to being nested in other form
$out .= '<form name="edittag" id="edittag" method="post" action="edit-tags.php" class=""> <input type="hidden" name="action" value="editedtag" /> <input type="hidden" name="tag_ID" value="' . esc_attr($issue_id) . '" /> <input type="hidden" name="taxonomy" value="issue" /> ' . wp_original_referer_field(true, 'current') . wp_nonce_field('update-tag_' . $issue_id) . ' <input name="name" id="name" type="hidden" value="' . $term_object->name . '" /> <input name="slug" id="slug" type="hidden" value="' . $term_object->slug .'" /> <input name="description" id="description" type="hidden" value="' . $term_object->description .'" /> <input type="hidden" value="" checked="" id="term_meta[issue_published]" name="term_meta[issue_published]"> <input type="submit" value="Unpublish" class="button-primary" id="submit" name="submit"></form>';
} else {
$out .= '<form name="edittag" id="edittag" method="post" action="edit-tags.php" class=""> <input type="hidden" name="action" value="editedtag" /> <input type="hidden" name="tag_ID" value="' . esc_attr($issue_id) . '" /> <input type="hidden" name="taxonomy" value="issue" /> ' . wp_original_referer_field(true, 'current') . wp_nonce_field('update-tag_' . $issue_id) . ' <input name="name" id="name" type="hidden" value="' . $term_object->name . '" /> <input name="slug" id="slug" type="hidden" value="' . $term_object->slug .'" /> <input name="description" id="description" type="hidden" value="' . $term_object->description .'" /> <input type="hidden" value="yes" checked="checked" id="term_meta[issue_published]" name="term_meta[issue_published]"> <input type="submit" value="Publish" class="button-primary" id="submit" name="submit"></form>';
}
break;
default:
break;
}
return $out;
}