bbp_get_topic_trash_link( array $args = array() )
Return the trash link of the topic
Description Description
Parameters Parameters
- $args
-
(Optional) This function supports these args: - id: Optional. Topic id - link_before: Before the link - link_after: After the link - sep: Links separator - trash_text: Trash text - restore_text: Restore text - delete_text: Delete text
Default value: array()
Return Return
(string) Topic trash link
Source Source
File: includes/topics/template.php
function bbp_get_topic_trash_link( $args = array() ) {
// Parse arguments against default values
$r = bbp_parse_args( $args, array(
'id' => 0,
'link_before' => '',
'link_after' => '',
'sep' => ' | ',
'trash_text' => esc_html__( 'Trash', 'bbpress' ),
'restore_text' => esc_html__( 'Restore', 'bbpress' ),
'delete_text' => esc_html__( 'Delete', 'bbpress' )
), 'get_topic_trash_link' );
// Get topic
$topic = bbp_get_topic( $r['id'] );
// Bail if no topic or current user cannot delete
if ( empty( $topic ) || ! current_user_can( 'delete_topic', $topic->ID ) ) {
return;
}
$actions = array();
$trash_days = bbp_get_trash_days( bbp_get_topic_post_type() );
if ( bbp_is_topic_trash( $topic->ID ) ) {
$actions['untrash'] = '<a title="' . esc_attr__( 'Restore this item from the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'untrash', 'topic_id' => $topic->ID ) ), 'untrash-' . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-restore-link">' . $r['restore_text'] . '</a>';
} elseif ( ! empty( $trash_days ) ) {
$actions['trash'] = '<a title="' . esc_attr__( 'Move this item to the Trash', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'trash', 'topic_id' => $topic->ID ) ), 'trash-' . $topic->post_type . '_' . $topic->ID ) ) . '" class="bbp-topic-trash-link">' . $r['trash_text'] . '</a>';
}
if ( bbp_is_topic_trash( $topic->ID ) || empty( $trash_days ) ) {
$actions['delete'] = '<a title="' . esc_attr__( 'Delete this item permanently', 'bbpress' ) . '" href="' . esc_url( wp_nonce_url( add_query_arg( array( 'action' => 'bbp_toggle_topic_trash', 'sub_action' => 'delete', 'topic_id' => $topic->ID ) ), 'delete-' . $topic->post_type . '_' . $topic->ID ) ) . '" onclick="return confirm(\'' . esc_js( esc_html__( 'Are you sure you want to delete that permanently?', 'bbpress' ) ) . '\' );" class="bbp-topic-delete-link">' . $r['delete_text'] . '</a>';
}
// Process the admin links
$retval = $r['link_before'] . implode( $r['sep'], $actions ) . $r['link_after'];
// Filter & return
return apply_filters( 'bbp_get_topic_trash_link', $retval, $r, $args );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |