BBP_Replies_Admin::row_actions( array $actions = array(), object $reply = false )
Reply Row actions
Description Description
Remove the quick-edit action link under the reply title and add the content and spam link
Parameters Parameters
- $actions
-
(Optional) Actions
Default value: array()
- $reply
-
(Optional) Reply object
Default value: false
Return Return
(array) $actions Actions
Source Source
File: includes/admin/replies.php
public function row_actions( $actions = array(), $reply = false ) {
// Disable quick edit (too much to do here)
unset( $actions['inline hide-if-no-js'] );
// View link
$view_link = bbp_get_reply_url( $reply->ID );
// Maybe add view=all
if ( ! in_array( $reply->post_status, array( bbp_get_closed_status_id(), bbp_get_public_status_id() ), true ) ) {
$view_link = bbp_add_view_all( $view_link, true );
}
// Reply view links to topic
$actions['view'] = '<a href="' . esc_url( $view_link ) . '" title="' . esc_attr( sprintf( __( 'View “%s”', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
// User cannot view replies in trash
if ( ( bbp_get_trash_status_id() === $reply->post_status ) && ! current_user_can( 'view_trash' ) ) {
unset( $actions['view'] );
}
// Only show the actions if the user is capable of viewing them
if ( current_user_can( 'moderate', $reply->ID ) ) {
// Show the 'approve' link on non-published posts only and 'unapprove' on published posts only
$approve_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'approve-reply_' . $reply->ID );
if ( bbp_is_reply_public( $reply->ID ) ) {
$actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>';
} else {
$actions['approved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply', 'bbpress' ) . '">' . _x( 'Approve', 'Approve reply', 'bbpress' ) . '</a>';
}
// Show the 'spam' link on published and pending replies and 'not spam' on spammed replies
if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id() ), true ) ) {
$spam_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_' . $reply->ID );
if ( ! bbp_is_reply_spam( $reply->ID ) ) {
$actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this reply as spam', 'bbpress' ) . '">' . esc_html__( 'Spam', 'bbpress' ) . '</a>';
} else {
$actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>';
}
}
}
// Trash
if ( current_user_can( 'delete_reply', $reply->ID ) ) {
$trash_days = bbp_get_trash_days( bbp_get_reply_post_type() );
if ( bbp_get_trash_status_id() === $reply->post_status ) {
$post_type_object = get_post_type_object( bbp_get_reply_post_type() );
$actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . "' href='" . esc_url( wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $reply->ID ) ), 'untrash-post_' . $reply->ID ) ) . "'>" . esc_html__( 'Restore', 'bbpress' ) . "</a>";
} elseif ( ! empty( $trash_days ) ) {
$actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $reply->ID ) ) . "'>" . esc_html__( 'Trash', 'bbpress' ) . "</a>";
}
if ( ( bbp_get_trash_status_id() === $reply->post_status ) || empty( $trash_days ) ) {
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $reply->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . "</a>";
}
}
// Sort & return
return $this->sort_row_actions( $actions );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |