本文整理汇总了PHP中WP_List_Table::row_actions方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_List_Table::row_actions方法的具体用法?PHP WP_List_Table::row_actions怎么用?PHP WP_List_Table::row_actions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_List_Table
的用法示例。
在下文中一共展示了WP_List_Table::row_actions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: answer_row_actions
public function answer_row_actions($column, $post_id)
{
global $post, $mode;
if ('answer_content' != $column) {
return;
}
$content = get_the_excerpt();
// get the first 80 words from the content and added to the $abstract variable
preg_match('/^([^.!?\\s]*[\\.!?\\s]+){0,40}/', strip_tags($content), $abstract);
// pregmatch will return an array and the first 80 chars will be in the first element
echo $abstract[0] . '...';
//First set up some variables
$actions = array();
$post_type_object = get_post_type_object($post->post_type);
$can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
//Actions to delete/trash
if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
if ('trash' == $post->post_status) {
$_wpnonce = wp_create_nonce('untrash-post_' . $post_id);
$url = admin_url('post.php?post=' . $post_id . '&action=untrash&_wpnonce=' . $_wpnonce);
$actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . $url . "'>" . __('Restore') . "</a>";
} elseif (EMPTY_TRASH_DAYS) {
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
}
if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
}
}
if ($can_edit_post) {
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, '', true) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $post->title)) . '" rel="permalink">' . __('Edit') . '</a>';
}
//Actions to view/preview
if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
if ($can_edit_post) {
$actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $post->title)) . '" rel="permalink">' . __('Preview') . '</a>';
}
} elseif ('trash' != $post->post_status) {
$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(__('View “%s” question')) . '" rel="permalink">' . __('View') . '</a>';
}
//***** END -- Our actions *******//
//Echo the 'actions' HTML, let WP_List_Table do the hard work
$WP_List_Table = new WP_List_Table();
echo $WP_List_Table->row_actions($actions);
}