好吧,所以这可能不是最有效的方法。。。但我找到了解决办法。最后,我不得不编写一个自定义函数来处理每个帖子行操作的添加。结果如下:
function wpg_row_actions() {
global $post;
if($post->post_type == \'page\') {
if(!current_user_can(\'edit_page\')) {
return;
}
}
else {
if(!current_user_can(\'edit_post\')) {
return;
}
}
if($post->post_status == \'trash\') {
$actionLinks = \'<div class="row-actions"><span class="untrash"><a title="\'.__(\'Restore this item\', \'quotable\').\'" href="\'.wp_nonce_url(get_admin_url().\'post.php?post=\'.$post->ID.\'&action=untrash\', \'untrash-\'.$post->post_type.\'_\'.$post->ID).\'">\'.__(\'Restore\', \'quotable\').\'</a> | </span>\';
$actionLinks .= \'<span class="trash"><a href="\'.wp_nonce_url(get_admin_url().\'post.php?post=\'.$post->ID.\'&action=delete\', \'delete-\'.$post->post_type.\'_\'.$post->ID).\'" title="\'.__(\'Delete this item permanently\', \'quotable\').\'" class="submitdelete">\'.__(\'Delete Permanently\', \'quotable\').\'</a></span>\';
}
else {
$actionLinks = \'<div class="row-actions"><span class="edit"><a title="\'.__(\'Edit this item\', \'quotable\').\'" href="\'.get_admin_url().\'post.php?post=\'.$post->ID.\'&action=edit">\'.__(\'Edit\', \'quotable\').\'</a> | </span>\';
$actionLinks .= \'<span class="inline hide-if-no-js"><a title="\'.__(\'Edit this item inline\', \'quotable\').\'" class="editinline" href="#">\'.__(\'Quick Edit\', \'quotable\').\'</a> | </span>\';
$actionLinks .= \'<span class="trash"><a href="\'.wp_nonce_url(get_admin_url().\'post.php?post=\'.$post->ID.\'&action=trash\', \'trash-\'.$post->post_type.\'_\'.$post->ID).\'" title="\'.__(\'Move this item to the Trash\', \'quotable\').\'" class="submitdelete">\'._x(\'Trash\', \'verb (ie. trash this post)\', \'quotable\').\'</a></span>\';
}
return $actionLinks;
}
function wpg_edit_testimonials_columns($columns) {
$columns = array(
\'cb\' => \'<input type="checkbox" />\',
\'testimonial_author\' => __(\'Author\', \'quotable\'),
\'testimonial_text\' => __(\'Testimonial\', \'quotable\'),
\'attribution_link\' => __(\'Attribution Link\', \'quotable\'),
\'date\' => __(\'Date Added\', \'quotable\')
);
return $columns;
}
function wpg_manage_testimonials_columns($column, $post_id) {
global $post;
$custom = get_post_custom($post->ID);
$testimonial_author_name = $custom[\'testimonial_author_name\'][0];
$testimonial_author_link = $custom[\'testimonial_author_link\'][0];
$wpg_row_actions = wpg_row_actions();
switch($column) {
case \'testimonial_author\':
echo $testimonial_author_name.$wpg_row_actions;
break;
case \'testimonial_text\':
echo $post->post_content;
break;
case \'attribution_link\':
echo $testimonial_author_link;
break;
default :
break;
}
}
add_filter(\'manage_edit-testimonials_columns\', \'wpg_edit_testimonials_columns\');
add_action(\'manage_testimonials_posts_custom_column\', \'wpg_manage_testimonials_columns\', 10, 2);
该函数根据查看的是垃圾帖子还是常规帖子来检查需要添加哪一版本的行操作。希望这能让其他人在以后的道路上少受几个小时的挫折。
然而,现在我似乎发现了一个全新的问题。当我“丢弃”其中一篇文章时,此自定义文章类型中每篇文章的自定义字段数据将被删除。。。但是that\'s a new question entirely.